﻿
        $(function ()
        {
            // $("#LoginDiv").hide();
        });
        function HideShowLogin()
        {
            if (document.getElementById("login").style.visibility == "hidden")
            {
                document.getElementById("login").style.visibility = "visible";
            }
            else
            {
                document.getElementById("login").style.visibility = "hidden";
            }
        }

        function validEmail(email) {
            var emailReg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
            return emailReg.test(email);
        }
        function trackBuyWithoutLogin() {
            if (typeof (_gat) == 'object') {
                var pageTracker = _gat._getTracker("UA-2263513-3");
                pageTracker._trackPageview('/Buy/BuyWithoutLogin');
            }
        }

        var vLoginIsBookmark = 0;
        var vLoginIsGTS = 0;
        var vLoginIsGTP = 0;
        var vLoginBookmarkStoreId = 0;
        var vLoginCampaign = 0;
        function clearV() {   
            vLoginIsBookmark = 0;
            vLoginIsGTS = 0;
            vLoginIsGTP = 0;
            vLoginCampaign = 0;
        }
        function clearH() {
            document.getElementById("loginHeaderLogin").style.display = "none";
            document.getElementById("loginHeaderBookmark").style.display = "none";
            document.getElementById("loginHeaderStore").style.display = "none";
            document.getElementById("loginHeaderProduct").style.display = "none";
            document.getElementById("loginHeaderCampaign").style.display = "none";
            document.getElementById("loginHeaderCampaign2").style.display = "none";
        }
        function callBookmark(check) {
            if (vLoginIsBookmark == 1) {
                vIsLogged = check;
                addBookmarkLogin(vLoginBookmarkStoreId);
                vLoginBookmarkStoreId = 0;
            }
        }
        function callGoToStore(i) {
            if (vLoginIsGTS == 1) {
                vUserId = i;
                fGoToStore();
            }
        }
        function callGoToProduct(i) {
       
            if (vLoginIsGTP == 1) {
                vUserId = i;
                fGoToProduct();
            }
        }
        function ShowMenuDiv() {
            document.getElementById("panelMenuDivPopUp").style.display = "block";
        }
        function panelMenuDivClick() {
            document.getElementById("panelMenuDivPopUp").style.display = "none";
        }
        function ShowLoginRegisterDiv1() {
            //LoginDiv
            //alert("1");
            $(".filmRollover").fadeOut('fast', null);
            $("#spanError").text("");
            document.getElementById("goondiv").style.display = "none";
            clearH();
            document.getElementById("loginHeaderLogin").style.display = "block";
            $("#LoginDiv").dialog({ width: 680, height: 450, modal: true });
            //$("#LoginDiv").simpleDialog();
            $("#LoginDiv").show();
            //$("#menuEl7").addClass("naviOpen");
        }
        function ShowLoginRegisterDiv(typ, id) {
            $(".filmRollover").fadeOut('fast', null);
            $("#spanError").text("");
            if (typ == "bookmarkStore") {
                vLoginIsBookmark = 1;
                vLoginBookmarkStoreId = id;
                document.getElementById("goondiv").style.display = "block";
                clearH();
                document.getElementById("loginHeaderBookmark").style.display = "block";
                $("#LoginDiv").dialog({ width: 680, height: 450, modal: true });
                $("#LoginDiv").show();
            } else if (typ == "goToStore") {
                vLoginIsGTS = 1;
                document.getElementById("goondiv").style.display = "block";
                clearH();
                document.getElementById("loginHeaderStore").style.display = "block";
                $("#LoginDiv").dialog({ width: 680, height: 450, modal: true });
                $("#LoginDiv").show();
            } else if (typ == "goToProduct") {
                vLoginIsGTP = 1;
                document.getElementById("goondiv").style.display = "block";
                clearH();
                document.getElementById("loginHeaderProduct").style.display = "block";
                $("#LoginDiv").dialog({ width: 680, height: 450, modal: true });
                $("#LoginDiv").show();
            } else if (typ == "campaign1") {
                vLoginCampaign = id;
                document.getElementById("goondiv").style.display = "none";
                clearH();
                document.getElementById("loginHeaderCampaign").style.display = "block";
                $("#LoginDiv").dialog({ width: 680, height: 450, modal: true });
                $("#LoginDiv").show();
                ShowRegisterTab();
                document.getElementById("loginLink").style.display = "none";
            } else if (typ == "campaign2") {
                vLoginCampaign = id;
                document.getElementById("goondiv").style.display = "none";
                clearH();
                document.getElementById("loginHeaderCampaign2").style.display = "block";
                $("#LoginDiv").dialog({ width: 680, height: 450, modal: true });
                $("#LoginDiv").show();
                ShowRegisterTab();
                document.getElementById("loginLink").style.display = "none";
            } else if (typ == "campaign3") {
                vLoginCampaign = id;
                document.getElementById("goondiv").style.display = "none";
                clearH();
                document.getElementById("loginHeaderCampaign3").style.display = "block";
                $("#LoginDiv").dialog({ width: 680, height: 450, modal: true });
                $("#LoginDiv").show();
                ShowRegisterTab();
                document.getElementById("loginLink").style.display = "none";
            }            
        }
    
        (function ()
    {
        if (typeof window.janrain !== 'object') window.janrain = {};
        window.janrain.settings = {};

        janrain.settings.tokenAction = 'event';
        /* _______________ can edit below this line _______________ */
        janrain.settings.tokenUrl = vPageAddr;
        janrain.settings.actionText = '';
        janrain.settings.width = '400';
        janrain.settings.providersPerPage = 4;

        /* _______________ can edit above this line _______________ */

        function isReady() { janrain.ready = true; };
        if (document.addEventListener)
        {
            document.addEventListener("DOMContentLoaded", isReady, false);
        } else
        {
            window.attachEvent('onload', isReady);
        }

        var e = document.createElement('script');
        e.type = 'text/javascript';
        e.id = 'janrainAuthWidget';

        if (document.location.protocol === 'https:')
        {
            e.src = 'https://rpxnow.com/js/lib/dothebrightthing/engage.js';
        } else
        {
            e.src = 'http://widget-cdn.rpxnow.com/js/lib/dothebrightthing/engage.js';
        }

        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(e, s);
    })();


    function janrainWidgetOnload()
    {          
        janrain.events.onProviderLoginToken.addHandler(function (response) {
            $.ajax({
                type: "POST",
                url: vPageAddr + "/LogJanrain.aspx",
                data: "token=" + response.token + "&cam=" + vLoginCampaign,
                beforeSend: function () {
                    $("#waitIconLog").show();
                    $("#waitIconReg").show();
                },
                success: function (res) {
                    if (res.substr(0, 3) == "ok|") {
                        //alert(res);      
                        
                                   // alert("1");
                       //alert( vLoginIsGTS);
                        //location.reload(true);
                        //location.href = "purchase?product";
                        callBookmark(1);
                        callGoToStore(res.split("|")[1]);
                        callGoToProduct(res.split("|")[1]);
                        if(res.split("|")[2] == "1") {
                            SendRegisterGA();
                        }
                        if (vLoginIsGTS == 1 || vLoginIsGTP == 1) {
                            $('#LoginDiv').dialog('close');
                              //      alert("2");
                         //  clearV();
                            //location.reload(true);
                        } else if (vLoginCampaign > 0) {
                            $('#LoginDiv').dialog('close');
                           //  alert("3");clearV();
                                        
                            ConfirmCampaign();

                            location.reload(true);
                        } else {
                          //  clearV();
                            location.reload(true);
                        }
                    } else {
                        $("#spanError").text(data);
                    }
                },
                complete: function () {
                    $("#waitIconLog").hide();
                    $("#waitIconReg").hide();
                },

            });
        });
    }

    function SendRegisterGA() {
        if (typeof (_gat) == 'object')
        {
            var pageTracker = _gat._getTracker("UA-2263513-3");
            pageTracker._trackPageview('/Register/NewUser');
        }
    }

    function SendCalculatorGA() {
        if (typeof (_gat) == 'object')
        {
            var pageTracker = _gat._getTracker("UA-2263513-3");
            pageTracker._trackPageview('/EnergyCalculator');
        }
    }

   // from here
       $(function ()
    {

 //   ShowLoginTab();
    //var control=""+"<%=styleStoreButton %>";
    /*if(control=="1")
    {
        $("#menuEl1").addClass("naviOpen");

        $("#menuEl1").addClass("naviOpen");
        $("#menuEl2").addClass("naviOpen");
        $("#menuEl3").addClass("naviOpen");
        $("#menuEl4").addClass("naviOpen");
        $("#menuEl5").addClass("naviOpen");
        $("#menuEl7").addClass("naviOpen");
   
    }
    if(control=="2")
    {
        $("#menuEl2").addClass("naviOpen");
    }
    if(control=="3")
    {
        $("#menuEl3").addClass("naviOpen");
    }
    if(control=="4")
    {
        $("#menuEl4").addClass("naviOpen");
    }
    if(control=="5")
    {
        $("#menuEl5").addClass("naviOpen");
    }
    if(control=="8")
    {
        $("#menuEl8").addClass("naviOpen");
    }//*/
    
        LoginRegisterClick();
    });



    function LoginRegisterClick()
    {
       // if ($("#loginBtn").is(":visible"))
       
    }
    function NameFocus()
    {
        if($("#registerTabLoginNameTB").val()==LOGIN_NAMETEXT)
        {
            $("#registerTabLoginNameTB").val("");
        }
    }
    function NameBlur()
    {
        if($("#registerTabLoginNameTB").val()=='')
        {
            $("#registerTabLoginNameTB").val(LOGIN_NAMETEXT);
        }
    }
    function EmailFocus()
    {
        if($("#loginTabLoginEmailTB").val()==LOGIN_EMAILTEXT)
        {
            $("#loginTabLoginEmailTB").val("");
        }
    }
    function EmailBlur()
    {
        if($("#loginTabLoginEmailTB").val()=='')
        {
            $("#loginTabLoginEmailTB").val(LOGIN_EMAILTEXT);
        }
    }
    function EmailFocusR()
    {
        if($("#registerTabLoginEmailTB").val()==LOGIN_EMAILTEXT)
        {
            $("#registerTabLoginEmailTB").val("");
        }
    }
    function EmailBlurR()
    {
        if($("#registerTabLoginEmailTB").val()=='')
        {
            $("#registerTabLoginEmailTB").val(LOGIN_EMAILTEXT);
        }
    }
    function EmailFocusF()
    {
        if($("#forgotTabLoginEmailTB").val()==LOGIN_EMAILTEXT)
        {
            $("#forgotTabLoginEmailTB").val("");
        }
    }
    function EmailBlurF()
    {
        if($("#forgotTabLoginEmailTB").val()=='')
        {
            $("#forgotTabLoginEmailTB").val(LOGIN_EMAILTEXT);
        }
    }
     function PasswordFocus()
    {
        if($("#loginTabLoginPasswordTB").val()==LOGIN_PASSWORD)
        {
            $("#loginTabLoginPasswordTB").val("");
        }
    }
    function PasswordBlur()
    {
    if($("#loginTabLoginPasswordTB").val()=='')
        {
            $("#loginTabLoginPasswordTB").val(LOGIN_PASSWORD);
        }
    }
    function PasswordFocusR()
    {
        if($("#registerTabLoginPasswordTB").val()==LOGIN_PASSWORD)
        {
            $("#registerTabLoginPasswordTB").val("");
        }
    }
    function PasswordBlurR()
    {
    if($("#registerTabLoginPasswordTB").val()=='')
        {
            $("#registerTabLoginPasswordTB").val(LOGIN_PASSWORD);
        }
    }
    function RePasswordFocus()
    {
        if($("#RegisterPass2TB").val()==LOGIN_RPASSWORD)
        {
            $("#RegisterPass2TB").val("");
        }
    }
    function RePasswordBlur()
    {
        if($("#RegisterPass2TB").val()=='')
        {
            $("#RegisterPass2TB").val(LOGIN_RPASSWORD);
        }
    }
    function CheckBeforeLogin()
    {
        if($("#LoginEmailTB").val()=="")
        return false;
        if($("#LoginEmailTB").val().lenght<4)
        return false;




        return true;
    }
    function LoginSubmit()
    {
        $("#spanError").text("");
        if($("#loginTabLoginEmailTB").val() == "" || $("#loginTabLoginEmailTB").val() == LOGIN_EMAILTEXT) {
            $("#spanError").text(LOGIN_ERROR5);
            return;
        }
        if($("#loginTabLoginPasswordTB").val() == "" || $("#loginTabLoginPasswordTB").val() == LOGIN_PASSWORD) {
            $("#spanError").text(LOGIN_ERROR5);
            return;
        }
        if(!validEmail($("#loginTabLoginEmailTB").val())) {
            $("#spanError").text(LOGIN_ERROR6);
            return;
        }

           $.ajax({
                       url: vPageAddr + "/LogJanrain.aspx",
                    type: 'POST',
                    async: true,
                    data: "login=" + "login"+ "&user=" + $("#loginTabLoginEmailTB").val() + "&pass=" + $("#loginTabLoginPasswordTB").val(),
                    beforeSend: function () {
                       $("#waitIconLog").show();
                    },
                    success: function (data) {
                       if(data.substr(0, 3) == "ok|")
                       {
                            callBookmark(1);
                            callGoToStore(data.split("|")[1]);
                            callGoToProduct(data.split("|")[1]);
                            if (vLoginIsGTS == 1 || vLoginIsGTP == 1) {
                                $('#LoginDiv').dialog('close');
                                clearV();
                            } else {
                                clearV();
                                location.reload(true);
                            }
                       }
                       else
                       {
                       
                        $("#spanError").text(data);
                       

                       }
                       //alert(data);
                    },
                    complete: function () {
                        $("#waitIconLog").hide();
                    },
                   

                });
    }

    function RegisterSubmit()
    {
        $("#spanError").text("");
        if($("#registerTabLoginEmailTB").val() == "" || $("#registerTabLoginEmailTB").val() == LOGIN_EMAILTEXT) {
            $("#spanError").text(LOGIN_ERROR5);
            return;
        }
        if($("#registerTabLoginPasswordTB").val() == "" || $("#registerTabLoginPasswordTB").val() == LOGIN_PASSWORD) {
            $("#spanError").text(LOGIN_ERROR5);
            return;
        }
        if($("#RegisterPass2TB").val() == "" || $("#RegisterPass2TB").val() == LOGIN_RPASSWORD) {
            $("#spanError").text(LOGIN_ERROR5);
            return;
        }
        if($("#registerTabLoginPasswordTB").val().length < 4 || $("#RegisterPass2TB").val().length < 4) {
            $("#spanError").text(LOGIN_ERROR3);
            return;
        }
        if($("#registerTabLoginPasswordTB").val() !=  $("#RegisterPass2TB").val()) {
            $("#spanError").text(LOGIN_ERROR4);
            return;
        }
        if(!validEmail($("#registerTabLoginEmailTB").val())) {
            $("#spanError").text(LOGIN_ERROR6);
            return;
        }
        if($("#registerTabLoginPasswordTB").val().length > 20 || $("#RegisterPass2TB").val().length > 20) {
            $("#spanError").text(LOGIN_ERROR7);
            return;
        }
        //alert($("#registerTabLoginSendTB").is(":checked") ? "1" : "0");
        
         $.ajax({
                       url: vPageAddr + "/LogJanrain.aspx",
                    type: 'POST',
                    async: true,
                    data: "login=" + "register"+ "&user=" + $("#registerTabLoginEmailTB").val() + "&pass=" + $("#registerTabLoginPasswordTB").val() + "&updat=" + ($("#registerTabLoginSendTB").is(":checked") ? "1" : "0") + "&nam=" + $("#registerTabLoginNameTB").val() + "&cam=" + vLoginCampaign,
                    beforeSend: function () {
                       $("#waitIconReg").show();
                    },
                    success: function (data) {
                       if(data.substr(0, 3) == "ok|")
                       {
                             callBookmark(1);
                             callGoToStore(data.split("|")[1]);
                             callGoToProduct(data.split("|")[1]);
                             if(data.split("|")[2] == "1") {
                                SendRegisterGA();
                            }
                             if (vLoginIsGTS == 1 || vLoginIsGTP == 1) {
                                $('#LoginDiv').dialog('close');
                                clearV();
                                location.reload(true);
                            } else if (vLoginCampaign > 0) {
                                $('#LoginDiv').dialog('close');
                                clearV();
                                ConfirmCampaign();
                                location.reload(true);
                            } else {
                                clearV();
                                location.reload(true);
                            }
                       }
                       else
                       {
                        //if(data=="error")
                        //{
                        $("#spanError").text(data);
                        //}
                        //alert("error");

                       }
                       //alert(data);
                    },
                    complete: function () {
                        $("#waitIconReg").hide();
                    },
                   

                });
    }
    function LoginDialogClose()
    {
    trackBuyWithoutLogin();
        $('#LoginDiv').dialog('close');
        if(vLoginIsBookmark == 1) {
            callBookmark(0);
        }
        if (vLoginIsGTS == 1) {
            callGoToStore("");
        }
        if (vLoginIsGTP == 1) {
            callGoToProduct("");
        }
        clearV();
    }
    
    function NeedRegisterChange()
    {
        if($("#NeedRegister").is(":checked"))
        {
            $("#forgotPass").show();
            $("#loginBtn").show();
            $("#RegisterPass2TBLabel").hide();
            $("#RegisterPass2TB").hide();
            $("#registerBtn").hide(); 
            $("#needLoginRegister").text("  "+LOGIN_GETACCOUNT);
        }
        else
        {
            $("#loginBtn").hide();
            $("#RegisterPass2TBLabel").show();
            $("#RegisterPass2TB").show();
            $("#registerBtn").show();
            $("#needLoginRegister").text("  "+LOGIN_TITLE);
            $("#forgotPass").hide();
            
            }
    }
    function ShowForgottenPassTab()
    {
        $("#loginTab").hide();
        $("#registerTab").hide();

        $("#forgotLink").hide();

        $("#spanError").text("");
        /**************************/
        $("#forgotTab").show();

        $("#loginLink").show();
        
        $("#registerLink").show();
    }

    function ShowLoginTab()
    {
       
        $("#forgotTab").hide();
        $("#registerTab").hide();

        $("#loginLink").hide();

        $("#spanError").text("");
        /**************************/
        $("#loginTab").show();

        $("#forgotLink").show();
        
        $("#registerLink").show();

                $("#defaultTab").hide();
    }
    function ShowRegisterTab()
    {
       
        $("#forgotTab").hide();
        $("#loginTab").hide();

        $("#registerLink").hide();

        $("#spanError").text("");
        /**************************/
        $("#registerTab").show();

        $("#forgotLink").show();
        
        $("#loginLink").show();

        $("#defaultTab").hide();
    }
    function ShowDefaultTab()
    {
        
        $("#forgotTab").hide();
        $("#registerTab").hide();

        $("#loginLink").hide();

        $("#spanError").text("");
        /**************************/
       
        $("#forgotTab").hide();
        $("#loginTab").hide();

        $("#registerLink").hide();

        $("#spanError").text("");
        /**************************/
       
        $("#defaultTab").show();
    }


    function ForgotSubmit()
    {
        $("#spanError").text("");
        if($("#forgotTabLoginEmailTB").val() == "" || $("#forgotTabLoginEmailTB").val() == LOGIN_EMAILTEXT) {
            $("#spanError").text(LOGIN_ERROR5);
            return;
        }
        if(!validEmail($("#forgotTabLoginEmailTB").val())) {
            $("#spanError").text(LOGIN_ERROR6);
            return;
        }

        $.ajax({
            url: vPageAddr + "/LogJanrain.aspx",
            type: 'POST',
            async: true,
            data: "login=" + "forgotten"+ "&user=" + $("#forgotTabLoginEmailTB").val(),
            beforeSend: function () {},
            success: function (data) {
            if(data=="ok")
            {
               location.reload(true);
            }
                       else
                       {
                       
                        $("#spanError").text(data);
                       

                       }
                       //alert(data);
                    },
                    complete: function () {
                        //alert("4");
                    },
                   

                });
    }
    function ChangeLang2() {
        document.getElementById("testF2").submit();
    }
    function changePassword(passwordInputID)
    {
        var passwordValue = document.getElementById(passwordInputID);
        if ((passwordValue.value == '<%= Tran.GetTrans("LOGIN", "PASSWORD") %>' || passwordValue.value == '<%= Tran.GetTrans("LOGIN", "RPASSWORD") %>') && passwordValue.type != "password")
        {
            password2Value = passwordValue.cloneNode(false);
            password2Value.type = "password";
            password2Value.value = "";
            passwordValue.parentNode.replaceChild(password2Value, passwordValue);
            setTimeout("password2Value.focus();", 10);

        }
    }
    function changePassword2(passwordInputID, tx)
    {
        var passwordValue = document.getElementById(passwordInputID);
        if(passwordValue.value == "" && passwordValue.type == "password") {
            if(tx == 1) {
                passwordValue.value = LOGIN_PASSWORD;
            } else {
                passwordValue.value = LOGIN_RPASSWORD;
            }
            password2Value = passwordValue.cloneNode(false);
            password2Value.type = "text";
            passwordValue.parentNode.replaceChild(password2Value, passwordValue);
        }
    }

    $(document).ready(function () {
        $("#energyWash").addClass("energy1Default");
        $("#energyWash .info").css({ 'display': 'block', 'float': 'left', 'margin-top': '65px' });
        // $(".energyWash .info").removeClass("info");
        $("#energyLight").hover(
                function () {
                    $("#energyWash .info").css({ 'display': 'none' });
                    $("#energyWash").removeClass("energy1Default");
                });

        $("#energyWash").hover(
            function () {
                $("#energyWash").addClass("energy1Default");
                $("#energyWash .info").css({ 'display': 'block', 'float': 'left', 'margin-top': '65px' });
            });
        $("#energyCar").hover(
            function () {
                $("#energyWash .info").css({ 'display': 'none' });
                $("#energyWash").removeClass("energy1Default");
            });
        /*});*/
        $("#energyModule").mouseleave(function () {
            $("#energyWash").addClass("energy1Default");
            $("#energyWash .info").css({ 'display': 'block', 'float': 'left', 'margin-top': '65px' });
        });
    });

    //from here
    /*
            function checkSearch() {
            if(document.getElementById("searchStore").value == "" ||
                document.getElementById("searchStore").value == SEARCHSTORE_EDIT ||
                document.getElementById("searchStore").value.length < 1) {
                return;
            }
            document.getElementById("searchStoreName").value = document.getElementById("searchStore").value;
            document.getElementById("sendForm").action = pageAddr + "/Stores/"+searchCategory+"/1/" + document.getElementById("searchStore").value.replace(/\W/gi, "-").replace(/[_]/gi, "-");
            document.getElementById("sendForm").submit();
        }

        function checkSearchProduct() {
            if(document.getElementById("searchProd").value == "" ||
                document.getElementById("searchProd").value == SEARCHPROD_EDIT ||
                document.getElementById("searchProd").value.length < 1) {
                return;
            }
            var str = document.getElementById("searchProd").value;
            // previously: document.getElementById("sendForm").action = "<%= Application["pageAddr"] %>/Search/" + document.getElementById("selCat").options[document.getElementById("selCat").selectedIndex].value + "/1/" + document.getElementById("searchProd").value.replace(/\W/gi, "-").replace(/[_]/gi, "-");
            document.getElementById("sendForm").action = pageAddr+"/Search/-/1/" + document.getElementById("searchProd").value.replace(/\W/gi, "-").replace(/[_]/gi, "-");
            document.getElementById("sendForm").submit();
        }*/
        //search functions below for homepage
        function checkSearchProdHome() {
            if(document.getElementById("searchProdH").value == "" ||
                document.getElementById("searchProdH").value == SEARCH_PROD_EDIT ||
                document.getElementById("searchProdH").value.length < 1) {
                return;
            }
            var str = document.getElementById("searchProdH").value;
            document.getElementById("sendFormProd").action = vPageAddr + "/Search/-/1/" + document.getElementById("searchProdH").value.replace(/\W/gi, "-").replace(/[_]/gi, "-");
            document.getElementById("sendFormProd").submit();
        }
        function EnterSearchProdHome(event)
        {
            if (event.keyCode == 13)
            {
                checkSearchProdHome();
                return false;
            }
            return true;
        }
        function checkSearchShopHome() {
            if(document.getElementById("searchStoreH").value == "" ||
                document.getElementById("searchStoreH").value == SEARCHSTORE_EDIT ||
                document.getElementById("searchStoreH").value.length < 1) {
                return;
            }
            document.getElementById("searchStoreName").value = document.getElementById("searchStoreH").value;
            document.getElementById("sendFormShop").action = vPageAddr + "/Stores/1/" + document.getElementById("searchStoreH").value.replace(/\W/gi, "-").replace(/[_]/gi, "-");
            document.getElementById("sendFormShop").submit();
        }
        function EnterSearchShopHome(event)
        {         
            if (event.keyCode == 13)
            {
                checkSearchShopHome();
                return false;
            }
            return true;
        }
        //search functions below for other pages
        function checkSearchProd(searchString, searchScope)
         {
            if(searchString == "")
            {
                return;
            }
            //Jamie: TODO - WARNING, hard coded string!!!!
            if(searchString.indexOf("Search in") == 0)
            {
                return;
            }
            if(searchString == SEARCH_PROD_EDIT)
            {
                return;
            }
            if(document.getElementById("searchProd").value.length < 1)
            {
                return;
            }
            var str = document.getElementById("searchProd").value;
            //search in category
            if(searchScope == "cat")
            {
                document.getElementById("sendForm").action = vPageAddr + "/Search/"+ searchCategory +"/1/" + document.getElementById("searchProd").value.replace(/\W/gi, "-").replace(/[_]/gi, "-");
            }
            //search in sub-category
            else if(searchScope != "")
            {
                document.getElementById("sendForm").action = vPageAddr + "/Search/"+ searchCategory + "/" + searchSubCategory + "/1/" + document.getElementById("searchProd").value.replace(/\W/gi, "-").replace(/[_]/gi, "-");
            }
            //search in everything
            else
            {
                document.getElementById("sendForm").action = vPageAddr + "/Search/-/1/" + document.getElementById("searchProd").value.replace(/\W/gi, "-").replace(/[_]/gi, "-");
            }
            document.getElementById("sendForm").submit();
        }
        function EnterSearchProd(event, searchString, searchScope)
        {
            if (event.keyCode == 13)
            {
                checkSearchProd(searchString, searchScope);
                return false;
            }
            return true;
        }

        function checkSearchShop() 
        {
            if(document.getElementById("searchStore").value == "" ||
                document.getElementById("searchStore").value == SEARCHSTORE_EDIT ||
                document.getElementById("searchStore").value.length < 1) {
                return;
            }
            document.getElementById("searchStoreName").value = document.getElementById("searchStore").value;
            document.getElementById("sendFormShop").action = vPageAddr + "/Stores/1/" + document.getElementById("searchStore").value.replace(/\W/gi, "-").replace(/[_]/gi, "-");
            document.getElementById("sendFormShop").submit();
        }
        function EnterSearchShop(event)
        {      
            if (event.keyCode == 13)
            {
                checkSearchShop();
                return false;
            }
            return true;
        }



        function changeType(str) {
            if(str == "PR") {
                document.location.href = vPageAddr+"/Search/";
            }
            if(str == "ST") {
                document.location.href = vPageAddr+"/Stores"+searchCategory;
            }
        }
        function goToPage(i) {
            document.location.href = vPageAddr+"/Stores/"+searchCategory+ i;
        }
        function goToStore(i) {
            if(document.getElementById("f_storAff" + i).value.toLowerCase() == "3" && document.getElementById("f_stor" + i).value.indexOf("_&") > 0) {
                document.getElementById("s_storName").value = document.getElementById("f_stor" + i).value.replace("_&", "_" + document.getElementById("f_stor2Aff" + i).value + "&");
            } else {
                document.getElementById("s_storName").value = document.getElementById("f_stor" + i).value + document.getElementById("f_stor2Aff" + i).value;
            }
            document.getElementById("s_storAff").value = document.getElementById("f_storAff" + i).value;
            document.getElementById("sendForm3").action = vPageAddr+"/GoTo?shop";
            document.getElementById("sendForm3").submit();
        }
        function scale(i) {
            var ow = i.width;
            var oh = i.height;
            if (i.width > 190) {
                i.width = 190;
                i.height = 190 / (ow / oh);
            }
            if (i.height > 75) {
                i.height = 75;
                i.width = 75 / (oh / ow);
            }
            i.style.visibility = "visible";
        }
        function displButtons(i) {
            document.getElementById("fa_st_" + i).style.display = "none";
            document.getElementById("fa_st2_" + i).style.display = "block";
        }
        function hideButtons(i) {
            document.getElementById("fa_st2_" + i).style.display = "none";
            document.getElementById("fa_st_" + i).style.display = "block";
        }
        function ShowDiv() {
            document.getElementById("panelDivPopUp").style.display = "block"; 
        }
        function panelDivClick() {
            document.getElementById("panelDivPopUp").style.display = "none";                
        }

        
