/********************************************/
/*				funciones.js	     		*/
/*  		Autor: Alex cáceres 			*/
/********************************************/
uds=0;
function visorp(id,w,h){
	url="visorproductos.php?id="+id;

	
	x=(screen.Width-w)/2;
	y=(screen.Height-h)/2;
	ventana=window.open(url,'popup','width='+w+',height='+h+',left='+x+',top='+y+',location=no,scrollbars=no,resize=no,status=no');
	//la doy foco
	ventana.focus();
	
}
function aCero(n){
	if(document.getElementById("cb_"+n).checked){
		uds=document.getElementById("uds_"+n).value;
		document.getElementById("uds_"+n).value=0;
	}else
		document.getElementById("uds_"+n).value=uds;
}
function carrito(n){
	document.location.href="carrito.php?action=add&id="+n+"&cant="+document.getElementById("uds_"+n).value+"&ref="+document.location.href;
}
function menos(n,m){
	if(document.getElementById("uds_"+n).value>m){
		document.getElementById("uds_"+n).value=parseInt(document.getElementById("uds_"+n).value)-parseInt(m);
	}
}
function mas(n,m){
	if(document.getElementById("uds_"+n).value<(101-m)){
		document.getElementById("uds_"+n).value=parseInt(m)+parseInt(document.getElementById("uds_"+n).value);
	}
}
function mas2(n,m){
	if(document.getElementById("uds_"+n).value<(100) && document.getElementById("uds_"+n).value!=0){
		document.getElementById("uds_"+n).value++;
	}
}
function menos2(n,m){
	if(document.getElementById("uds_"+n).value>1 && document.getElementById("uds_"+n).value!=0){
		document.getElementById("uds_"+n).value--;
	}
}
function showTip(id){
	if(document.getElementById(id).innerHTML!="")
		document.getElementById(id).style.display="block";
	
}
function hideTip(id){
	document.getElementById(id).style.display="none";
}
function showCalendar(){
	document.getElementById('calendario').style.display="block";
	document.getElementById('calendarioon').style.display="none";
	document.getElementById('calendariooff').style.display="block";
}
function hideCalendar(){
	document.getElementById('calendario').style.display="none";
	document.getElementById('calendariooff').style.display="none";
	document.getElementById('calendarioon').style.display="block";
}

//Alex fullpopup 2.0 compatible mozilla

function popUp(url,w,h){
	x=(screen.width-w)/2;
	y=(screen.height-h)/2;
	ventana=window.open(url,'popup','width='+w+',height='+h+',left='+x+',top='+y+',location=no,scrollbars=no,resize=no,status=no');
	//la doy foco
	ventana.focus();
}
function legal(){
	w=774;
	h=524;
	url="../textolegal/index.php";
	x=(screen.width-w)/2;
	y=(screen.height-h)/2;
	ventana=window.open(url,'popup','width='+w+',height='+h+',left='+x+',top='+y+',location=no,scrollbars=no,resize=no,status=no');
	//la doy foco
	ventana.focus();
}
function comollegar(){
	w=724;
	h=634;
	url="comollegar.php";
	x=(screen.width-w)/2;
	y=(screen.height-h)/2;
	ventana=window.open(url,'comollegar','width='+w+',height='+h+',left='+x+',top='+y+',location=no,scrollbars=no,resize=no,status=no');
	//la doy foco
	ventana.focus();
}
function pago(){
	w=774;
	h=524;
	url="../formasdepago/index.php";
	x=(screen.width-w)/2;
	y=(screen.height-h)/2;
	ventana=window.open(url,'popup','width='+w+',height='+h+',left='+x+',top='+y+',location=no,scrollbars=no,resize=no,status=no');
	//la doy foco
	ventana.focus();
}
function niveles(id){
	w=774;
	h=524;
	url="../niveles/nivel.php?id="+id;
	x=(screen.width-w)/2;
	y=(screen.height-h)/2;
	ventana=window.open(url,'niveles','width='+w+',height='+h+',left='+x+',top='+y+',location=no,scrollbars=no,resize=no,status=no');
	//la doy foco
	ventana.focus();
}
function nivel(id,idf,idt){
	w=774;
	h=524;
	url="../niveles/nivel.php?id="+id+"&idf="+idf+"&idt="+idt;
	x=(screen.width-w)/2;
	y=(screen.height-h)/2;
	ventana=window.open(url,'niveles','width='+w+',height='+h+',left='+x+',top='+y+',location=no,scrollbars=no,resize=no,status=no');
	//la doy foco
	ventana.focus();
}
function redim(w,h){
		proporcion=w/h;
		
		ini=w/100;
		for(i=ini;i<w;i+=10){
		  if(i>ini)
		  	window.focus();
		  j=i/proporcion;
		  moveTo((screen.width-i)/2,(screen.height-j)/2);
		  
		  idInt=setInterval(vacio,1000);
		  resizeTo(i,j);
		}
		//finalizo
		resizeTo(w+12,h+63);
		clearInterval(idInt);
	}
	
