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 = document.location.host; var sPath = document.location.pathname; var sParams = document.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 URL FIX*/ $(".menu .child:empty").remove(); $(".menu .child p:first-child a").each(function() { $parent = $(this).parent().parent().prev().children("a"); $parent.attr("href", $(this).attr("href")); }); $(".menu .child[code='"+$("#current_head_category").html()+"']").addClass("active"); $(".menu p[code='"+$("#current_head_category").html()+"'] a").addClass("active"); $(".menu p[code='"+$("#current_category").html()+"'] a").addClass("active"); $(".display_home .cat_item").each(function() { $mirror = $(".menu p[code='"+$(this).attr("code")+"']") $(this).find("a").attr("href", $mirror.children("a").attr("href")); }); /*CAROUSELS*/ $("#carousel").jCarouselLite({ circular: false, visible: 1, btnNext: ".pager .arrow_right", btnPrev: ".pager .arrow_left", speed: 400, mouseWheel: true }); if ($("#carousel li").size() <= 1) $(".pager .arrow_right").hide(); $("#carousel_related").jCarouselLite({ circular: false, visible: 7, btnNext: ".related_pager .arrow_right", btnPrev: ".related_pager .arrow_left", speed: 400, mouseWheel: true, scroll: 2 }); if ($("#carousel_related li").size() <= 1) $(".related_pager .arrow_right").hide(); function setBasketCarousel() { $(".header .links .basket .basket_holder").css("opacity", 0); $(".header .links .basket .basket_holder").show(); iCarMinLength = 4; iCarItems = $(".header .links .basket .basket_holder #carousel_lite li").size() > iCarMinLength ? iCarMinLength : $(".header .links .basket .basket_holder #carousel_lite li").size(); if ($(".header .links .basket .basket_holder #carousel_lite li").size() <= iCarMinLength) $(".pager_lite .arrow_right").hide(); $("#carousel_lite").jCarouselLite({ circular: false, visible: iCarItems, speed: 400, vertical: true, btnNext: ".pager_lite .arrow_right", btnPrev: ".pager_lite .arrow_left", mouseWheel: true }); $(".header .links .basket .basket_holder").css("opacity", 100); if ($.browser.msie && $(".header .links .basket .basket_holder").size() > 0) $(".header .links .basket .basket_holder").get(0).style.removeAttribute("filter"); $(".header .links .basket .basket_holder").hide(); } setBasketCarousel(); /*STRIP BEHAVIOUR*/ $(".carousel_strip img").click(function() { $(".carousel_strip img").removeClass(); $("#strip_detail").load("detail.aspx?p="+$(this).attr("code")+"&c="+$(this).attr("cat")+"&rnd="+(new Date).getTime()); $(this).addClass("active"); }); $(".carousel_strip img:first").trigger("click"); /*FULLSIZE IMAGES*/ $("a.fancybox").fancybox({ overlayOpacity: 0.50, callbackOnShow: function() { $("#fancy_left:not(:hidden)").children("span").css("left", 20); $("#fancy_right:not(:hidden)").children("span").css("right", 20); } }); $(".zoom").click(function() { $(".fullsize-icon").trigger("click"); }); /*TABS*/ $(".tab").each(function() { if ($(this).is(":empty")) { $("#tabs ul li:eq("+$("#tabs .tab").index(this)+")").remove(); $(this).remove(); } }); $("#tabs").tabs().show(); $(document.createElement("div")).addClass("tab_bottom").prependTo($(".tab")); $(document.createElement("div")).addClass("tab_top").prependTo($(".tab")); /*BUY BEHAVIOUR*/ $(".buy").live("click", function() { setBasketLoading(); prodCode = $(this).attr("code"); $(this).parent().addClass("small_loading").end().remove(); $.ajax({ url: "/action.aspx", data: "a=3&p="+prodCode+"&ps=1&c=0&q=1&at=0&referer="+escape(document.location)+"&rnd="+(new Date).getTime(), cache: false, success: function() { reloadBasket(); reloadBuyButton(); } }); return false; }); function setBasketLoading() { $("#basket").empty(); $(document.createElement("div")).addClass("small_loading").appendTo($("#basket")); } function reloadBasket() { $.ajax({ url: "/load_basket.aspx", data: "rnd="+(new Date).getTime(), cache: false, success: function(html) { $("#basket").empty().html(html); //$(".basket_pill").fadeIn().fadeOut(); setBasketCarousel(); setBasketBehaviour(true); } }); } function reloadBuyButton() { $("#buy_holder").removeClass("small_loading").load("/load_buy_button.aspx?p="+$("#buy_holder").attr("code")+"&rnd="+(new Date).getTime()); } /*BASKET BEHAVIOUR*/ function setBasketBehaviour(open) { $(".basket_info").mouseover(showPill); $(".basket_pill").mouseout(hidePill); $(".basket_pill").click(showBasket); function showPill() { $(".basket_pill").fadeIn(); } function hidePill() { $(".basket_pill").fadeOut(); } function showBasket() { $(".basket_pill").unbind("mouseout"); $(".basket_pill").show(); $(".basket_holder").slideDown(); $(".basket_pill").unbind("click").click(hideBasket); } if (open) showBasket(); function hideBasket() { $(".basket_holder").slideUp(); $(".basket_pill").mouseout(hidePill); $(".basket_pill").unbind("click").click(showBasket); } $(".basket .delete_button").click(function() { var code = $(this).attr("code"); var line = $(this).attr("line"); $(".basket_holder").slideUp(function() { setBasketLoading(); $.ajax({ url: "/action.aspx", data: "a=3&p="+code+"&ps=1&c=0&nl="+line+"&q=1&at=2"+"&rnd="+(new Date).getTime(), cache: false, success: function() { if (document.location.href.indexOf("basket") >= 0) { window.location.reload() } reloadBasket(); reloadBuyButton(); } }); }); return false; }); } setBasketBehaviour(); /*SHIPPING METHODS DIALOG*/ $("#shipping_methods").dialog({ width: 600, height: 400, autoOpen: false, title: $("#shipping_methods").attr("title"), modal: true }); $(".shipping_methods").click(function() { $("#shipping_methods").dialog("open"); return false; }); /*WARRANTY DIALOG*/ $("#warranty").dialog({ width: 600, height: 400, autoOpen: false, title: $("#warranty").attr("title"), modal: true }); $(".warranty").click(function() { $("#warranty").dialog("open"); return false; }); /*STOCK ALERT*/ if ($(".stock_alert").size()) { if (parseInt($(".stock_alert").attr("stock")) > 0) { $(".stock_alert").remove(); } } $("#stock_alert").dialog({ width: 280, height: 80, autoOpen: false, title: $("#stock_alert").attr("title"), modal: true }); $(".stock_alert").click(function() { if ($("#user_logged").size()) { $.ajax({ url: "/product_alert.aspx", data: "a=1&p="+$(this).attr("code")+"&rnd="+(new Date).getTime(), cache: false, success: function(html) { if (html == "true") { $("#stock_alert").dialog("open"); } } }); } else { document.location.href = "/login.aspx?backto=" + document.location.href.replace(/&/g, "|"); } return false; }); /*WISHLIST*/ $("#wishlist").dialog({ width: 280, height: 80, autoOpen: false, title: $("#wishlist").attr("title"), modal: true }); $(".wishlist").click(function() { if ($("#user_logged").size()) { $.ajax({ url: "/action.aspx", data: "a=wish&wa=0&p="+$(this).attr("code")+"&rnd="+(new Date).getTime(), cache: false, success: function(html) { if (html == "true") { $("#wishlist").dialog("open"); } } }); } else { document.location.href = "/login.aspx?backto=" + document.location.href.replace(/&/g, "|"); } return false; }); /*WISHLIST REMOVE ITEM*/ $(".wishlist_holder span").mouseenter(function() { $(this).children(".delete").show(); }); $(".wishlist_holder span").mouseleave(function() { $(this).children(".delete").hide(); }); $(".wishlist_holder span .delete").click(function() { var $wish_item = $(this).parent(); $.ajax({ url: "/action.aspx", data: "a=wish&wa=1&p="+$(this).attr("code")+"&rnd="+(new Date).getTime(), cache: false, success: function(html) { if (html == "true") { $wish_item.fadeOut(function() { $(this).remove(); }); } } }); return false; }); /*SEND TO A FRIEND*/ $("#send").dialog({ width: 300, height: 400, autoOpen: false, title: $("#send").attr("title"), modal: true }); $(".send").click(function() { $("#name").val(""); $("#email").val(""); $("#friend_email").val(""); $("#remarks").val(""); $("#name_required").empty(); $("#email_required").empty(); $("#friend_email_required").empty(); $("#send").dialog("open"); $("#send_submit").click(function() { bSend = true; bSend = bSend && validateName(); bSend = bSend && validateEmail(); bSend = bSend && validateFriendEmail(); if (bSend) { $("#send .submit").children("a").hide().end().addClass("recommend_loading"); $.ajax({ url: "/recommend.aspx", data: "email="+encodeURI($("#email").val())+"&name="+encodeURI($("#name").val())+"&femail="+encodeURI($("#friend_email").val())+"&remarks="+encodeURI($("#remarks").val())+"&p="+$("#send_submit").attr("code")+"&rnd="+(new Date).getTime(), cache: false, success: function(html) { if (html != "true") { alert("Se ha producido un error de conexión"); } $("#send").dialog("close"); $("#send .submit").children("a").show().end().removeClass("recommend_loading"); } }); } return false; }); $("#name").blur(validateName); $("#email").blur(validateEmail); $("#friend_email").blur(validateFriendEmail); function validateName() { $("#name_required").empty(); if ($("#name").val() == "") { $("#name_required").html("- campo requerido"); return false; } return true; } function validateEmail() { $("#email_required").empty(); if ($("#email").val() == "") { $("#email_required").html("- campo requerido"); return false; } else { if (!EmailCheck($("#email").val())) { $("#email_required").html("- email incorrecto"); return false; } } return true; } function validateFriendEmail() { $("#friend_email_required").empty(); if ($("#friend_email").val() == "") { $("#friend_email_required").html("- campo requerido"); return false; } else { if (!EmailCheck($("#friend_email").val())) { $("#friend_email_required").html("- email incorrecto"); return false; } } return true; } return false; }); /*CUSTOMIZER BEHAVIOUR*/ var sLangCode = 1; var sRegionCode = 1; $("#customizer_holder").css("opacity", 0); $("#customizer_holder").show(); $("#language_carousel").jCarouselLite({ circular: true, visible: 1, btnNext: ".language_control .pager_right", btnPrev: ".language_control .pager_left", speed: 400, mouseWheel: true, start: 0, afterEnd: function(li) { sLangCode = li.attr("lang"); } }); $("#region_carousel").jCarouselLite({ circular: true, visible: 1, btnNext: ".region_control .pager_right", btnPrev: ".region_control .pager_left", speed: 400, mouseWheel: true, start: 0, afterEnd: function(li) { sRegionCode = li.attr("code"); } }); $("#customizer_holder").css("opacity", 100); $("#customizer_holder").hide(); $("#customizer_holder").dialog({ width: 260, height: 300, autoOpen: false, title: $("#customizer_holder").attr("title"), modal: true }); $("#customizer").click(function() { $("#customizer_holder").dialog("open"); return false; }); $("#customizer_submit").click(function() { sLang = sLangCode; sRegion = sRegionCode; 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, "?"); sBackTo = ""; if(sParams == "") { sBackTo = "http://"+sURL+sPath+"?l="+sLang; } else { sBackTo = "http://"+sURL+sPath+sParams+"&l="+sLang; } sBackTo = sBackTo.replace(/&/g, "|"); //llamar a customize pasando code & backto document.location.href = "/customize.aspx?code="+sRegion+"&l="+sLang+"&backto="+sBackTo return false; }); /*FAQS BEHAVIOUR*/ $(".collapse_question").click(function() { $(".collapse_answer").hide(); $(".collapse_answer[code="+$(this).attr("code")+"]").show(); $(".collapse_question").removeClass("selected"); $(this).addClass("selected"); }); $(".collapse_question:first").trigger("click"); });