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 nuevoAjax(){
	var xmlhttp=false;
	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(E){
			xmlhttp = false;
		}
	}	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}
function loadFilters(ruta,id){	
	ajax=nuevoAjax();
	ruta2 = ruta + "/cm/_ajax_category.php";
	ajax.open("POST","/cm/_ajax_category.aspx",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			$('#filtros').html(ajax.responseText);
			var titulo = $('.medio-left-tit').text();
			var tit =   ret_AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','180','height','30','src',ruta+'/Templates/_swf/titulosmenu','FlashVars','titulo='+titulo,'quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie',ruta+'/Templates/_swf/titulosmenu' ); //end AC code
			$('.medio-left-tit').html(tit);
			
			$( ".filtros_row" ).each(
				function(){
					var text = $(this).text();
					var flashh =ret_AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','180','height','24','src',ruta+'/Templates/_swf/titulosmenu-b','FlashVars','titulo='+text,'quality','high','wmode','transparent','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie',ruta+'/Templates/_swf/titulosmenu-b' );
					$(this).html(flashh);
				}										
			)
			//$('.filtros_row').html($(this).html()+" //");
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("&Id="+id);
}

function recover(ruta) {
	window.open(RootPath+"/forgotPassword.aspx", "myWindow", "status = 1, height = 163, width = 372, resizable = 0" );
}


function error_alert(errorcode){
	switch(errorcode){
			case 1:
				alert('Usuario o contrasena incorrectos');
			break;
			case 2:
				alert('Hubo un error en la votación. Inténtelo en unos minutos');
			break;
			case 3:
				alert('En este momento no se pueden realizar compras en el portal. Contáctenos para más información.');
			break;
			case 4:
				alert('Se produjo un error en el proceso de pago. Contáctenos para más información.');
			break;
			case 5:
				alert('El producto seleccionado no posee el stock suficiente.');
			break;
			case 6:
				alert('El nombre de usuario ya existe');
			break;
			case 7:
				alert('Hubo un error al intentar actualizar sus datos');
			break;
			case 8:
				alert('Error en el costo de envío');
			break;
			case 9:
				alert('El registro ha sido removido o se encuentra deshabilitado');
			break;
			case 10:
				alert('Su cuenta se encuentra inactiva. Contáctenos para más información.');
			break;
			case 666:
				alert('Se ha producido un error');
			break;
	}
	if(errorcode>0){
	document.location.reload();
	}
}

var consultaMode=0;
function showConsulta(){
	var formulario_consulta = document.getElementById('contact_form');
	if(consultaMode==0){
		formulario_consulta.style.display="inline";
		consultaMode=1;
	}else{
		formulario_consulta.style.display="none";
		consultaMode=0;
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
/*
function MM_setTextOfTextfield(formulario,objId,x,newText,checkText) { //v9.0
  with (document){
	if(getElementById){
		  var obj = document.forms[formulario][objId];
	}
	if(obj && obj.value==checkText){
		obj.value = newText;
	}
  }
}
*/
function MM_setTextOfTextfield(formulario,objId,x,newText,checkText) { //v9.0
  with (document){
	if(getElementById){
		  var obj = document.forms[formulario][objId];
	}
	if(obj && obj.value==checkText){
		obj.value = newText;
	}
  }
}

function MM_resetField(formulario,objId,checkText) { //v9.0
  with (document){
	if(getElementById){
		  var obj = document.forms[formulario][objId];
	}
	if(obj && obj.value==""){
		obj.value = checkText;
	}
  }
}

function getElementsByClassName(clsName){
   var i;
   var matches=new Array();
   var els = document.getElementsByTagName('*');
   for(i=0; i<els.length; i++) {
      if(els.item(i).className==clsName) {
         matches.push(els.item(i));
      }
   }
   return matches;
}

function openmenu(cual,url){
			if(categoriaexpand && categoriaexpand!=0 && categoriaexpand!=cual){
				var occb = getElementsByClassName('padre_'+categoriaexpand);
				if(occb && occb.length>0){				
					for(i=0;i<occb.length;i++){
						occb[i].style.display="none";				
					}
				}				
			}
			var occ = getElementsByClassName('padre_'+cual);
			if(occ && occ.length>0){				
				for(i=0;i<occ.length;i++){
					occ[i].style.display="inline-block";				
				}
				categoriaexpand=cual;
			}else{
				document.location.href=url;	
			}

}


function __setKw(){
	document.getElementById('Keywords').value = document.getElementById('Name').value;
}
function setCategoria(valor,nombre){
	document.getElementById('textsearch').innerHTML = nombre;
	document.getElementById('nav').style.display = "none";
	document.getElementById('Id').value = valor;
	setTimeout( function(){	document.getElementById('nav').style.display = "inline";},2);
	//document.buscador.Name.focus();
}
function setHidden(campo,valor,lista,nombre){
	//document.getElementById('nav'+lista).style.display = "none";
	//alert(campo)
	document.getElementById(campo).value = valor;
	//document.getElementById('textsearch_'+lista).innerHTML = "<font color='#000000'><b>"+nombre+"</b></font>";
	//setTimeout( function(){	document.getElementById('nav'+lista).style.display = "inline";},2);
}

function setHiddenSub(campo,valor,lista,nombre){
	document.getElementById(campo).value = valor;
	document.getElementById('filter_id').value = lista;
	SetFilteredSearch();
}
function inspector(el) {
var str ="";
for (var i in el){
	str+= i + ": " + el.getAttribute(i) + "<br>";
}
document.write(str);
}

function qty_add(sumar,minStock,stock){
	var cantidad_form = document.getElementById('Quantity');
	var cantidad = parseInt(cantidad_form.value);
	if(sumar > 0){
		if(stock > cantidad){
			cantidad_form.value=cantidad+1;
		}		
	}else{
		if(cantidad > minStock && cantidad > 1){
			cantidad_form.value=cantidad-1;
		}
	}	
}


function MM_validateFormSuscribe() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormSuscribe.arguments;
    for (i=0; i<(args.length-2); i+=3){
		test=args[i+2];
		val=document.forms['susc'].elements[(args[i])];	
		if(val.value=="Nombre y Apellido" || val.value=="E mail"){			
			valor="";			
		}else{
			valor=val.value;	
		}
		if (val){
			nm=val.name;
			if(nm=="suscriberFirstName"){			
				nm="Nombre y Apellido";	
			}
			if(nm=="suscriberName"){			
				nm="email";	
			}
			if((val=valor)!=""){
				if (test.indexOf('isEmail')!=-1) {
					p=val.indexOf('@');
					if (p<1 || p==(val.length-1)) errors+='- '+val+' no es un email válido.\n';
				}else if (test!='R') {
					num = parseFloat(val);
					if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
					if (test.indexOf('inRange') != -1) {
						p=test.indexOf(':');
						min=test.substring(8,p);
						max=test.substring(p+1);
						if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
					}
				}
			}else if(test.charAt(0) == 'R')errors += '- '+nm+' debe estar completo.\n';
		}
    }
	if (errors) alert('Error al enviar el formulario:\n'+errors);
    document.MM_returnValue = (errors == '');
} }



function MM_validateFormLogin() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormLogin.arguments;
    for (i=0; i<(args.length-2); i+=3){
		test=args[i+2];
		val=document.forms['login'].elements[(args[i])];	
		if(val.value=="usuario" || val.value=="password"){			
			valor="";			
		}else{
			valor=val.value;	
		}
		if (val){
			nm=val.name;
			if(nm=="customerName"){			
				nm="usuario";	
			}
			if(nm=="customerPassword"){			
				nm="password";	
			}
			if((val=valor)!=""){
				if (test.indexOf('isEmail')!=-1) {
					p=val.indexOf('@');
					if (p<1 || p==(val.length-1)) errors+='- '+val+' no es un email válido.\n';
				}else if (test!='R') {
					num = parseFloat(val);
					if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
					if (test.indexOf('inRange') != -1) {
						p=test.indexOf(':');
						min=test.substring(8,p);
						max=test.substring(p+1);
						if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
					}
				}
			}else if(test.charAt(0) == 'R')errors += '- '+nm+' debe estar completo.\n';
		}
    }
	if (errors) alert('Error al enviar el formulario:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

function MM_validateFormLogin2() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormLogin2.arguments;
    for (i=0; i<(args.length-2); i+=3){
		test=args[i+2];
		val=document.forms['login2'].elements[(args[i])];	
		if(val.value=="usuario" || val.value=="password"){			
			valor="";			
		}else{
			valor=val.value;	
		}
		if (val){
			nm=val.name;
			if(nm=="customerName"){			
				nm="usuario";	
			}
			if(nm=="customerPassword"){			
				nm="password";	
			}
			if((val=valor)!=""){
				if (test.indexOf('isEmail')!=-1) {
					p=val.indexOf('@');
					if (p<1 || p==(val.length-1)) errors+='- '+val+' no es un email válido.\n';
				}else if (test!='R') {
					num = parseFloat(val);
					if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
					if (test.indexOf('inRange') != -1) {
						p=test.indexOf(':');
						min=test.substring(8,p);
						max=test.substring(p+1);
						if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
					}
				}
			}else if(test.charAt(0) == 'R')errors += '- '+nm+' debe estar completo.\n';
		}
    }
	if (errors) alert('Error al enviar el formulario:\n'+errors);
    document.MM_returnValue = (errors == '');
} }


