var newwindow = '';


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_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

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_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 mover(destino,id,id2){
	if (destino == "contacta"){	
		popitup( destino + '.aspx','contacta','dependent=yes,resizable= no,menubar=no, status = no',620,470);		
	/*llamar a contacta, pero desde la lista de precios*/
	} else if (destino == "contactaDesdePrecios"){	
		popitup( '../contacta.aspx','contacta','dependent=yes,resizable= no,menubar=no, status = no',620,470);		
	} else if (destino  == "logos") {
		popitup(id, "logos",'dependent=yes,resizable= yes,menubar=yes, status = yes,toolbar=yes,scrollbars = yes',620,470);
	} else if (destino == "DetalleNovedad"){
		popitup(destino + '.aspx?ID=' + id,'DetalleNovedad','dependent=yes,resizable= no,menubar=no, status = yes,toolbar=no,scrollbars = yes',400, 370);	
	} else if (destino == "DetalleOferta"){
		popitup(destino + '.aspx?ID=' + id,'DetalleOferta','Dependent=yes,resizable= no,menubar=no, status = yes,toolbar=no,scrollbars = yes', 400,370)		
	} else if (destino == "DetalleProducto"){
		popitup(destino + '.aspx?idProducto=' + id + '&idDetalle=' + id2,'DetalleProducto','Dependent=yes,resizable= no,menubar=no, status = yes,toolbar=no,scrollbars = yes', 400,370)		
	} else if (destino == "FichCatalogoPDF"){
		popitup('../Descargas/Catalogos/CatalogoPDF.pdf','Catalogo','dependent=yes,resizable= yes,menubar=no, status = no,scrollbars = yes', 450,450);	
	} else if ( destino == "PlanoSituacion"){
		popitup(destino + '.aspx?Delegacion=' + id , 'PlanoSituacion', 'dependent=yes,resizable= no,menubar=no, status = no,scrollbars = no',485,515)		
	} else if (destino == "ListaProductos"||destino == "QuienesSomos" || destino == "Inicio"){
		if (document.all) {
			parent.document.all.contenido.src = destino + '.aspx';							
		} else {
			parent.document.getElementById("contenido").src = destino + '.aspx';
		}
	} else if (destino == "Inicio" || destino == "Novedades" || destino == "Ofertas" || destino == "links" ){
		if (document.all) {
			document.all.contenido.src = destino + '.aspx';							
		} else {
			document.getElementById("contenido").src = destino + '.aspx';	
		}
	} else if (destino == "catalogoPDF"||destino == "Delegaciones" || destino == "DescargasMain"){
		if (document.all) {
			document.all.contenido.src = destino + '.aspx';							
		} else {
			document.getElementById("contenido").src = destino + '.aspx';	
		}
	}  else if (destino == "Lista"){
		if (document.all) {
			document.all.contenido.src = './ListaPrecios/' + destino + '.aspx';							
		} else {
			document.getElementById("contenido").src = './ListaPrecios/' + destino + '.aspx';	
		}
	}  else if (destino == "ListaPrecios"){
		popitup('./ListaPrecios.aspx','Precios','dependent=yes,resizable= yes,menubar=no, status = no,scrollbars = yes',450,450);	
	} else if (destino == "ListaPreciosGold"){
		popitup('./gold/ListaPreciosGold.aspx','Precios','dependent=yes,resizable= yes,menubar=no, status = no,scrollbars = yes',450,450);	
	}else if (destino == "ListaPreciosSilver"){
		popitup('./silver/ListaPreciosSilver.aspx','Precios','dependent=yes,resizable= yes,menubar=no, status = no,scrollbars = yes',450,450);	
	}else if (destino == "ListaPreciosBronze"){
		popitup('./bronze/ListaPreciosBronze.aspx','Precios','dependent=yes,resizable= yes,menubar=no, status = no,scrollbars = yes',450,450);	
	} 
	else if (destino == "VerDemostracion"){
		popitup('../../Descargas/ListaPrecios/bronze/CatalogoPDF.pdf','Precios','dependent=yes,resizable= yes,menubar=no, status = no,scrollbars = yes',450,450);	
	}	
	else if (destino == "ListaServicios"){
		if (document.all) {
			document.all.contenido.src = 'Servicios.aspx';							
		} else {
			document.getElementById("contenido").src = 'Servicios.aspx';	
		}	
	}
	else if (destino == "CondicionesGarantia"){
		if (document.all) {
			document.all.contenido.src = '../CondicionesGarantia.htm';							
		} else {
			document.getElementById("contenido").src = '../CondicionesGarantia.htm';	
		}	
	}
	else if (destino == "AvisoLegal"){
		popitup('../AvisoLegal.htm','AvisoLegal','dependent=yes,resizable= yes,menubar=no, status = no,scrollbars = yes',450,450);	
	} 
	
	else if (destino == "DescargaDriver"||destino == "DescargaHojaTecnica"||destino == "DescargaPrograma"){
		popitup(id,'Descarga','dependent=yes,resizable= yes,menubar=no, status = no,scrollbars = yes',450,450);				
	}
	
	return;
	//parent.document.all.contenido.height =400;	
}

