// -----------------------------------------------------------------------
// Common functions
// -----------------------------------------------------------------------
var saveWidth = 0;
var showOriginal = false;
var isScaled = false;
// -----------------------------------------------------------------------
function fnOver(strIdTd) {
	document.getElementById(strIdTd).background = "img/site/fondo_over_botonera.gif";
	return(true);
}
// -----------------------------------------------------------------------
function fnOut(strIdTd) {
	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_old(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 scaleImg(what,maxW){
	//what = document.getElementById(what);
	var winWx=0;

	if (document.body) {
		winW = (document.body.clientWidth);
		winH = (document.body.clientHeight);
	} else {
		winW = (window.innerWidth);
		winH = (window.innerHeight);
	}


	if (maxW != 0){
		winW = maxW;
	} else {
		if ( what.height > (winH-100)){
			winWx = ((winH-100) * what.width / what.height);
		}
	}

	if (winWx < winW && winWx > 0){
		winW = winWx;	
	}

	if (showOriginal == false){
		saveWidth = what.width ;
		if ( what.width > (winW-100)) {
			isScaled = true;
			showOriginal = true;
			what.style.cursor = "pointer";
			what.width = (winW-100);
			what.alt = "Click para Ampliar";
		}
	} else {
		if (isScaled){
			showOriginal = false;
			what.width = saveWidth;
			what.alt = "Click para Reducir";
		}
	}

}
// -----------------------------------------------------------------------
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=yes,resizable=yes';
	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 = "viewdoc.php?tipo=" + tipo + "&archivo=" + archivo;
		mywin = winaux(url,tipo,720,550,"yes","yes","no","no","no",1);	
	}
}
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------