function MM_validateFormContact() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormContact.arguments;
    for (i=0; i<(args.length-2); i+=3){
		test=args[i+2];
		val=document.forms['consulta'].elements[(args[i])];	
		/*
		if(val.value=="nombre y apellido" || val.value=="email"){			
			valor="";			
		}else{
			valor=val.value;	
		}
		*/
		valor=val.value;
		if (val){
			nm=val.name;
			if(nm=="txtFirstName"){			
				nm="Nombre";	
			}
			if(nm=="txtLastName"){			
				nm="Apellido";	
			}
			if(nm=="txtEmail"){			
				nm="E-mail";	
			}
			if(nm=="txtPhone"){			
				nm="Teléfono";	
			}
			if(nm=="txtCity"){			
				nm="Ciudad";	
			}
			if(nm=="Comentario"){			
				nm="Comentario";	
			}
			if((val=valor)!=""){
				if (test.indexOf('isEmail')!=-1) {
					p=val.indexOf('@');
					if (p<1 || p==(val.length-1)) errors+='- '+val+' no es un email válido.\n';
				}else if (test!='R') {
					num = parseFloat(val);
					if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
					if (test.indexOf('inRange') != -1) {
						p=test.indexOf(':');
						min=test.substring(8,p);
						max=test.substring(p+1);
						if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
					}
				}
			}else if(test.charAt(0) == 'R')errors += '- '+nm+' debe estar completo.\n';
		}
    }
	if (errors) alert('Error al enviar el formulario:\n'+errors);
    document.MM_returnValue = (errors == '');
} }


