// -----------------------------------------------------------------------
// Common functions
// -----------------------------------------------------------------------
var saveWidth = 0;
var swidth=509;
var sheight=41;
var sbcolor="#005CA4"	 //005CA4	355056
var sspeed=1;
var srcolor="#FFFFFF";			 //CCFF00  FFFFFF
var resumesspeed=sspeed;
// -----------------------------------------------------------------------
function fnOver(strIdTd,bcolor) {
	if (bcolor != ""){
		document.getElementById(strIdTd).style.backgroundColor = bcolor;
	}
	return(true);
}
// -----------------------------------------------------------------------
function fnOut(strIdTd) {
	document.getElementById(strIdTd).style.backgroundColor = "";
	document.getElementById(strIdTd).background = "img/site/blank.gif";
	return(true);
}
// -----------------------------------------------------------------------
function AX_swapImgRestore() { //v3.0
  var i,x,a=document.AX_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
// -----------------------------------------------------------------------
function AX_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.AX_p) d.AX_p=new Array();
    var i,j=d.AX_p.length,a=AX_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.AX_p[j]=new Image; d.AX_p[j++].src=a[i];}}
}
// -----------------------------------------------------------------------
function AX_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=AX_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
// -----------------------------------------------------------------------
function AX_swapImage() { //v3.0
  var i,j=0,x,a=AX_swapImage.arguments; document.AX_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=AX_findObj(a[i]))!=null){document.AX_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// -----------------------------------------------------------------------
function AX_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.AX_pgW=innerWidth; document.AX_pgH=innerHeight; onresize=AX_reloadPage; }}
  else if (innerWidth!=document.AX_pgW || innerHeight!=document.AX_pgH) location.reload();
}
AX_reloadPage(true);
// -----------------------------------------------------------------------
function scaleImg(what,maxW){
	//what = document.getElementById(what);
	if ( navigator.appName == "Netscape" ) {
		winW = window.innerWidth;
	}
	if ( navigator.appName.indexOf("Microsoft") != -1 ) {
		winW = document.body.offsetWidth;
	}
	if (maxW != 0){
		winW = maxW;
	}
	if ( what.width > (winW-100) || saveWidth >(winW-100) ) {
		if ( what.width == (winW-100) ){
			what.width = saveWidth;
		} else {
			saveWidth = what.width;
			//what.style.cursor = "pointer";
			what.width = (winW-100);
		}
	}
}
// -----------------------------------------------------------------------
function newwindow(url,width,height,status,resize) {
	if (resize==''){
		resize='no';
	} else {
		resize='yes';
	}
	if (status==''){
		status='no';
	} else {
		status='yes';
	}
	win1=window.open(url,"","width=" + width + ", height=" + height + ", status=" + status + ", resizable=" + resize + ', scrollbars=yes');
}
// -----------------------------------------------------------------------
function AmpliarImagen(strDIMGGRAN) {
	var altoPantalla = window.screen.height;
	var anchoPantalla = window.screen.width;
	var sPropsVentana;
	var left = (anchoPantalla / 2) - (500 / 2);
	var top = (altoPantalla / 2) - (600 / 2);
	sPropsVentana  = 'width=500,height=525';
	sPropsVentana += ',top=' + top + ',left=' + left;
	sPropsVentana += ',scrollbars=no,resizable=no';
	var imagepath="" + escape(strDIMGGRAN);
	var url = "viewimage.php?simagen=" + imagepath ;
	window.open( url , 'imagen',sPropsVentana);
}
//------------------------------------------------------------
function roundNum(amount){  
	var s = "";
	var decimal;  
	amount = parseFloat(amount);  
	if (!(isNaN(amount))) {
		amount = Math.round(amount * 100);
		amount = amount / 100;
		s = new String(amount);
		decimal = s.indexOf(".");    
		if (decimal == -1) {      
			// whole number
			s+= ".00";    
		} else {      
			if (decimal == (s.length - 2)) {
				s+= "0";      
			}    
		}  
	} else {
		s = "0.00";  
	}  
	return s;
}
//------------------------------------------------------------
function winaux(u,n,w,h,rs,sb,mb,tb,st,x) {
	var remote = null;
	var altoPantalla = window.screen.height;
	var anchoPantalla = window.screen.width;
	var left = (anchoPantalla / 2) - (w / 2);
	var top = (altoPantalla / 2) - (h / 2);
	if (rs == '' || rs == null || rs != 'yes'){ rs = 'no'; }
	if (sb == '' || sb == null || sb != 'yes'){ sb = 'no'; }
	if (mb == '' || mb == null || mb != 'yes'){ mb = 'no'; }
	if (tb == '' || tb == null || tb != 'yes'){ tb = 'no'; }
	var args = 'width='+w+',height='+h+',top='+top+',left='+left+',resizable='+rs+',scrollbars='+sb+',menubar='+mb+',toolbar='+tb+',status=no,location=no,directories=no';
	remote = window.open(u,n,args);
	if (remote != null) {
		if (remote.opener == null)
			remote.opener = self;
	}
	if (x == 1) { return remote; }
}
//------------------------------------------------------------
function ViewDoc(tipo, archivo){
	if ( tipo != '' && archivo != ''){
		url = "view_doc.php?tipo=" + tipo + "&archivo=" + archivo;
		mywin = winaux(url,tipo,720,550,"yes","yes","no","no","no",1);	
	}
}
//------------------------------------------------------------
function Viewpracticas(archivo){
	if (archivo != ''){
		url = "view_practicas.php?archivo=" + archivo;
		mywin = winaux(url,'practicas',720,550,"yes","yes","no","no","no",1);	
	}
}
//------------------------------------------------------------
function Viewnormas(archivo){
	if (archivo != ''){
		url = "view_normas.php?archivo=" + archivo;
		mywin = winaux(url,'normas',720,550,"yes","yes","no","no","no",1);	
	}
}
//------------------------------------------------------------
function AmpliarImagen(strDIMGGRAN) {
	var altoPantalla = window.screen.height;
	var anchoPantalla = window.screen.width;
	var sPropsVentana;
	var left = (anchoPantalla / 2) - (500 / 2);
	var top = (altoPantalla / 2) - (600 / 2);
	sPropsVentana  = 'width=600,height=525';
	sPropsVentana += ',top=' + top + ',left=' + left;
	sPropsVentana += ',scrollbars=no,resizable=no';
	var imagepath="" + escape(strDIMGGRAN);
	var url = "view_image.php?simagen=" + imagepath ;
	window.open( url , 'imagen',sPropsVentana);
}
//------------------------------------------------------------
function Votar(encuesta,urlvoto){
	if ( encuesta != ''){
		url = "votar.php" + urlvoto + "&enc=" + encuesta;
		mywin = winaux(url,"votacion",430,340,"yes","yes","no","no","no",1);	
	}
}
//------------------------------------------------------------
function SS_start(){
	if (document.all) {
		iemarquee(slider);
	}else if(document.getElementById){
		ns6marquee(document.getElementById('slider'));
	}else if(document.layers){
		ns4marquee(document.slider1.document.slider2);
	}
}
// -----------------------------------------------------------------------
function iemarquee(whichdiv){
	iediv=eval(whichdiv);
	iediv.innerHTML=wholemessage; 
	iediv.style.pixelTop=sheight;
	sizeup=iediv.offsetHeight;
	ieslide();
}
// -----------------------------------------------------------------------
function ieslide(){
	if (iediv.style.pixelTop>=sizeup*(-1)){
		iediv.style.pixelTop-=sspeed;
		setTimeout("ieslide()",100);
	}else{
		iediv.style.pixelTop=sheight;
		ieslide();
	}
}
// -----------------------------------------------------------------------
function ns4marquee(whichlayer){
	ns4layer=eval(whichlayer);
	ns4layer.document.write(wholemessage);
	ns4layer.document.close();
	sizeup=ns4layer.document.height;
	ns4layer.top-=sizeup;
	ns4slide();
}
// -----------------------------------------------------------------------
function ns4slide(){
	if (ns4layer.top>=sizeup*(-1)){
		ns4layer.top-=sspeed;
		setTimeout("ns4slide()",100);
	}else{
		ns4layer.top=sheight;
		ns4slide();
	}
}
// -----------------------------------------------------------------------
function ns6marquee(whichdiv){
	ns6div=eval(whichdiv);
	ns6div.innerHTML=wholemessage;
	ns6div.style.top=sheight;
	sizeup=ns6div.offsetHeight;
	ns6slide();
}
// -----------------------------------------------------------------------
function ns6slide(){
	if (parseInt(ns6div.style.top)>=sizeup*(-1)){
		ns6div.style.top=parseInt(ns6div.style.top)-sspeed;
		setTimeout("ns6slide()",100);
	}else{
		ns6div.style.top=sheight;
		ns6slide();
	}
}
// -----------------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------

