/* Pinta una barra de puntuacion */
function PintaAtributos(puntuacion, capa)
{
	var sHtml="";
	
	/* Pinta atributos ON */
	for(var i=0; i< puntuacion; i++)
	{
		sHtml= sHtml + "<img src=/images/attributes_on.gif id=img " + i + " alt=attributes_on.gif>";
	}
	
	/* Pinta atributos OFF */
	for(var i=5; i> puntuacion; i--)
	{
		sHtml= sHtml + "<img src=/images/attributes_off.gif id=img " + i + " alt=attributes_off.gif>";	
	}
	document.getElementById('BarraAtributos' + capa).innerHTML = sHtml;
}

function OnReadyStateChangeRegisterShopGenericLog()
{
}
			
function RegisterSessionLog(){

}


function OnReadyStateChangeRegisterShopGenericLog(){

}

function RegisterShopGenericLog(affiliate,shop,customer,type,code,p1,p2,p3){

var ajax;
if (window.XMLHttpRequest) 
        ajax = new XMLHttpRequest();
else
	ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
	
ajax.onreadystatechange = OnReadyStateChangeRegisterShopGenericLog;	

var sURL;
var sQuery;

sURL="/tools/register_shop_generic_log.aspx";
sQuery = "affiliate=" + affiliate;
sQuery+="&shop=" + shop;
sQuery+="&customer=" + customer;
sQuery+="&type=" + type;
sQuery+="&code=" + code;
sQuery+="&p1=" + p1;
sQuery+="&p2=" + p2;
sQuery+="&p3=" + p3;
var d = new Date();
var curr_msec = d.getMilliseconds()
sQuery+="&rnd=" + curr_msec;
ajax.open("POST", sURL, false);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send(sQuery); 

ajax = null;

}

function ShowPriceShipMethod(oCombo,url)
{
	document.location.href='/product.aspx'+url+'&cship='+oCombo.options[oCombo.selectedIndex].value;
}


function SearchSearchIt() {
	if (document.getElementById('txtSpSearch').value.length > 2) {
		sDummy = new String(document.getElementById('txtSpSearch').value);
		oRegExp = new RegExp(' ', 'g');
		
		document.location.href = 'list.aspx?search=' + sDummy.replace(oRegExp, '+');
	}
}

function EmailCheck(sEmail) {
	var at = "@";
	var dot = ".";
	var lat = sEmail.indexOf(at);
	var lstr = sEmail.length;
	var ldot = sEmail.indexOf(dot);

	if (sEmail.indexOf(at)==-1) { return false; }
	if (sEmail.indexOf(at)==-1 || sEmail.indexOf(at)==0 || sEmail.indexOf(at)==lstr) { return false; }
	if (sEmail.indexOf(dot)==-1 || sEmail.indexOf(dot)==0 || sEmail.indexOf(dot)==lstr) { return false; }
	if (sEmail.indexOf(at,(lat+1))!=-1) { return false; }
	if (sEmail.substring(lat-1,lat)==dot || sEmail.substring(lat+1,lat+2)==dot) { return false; }
	if (sEmail.indexOf(dot,(lat+2))==-1) { return false; }
	if (sEmail.indexOf(" ")!=-1) { return false; }

 	return true;
}


function changelanguage(ai_ilanguage){

	
	var url=document.forms[0].action;
	var matchStr=/(\&l=.)/;
	var matchStr2=/(\?l=.)/;
	var symbol='&';
	var question='?';

	url = url.replace(matchStr, '');
	url = url.replace(matchStr2, '');
	if ((url.indexOf(question))==-1) symbol='?';
	
	if (url.substring(0,1)=='/')
		document.location.href=url+symbol+'l='+ai_ilanguage;
	else
		{
			if (window.opera)
				document.location.href=url+symbol+'l='+ai_ilanguage;		
			else
				if(document.all)
					document.location.href='/'+url+symbol+'l='+ai_ilanguage;
				else
					document.location.href=url+symbol+'l='+ai_ilanguage;		
		}
}




function SelectCategory(ai_icategory, ai_ilevel){
	if (ai_ilevel>1)
		document.location.href='/list.aspx?c='+ai_icategory+'&md=2';
	else	
		document.location.href='/category.aspx?c='+ai_icategory;
}


function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return "";
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

function IsThereCookies(){
testValue=Math.floor(1000*Math.random());
SetCookie('AreCookiesEnabled',testValue);
return (testValue==ReadCookie('AreCookiesEnabled')); 
}


function showVariantContent(type, field, index, at) {
window.open('/show_variant_content.aspx?type='+type+'&field='+field+'&index='+index+'&at='+at, 'suscriber_legal_notice', 'toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=250,left=' + ((screen.width -400) / 2) + ',top=' + ((screen.height -250) / 2));
}