function MM_validateFormComment() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormComment.arguments;
    for (i=0; i<(args.length-2); i+=3){
		test=args[i+2];
		val=document.forms['myform'].elements[(args[i])];	
		if(val.value=="nombre y apellido" || val.value=="email"){			
			valor="";			
		}else{
			valor=val.value;	
		}
		if (val){
			nm=val.name;
			if(nm=="postName"){			
				nm="nombre";	
			}
			if(nm=="postMail"){			
				nm="email";	
			}
			if(nm=="postText"){			
				nm="comentario";	
			}
			if((val=valor)!=""){
				if (test.indexOf('isEmail')!=-1) {
					p=val.indexOf('@');
					if (p<1 || p==(val.length-1)) errors+='- '+val+' no es un email válido.\n';
				}else if (test!='R') {
					num = parseFloat(val);
					if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
					if (test.indexOf('inRange') != -1) {
						p=test.indexOf(':');
						min=test.substring(8,p);
						max=test.substring(p+1);
						if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
					}
				}
			}else if(test.charAt(0) == 'R')errors += '- '+nm+' debe estar completo.\n';
		}
    }
	if (errors) alert('Error al enviar el formulario:\n'+errors);
    document.MM_returnValue = (errors == '');
} }



function MM_validateFormServices() { //v4.0

  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormServices.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
		
		
		if(val.value=="Número de Orden" || val.value=="N&uacute;mero de Orden"){			
			valor="";
			terror="Por favor complete el número de orden";
		}else if(val.value=="buscar..."){			
			valor="";
			terror="Por favor ingrese el texto a buscar";
		}else{
			valor=val.value;
		}
		
		//alert(valor);
		
      if (val) { nm=val.name; if ((val=valor)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert(terror);
    document.MM_returnValue = (errors == '');
} }

function MM_validateFormReg() { //v4.0
	error_text="Error al enviar el formulario";	
	error_email="no es un email válido";
	error_pie="debe estar completo";
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormReg.arguments;	
	var k = 0;
    for (i=0; i<(args.length-2); i+=3){
		test=args[i+2];
		val=document.forms['f_registracion'][args[i]];
		valor=val.value;
		
		if (val){
			nm=val.name;			


			
			if(nm=="customerName"){			
				nm="email";	
			}
			if(nm=="customerPassword"){			
				nm="password";	
			}
			if(nm=="customerCompany"){			
				nm="empresa";	
			}
			
			if(nm=="customerIdentificationNumber"){			
				nm="DNI";
			}
			
			if(nm=="customerFirstName"){	
				nm="Nombre";	
			}
			if(nm=="customerLastName"){	
				nm="Apellido";	
			}
			if(nm=="customerPhone"){			
				nm="Teléfono";	
			}
			if(nm=="customerMobile"){			
				nm="Celular";	
			}
			if(nm=="customerAddress"){			
				nm="Direccion";	
			}
			if(nm=="customerCity"){			
				nm="Ciudad";	
			}
			if(nm=="customerState"){			
				nm="Provincia";	
			}
			if(nm=="customerPostalCode"){			
				nm="Código Postal";	
			}
			if(nm=="conditions"){			
				nm="Términos y Condiciones";	
			}
			
			if(val != null && test=='checked'){
               if(!val.checked)
                  errors += '- '+nm+' debe estar seleccionado.\n';
            }else if(valor!="" && valor!=nm){
				if (test.indexOf('isEmail')!=-1) {
					p=valor.indexOf('@');
					if (p<1 || p==(valor.length-1)) errors+='- '+valor+' '+error_email+'.\n';
				}else if (test!='R') {
					num = parseFloat(val);
					if (isNaN(valor)) errors+='- '+nm+' must contain a number.\n';
					if (test.indexOf('inRange') != -1) {
						p=test.indexOf(':');
						min=test.substring(8,p);
						max=test.substring(p+1);
						if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
					}
				}
			}else if(test.charAt(0) == 'R')errors += '- '+nm+' '+error_pie+'.\n';
		}
    }
	if(errors){
		alert(error_text+':\n'+errors);
	}else{
		//document.forms['f_registracion'].submit();
	}
	
    document.MM_returnValue = (errors == '');
}
}





						function buildMarcas(){
							var espacioMarcas = document.getElementById('marcas_cat');
							var conc = '';
							var mass=1;
							conc += '<select name="marcas_sel" id="marcas_sel" onchange="subMarcas(this.options[this.selectedIndex].value,this.options[this.selectedIndex])"> <option class="optionoff" disabled="disabled" selected="selected">Seleccione la marca</option>';
							if(marq.length>1){
								for(m=1;m<marq.length;m++){
									if(marq[m][2]==2){
										var ssel ="";
										if( (marcaId && marcaId==marq[m][1])){
											ssel=" selected='selected'";
											hayMarcaSel=mass;										
										}
										conc += "<option value='"+marq[m][1]+"' id='op_marca_"+m+"'"+ssel+">"+marq[m][0]+"</option>\n";
										mass++;
									}
								}
							}
							conc += ' </select>';
							espacioMarcas.innerHTML = conc;
						}
						
						function buildCategorias(){	
							if(buscadorPadre==0){
								buscadorPadre = buscarCat(buscadorId);
				 			}
							var mass=1;
							var espacioCat = document.getElementById('cat');
							var conc = '';
							conc += '<select name="cat_sel" id="cat_sel" onchange="subCat(this.options[this.selectedIndex].value,this.options[this.selectedIndex])"> <option class="optionoff" disabled="disabled" selected="selected">Seleccione el tipo de parte</option> ';
							if(cats.length>1){								
								for(m=1;m<cats.length;m++){
									if(cats[m][2]==2){
										var ssel ="";
										if( (buscadorId && buscadorId==cats[m][1]) || (buscadorPadre && buscadorPadre==cats[m][1]) ){
											ssel=" selected='selected'";
											hayCatSel = mass;	
										}
										conc += "<option value='"+cats[m][1]+"' id='op_cat_"+m+"'"+ssel+">"+cats[m][0]+"</option>\n";
										mass++;
									}
								}
							}
							conc += ' </select>';
							espacioCat.innerHTML = conc;			

						}
						
						function subMarcas(marca,orden){

							if(marca && marca>0){
								var espacioSubMarcas = document.getElementById('marcas_subcat');
								document.getElementById('SearchButton').className  = "header_search_boton_on";
								document.getElementById('SearchButton').disabled  = false;	
								var mass=1;
								var conc2 = '';
								conc2 += '<select name="submarcas_sel" id="submarcas_sel" onchange="setCategoria(this.options[this.selectedIndex].value,0)"> <option value="-1" selected="selected">Todos</option>';								
									for(m=1;m<marq.length;m++){
										if(marq[m][3]==marca){
											var ssel ="";
											if(modeloId && modeloId==marq[m][1]){
											   ssel=" selected='selected'";
											   haySubMarcaSel = marq[m][1];
											}
											conc2 += "<option value='"+marq[m][1]+"'"+ssel+">"+marq[m][0]+"</option>\n";
											mass++;
										}
									}
								conc2 += '</select>';				
								espacioSubMarcas.innerHTML = conc2;
								marcaSel=orden.id;
								setCategoria(marca,0);
							}else{					
								var catOrig = document.getElementById(marcaSel);								
								catOrig.selected = true;
							}			
						}
						
						function subCat(catt,orden){
							setCategoria(0,catt);
							if(catt && catt>0){
								var espacioSubCat = document.getElementById('subcat');								
								var conc2 = '';
								conc2 += '<select name="subcat_sel" id="subcat_sel" onchange="setCategoria(0,this.options[this.selectedIndex].value)"> <option value="-1" selected="selected">Todos</option> ';								
									for(m=1;m<cats.length;m++){										
										if(cats[m][3]==catt){
											var ssel ="";
											if( (buscadorId && buscadorId==cats[m][1]) || (buscadorPadre && buscadorPadre==cats[m][1]) ){
												ssel=" selected='selected'";
												haySubCatSel = cats[m][1];
											}
											conc2 += "<option value='"+cats[m][1]+"'"+ssel+">"+cats[m][0]+"</option>\n";
										}
									}
								conc2 += '</select>';				
								espacioSubCat.innerHTML = conc2;
								catIdSel=orden.id;
								//setCategoria(marca,0);
							}else{					
								var subcatOrig = document.getElementById(catIdSel);								
								subcatOrig.selected = true;
							}			
						}
						
						
						function buscarPadre(id){
							for(i=0;i<marq.length;i++){
								var elemento = marq[i];
								if(elemento[1]==id && elemento[2]==3){
									return elemento[3];
								}								
							}							
						}
						function buscarCat(id){
							for(i=0;i<cats.length;i++){
								var elemento = cats[i];
								if(elemento[1]==id && elemento[2]==3){
									return elemento[3];
								}								
							}							
						}
						
						function setCategoria(marca,categoria){
							//si le paso el tipo de categoria
							document.getElementById('SearchButton').disabled  = false;
							document.getElementById('SearchButton').className  = "header_search_boton_on";
							if(categoria!=0){								
								if(categoria!=-1){
									if(modeloSel!=-1){
										document.getElementById('Categories').value = categoria+","+modeloSel;
									}else{
										document.getElementById('Categories').value = categoria+",";
									}
									catSel = categoria;
								}else{
									var padre = document.getElementById('cat_sel').options[document.getElementById('cat_sel').selectedIndex].value;
									if(modeloSel!=-1){
										if(padre && padre!=-1){
										document.getElementById('Categories').value = padre+","+modeloSel;
										}else{
										document.getElementById('Categories').value = ","+modeloSel;	
										}
									}else{
										if(padre && padre!=-1){
										document.getElementById('Categories').value = padre+",";
										}
									}
								}
							}else if(marca!=0){
								if(marca!=-1){
									var padre = buscarPadre(marca);
									if(padre){
										modeloSel=padre+","+marca;
									}else{
										modeloSel=marca;
									}
									if(catSel && catSel!=-1){
									document.getElementById('Categories').value = catSel+","+modeloSel;
									}else{
									document.getElementById('Categories').value = ","+modeloSel;
									}
								}else{
									setCategoria(document.getElementById('marcas_sel').options[hayMarcaSel].value,categoria)
								}						
							}							
						}					

		function ddesplegar(cual,url,depth,parent){
			// primero me fijo si:
			// 1- hay algo abierto y eso abierto es distino a la actual
			// 2- no hay nada abierto
			//alert(depth+"-"+levelexpand)
			$('#btn-'+categoriaexpand).css("color","#333333");
			if((categoriaexpand!=0 && categoriaexpand!=cual) || categoriaexpand==0){
					if(categoriaexpand!=0 && depth < levelexpand){	
						$('.boton-'+(depth+1)).css("display","none");
						$('.boton-'+(depth+2)).css("display","none");
						$('.btn-child-'+categoriaexpand).css("display","none");
						//$('.btn-'+categoriaexpand).css("background-image","url("+RootPath+"/Templates/_css/_img/menu-left-btn.gif)");
					}
					var btnChild = $('.btn-child-'+cual).css("display","inline-block");
					$('#btn-'+cual).css("color","#FF0000");					
					if(btnChild.length>0){
						//$('.btn-'+cual).css("background-image","none");
						//if(depth==1)
						//btnChild[btnChild.length-1].style.marginBottom='15px';
					}else{
						document.location.href = url;	
					}
				categoriaexpand=cual;
				levelexpand = depth+1;
				
			//si la categoría abierta es igual a la actual
			}else if(categoriaexpand==cual){
				//cierro los hijos
				var btnChild = $('.btn-child-'+cual).css("display","none");
				//si esos hijos tienen más hijos, los cierro
				if(btnChild.length>0){					
					for(i=0;i<btnChild.length;i++){
						var idpp = btnChild[i].id;
						$('.btn-child-'+idpp).css("display","none");
					}
				}
				//$('.btn-'+categoriaexpand).css("background-image","url("+RootPath+"/Templates/_css/_img/menu-left-btn.gif)");
				categoriaexpand=parent;
				levelexpand = depth;
			}
			//alert(levelexpand);
		}


			function desplegar(cual,url,depth,modo){				
				//cierro todos los niveles por debajo del boton					
				var pdepth = parseInt(depth)+1;
				var accion = 0;

				//si hay una categoria expandida y no es esta, o si no hay ninguna
				if((categoriaexpand!=0 && categoriaexpand!=cual) || categoriaexpand==0){
						var btnChild = $('.btn-child-'+cual).css("display","inline-block");
						if(btnChild.length<1){	
							document.location.href = url;	
						}
						if(categoriaexpand!=0 && categoriaexpanddepth==depth){							
							$('.btn-child-'+categoriaexpand).css("display","none");				
						}else{
							categoriaexpanddepth=depth;	
						}
						//muestro los hijos la actual
						//$('.btn-'+cual).css('border-bottom-color','#FFFFFF');
						
						//y si no tiene, voy al link
						//if(btnChild.length<1 && modo!='auto'){
						categoriaexpand=cual;
						accion=1;
				//si la categoria que estoy expandiendo esta abierta, la cierro.
				}else if(categoriaexpand==cual){
					//alert('aca');
					//$('.btn-'+cual).css('border-bottom-color','#E9E9E9');
					$('.btn-child-'+categoriaexpand).css("display","none");
					categoriaexpand=0;
					accion=1;
				}
				if(accion==0){
					desplegar(36,'',2);;
				}
			}
			
			
