//---------------------------------------------------------------------//
//  Funcion RollOver
function show(imgDocID,imgObjName){
    document.images[imgDocID].src = eval(imgObjName + ".src");
}

//---------------------------------------------------------------------//
//  Abrir ventana
function openwindow(location, name, width, height, x, y) {
  window.open(location, name, 'height=' + height + ',width=' + width + ',screenX=' + x + ',screenY=' + y + ',scrollbars=yes,left=' + x + ',top=' + y );
}

//---------------------------------------------------------------------//
//  Dada una cadena comprobamos si es o no una fecha valida
function CorrectDate( vardate ) {
  var dayNr, monthNr, yearNr;
  var bDateOk;
  var bEncDate, bEncMonth,bEncYear;
  var indice, iStartDate,iEndDate,iStartMonth,iEndMonth,iStartYear,iEndYear;
     
  //Inicialización d las var locales
  bDateOk = false;
  bEncDate = false;
  bEncMonth = false;
  bEncYear = false;
  iIStartDate = 0;
  indice = 0;
  //Fin inicializacion var locales
     
  //Encontramos el dia, mes y año en la cadena d texto
  while (((! bEncDate) || (! bEncMonth)|| (! bEncYear)) && (vardate.length >= indice))
  {
	if (vardate.substring(indice,indice+1)=="/"){
		if (! bEncDate)
		   {
			   bEncDate = true;
			   iEndDate = indice;
			   iStartMonth = iEndDate+1;
			   dayNr = vardate.substring(iStartDate,iEndDate);
		   }
		else{
			   bEncMonth = true;
			   iEndMonth = indice;
			   iStartYear = iEndMonth+1;
			   monthNr = vardate.substring(iStartMonth,iEndMonth);
			}
		 }
   		 
		if ((vardate.substring(indice,indice+1)==" "  || indice == vardate.length) && (bEncDate) && (bEncMonth))
			{
				bEncYear = true;
			   iEndYear = indice;
			   yearNr = vardate.substring(iStartYear,iEndYear);
			 }
   	
	indice = indice + 1;
  }
  //Fin while: dia, mes y año obtenidos
     
  //Verificamos q dia, mes y año son validos  
  if (yearNr>=0) {
    if ( (monthNr>=1) && (monthNr<=12)) {    
      if (monthNr==2) {
      // Febrero
        if ( ( (yearNr % 4 == 0) && (yearNr % 100 != 0) ) || (yearNr % 400 == 0) ) { 
        // Es bisiesto
          if ( dayNr<=29 ) { bDateOk=true }
        } else {
          if ( dayNr<=28 ) { bDateOk=true }          
        }
      } else {
        if ( (monthNr==1) || (monthNr==3) || (monthNr==5) || (monthNr==7) || (monthNr==8) || (monthNr==10) || (monthNr==12) ) {
        // Meses de 31 días
          if ((dayNr>=1) && (dayNr<=31) ) { bDateOk=true }
        } else {
        // Meses de 30 días
          if ((dayNr>=1) && (dayNr<=30) ) { bDateOk=true }
        }
      }
    }
  } 
  //Fin verificacion

  return bDateOk;
}

	//  Funciones para entrar desde la Intro de Flash


function esp()
{
       window.location.href="/home.asp?lang=ES";
}
function eng()
{
       window.location.href="/home.asp?lang=EN";
}
	// Fin de la funcion


function popup(name) {
	miRuta= name + '.html';
	ventana=window.open(miRuta, name, 'left=100,top=100,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,height=400,width=440');
	ventana.focus();

}

 function OpenPopUp() {
		   window.open('/content_popup.asp?obj=4', 'seguridad', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,top=' + (window.screen.height - 400) / 2 +  ',left=' + (window.screen.width - 500) / 2 + ',width=480,height=575');
  }
  
  function OrderNavigation(ai_sCat,ai_sParent,ai_sDirect)
   {
	 document.frm_navigator.action='/browsing.asp?category='+ai_sCat+'&category_parent='+ai_sParent;   
     document.frm_navigator.nav.value='true';
     document.frm_navigator.submit();
	
   }

   function OrderNavigation_ambient(ai_sCat,sAmbient, show_all,speed,play)
   {
//	window.document.frm_navigator.action='/browsing_ambient.asp?category='+ai_sCat+'&category_parent='+ai_sParent+'&direct='+ai_sDirect+'&type_ambient='+ai_sAmbient;
	window.document.frm_navigator.action='/browsing_ambient.asp?ambient_to_show=' + sAmbient + '&catgid=' + ai_sCat + '&show_all=' + show_all + '&speed=' + speed + '&play=' +play;
      window.document.frm_navigator.submit();
   }
   
function OpenAttributesPopUp(piecaj,cajaspale,m2,peso,pesocaj,tipo,ml) {
   window.open('/product_popup.asp?piecaj=' + piecaj + '&cajaspale=' + cajaspale + '&m2=' + m2 + '&peso=' + peso + '&pesocaj=' + pesocaj + '&tipo=' + tipo + '&ml=' + ml, 'ProductPopUp', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,top=' + (window.screen.height - 400) / 2 +  ',left=' + (window.screen.width - 500) / 2 + ',width=620,height=150');
}
function OpenAdvicePopUp(prodid,especial) {
   window.open('/advice_popup.asp?prodid=' + prodid + '&especial=' +especial, 'AdvicePopUp', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=0,width=480,height=120');
}

function TrimPopUp() {
   window.open('/trim_popup.asp', 'AdvicePopUp', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,top=' + (window.screen.height - 400) / 2 +  ',left=' + (window.screen.width - 500) / 2 + ',width=620,height=151');
}

function OpenCorpPopUp (URL){ 
window.open(URL,"ventana1","width=450, height=260, scrollbars=yes, menubar=no, location=no, resizable=no")
}

function imprimirPagina() { 
	if (window.print) {
		window.print(); 
	}
	else {
		alert('<%=DMSiteTexts( oCustomer("cust_language_cd") & "_ERROR_PRINT" )%>'); 
	}
}

  function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  document.getElementById("if1").style.height=myHeight-250+"px";
}