function moverUrlServicios(URL){
	//if (LISTA =='SI'){
	//	popitup( URL ,'Productos','dependent=yes,resizable= yes,height=450,width=620,location = yes,menubar=yes, status = yes,scrollbars = yes');		
	//} else {
		popitup( URL,'Servicios','dependent=yes,resizable= no,location = no,menubar=no, status = yes,toolbar=no, scrollbars= yes',620,550);			
	//}
}

function moverUrlListaProductos(URL){
	//pequeña chapu para que aparezcan las barras de navegación únicamente en el link de armarios
	if (URL.indexOf("Armarios")!= -1){
		popitup( URL ,'Productos','dependent=yes,resizable= yes,location = yes,menubar=yes, status = yes,toolbar=yes, scrollbars = yes',620,550);		
	} else {
		popitup( URL,'Productos','dependent=yes,resizable= yes, location = no, menubar=no,  status = yes,toolbar=no, scrollbars= yes',620,550);			
	}
}
function moverUrlDemostracion(URL){
	//if (LISTA =='SI'){
	//	popitup( URL ,'Productos','dependent=yes,resizable= yes,height=450,width=620,location = yes,menubar=yes, status = yes,scrollbars = yes');		
	//} else {
		popitup( URL,'Demo','dependent=yes,resizable= yes,location = yes,menubar=yes, status = yes,toolbar=yes, scrollbars= yes',620,550);			
	//}
}

function mover1(destino){
	 if (window.parent){
		if ( destino == "DescargaDrivers"){
			parent.document.all.contenido.src = "./Descargas.aspx?Id=Drivers";				
		} else if ( destino == "DescargaProgramas"){
			parent.document.all.contenido.src = "./Descargas.aspx?Id=Programas";				
		} else if ( destino == "DescargaHojasTecnicas"){
			parent.document.all.contenido.src = "./Descargas.aspx?Id=HojasTecnicas";				
		}		
	} else if (window.opener){
		if ( destino == "DescargaDrivers"){
			opener.document.getElementById("contenido").src = "./Descargas.aspx?Id=Drivers";				
		} else if ( destino == "DescargaProgramas"){
			opener.document.getElementById("contenido").src = "./Descargas.aspx?Id=Programas";				
		} else if ( destino == "DescargaHojasTecnicas"){
			opener.document.getElementById("contenido").src = "./Descargas.aspx?Id=HojasTecnicas";				
		}		
	}
}

function popitup(url,name, parameters, width, height)
{
	if (!newwindow.closed && newwindow.location)
	{
		newwindow.location.href = url;
		
		//lo coloco por los bloqueadores de popups		
		if (newwindow == null){
			return false;
		}		
	}
	else
	{
		newwindow=OpenBrWindow(url,name,parameters,width, height );
		
		//lo coloco por los bloqueadores de popups
		if (newwindow == null){
			return false;
		}
		
		//comprobamos si la ventana existe antes de utilizar la ventana
		if (!newwindow.opener && !window.opener.closed){
			newwindow.opener = self;
		}
	}
	

	if (window.focus && newwindow != null) {
		try{
			newwindow.focus()
		} catch(ex){
			//se puede producir una exception en caso de programas que bloqueen popups
		}
	}
	
		
	
	return false;
}


/*function centrarPopUp(ventana){
	var screen_height,screen_width;
	var x,y;
	
	x = 0;
	y = 0;

	if (window.innerHeight) // all except Explorer
	{
		x = ventana.innerWidth;
		y = ventana.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = ventana.document.documentElement.clientWidth;
		y = ventana.document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{

		x = ventana.document.body.clientWidth;
		y = ventana.document.body.clientHeight;
	}
	
	if (window.screen){

		left_point = parseInt((screen.width-x)/2); 
		if (left_point<0){
			left_point = 0;
		}

		top_point = parseInt((screen.height-y)/2); 
		if (top_point<0){
			top_point = 0;
		}

		ventana.moveTo(left_point,top_point); 
	}

}*/

function OpenBrWindow(theURL,winName,features, myWidth,myHeight) { //v3.0
  var myLeft;
  var myTop;
  var theWindow
  
  if(window.screen){
    myLeft = parseInt((screen.availWidth- myWidth  )<0? 0 :(screen.availWidth-myWidth  )/2);
    myTop =  parseInt((screen.availHeight-myHeight)<0? 0 :(screen.availHeight-myHeight)/2);
    
    features+=(features!='')?',':'';
    
    features+=' left='+myLeft+',top='+myTop;
    
	features+=((features!='')?',':'')+'width='+myWidth+',height='+myHeight;    
    
    theWindow = window.open(theURL,winName,features);
    

  } else {
	
	features+=(features!='')?',':'';
		
	theWindow = window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight); 
  }
     
 return theWindow;
   
   
 }
 
 /*
 <script language="JavaScript1.2">

window.moveTo(0,0);
if (document.all){ top.window.resizeTo(screen.availWidth,screen.availHeight); }
else if (document.layers||document.getElementById){
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
</script>

 */
/*function cursorWait(){
	window.document.body.style.cursor = 'crosshair';
}

function cursorReady(){
	window.document.body.style.cursor = 'default';
}*/