function autoDesplegar(){

	if(idPage && idPage.length > 1){
		//despliego la categoría ppal;
		var btnChild = $('.btn-child-'+idPage[1]).css("display","inline-block");
		categoriaexpand=parseInt(idPage[1]);
		levelexpand = 2;		
	}
	if(idPage && idPage.length > 2){
		//despliego la categoría ppal;
		var btnChild = $('.btn-child-'+idPage[2]).css("display","inline-block");
		categoriaexpand=parseInt(idPage[2]);
		levelexpand = 3;		
	}
	for(i=0;i<idPage.length;i++){
		var bot = document.getElementById('btn-'+idPage[i]);
		if(bot){
			bot.style.color = "#FF0000";
		}
	}
/*
	if(idPage && idPage.length > 2){
		var btnChild = $('.btn-child-'+idPage[3]).css("display","inline-block");
		if(btnChild.length>0){
			$('.btn-'+idPage[3]).css("background-image","none");
			btnChild[btnChild.length-1].style.marginBottom='15px';
			categoriaexpand=idPage[3];
		}
	}
	if(idPage && idPage.length > 3){
		var btnChild = document.getElementById('btn-'+window.idPage[4]);
		if(btnChild){
			//btnChild.removeAttribute("href");
			btnChild.className = 'boton-2-sel';
		}
	}
	*/
	
}


