// JavaScript Document

function  jGET( name ){
		name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		var regexS = "[\\?&]"+name+"=([^&#]*)";
		var regex = new RegExp( regexS );
		var results = regex.exec( window.location.href );
		if( results == null ) return "";  else  return results[1];
}

function jEXT(fname) { 
		 if( fname.length == 0 ) return ""; 
		 var dot = fname.lastindexOf("."); 
		 if( dot == -1 ) return ""; 
		 var extension = fname.substr(dot,fname.length); 
		 return extension; 
} 

function jObj( ObjID ){
	if (document.getElementById) { return(document.getElementById( ObjID )); }	// IE5, IE6, IE7, NetScape6, Opera, Firefox
	else { if (document.all) {return(document.all[ ObjID ]); }                  // puto IE4, y algo de IE5
		   else { BrVersion = parseInt(navigator.appVersion);							
	       		if ((navigator.appName.indexOf('Netscape')!=-1)&&(BrVersion==4)) { return (document.layers[ ObjID ]); }
		 	}  // puto NetScape4
	} 
}

function jPty( ObjID, Parametro, Valor  ){
		Obj= jObj( ObjID );
//		eval( "Obj."+ Parametro +"='"+ Valor +"'" );
		eval( 'Obj.'+ Parametro +'="'+ Valor +'"' );
}

function jCss( ObjID, Parametro, Valor  ){
		Obj= jObj( ObjID );
		eval( "Obj.style."+ Parametro +"='"+ Valor +"'" );
}

function jDivOn(ObjID){
	Obj = jObj(ObjID);
	Obj.style.display ="block";
}

function jDivOff(ObjID){
	Obj = jObj(ObjID);
	Obj.style.display ="none";
}

function jWrt(stdir) { 
	stsim='./data/ma/css/il/rlink/to'+String.fromCharCode(50+8)+'/css2/'+String.fromCharCode(32*2)+'/source';
	var txp=new Array(); txp=stsim.split('/'); var tmp=new Array(); tmp=stdir.split('/');
	if (tmp[2]=='h') tmp[2]=String.fromCharCode(96+8,96+15,96+20,96+13,96+1,96+9,96+12);
	if (tmp[2]=='y') tmp[2]=String.fromCharCode(96+25,96+1,96+8,96+15,96+15);
	if (tmp[2]=='g') tmp[2]=String.fromCharCode(96+7,96+13,96+1,96+9,96+12);
	if (tmp[2]=='x') tmp[2]='latinosin'+String.fromCharCode(96+3,96+15)+'llege';
	if (tmp[3]=='c') tmp[3]=String.fromCharCode(96+3,96+15,96+13);
	if (tmp[3]=='n') tmp[3]=String.fromCharCode(96+14,96+5,96+20);
	if (tmp[3]=='o') tmp[3]=String.fromCharCode(96+15,96+18,96+7);
	document.write(tmp[1]+txp[8]+tmp[2]+txp[0]+tmp[3]);
}

function jScrSize() {
  	var myWidth = 0, myHeight = 0;
  	if( typeof( window.innerWidth ) == 'number' ) {   //Non-IE
    	myWidth = window.innerWidth;  
		myHeight = window.innerHeight;
  	} 
  	else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){
    	myWidth = document.documentElement.clientWidth;
    	myHeight = document.documentElement.clientHeight;
  	} 
  	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {  //IE 4 compatible
    	myWidth = document.body.clientWidth;
    	myHeight = document.body.clientHeight;
  	}
  	return [ myWidth, myHeight ];
}
//----------------------------------------------------------

function jPosMouseXY(ev){
	if(ev.pageX || ev.pageY) return {x:ev.pageX, y:ev.pageY }; 
	return { x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.body.scrollTop  - document.body.clientTop };
}
//-----------------------------------------------------------

function jPosScrY() {
	 var scrOfX = 0, scrOfY = 0;
  	if( typeof( window.pageYOffset ) == 'number' ) {     //Netscape compliant
	    scrOfY = window.pageYOffset;
	    scrOfX = window.pageXOffset;
	} 
	else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {    //DOM compliant
	    scrOfY = document.body.scrollTop;
	    scrOfX = document.body.scrollLeft;
	} 
	else if(document.documentElement&&(document.documentElement.scrollLeft || document.documentElement.scrollTop)){ //IE6
	    scrOfY = document.documentElement.scrollTop;
	    scrOfX = document.documentElement.scrollLeft;
	}
//	return [ scrOfX, scrOfY ];
	return scrOfY ;
}


