
			function OnReadyStateChangeRegisterShopGenericLog()
			{
			}
			
			function RegisterSessionLog(){
				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_session_log.aspx";
				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 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;
}


//JFS 22-09-2008
function changelanguage(ai_ilanguage){

    var sURL    = window.location.host;
    var sPath   = window.location.pathname;
    var sParams = window.location.search;

    var sMatchStr  =/(\&l=.)/;
    var sMatchStr2 =/(\?l=.)/;

    //alert(sURL);
    //alert(sPath);
    //alert(sParams);

    sParams = sParams.replace(sMatchStr, '');
    sParams = sParams.replace(sMatchStr2, '?');

    if(sParams == '') { 
        document.location.href = 'http://' + sURL + sPath + '?l=' + ai_ilanguage;
    } else {
        document.location.href = 'http://' + sURL + sPath + sParams + '&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;
}


function showPopUp(url) {
    window.open(url, "content_pop_up", "toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=755,height=550,left=" + ((screen.width - 755) / 2) + ",top=" + ((screen.height - 550) / 2));
}



/*JQUERY SCRIPTS*/

$(document).ready(function() {

    /*MENU TABS*/
    var curCat = $("#header_category").html();
    
    $(".tabs ul[value=cat_"+curCat+"]").parent().addClass("selected").end().removeClass().appendTo($(".red_zone").empty());
    $(".category_list div[value=subcat_"+curCat+"]").prev().addClass("selected");
    $(".category_list div[value=subcat_"+curCat+"]:parent").show();
    
    $(".tabs li h3 > a").addClass("tablink");
    $(".tabs ul:empty").remove();
    $(".tabs > ul").superfish({
        autoArrows: false,
        dropShadows: false
    });
    $(".tabs > ul > li > ul").each(function() {
        iWidth = $(this).parent().width()-2;
        $(this).width(iWidth).find("li").width(iWidth);
    });
    
    /*SEARCH FUNCTIONALITY*/
    $("#searchButton").click(function() {
        if ($("#spHeader_spSearch_ddCategories").val() == "") {
            sCat = 0;
        }
        else {
            sCat = $("#spHeader_spSearch_ddCategories").val();
        }
        if($("#txtSearch").val().length < 3) {
            alert("Introduzca al menos tres caracteres para realizar la busqueda");
        }
        else {
            document.location.href = "/list.aspx?advs=1&cat=" + sCat + "&search=" + $("#txtSearch").val();            
        }
    });
    if ($("#searchText").length > 0) {
        if ($("#searchText").html() != "") {
            $("#txtSearch").val($("#searchText").html());
        }
    }
    if ($("#searchCategory").length > 0) {
        if ($("#searchCategory").html() != "") {
            $("#spHeader_spSearch_ddCategories").val($("#searchCategory").html());
        }
    }
        
    
    /*TAG SELECTOR*/
    $("#tag_list_send").click(function() {
        document.location.href = "/tag_list.aspx?tag=" + $("#tag_select").val();
    });
	
	/*PRODUCT TABS*/
	$(".product_tabs > div:empty").remove();
	$(".product_tabs > div:first").removeClass("hidden");	
	$(".product_tabs > div").each(function() {
	    $("<span></span>").text($(this).attr("value")).appendTo($(".product_tabs .tabs_holder")).click(function() {
	        $(".product_tabs .tabs_holder > span").removeClass();
	        $(this).addClass("selected");
	        $(".product_tabs > div").hide();
	        $(".product_tabs > div[value="+this.innerHTML+"]").show();
	    });	    
	});
	$(".product_tabs .tabs_holder > span:first").addClass("selected");
	
	/*ACCESORIES*/
	$(".product_accesories .accesory:odd").css("background-color", "#efefef");
	
	/*IMAGE ZOOM*/
	$(".productImageAnchor[href*=no_image]").remove();
	$(".productImageAnchor").fancybox();
	
	/*FILTER LISTS*/
	$("#filterSubmit").click(function() {
	    if ($("#filterPrice").val() == 0 && $("#filterTag").val() == 0) {
	        alert("Seleccione al menos un criterio para el filtro.");
	    }
	    else {
	        document.location.href = "/list.aspx?advs=1&price=" + $("#filterPrice").val() + "&tag=" + $("#filterTag").val() + "&cat=" + $("#filterCategory").text() + "&filter=1";
        }
	});
	
	/*COMPARATIVE*/
	$(".comparativeProductHolder").height($(".comparativeProductHolder table td").height() + 100);
    $(".center_holder_whole td > .comparatorAtt:even").css("background", "#f2f2f2");
    var maxWidth = 0;
    $(".comparativeProductHolder table td").each(function() {
        if ($(this).width() > maxWidth) {
            maxWidth = $(this).width();
        }
    });
    $(".comparativeProductHolder table").width($(".comparativeProductHolder table td").length * maxWidth);
    $(".comparativeProductHolder table td").width(maxWidth);
    
     $("#FooterIDNoFollow").live("click", function() {
        return false;
    });
    
});