function changeView(cant,dir){
	if(cant==8){
		rpp=1000;
	}else{
		rpp=8;		
	}
	document.location.href=dir+"?RecsPerPage="+rpp;
}

function showColors(id){
		//alert(id);
		$('#globe-'+id).fadeIn();
		// return true;
}
function hideColors(id){
		$('#globe-'+id).fadeOut();
		// return true;
}

function submenu(cual,position,ancho){
	var anchoa = parseInt(ancho)-35;
	//alert(ancho);
	if(submenusel!=0){
		$('#submenu-'+submenusel).fadeOut();
	}
	if(submenusel!=cual){
		$('#submenu-'+cual).css("min-width",ancho-1+"px");
		$('#submenu-'+cual+" a").css("min-width",anchoa-1+"px");
		$('#submenu-'+cual).css("left",position);	
		$('#submenu-'+cual).fadeIn();
		submenusel = cual;		
		$('body').mousemove(function(e){
			 if(submenusel != 0){
				 //alert(e.pageX-this.offsetLeft);
				//var x = $('.cuerpo').offset().left;
				var mx = e.pageX -$('#submenu-'+cual).offset().left; -  $('.title').offset().left;
				var my = e.pageY - $('#submenu-'+cual).offset().top; -  $('.title').offset().top;
				//$('.header-cart').html(my); 
				if(mx < 0 || my < -24 ||mx > $('#submenu-'+cual).width() || my >$('#submenu-'+cual).height() ){
					$('#submenu-'+cual).fadeOut();
					submenusel = 0;
					$('body').mousemove = null; 
				}
			}
		});
		
	}else{
		submenusel = 0;
	}
}
