// -----------------------------------------------------------------------
// Common functions
// -----------------------------------------------------------------------
var saveWidth = 0;
var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all


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 VerBanner(banner){
	var newurl = 'viewbanner.php?bannername=' + banner ;
	var sPropsVentana = 'width=400,height=300,scrollbars=no,resizable=no,scrollbars=no,resizable=no,status=no';
	window.open( newurl , 'banner', sPropsVentana);
}
// -----------------------------------------------------------------------
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 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(n,u,w,h,x,rs,sb,mb,tb,st) {
	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 ventanadisco(disco){
	if (disco != ''){
		var urldisco="disco.php?album=" + disco;
		var discowindow = dhtmlwindow.open('discobox', 'iframe', urldisco, 'DISCO', 'width=360px,height=300px,left=400px,top=100px,scrolling=1,center=1'); 
	}
}
//--------------------------------------------------------------------
function ventananoticia(noticia){
	if (noticia != ''){
		var urlnoticia="noticia.php?noticia=" + noticia;
		var discowindow = dhtmlwindow.open('noticiabox', 'iframe', urlnoticia, 'NOTICIA', 'width=460px,height=400px,left=300px,top=130px,scrolling=1,center=1'); 
	}
}
//--------------------------------------------------------------------
function ventanaimagen(strDIMGGRAN){
	if (strDIMGGRAN != ''){
		var imagepath="multimedia/" + escape(strDIMGGRAN);
		var urlimagen="view_image.php?simagen=" + imagepath;
		var discowindow = dhtmlwindow.open('discoimgbox', 'iframe', urlimagen, 'IMAGEN', 'width=600px,height=525px,left=300px,top=130px,scrolling=1,center=1'); 
	}
}
//--------------------------------------------------------------------
function ventanalyric(strURL){
	if (strURL != ''){
		var urllyric=strURL;
		var discowindow = parent.dhtmlwindow.open('discolyricbox', 'iframe', urllyric, 'LETRA', 'width=450px,height=520px,left=300px,top=130px,scrolling=1,center=1'); 
	}
}
//--------------------------------------------------------------------
function ViewSong(action,songid,albumid) {
	var altoPantalla = window.screen.height;
	var anchoPantalla = window.screen.width;
	var sPropsVentana;
	var left;
	var top;
	if (action=='play'){
		var url = 'reproductor.php?songid=' + songid + '&albumid=' + albumid;
		parent.reproductor.location= url;
	} else if (action=='lyric'){
		var url = 'view_song.php?song_id=' + songid + '&album=' + albumid + '&action=' + action;
		ventanalyric(url);
	} 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';
		var url = 'view_song.php?song_id=' + songid + '&album=' + albumid + '&action=' + action;
		window.open( url , action,sPropsVentana);
	} 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';
		var url = 'view_song.php?song_id=' + songid + '&album=' + albumid + '&action=' + action;
		window.open( url , action,sPropsVentana);
	} else {
		return;
	}
}
//----------------------------------------------------------------------------------------