function zoom(id){
		
		w=525;
		h=440;
		x=(screen.width-w)/2;
		y=(screen.height-h)/2;
		popup=window.open('zoom.php?id='+id,'zoom','width='+w+',height='+h+',top='+y+',left='+x+',scrollbars=0,resizable=0,toolbar=0,location=0, status=0');
		popup.focus();
}

function enviarAmigo(){
		
		w=400;
		h=400;
		x=(screen.width-w)/2;
		y=(screen.height-h)/2;
		popup=window.open('../enviaraunamigo/index.php','zoom','width='+w+',height='+h+',top='+y+',left='+x+',scrollbars=0,resizable=0,toolbar=0,location=0, status=0');
		popup.focus();
}

function fotozoom(id){
		
		w=502;
		h=402;
		x=(screen.availWidth-w)/2;
		y=(screen.availHeight-h)/2;
		popup=window.open('fotozoom.php?id='+id,'fotozoom','width='+w+',height='+h+',top='+y+',left='+x+',scrollbars=0,resizable=0,toolbar=0,location=0, status=0');
		popup.focus();
}

function inm(){
		
		w=703;
		h=510;
		x=(screen.width-w)/2;
		y=(screen.height-h)/2;
		popup=window.open('http://www.inm.es/cgi-bin/locali.cgi?ig=19159','inm','width='+w+',height='+h+',top='+y+',left='+x+',scrollbars=0,resizable=0,toolbar=0,location=0, status=0');
		popup.focus();
}


//Alex rollOver 2.0
function over(id){
	on=document.getElementById(id).src;
	document.getElementById(id).src=on.replace("off.gif","over.gif");
}

//Alex rollOut 2.0
function out(id){
	off=document.getElementById(id).src;
	document.getElementById(id).src=off.replace("over.gif","off.gif");
}

//Alex div rollOver 1.1
function divover(id){
	if(id.lastIndexOf('submenu')!=-1)
		document.getElementById(id).style.backgroundImage="url(../img/comun/bgbotover.gif)";
}

//Alex div rollOut 1.1
function divoff(id){
	if(id.lastIndexOf('submenu')!=-1)
		document.getElementById(id).style.backgroundImage="url(../img/comun/bgbotoff.gif)";
}

function divbotover(id){
	if(id.lastIndexOf('boton')!=-1)
		document.getElementById(id).style.backgroundImage="url(../img/comun/bgbotonover.gif)";
}

//Alex div rollOut 1.1
function divbotoff(id){
	if(id.lastIndexOf('boton')!=-1)
		document.getElementById(id).style.backgroundImage="url(../img/comun/bgbotonoff.gif)";
}

function divbotthover(id){
	if(id.lastIndexOf('botth')!=-1)
		document.getElementById(id).style.backgroundImage="url(../img/comun/bgbotthover.gif)";
}

//Alex div rollOut 1.1
function divbotthoff(id){
	if(id.lastIndexOf('botth')!=-1)
		document.getElementById(id).style.backgroundImage="url(../img/comun/bgbotthoff.gif)";
}

var t;
function show(id){
		document.getElementById(id).style.display="block";
		clearTimeout(t);
}
function hide(id){
		var str="document.getElementById('"+id+"').style.display='none'";
		t=setTimeout(str,100);
}

function vacio(){
	//para hacer pausa	
}

