// -----------------------------------------------------------------------
// Common functions
// -----------------------------------------------------------------------
var saveWidth = 0;


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="multimedia/" + escape(strDIMGGRAN);
	var url = "view_image.php?simagen=" + imagepath ;
	window.open( url , 'imagen',sPropsVentana);
}
//------------------------------------------------------------
function ViewSong(action,songid,albumid) {
	var altoPantalla = window.screen.height;
	var anchoPantalla = window.screen.width;
	var sPropsVentana;
	var left;
	var top;
	if (action=='play'){
		left = (anchoPantalla / 2) + (755 / 2) - (320);
		top =  80 ;
		sPropsVentana  = 'width=320,height=180';
		sPropsVentana += ',top=' + top + ',left=' + left;
		sPropsVentana += ',scrollbars=no,resizable=no';
	} else if (action=='score'){
		left = (anchoPantalla / 2) - (580 / 2);
		top = (altoPantalla / 2) - (720 / 2);
		sPropsVentana  = 'width=720,height=580';
		sPropsVentana += ',top=' + top + ',left=' + left;
		sPropsVentana += ',scrollbars=yes,resizable=yes';
	} else if (action=='download'){
		left = (anchoPantalla / 2) - (100 / 2);
		top = (altoPantalla / 2) - (50 / 2);
		sPropsVentana  = 'width=100,height=50';
		sPropsVentana += ',top=' + top + ',left=' + left;
		sPropsVentana += ',scrollbars=yes,resizable=yes';
	} else if (action=='playmidi'){
		left = (anchoPantalla / 2) - (100 / 2);
		top = (altoPantalla / 2) - (50 / 2);
		sPropsVentana  = 'width=100,height=50';
		sPropsVentana += ',top=' + top + ',left=' + left;
		sPropsVentana += ',scrollbars=yes,resizable=yes';
	} else if (action=='view'){
		left = (anchoPantalla / 2) - (450 / 2);
		top = (altoPantalla / 2) - (540 / 2);
		sPropsVentana  = 'width=450,height=540';
		sPropsVentana += ',top=' + top + ',left=' + left;
		sPropsVentana += ',scrollbars=yes,resizable=yes';
	} else {
		return;
	}
	var url = 'view_song.php?song_id=' + songid + '&album=' + albumid + '&action=' + action;
	window.open( url , action,sPropsVentana);
}
//------------------------------------------------------------
function ViewVideo(action,video) {
	var altoPantalla = window.screen.height;
	var anchoPantalla = window.screen.width;
	var sPropsVentana;
	var left;
	var top;
	if (action=='play'){
		left = (anchoPantalla / 2) + (755 / 2) - (450);
		top =  80 ;
		sPropsVentana  = 'width=450,height=390';
		sPropsVentana += ',top=' + top + ',left=' + left;
		sPropsVentana += ',scrollbars=no,resizable=yes';
	} else {
		return;
	}
	var url = 'view_video.php?video=' + video + '&action=' + action;
	window.open( url , action,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;
}
//------------------------------------------------------------
  
