function openWin(v_strPage, v_strWidth, v_strHeight){
	window.open(v_strPage,"oprnWin","dependent=yes,Height=" + v_strHeight + ",Width=" + v_strWidth + ",location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no");
}

function RedirectTimeout(){	
	setTimeout("document.location = '/'", 5000); 
}

function OpenZoomWindow1(sImg,sTitle,sWidth,sHeight,sClose,sDescription){
	var tb_pathToImage = "img/sistema/loadingAnimation.gif";

	/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/

	//on page load call tb_init
	$(document).ready(function(){	
	tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
	imgLoader = new Image();// preload image
	imgLoader.src = tb_pathToImage;	
	});	
}

function OpenZoomWindow(sImg,sTitle,sWidth,sHeight,sClose,sDescription){
			
	if(sClose==null) sClose = "close";
	var sTotHeight;		
	
	if(sDescription!=null && sDescription!='')
		sTotHeight = (sHeight/1+40);
	else
		sTotHeight = (sHeight/1+17);
		
	var left_frm = screen.width/2;
	var top_frm = screen.heigth/2;
	
	left_frm -= (sWidth/2);
	//top_frm -= (sTotHeight/2);		
	
	top_frm = 100;		
	
	var srcimgbig = sImg;
	var srcimg = sImg.replace('_big','');
	
	imgLoaderbig = new Image();// preload image		
	imgLoaderbig.src = srcimgbig;
	
	var img_width = imgLoaderbig.width;
	var img_height = imgLoaderbig.height;
	
	//alert(img_width);
	//alert(img_height);
	
	if(imgLoaderbig.width > 0 && imgLoaderbig.width != 28 )
	{
		sImg = srcimgbig;
		img_width = imgLoaderbig.width;
		img_height = imgLoaderbig.height		
	}
	else
	{
		sImg = srcimg;
		imgLoader = new Image();// preload image		
		imgLoader.src = srcimg;
		img_width = imgLoader.width;
		img_height = imgLoader.height		
	}	
	
	w = img_width;
	h = img_height;
	
	if(img_width > sWidth){
		
		var w = sWidth;		
		
		h = (w / img_width) * img_height;		
		h = Math.round(h);
		
	}
	
	img_width = w;
	img_height = h;	
	
	if(img_height > sHeight){
		
		var h = sHeight;		
		
		w = (h / img_height) * img_width;
		w = Math.round(w);
	}	
		
	//var oWin = window.open('','','status=0,scrollbars=0,height=' + sTotHeight + 'px,width='+sWidth+'px');
	var oWin = window.open('','','status=0,scrollbars=0,height=' + sTotHeight + 'px,width=' + sWidth + 'px,left=' + left_frm + 'px,top=' + top_frm + 'px');	
	var sHtml = '<html>\n';
	sHtml += '<head><title>' + sTitle + '</title>\n';
	sHtml += '<style type=\"text/css\">\n';
	sHtml += '.fntDefault { text-decoration: none; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #514C3C }\n';
	sHtml += '</style>\n</head>\n';
	sHtml += '<body bgcolor=\"#ffffff\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n';	
	
	//sHtml += '<div id=\"TB_load\"><img src=\"' + imgLoaderli.src + '\" /></div>\n';	
	//$('#TB_load').show();
	
	sHtml += '<table width=\"100%\" height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n';
	//sHtml += '<tr><td align=\"center\" valign=\"middle\"><img border=\"0\" src=\"'+sImg+'\" width=\"'+w+'\" height=\"'+h+'\"></td></tr>\n';
	sHtml += '<tr><td align=\"center\" valign=\"middle\"><img border=\"0\" src=\"'+sImg+'\"></td></tr>\n';
	if(sDescription!=null && sDescription!=''){
		sHtml += '<tr height=\"15\" style=\"padding:4px\"><td align=\"left\" valign=\"top\" class=\"fntDefault\">' + sDescription + '</td></tr>\n';
	}
	sHtml += '<tr height=\"2\"><td bgcolor=\"#EBEAE5\"><img src=\"img/shared/np.gif\" height=\"2\"></td></tr>\n';	
	sHtml += '<tr height=\"15\"><td bgcolor=\"#F8F7F1\" align=\"right\" valign=\"middle\" class=\"fntDefault\"><a class=\"fntDefault\" href=\"javascript:window.close()\">' + sClose + '</a>&nbsp;&nbsp;</td></tr>\n';
	sHtml += '</table>\n';
	sHtml += '</body>\n';
	sHtml += '</html>';	
		
	oWin.document.write(sHtml);	
}

function voidFunction(){
	//ie bug
}
function 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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function changeImageBox(v_strImageBoxName,v_strImage){
	var objImageBox = findObj(v_strImageBoxName);
	//var objImageBox = window.document.imageBox;
	objImageBox.SetVariable("_root.imageToLoad", v_strImage);
	objImageBox.GoToFrame(1);
}
function npwidthmax(){
	//calcola width della pagina, toglie larghezza menu sinistra e larghezza menu destra return (la differenza)
	size = parseInt(window.innerWidth) - 440;	
	return size;
}
function credits(){
	window.open("credits.htm","credits","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=320,height=140");
}
function PopUpWindow(v_strFile,v_strWidth,v_strHeight){
	window.open(v_strFile,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + v_strWidth + ",height=" + v_strHeight);
}
//Marco A
function DisplayDefaultImageBig(img)
{
	img.src = 'img/sistema/sinimagenbig.jpg';
}

