﻿function ShowSearchResults() {
    var sk = $.trim($("#txtSearchKey").val());
    if ((sk == "Find my device (Brand OR Model OR Name OR Keyword)") || (sk == "SEARCH")) {      
        $("#txtSearchKey").css("color", "red");
        setTimeout(function () {
            $("#txtSearchKey").css("color", "#9492A6");
        }, 3000);
        }
        else {
            sk = escape(sk); var spage = "../home/search.aspx?search=" + sk;
            if (document.getElementById("hdnLevel") != null) {
                if (document.getElementById("hdnLevel").value == "root") // this is being called from the vendor home page
                {
                    spage = "../../home/search.aspx?search=" + sk;
                }
            }
            location.href = spage;
        }    
}
$(document).ready(function () {
    $("#txtSearchKey").keydown(function (event) {
        if (event.keyCode == 10 || event.keyCode == 13) {
            ShowSearchResults();
            return false;
        }
    });
    $("#aLogin,#aSignUp,#aFeedback,#login_txt,#create_account,#btnLogin,#aDataEraser").fancybox({
        'scrolling': 'no', 'titleShow': true, 'titlePosition': 'over', 'onClosed': function () {
            $("#login_error").hide();
        }
    });
    $(".seoLink").click(function () {
        seoText = $(this).text(); seoText = seoText.replace("Sell ", ""); seoText = seoText.replace("Recycle ", "");        $("#txtSearchKey").val(seoText);
        var spag = "../home/search.aspx?search=" + seoText;
        if (document.getElementById("hdnLevel") != null) {
            if ($("#hdnLevel").val() == "root") // this is being called from the vendor home page
            {
                spag = "../../home/search.aspx?search=" + seoText;
            }
        }
        location.href = spag;
    });
    $(".seoImgLink").click(function () {
        var sitxt = $(this).attr('title'); sitxt = sitxt.replace("Sell ", ""); var spag1 = "../../home/search.aspx?search=" + sitxt;  window.location.href = spag1;
    });
    $("#bttndataeraser").click(function () {
        file = $("#footer1_ddlItem").val();
        if ((file != "") && (file != null)) {
            loc = "http://www.cellphonedataeraser.com/pdfs/" + file
            window.open(loc, '_blank');
        }
        else {
            alert("Please select a model");
        }
    });
    $('#footer1_ddlManufacturer').change(function () {
        mid = $("#footer1_ddlManufacturer").val();
        strUrl = "../Lib/handlers/Modellookup.aspx?mode=modellistitems&mid=" + mid;
        if ($("#loadingdataeraser").attr("class") == "loading-invisible") {
            $("#loadingdataeraser").removeClass().addClass("loading-visible-dataeraser");
            $("#divSignUpMsg").html("");
            $.ajax({ url: strUrl, success: function (data) {
                $("#loadingdataeraser").removeClass().addClass("loading-invisible");
                $("#footer1_ddlItem").html(data);
            }
            });
        }
    });
});
function Edit() {
    $("#divAddress").fadeOut(400, function () {
        $("#divEdit").fadeIn(400); $("#LinkButton1").fadeOut(300); $("#lnkGoback").fadeIn(300); $("#linkEdit").fadeOut(300);
    });
}
function GoBack() {
    $("#divEdit").fadeOut(400, function () {
        $("#divAddress").fadeIn(400);$("#LinkButton1").fadeIn(300); $("#linkEdit").fadeIn(300); $("#lnkGoback").fadeOut(300);
    });
}