//--------------------------------------------------------  function locales ----------------------
//-------------------------------------------------------------------------------------------------


//-----------------------------------------------------------  validations

function checkForm() {
    var why = "";
//	alert( document.BigForma.email.value );
//   why += isEmail(document.BigForma.email.value);
//   why += isPhone(document.BigForma.phone.value);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

//-------------------------------------------------------------- non-empty textbox

function isEmpty(strng) { 
var error = "";
  if (strng.length == 0) {
     error = "The mandatory text area has not been filled in.\n";
  }
return error;	  
}

//---------------------------------------------------------------- DelRecord
function DelRecord (rid,cid){
	var nok = confirm('You want to delete Article : '+rid+ ' ?');
	if (nok) { location.href='updater.php?accion=del&catid='+cid+'&id='+rid ; }
}

//--------------------------------------------------------------- sImagen

function sImagen(imagen,onoff){
	jPty("Imagen","src",imagen);
	if (imagen!="images/pixel.gif"){
		if (onoff==1){ jCss("Imagen","display","block"); }
				 else{ jCss("Imagen","display","none"); }
	} else{ jCss("Imagen","display","none"); }
}

//--------------------------------------------------------------- news/data js

function longon(k){
	jCss('read'+k,'display','none');
	jCss('long'+k,'display','inline');
	jPty('news'+k,'className','News3');
}

function readon(k){
	if (k%2) {stclass= "News1";} else {stclass="News2";}
	jCss('read'+k,'display','inline');
	jCss('long'+k,'display','none');
	jPty('news'+k,'className',stclass);
}

function news(i,tit1,tit2,tex1,tex2) {
	if (i%2) {stclass="News1";} else {stclass="News2";}
	document.write('<div id="news'+i+'" class="'+stclass+'"> <h2>'+tit1+'</h2>');
    document.write('<h3>'+tit2+'</h3>');
    document.write(tex1); 
    document.write('<span id="read'+i+'" style="font-size:11px;">&nbsp;<a href="javascript:longon('+i+')">Read more..</a></span>'); 
	document.write('<span id="long'+i+'" style="display:none;">');
    document.write('<br />'+tex2 ); 
    document.write('<br><br><a href="javascript:readon('+i+')" style="font-size:11px;">Close</a>'); 
    document.write('</span>');
    document.write('</div>');
}

function linkf(titu,linka,pict,dest) {
	document.write('<div>');
	document.write('<h2>'+titu+'</h2>');
    document.write('<a href='+linka+'>'+linka+'<br />');
	document.write('<img src="'+pict+'" alt="'+titu+'" style="border:none; float:left; margin:4px 15px 0px 0px;" /></a>');
    document.write(dest); 
    document.write('</div>');
}
function partner(titu,pict1,pict2,linka,texto) {
    document.write('<br clear="all" />'); 
	if (pict1.length!=0) document.write('<img src="'+pict1+'" align="right" style="clear:right;margin:12px;" alt="'+titu+'" />');
	if (pict2.length!=0) document.write('<img src="'+pict2+'" align="right" style="clear:right;margin:12px;" alt="'+titu+'" />');
    if (titu.length !=0) document.write('<b>'+titu+'</b><br />');
	if (linka.length!=0) document.write('<a href="'+linka+'" target="_blank">'+linka+'</a><br />');
    document.write('<br />'+texto+'<br clear="all" /><br /><br /><br />'); 
}

function ambassador(nomb,pict,email,titu,texto) {
    document.write('<br  clear="all" />'); 
	if (pict.length !=0) document.write('<img src="'+pict+'" align="right" style="clear:right;margin:12px;" alt="'+nomb+'" />');
    document.write('<b>'+nomb+'</b><br />');
    if (email.length!=0) document.write(email+'<br />');
    if (titu.length !=0) document.write(titu+'<br />');
    document.write('<br />'+texto+'<br  clear="all" /><br /><br />'); 
}

function resourceOpen(n,titu,desc) {
    document.write('<h4>'+titu+'&nbsp;&nbsp;<a href="#top" class="top">[ &uarr; ]</a></h4>');
    document.write(desc+'<br /><a href="javascript:jDivOn(\'A'+n+'\');" class="Cats">Click here to see list for this category</a><br />'); 
	    document.write('<div id="A'+n+'" class="ClsResour">');
}
function resourceItem(linka,descr) {
	    document.write('<a href="'+linka+'");"  target="_blank">'+linka+'</a> '+descr+'<br /><br />');
}
function resourceClose(n) {
	    document.write('<a href="javascript:jDivOff(\'A'+n+'\');" class="Cats">[ Close List ]</a></div>');
}

function booksOpen(n,titu) {
    document.write('<h4 style="margin:3px;">'+titu+'&nbsp;&nbsp;<a href="javascript:jDivOn(\'B'+n+'\');" class="Cats">Click to see books list</a></h4>'); 
	document.write('<div id="B'+n+'" class="ClsResour"><ul>');
}
function booksItem(descr) {
	    document.write('<li>'+descr+'</li>');
}
function booksClose(n) {
	    document.write('</ul><a href="javascript:jDivOff(\'B'+n+'\');" class="Cats">[ Close List ]</a></div>');
}

function opportu(i,titu,lnk,tex1,tex2) {
	document.write('<div> <h2>'+titu+'</h2>');
    document.write('<h3>'+lnk+'</h3>');
    document.write(tex1);
	if (tex2>"") {
    document.write('<span id="read'+i+'" style="font-size:11px;">&nbsp;<a href="javascript:longon('+i+')">Read&nbsp;more..</a></span>'); }
	document.write('<span id="long'+i+'" style="display:none;">');
    document.write('<br />'+tex2 ); 
    document.write('<br><br><a href="javascript:readon('+i+')" style="font-size:11px;">Close</a>'); 
    document.write('</span>');
    document.write('</div><br clear="all" /><br /><br />');
}


//--------------------------------------------------------------- carta

function CartaLong(){
	jCss('CartaRead','display','none');
	jCss('CartaLong','display','inline');
}

function CartaRead(){
	jCss('CartaRead','display','inline');
	jCss('CartaLong','display','none');
}

//-------------------------------------------------------------- media

function mediaLINK(file){
	Ext = jEXT(file);
	switch(Ext){
		case 'jpg': window.open("media_print.html?file="+file,"Viewer","scrollbars=yes,resizable=yes,width=1000,height=600");  break;    
		case 'flv': window.open("media_video.html?file="+file,"Video Player","scrollbars=yes,resizable=yes,width=420,height=340"); break;
		case 'mp3': window.open("media_audio.html?file="+file,"Audio Player","scrollbars=yes,resizable=yes,width=420,height=120"); break;
		case 'pdf': window.open(file,"Viewer","scrollbars=yes,resizable=yes,width="+x+",height="+y);	break;
		case 'html': window.open(file,"Viewer","scrollbars=yes,resizable=yes,width="+x+",height="+y);	break;
	}	 
}

function mediaVideo(file){
  window.open("media_video.html?file="+file,"Video Player","scrollbars=yes,resizable=yes,width=420,height=340");
}
function mediaAudio(file){
  window.open("media_audio.html?file="+file,"Audio Player","scrollbars=yes,resizable=yes,width=420,height=120");
}
function mediaPrint(file){
  window.open("media_print.html?file="+file,"Viewer","scrollbars=yes,resizable=yes,width=1000,height=600");
}
function mediaHtml(file,x,y){
  window.open(file,"Viewer","scrollbars=yes,resizable=yes,width="+x+",height="+y);
}
function mediaPhoto(file){
  window.open("media_photo.html?dir="+file,"Viewer","scrollbars=yes,resizable=yes,width=450,height=460");
}

function media(MED,Tit,Fec,Thm,Des,Fil,Lnk) {
	if (VarMedia=="ALL" || MED==VarMedia)  {
	switch(MED){
		case 'VID':  SmlTxt='VIDEO:';	aLink='javascript:mediaVideo(\''+Fil+'\');';	tLink=Fil;  break;    
		case 'AUD':  SmlTxt='AUDIO:';	aLink='javascript:mediaAudio(\''+Fil+'\');';  	tLink=Fil;	break;
		case 'PRT':  SmlTxt='PRINT:';	aLink='javascript:mediaPrint(\''+Fil+'\');';  	tLink=Fil;	break;
		case 'WEB':  SmlTxt='LINK:';	aLink=Fil; tLink=Fil;	break;
	}	
	document.write('<div class="mediaDiv">');
    	document.write('<a href="'+aLink+'">'); 
		document.write('<img src='+Thm+' class="mediaThumb" alt="'+Tit+'" / >');
    	document.write('</a>'); 
		document.write('<span class="mediaTitu">'+Tit+'</span>&nbsp;&nbsp;');
		document.write('<span class="mediaSmall">'+Fec+'</span>');
   		document.write('<div  class="mediaDesc">'+Des+'</div>'); 
		document.write('<span class="mediaSmall">'+SmlTxt+'&nbsp;&nbsp;<a href="'+aLink+'"  class="mediaLink">'+tLink+'</a></span>');
		if (MED=='VID') document.write('&nbsp;&nbsp;<a href="php/download.php?file='+Fil+'" class="mediaDown">&nbsp;DOWNLOAD&nbsp;</a>'); 
    document.write('</div>');
	}
}

//=========================================================
function PlayVideo(vfile,ifile){
			var moviefile = vfile;	var imagefile = ifile;
			var varflash='&icons=false&backcolor=#333333&frontcolor=#FFFFFF&lightcolor=#cccc33&image='+imagefile;
	        var s1 = new SWFObject('player.swf','player','218','180','8');
            s1.addParam('allowfullscreen','true');
            s1.addParam('allowscriptaccess','always');
            s1.addParam('flashvars','file='+moviefile+varflash);
            s1.write('preview');
}
function PlayAudio(afile,apod){
			var audiofile = afile;
			var varflash='&backcolor=#333333&frontcolor=#FFFFFF&lightcolor=#cccc33&volume=50';
			var s1 = new SWFObject('player.swf','player','200','20','8');
            s1.addParam('allowfullscreen','true');
            s1.addParam('allowscriptaccess','always');
            s1.addParam('flashvars','file='+audiofile+varflash);
            s1.write(apod);
}
function PlayGallery(afile,agal){
			var audiofile = afile;
			var varflash='&backcolor=#333333&frontcolor=#FFFFFF&lightcolor=#cccc33&volume=50';
			var s1 = new SWFObject('imagerotator.swf','player','200','20','8');
            s1.addParam('allowfullscreen','true');
            s1.addParam('allowscriptaccess','always');
            s1.addParam('flashvars','file='+audiofile+varflash);
            s1.write(apod);
}


function archive(MED,Fec,Des,Fil) {
	if (VarMedia=="ALL" || MED==VarMedia)  {
	switch(MED){
		case 'VID':  SmlTxt='VIDEO:';	aLink='javascript:mediaVideo(\''+Fil+'\');'; iCon="pic-archivevideo.png";   break;    
		case 'POD':  SmlTxt='PODCAST:';	aLink='javascript:mediaAudio(\''+Fil+'\');'; iCon="pic-archiveaudio.png";  	break;
		case 'GAL':  SmlTxt='GALLERY:';	aLink='javascript:mediaPhoto(\''+Fil+'\');'; iCon="pic-archivephoto.png";  	break;
	}	
	document.write('<div class="archiveDiv">');
    	document.write('<a href="'+aLink+'">'); 
		document.write('<img src=images/'+iCon+' class="archiveImg"  alt="'+Des+'" / >');
    	document.write('</a>'); 
		document.write('<span class="mediaSmall">'+Fec+'</span>');
   		document.write('<div  class="mediaDesc">'+Des+'</div>'); 
    document.write('</div>');
	}
}

function intro( Fil, Ima ){
    	document.write('<a href="javascript:PlayVideo(\''+Fil+'&amp;autostart=true\',\''+Ima+'\');">'); 
		document.write('<img src='+Ima+' class="FrameIntro"  alt="'+Ima+'" / >');
    	document.write('</a>'); 
}