function DisplayDefaultImage(img)
{
	//if(img.src='')
	//{
	//	img.src = './img/sistema/sinimagen.jpg';
	//	img.visible = false;
	//}
	//else
	//{
		img.title = img.src;
		img.src = './img/sistema/sinimagen.jpg';
	//}	
}

function DisplayDefaultImage1(img)
{
	img.src = '../img/sistema/sinimagen.jpg';
}
function DisplayDefaultImageT(img)
{
	img.src = './imagenes/transparente.gif';
}

function buscar(cadena)
{	
	var cad = document.Form1.txtbusqueda.value;
	if(cad == "")
	{
		alert("Por favor ingresa el dato correspondiente en el campo de b\u00fasqueda") 
		document.Form1.txtbusqueda.focus();		
	}
	else
	{
		window.location = "arbol.aspx?buscar=" + cad;
	}
}

function busqueda(cadena)
{	
	if(cadena == "")
	{
		alert("Por favor ingresa el dato correspondiente en el campo de b\u00fasqueda") 
		//document.Form1.txtbusqueda.focus();		
	}
	else
	{
		window.location = "arbol.aspx?buscar=" + cadena;
	}
}

function labelimg(chk)
{
	if(chk.checked)
	{
		document.getElementById("lblTitImg").innerHTML = "Imagen Men\u00fa:";
		document.getElementById("lblMedImg").innerHTML = "Medidas: 44 X 48 pixeles.";
	}
	else
	{
		document.getElementById("lblTitImg").innerHTML = "Imagen:";
		document.getElementById("lblMedImg").innerHTML = "Medidas: 150 X 150 pixeles.";
	}
}

function open_1(url){	
	var t = document.getElementById("listadoProductos_txtTipoLista").value;		
	var decode_edad = "";
	
	v1 = url.split('edad=');
	
	if(v1.length > 1)
	{
		decode_edad = "&edad=";
		
		v2 = v1[1].split('&');				
		
		if(v2.length > 0)
		{
			url = url.replace("&edad=" + v2[0],"");
			
			v3 = v2[0].split(',');			
			
			if(v3.length > 0)
			{								
				for( var i=0; i<v3.length; i++)
				{	
					if(i>0)
					{
						decode_edad = decode_edad + ",";
					}					
					
					decode_edad = decode_edad + v3[i].replace('+','%2b'); 					
				}				
			}
		}				
	}	
	
	url = url + decode_edad;
	
	window.location=url+'&lst=' + t;
}						
			
function open_(url){
	
	var t='icon';
	var decode_edad = "";
	
	v1 = url.split('edad=');
	
	if(v1.length > 1)
	{
		decode_edad = "&edad=";
		
		v2 = v1[1].split('&');				
		
		if(v2.length > 0)
		{
			url = url.replace("&edad=" + v2[0],"");
			
			v3 = v2[0].split(',');			
			
			if(v3.length > 0)
			{								
				for( var i=0; i<v3.length; i++)
				{	
					if(i>0)
					{
						decode_edad = decode_edad + ",";
					}					
					
					decode_edad = decode_edad + v3[i].replace('+','%2b'); 					
				}				
			}
		}				
	}	
	
	url = url + decode_edad;	
	
	if(document.getElementById("listadoProductos_txtTipoLista")!= null){
		t = document.getElementById("listadoProductos_txtTipoLista").value;
	}	
	window.location=url+'&lst=' + t;				
}

function ordenar(f,s){	//Marco A. 26/nov/09

	url = document.location.href;
	
	partes = url.split('/'); 
	// Obtención del nombre de la página y sus parámetros. 
	
	s_url = partes[partes.length-1];
	s_url_prev = s_url;
	
	valores = s_url.split('?');
		
	for(var i=0; i<valores.length; i++){		
		valor = "?" + valores[i];		
		s_url = s_url.replace(valor,"");				
	}		
		
	if(s_url.indexOf('?')>-1)
	{
		fn = "&f=" + f;
		sn = "&s=" + s;			
	}
	else
	{
		fn = "?f=" + f;
		sn = "&s=" + s;			
	}
	
	urlnew = s_url + fn + sn;
	
	if(document.getElementById("ddlCat")!= null)
	{
		with(document.forms[0]){
			cat = ddlCat.options[ddlCat.selectedIndex].value;
			urlnew = urlnew + "&cat=" + cat
		}		
	}
	
	if(document.getElementById("ddlScat")!= null)
	{
		with(document.forms[0]){
			scat = ddlScat.options[ddlScat.selectedIndex].value;
			urlnew = urlnew + "&scat=" + scat
		}		
	}
	
	if(document.getElementById("ddlMarca")!= null)
	{
		with(document.forms[0]){
			marca = ddlMarca.options[ddlMarca.selectedIndex].value;
			urlnew = urlnew + "&marca=" + marca
		}		
	}	
	
	if(s_url_prev != urlnew)
		window.location = urlnew;	
}