function ValidatorBefore() {
    if (document.all){
    var i;
    for (i = 0; i < Page_Validators.length; i++) {
        ValidatorValidate(Page_Validators[i]);
    }
    ValidatorUpdateIsValid();    
    Page_BlockSubmit = !Page_IsValid;
    return Page_IsValid;
    }
    else return true;
}

var iMaxCategories = 350;

function showSubCat(iCat) {
	if (document.getElementById) {
		
		for (i=0; i < iMaxCategories; i++) {
			if (document.getElementById('subCatH_' + i)) {
				if (document.getElementById('subCatH_' + i).uParent != 4) {
					document.getElementById('subCatH_' + i).style.display = 'none';
				}
			}
		}
		
		
		for (i=0; i < iMaxCategories; i++) {
			if (document.getElementById('subCatH_' + i)) {
				if ((document.getElementById('subCatH_' + i).uParent != iCat) && (i != document.getElementById('subCatH_' + iCat).uParent)) {
					document.getElementById('subCatH_' + i).style.display = 'none';
					
				}
			}
		}

		if (document.getElementById('subCatH_' + iCat)) {
			document.getElementById('subCatH_' + iCat).style.display = '';
			//if (iCat != 90) { document.getElementById('subCatH_90').style.display = 'none'; }
		}
	}
}


function showSubCatH(iCat, iParent) {
	if(iParent==4){
		if (document.getElementById) {
			
			for (i=0; i < iMaxCategories; i++) {
				if (document.getElementById('subCatH_' + i)) {
					if (document.getElementById('subCatH_' + i).uParent != 4) {
						document.getElementById('subCatH_' + i).style.display = 'none';
					}
				}
			}
			
			for (i=0; i < iMaxCategories; i++) {
				if (document.getElementById('subCatH_' + i)) {
					if ((document.getElementById('subCatH_' + i).uParent != iCat) && (i != document.getElementById('subCatH_' + iCat).uParent)) {
						document.getElementById('subCatH_' + i).style.display = 'none';
						
					}
				}
			}

			if (document.getElementById('subCatH_' + iCat)) {
				document.getElementById('subCatH_' + iCat).style.display = '';
				//if (iCat != 90) { document.getElementById('subCatH_90').style.display = 'none'; }
			}
		}
	}
}


function hideSubCatAll(id){
	if (document.getElementById) 	
		for (i=0; i < iMaxCategories; i++) {
			if (document.getElementById('subCatH_' + i)) {
				if ((document.getElementById('subCatH_' + i).uParent != 4) && (document.getElementById('subCatH_' + i).uParent != id)) {
					document.getElementById('subCatH_' + i).style.display = 'none';
				}
			}
		}
	
	
		for (i=0; i < iMaxCategories; i++)
			if (document.getElementById('subCatH_' + i))
				document.getElementById('subCatH_' + i).style.display = 'none';
}



var timerID = 0;

function HideTimer(id) 
{
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }
   hideSubCatAll(id);
}

function HideStart(id) 
{
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }
   timerID  = setTimeout("HideTimer("+id+")", 2000);
}


function HideStop(id) 
{
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }
}



function ChgImg(ai_iNumberImg, ai_iProduct) {
	var iTemp = document.getElementById("oImgSmall" + ai_iNumberImg).getAttribute("udImage");

	document.getElementById("oImgSmall" + ai_iNumberImg).innerHTML = "<img src=/images/product/1/small/ps_1_" + document.getElementById("oImgH").getAttribute("udImage") + "_" + ai_iProduct + ".jpg width=80 height=80>";
	document.getElementById("oImgSmall" + ai_iNumberImg).setAttribute("udImage", document.getElementById("oImgH").getAttribute("udImage"));
	
	//document.getElementById("oImgH").innerHTML = "<a href=/images/product/1/large/pl_1_" + iTemp + "_" + ai_iProduct + ".jpg target=_img><img src=/images/product/1/medium/pm_1_" + iTemp + "_" + ai_iProduct + ".jpg width=250 height=250></a>";
	document.getElementById("oImgH").innerHTML = "<a href='javascript:void(null);' onClick=window.open('zoom.aspx?p=" + ai_iProduct + "&image=/images/product/1/large/pl_1_" + iTemp + "_" + ai_iProduct + ".jpg','','scrollbars=no,resizable=yes;');><img src=/images/product/1/medium/pm_1_" + iTemp + "_" + ai_iProduct + ".jpg width=250 height=250></a>";
	
	document.getElementById("oImgH").setAttribute("udImage", iTemp);
}

