


			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 setMenuBehaviour() {
    try {
        if (document.all && document.getElementById) 
        {
            navRoot = document.getElementById("nav");
            for (i = 0; i < navRoot.childNodes.length; i++) 
            {
                node = navRoot.childNodes[i];
                if (node.nodeName == "LI") 
                {
                    node.onmouseover = function () 
                    {
                        //this.className += " over";
                        $(".productCycle, .categoryBrowsingHolder, .categoryGenericControls, .productMiddle, .categoryGenericMiddle, .categoryCenterMiddle").css("z-index", "-1");
                    }
                    node.onmouseout = function () 
                    {
                        //this.className=this.className.replace(" over", "");
                        $("..productCycle, .categoryBrowsingHolder, .categoryGenericControls, .productMiddle, .categoryGenericMiddle, .categoryCenterMiddle").css("z-index", "0");
                    }
                }
            }
        }
    }
    catch(e)
    {
    }
}

//LGP 28/07/2010
var divPriceName = ".productPrice";
var price_Array = new Array();
var price;
function calcPrice(price){
	var iCant = parseInt($("input.productQuantity").val());
	if (isNaN(iCant)) {
		iCant = 1;
	}
	var nPrice;
	var lastIndex = price_Array.length-2;
	for( var i = 0; i < price_Array.length; i++) {
		if ( iCant >= price_Array[i].split(":")[0] && iCant <= price_Array[i].split(":")[1] ) {
			nPrice = Math.round(( 1 * parseFloat(price_Array[i].split(":")[2].replace(",", ".")))*100)/100;
			break;
		} 
	}
	if(isNaN(nPrice)) {
		nPrice = Math.round( (1 * price )*100)/100;
	}
	if(!isNaN(nPrice)) {
		$(divPriceName).html((""+ nPrice+"").replace(".", ",")+" &euro;");
	}
}

function setProductCycleBehaviour() {
    $(".productHotspotItemImage img").mouseover(function (e) {
        $(this).parent("a").parent("div").parent("div").children(".productHotspotItemName, .productHotspotItemPrice").fadeIn(200);        
    });
    $(".productHotspotItem").mouseout(function () {
        $(this).children(".productHotspotItemName, .productHotspotItemPrice").fadeOut(200);
    });
}

function setImageProductBehaviour() {
    $(".dsi_43_1_image").mouseenter(function () {
        $(this).children(".dsi_43_1_out").fadeOut("200");
    });

    $(".dsi_43_1_image").mouseleave(function () {
        $(this).children(".dsi_43_1_out").fadeIn("200");
    });
}

function setTabsBehaviour() {
    $(".ds_37_1_tabs").children("ul").children("li").click(function () {
        $("#tab_1, #tab_2, #tab_3, #tab_4").fadeOut("100");
        
        var id = $(this).attr("id");

        try {
            $('.ds_37_1_content div[id^="tab_"]').css('display', 'hidden');
        }
        catch (e) {
        }
        

        
        $("#tab_" + id).fadeIn(900);
        $(".ds_37_1_tabs ul li.on").removeClass("on");
        $(this).addClass("on");

    });
    $(".ds_37_1_tabs ul li:first").click();
}

$(document).ready(function () {

    $("a[id^='tab']").click(function () {
        var code = $(this).attr("id").replace("tab", "");
        $(".ccont").hide();


        $("a[id^='tab']").each(function () {
            $(this).css("background-color", "#FAE0EB").css("color", "#000");
        });


        $("a[id='tab" + code + "']").each(function () {
            $(this).css("background-color", "#000").css("color", "#FFF");
        });

        $("#cicle" + code).show();
    });

    $("a[id^='tab']:last").click();
















    setMenuBehaviour();

    $(".categoryGenericTop a:last").addClass("last");

    if ($('.productCycle .products').length > 0) {
        $('.productCycle .products').cycle({
            fx: 'fade',
            speed: '500',
            timeout: 0,
            next: '.pnext',
            prev: '.pprev'
        });
        $('.productCycle').css("display", "block");
    }

    MM_preloadImages("");

    try {
        price = parseFloat($(divPriceName).html().split(" ")[0].replace(",", "."));
    } catch (err) { }
    $("input.productQuantity").keydown(function (event) {
        if (!(event.keyCode == 46 || event.keyCode == 8) && (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105)) {
            event.preventDefault();
        }
        if ($(this).val() < 1 && (event.keyCode == 48 || event.keyCode == 96)) {
            event.preventDefault();
            $(this).val(1);
        }
    });

    $("input.productQuantity").keyup(function (event) {
        try { calcPrice(price); } catch (e) { }
    });
    $("input.productQuantity").click(function (event) {
        $(this).focus();
        $(this).select();
    });

    setImageProductBehaviour();

    setProductCycleBehaviour();
    try {
        $.simpledropdown("#ddOrder");
    }
    catch (e) {
    }

    var sOption = $.query.get("i") + "" + $.query.get("om");
    switch (sOption) {
        case "10":
            $("li.selected").text($("li#" + sOption + " a").text()); break;
        case "11":
            $("li.selected").text($("li#" + sOption + " a").text()); break;
        case "20":
            $("li.selected").text($("li#" + sOption + " a").text()); break;
        case "21":
            $("li.selected").text($("li#" + sOption + " a").text()); break;
    }

    setTabsBehaviour();

    $("#hiddenNewsletter div").appendTo($("#newsletter"));
    $("#txtSpSuscriber").focus(function () {

        if ($(this).val() == $("#txtSpSuscriber2").val()) {
            $(this).val("");
        }
    });
    $("#txtSpSuscriber").blur(function () {
        if ($(this).val() == "") {
            $(this).val($("#txtSpSuscriber2").val());
        }
    });

    if ($(".ds_43_1_products").children().length == 0) {
        $(".ds_43_1").css("display", "none");
    }

    $(".contentCarouselItem").each(function () {
        $(this).children(".contentCarousel").children("ul").cycle({
            fx: 'fade',
            speed: '500',
            timeout: 0,
            next: $(this).children(".contentCarousel").children("#next"),
            prev: $(this).children(".contentCarousel").children("#prev"),
            pager: $(this).children(".contentCarousel").children("#nav"),
            cleartypeNoBg: true
        });
    });


    //    $(".contentNewsTitle a").each(function () {
    //        $(this).html('"' + $(this).html()  + '"');
    //    });

    $("#mySlides").cycle({
        fx: 'fade',
        timeout: 4000
    });

    if ($(".productRightHeader .productReference span.price").html() != "") {
        $(".productRightHeader .productReference span.text").css("display", "block");
    }






});
