function validar_formulario(formulario)
{

if (formulario.radiobutton[0].checked== false ) 
 {
  alert("Tiene que leer y aceptar las condiciones generales.");
  // formulario.radio.focus();
   return (false);
  }	
  
 if (formulario.select.value=="" || formulario.select.value=="Forma de pago" ) 
 {
  alert("Selecione una forma de pago");
   formulario.select.focus();
   return (false);
  }		
 if (formulario.first_name.value.length <=0 ) 
 {
  alert("Rellene el campo Nombre");
   formulario.first_name.focus();
   return (false);
  }
 if (formulario.last_name.value.length <=0 ) 
 {
  alert("Rellene el campo Apellidos");
   formulario.last_name.focus();
   return (false);
  }
 if (formulario.H_PhoneNumber.value.length <=0 ) 
 {
  alert("Rellene el campo Telefono");
   formulario.H_PhoneNumber.focus();
   return (false);
  }

 return true;
}

function tipodepago(valor)
{
 document.location.href='?pago='+valor;
} 


function combonivel(formulario,com,pad)
{
	var i=0;
	var url=location.search;
	var cat,cat1,cat2,subcat,subcat1;
		//alert("hola");
  if(formulario!="-- Crear nivel --")
   {
	com+=1;
	url="?sec=sec_escap";
	url+="&niveles="+com;
	url+="&padre="+formulario;	
   } 
  else
   {
   // if(formulario=="-- Crear nivel --") 
	 //{
		 url="?sec=sec_niv";
		 url+="&niveles="+com;	
		 url+="&padre="+pad;	
	 //}
   } 
	// alert(url);
		location.href=url;
	//alert(com+" --- "+formulario+" --- "+url);
		
}

function combo_cant_min(formulario)
{
	var i=0;
	var url=location.search;
			//alert(formulario);
 		 url+="&unidades="+formulario;
		//alert(url);
		location.href=url;
		
}

/**var capa 
var maxAncho = 300 //define la anchura máxima de la imagen
var maxAlto = 300 //define la altura máxima de la imagen
var anchura;
var altura;
var marco=10;
var desplx=20;
var desply=115;**/
function zoom(idCapa,op,im)
{
 var jx = new Array(); 
 var jy = new Array(); 
 var cap2 = parent.document.getElementById("capa2"); 
 
 if(idCapa=="capa3") { 
	// Capa=parent.parent.capa3.style;
	
	Capa=parent.document.getElementById(idCapa).style;
	
	 //Capa.visibility="visible";
	 //return;
	 
	// imagen=parent.capa3.document.images['imag'];
		
	 var imagen = parent.document.images[0];	
	
	
	
	Capa.visibility="hidden";
	
	x= (cap2.style.left);
	y= (cap2.style.top);    
	 jx = x.split("p"); 
	x=Number(jx[0])+desplx+'px';
	 jy = y.split("p");
	y=Number(jy[0])+desply+'px'; 
	
	
	var pic=new Image(); 
    pic.src=im; 
	
	
	
	imagen.src=pic.src;
	
	
	
	anchura=pic.width;
	altura=pic.height;
	
   //  if(anchura > maxAncho)
	//	{
		porcientoAnchura = parseInt((maxAncho/anchura)*100)
		imagen.width = maxAncho
		imagen.height = (porcientoAnchura*altura)/100
	//	}

	/** if (altura > maxAlto)
		{
		porcientoAltura = maxAlto/altura*100
		imagen.height = maxAlto
		imagen.width = porcientoAltura*anchura/100
		}**/
	imagen.hspace=marco;
	imagen.vspace=marco;
	
	Capa.left=x; 
	Capa.top=y;

	Capa.height=(imagen.height+(2*marco))+'px'; 
	Capa.width=(imagen.width+(2*marco))+'px';
	
	
	Capa.visibility=op;	
	

	
	  return;
	  }
}

function imageResize (imagen){
  //  var porcentaje = .5;
	ancho=imagen.width;
	altura=imagen.height;
	
	porcientoAnchura = parseInt((maxAncho/ancho)*100)
		imagen.width = maxAncho
		imagen.height = (porcientoAnchura*altura)/100
   // imagen.width = imagen.width * porcentaje;
  }

function imprSelec(nombre)
{
  var ficha = document.getElementById(nombre);
  var ventimp = window.open(' ', 'popimpr');
  ventimp.document.write( ficha.innerHTML );
  ventimp.document.close();
  ventimp.print( );
  ventimp.close();
} 

function alto(ob)
{ 

 theobject=ob;
 if(ob.filters) ob.filters.alpha.opacity=100; 
  else ob.style.opacity=1; 
highlighting=setInterval("highlightit(theobject)",50) ;
}
function bajo(ob)
{
	 
 clearInterval(highlighting);
 if(ob.filters) ob.filters.alpha.opacity=100; 
  else ob.style.opacity=1; 
}
function highlightit(cur2)
{ 
	if(cur2.filters)
	 {
	  if (cur2.filters.alpha.opacity>50) cur2.filters.alpha.opacity-=5;
        else if (window.highlighting) clearInterval(highlighting) ;
	 }
	else
	{
	
	 if (cur2.style.opacity>=0.5 )cur2.style.opacity-=0.05;
	  else  if (window.highlighting) clearInterval(highlighting) ;
	//cur2.style.opacity=0.5;
	// clearInterval(highlighting) ;
	
    }


 
}

function detalle(valor)
{
  window.open("detalle/detalle.php?id="+valor,"OFERTA","top=10,left=20,width=580,height=500,scrollbars=yes,resizable=yes");
} 
function condiciones()
{
  window.open("condiciones.php","CONDICIONES","top=60,left=60,width=580,height=500,scrollbars=yes,resizable=yes");
} 
function abrir_ventana(valor)
{
  window.open("carro/"+valor,"OFERTA","top=10,left=20,width=580,height=500,scrollbars=yes,resizable=yes");
} 

function MM_findObj(n, d) {
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; 
	obj.style.visibility=v;
	}
}
function DockToBottomRight() 
{ 
 //var despl_x=164;
 //var despl_y=114;
	var windowHeight = document.body.clientHeight; 
	var windowWidth = document.body.clientWidth; 
	var windowScrollTop = document.body.scrollTop; 
	var windowScrollLeft = document.body.scrollLeft;
		
	 
	var cap1 = document.getElementById("capa"); 
	var cap2 = document.getElementById("capa2"); 

	 cap1.style.top = despl_y;
	 cap1.style.left = ((windowWidth-cap1.clientWidth)/2 ) + despl_x+"px"; 
	 cap2.style.top =0; 
	 
	// alert(cap2.clientWidth);
	cap2.style.left =( (windowWidth-cap2.clientWidth)/2 )+"px";
	
	 //cap2.style.left ='68px';
}  
 window.onscroll=DockToBottomRight; 
 window.onresize=DockToBottomRight; 
 window.onload=DockToBottomRight; 

