
constMaxItem=3;
var Pop;

function fnDispThis(active)
{
for (i=1; i < constMaxItem+1; i++)
	{
	if (i!=active)
		{
		document.all("sub"+i).style.display="NONE"
		}
	else
		{
		document.all("sub"+active).style.display="BLOCK"
		}
	}
}



function GetPath(aPath){	
	var DirS =new Array('/Funciones/','/Imagenes/','/img/','/Modules/','/Styles/');	
	var AP=new String(location.href);
	var PTO=new String(aPath);	
	var RPP;
	var PrP;
	var Parameters =new String('');	
	PrP=aPath.lastIndexOf('?');
	if (PrP !=-1){
	   PTO=aPath.slice(0,PrP);
	   Parameters=aPath.slice(PrP);}
	AP=AP.toLowerCase();	
	PTO=PTO.toLowerCase();		
	PTO=PTO.slice(1,PTO.length);	
	for (counter=0;counter<DirS.length;counter++){		
		var Directory=new String(DirS[counter]);		
		Directory=Directory.toLowerCase();			
		RPP=AP.lastIndexOf(Directory);	
		alert(AP + ' ' +Directory);	
		if (RPP > -1){ 
			AP=AP.slice(0,RPP);							
			return AP + PTO + Parameters;}}	
	if (RPP=-1)
		return AP}
function Activa(Elemento){
	//Elemento.src = "imagenes/" +Elemento.name +"_i.gif"
}
function DesActiva(Elemento){
	// Elemento.src = "imagenes/" +Elemento.name +".gif"
}

function OpenRegistro(){
		pt=new String(location.href);
	PrP=pt.lastIndexOf('?');
	if (PrP !=-1)
	   pt=pt.slice(0,PrP);

	PrP=pt.toLowerCase().lastIndexOf('default.asp');
	pt=pt.slice(0,PrP)+'Registro.asp';
	window.open(pt,'Registrese','width=400,height=400,top=100,left=100');  
	return false;}
	
function OpenPass(){
	pt=new String(location.href);
	PrP=pt.lastIndexOf('?');
	if (PrP !=-1)
	   pt=pt.slice(0,PrP);

	PrP=pt.toLowerCase().lastIndexOf('default.asp');
	pt=pt.slice(0,PrP)+'Pass.asp';
	window.open(pt,'Olvido','width=350,height=250,top=100,left=100');   
	return false;}

function OpenBuy(idarticulo){
	cont=confirm('Seguro que quiere aņadir ' + idarticulo + ' a su pedido')
	if(cont){
	pt=new String(location.href);
	PrP=pt.lastIndexOf('?');
	if (PrP !=-1)
	   pt=pt.slice(0,PrP);

	PrP=pt.toLowerCase().lastIndexOf('default.asp');
	pt=pt.slice(0,PrP)+'Modules/carrito_unidades.asp?IdArticulo=' + idarticulo;
	window.open(pt,'Compre','width=400,height=180,top=100,left=100');   
	}
	return false;}
	
function OpenArticulo(idarticulo){

	pt=new String(location.href);
	PrP=pt.lastIndexOf('?');
	if (PrP !=-1)
	   pt=pt.slice(0,PrP);
	
	PrP=pt.toLowerCase().lastIndexOf('default.asp');
	pt=pt.slice(0,PrP)+'Modules/Articulo.asp?IdArticulo=' + idarticulo;
	frm=window.open(pt,'Articulo','width=400,height=250,top=100,left=100');
	frm.focus();

	return false;}
	

function removeArticulo(idarticulo,i){
	cont=confirm('Seguro que quiere eliminar el ' + idarticulo + ' de su pedido');
	if(cont){
	pt=new String(location.href);
	PrP=pt.lastIndexOf('&Remove');
	if (PrP !=-1)
	   pt=pt.slice(0,PrP);
	//alert(pt + '&Remove=' + i);
	window.location= pt + '&Remove=' + i;
	//window.location.reload();
	}
	return false;}
	
function enviarPedido(){
	cont=confirm('Seguro que quiere enviar el pedido');
	if(cont){
	pt=new String(location.href);
	PrP=pt.lastIndexOf('?');
	if (PrP !=-1)
	   pt=pt.slice(0,PrP);

	PrP=pt.toLowerCase().lastIndexOf('default.asp');
	pt=pt.slice(0,PrP)+'PedidoDatos.asp';
	window.open(pt,'Enviar','width=400,height=300,top=100,left=100');  

	}
	return false;}
	
function borrarPedido(){
	cont=confirm('Seguro que quiere eliminar todo el pedido');
	if(cont){
		pt=new String(location.href);
		PrP=pt.lastIndexOf('&Eliminar');
		if (PrP !=-1)
			pt=pt.slice(0,PrP);
		
		window.location= pt + '&Eliminar=1' ;
			
	}
	return false;}
	
	function OpenCalendar(aObjectId, postBack, aPath, aControlType){	
	var txtName;
	var txtValue;		
	if (aControlType == 1){txtId=GetTxtId(aObjectId);	}
	else{	txtId=aObjectId;}	
	txtValue=Object(txtId).value	
	aPath=GetPath(aPath)+aPath;	
	Pop=window.open(aPath+"?id="+ txtId + "&selected="+txtValue+"&postBack="+postBack
	,'Calendar'	
	,'dependent=1,width=170,height=225,top=' + GetY(225) + ',left=' + GetX(170));			
	Pop.focus();	
	return false;}
	
	function SetDate(newDate,IdControl,postBack){	
	eval("opener.document.forms[0].elements['"+ IdControl + "'].value ='" + newDate + "';");		
	window.close();	
	if (postBack)
		__doPostBack('IdControl','');		
	return false;}
	
	function GetX(aWidth){	
    var xMax = screen.width;    	
    return  (xMax/2)-(aWidth/2);}
    
function GetY(aHeight){	
    var  yMax = screen.height;
    return  (yMax/2)-(aHeight/2);}
	
	function GetPath(aPath){	
	var DirS =new Array('/Java/','/DesktopModules/','/Opens/','/Styles/','/Images/','/img/','/Modulos/','/admin/');	
	var AP=new String(location.href);
	var PTO=new String(aPath);	
	var RPP;
	var PrP;
	PrP=AP.lastIndexOf('Default.aspx');
		if (PrP !=-1)
			AP=AP.slice(0,PrP);
	var Parameters =new String('');	
	PrP=aPath.lastIndexOf('?');
	if (PrP !=-1){
	   PTO=aPath.slice(0,PrP);
	   Parameters=aPath.slice(PrP);}
	AP=AP.toLowerCase();	
	PTO=PTO.toLowerCase();		
	PTO=PTO.slice(1,PTO.length);			
	for (counter=0;counter<DirS.length;counter++){		
		var Directory=new String(DirS[counter]);		
		Directory=Directory.toLowerCase();			
		RPP=AP.lastIndexOf(Directory);		
		if (RPP > -1){ 
			AP=AP.slice(0,RPP);							
			return AP + PTO + Parameters;}}	
	if (RPP=-1)
		return AP}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;
var ver4 = (NS4 || IE4) ? 1 : 0;
function imprimir()
{
if (ver4) {if (window.print) window.print(); else if (window.top.contenido.print) window.top.contenido.print(); 	
else alert("Usted no dispone de un navegador que soporte dicha funcionalidad.\nPara Imprimir pulse Ctrl+P");}
else alert("Usted no dispone de un navegador que soporte dicha funcionalidad.\nPara Imprimir pulse Ctrl+P");}

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) { //v3.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=MM_findObj(n,d.layers[i].document); 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];}
}



