


			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 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 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    = document.location.host;
    var sPath   = document.location.pathname;
    var sParams = document.location.search;

    var sMatchStr  =/(\&l=.)/;
    var sMatchStr2 =/(\?l=.)/;

    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));
}

function utf8_encode(string) {
    var navegador = navigator.appName
    if (navegador == "Microsoft Internet Explorer") {
        string = string.replace(/\r\n/g, "\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if ((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }
    }
    else {
        utftext = string;
    }
    return utftext;
}


function setFilter(value, control) {
    document.getElementById(control).value = value;
}

function setFilterField(idControl) {
    $("#spListCenter_txt_" + idControl).attr("value", $("#spListCenter_sb_" + idControl + "_cb_" + idControl).val());
}

function setEmbalaje(obj) {
    var idProduct = obj.getAttribute("value");
    var sUrl = "/action.aspx?a=3&p=" + idProduct + "&pt=8&ps=1&c=4&q=1&at=0&du1=0|0&referer=" + window.location;
    window.location = sUrl;
}

function setEnvoltorio(obj) {
    var idProduct = obj.getAttribute("value");
    var sUrl = "/action.aspx?a=3&p=" + idProduct + "&pt=9&ps=1&c=4&q=1&at=0&du1=0|0&referer=" + window.location;
    window.location = sUrl;
}

function setTarjetaRegalo(obj) {
    var idProduct = obj.getAttribute("value");
    var sUrl = "/action.aspx?a=3&p=" + idProduct + "&pt=10&ps=1&c=4&q=1&at=0&du1=0|0&referer=" + window.location;
    window.location = sUrl;
}

function setWineryFilter(value, control) {
    $("#winery_value").attr("code",value);
}

function doWineryFilter() {
    if ($("#winery_value").attr("code") != "-1" && $("#winery_value").attr("code") != " " && $("#winery_value").attr("code") != "")
        document.location = "/winery_search.aspx?winery=" + $("#winery_value").attr("code");
}

function checkBankData() {
    
    if ($("#Customer_data_center_txtBankName").val() == "")
        $("#message_bankname").css("display","block");

    if ($("#Customer_data_center_txtBankCode").val() == "")
        $("#message_bankcode").css("display", "block");

    if ($("#Customer_data_center_txtOfficeCode").val() == "")
        $("#message_officecode").css("display", "block");

    if ($("#Customer_data_center_txtDC").val() == "")
        $("#message_dc").css("display", "block");

    if ($("#Customer_data_center_txtAccountNumber").val() == "")
        $("#message_accountnumber").css("display", "block");
}

function hideBankData() {
    $("#message_bankname").css("display", "none");
    $("#message_bankcode").css("display", "none");
    $("#message_officecode").css("display", "none");
    $("#message_dc").css("display", "none");
    $("#message_accountnumber").css("display", "none");
}

$(document).ready(function () {

    setFilterField("prds_ax57");
    setFilterField("prds_ax58");
    setFilterField("prds_ax59");
    setFilterField("prds_ax60");

    $(".ds_37_1_links a:last ").css("border-right", "none");

    if ($(".ds_37_1_image_aux li").lenght > 0) {

        $(".ds_37_1_image_aux").jCarouselLite({
            auto: 0,
            speed: 1000,
            visible: 3,
            btnNext: ".next",
            btnPrev: ".prev",
            easing: "linear"
        });
    }
    else {
        $(".ds_37_1_carrousel .prev").css("display", "none");
        $(".ds_37_1_carrousel .next").css("display", "none");
    }

    $(".lightview").lightBox();

    MM_preloadImages("");

    /* PRODUCT CARROUSEL */

    /*************/

    /* PRODUCT TABS */
    $(".ds_37_1_tabs li").click(function () {
        $(".ds_37_1_holder div").hide();
        $("#tab" + $(this).attr("ID")).show();

        $(".li_on").removeClass("li_on");
        $(this).addClass("li_on");
    });

    $("#tab1").show();
    $("#1").addClass("li_on");
    /**********************/

    $("#mySlides").cycle({
        fx: 'fade',
        timeout: 6000,
        next: '.hs_6_1_next',
        prev: '.hs_6_1_prev'
    });


    var category1 = $("#head_category_code1").val();
    var category2 = $("#head_category_code2").val();
    var category3 = $("#head_category_code3").val();

    ExpandCategory(category1);
    ExpandCategory(category2);
    ExpandCategory(category3);


    if ($(".ds_37_1_similar_products").html() == "") {
        $(".ds_37_1_similar").css("display", "none");
    }


    if ($(".ds_37_1_variants select").length == 0) {
        $(".ds_37_1_buy .ds_37_1_buy_separator").css("display", "none");
        $(".ds_37_1_bottom").css("height", "60px");
        $(".ds_37_1_buy").css("height", "60px");
    }


    if ($(".ds_34_1_denominacion").children().size() == 0) {
        $(".ds_34_1_denominacion").css("background-color", "#FFF");
    }

    if ($(".ds_37_2_similar .ds_37_1_similar_products .ds_33_1_category .ds_33_1_item_left").length == 0) {
        $(".ds_37_2_similar").hide();
    }

    if ($(".ds_37_1_similar .ds_37_1_similar_products .ds_33_1_category .ds_33_1_item_left").length == 0) {
        $(".ds_37_1_similar").hide();
    }

    /* CLUB BEHAVIOUR */
    $("#Customer_data_center_chkClub").click(function () {
        $(".register_club").toggle();
        var enable = $(this).attr("checked");
    });

    if ($("#Customer_data_center_chkClub").attr("checked") == true) {
        $(".register_club").css("display", "table-row");
        checkBankData();
    }

    $(".os1_1_1_register_button img").click(function () {
        if ($("#Customer_data_center_chkClub").attr("checked") == true) {
            checkBankData();
        }
        else {
            hideBankData();
        }

    });

if($(".ds_33_1_filter_temp_hidden").length > 0) $(".ds_33_1_filter_temp").css("display","none");

});
