﻿/// <reference path="jquery-1.3.2-vsdoc2.js" />
var Loading = "<img src='Images/Loading.gif' alt='' />";
var PageID = 0;
FlashTitle = { Message1: "", Message2: "", Height: "" }
var PageUrl;
var Lang;
function Load() {
    Lang = $("#Lang").val();

    PageUrl = $("#PageUrl").val();

    $("#Logo").click(function() {
        if (Lang == "tr") {
            Redirect(PageUrl + "Home/");
        }
        if (Lang == "en") {
            Redirect(PageUrl + "EN/Home/");
        }
    });

    $("td").each(function() {
        if ($(this).html() == "") { $(this).html("&nbsp;"); }
    });

    $("#Search").autocomplete(Products, {
        minChars: 0,
        autoFill: true,
        mustMatch: true,
        matchContains: false,
        scrollHeight: 220,
        width: 194,
        formatItem: function(row, i, max, term) {
            return row.name;
        },
        formatResult: function(row) {
            return row.name;
        }
    }).result(function(data, i, n, value) {
        Redirect(i.Url);
    });



    $("#SearchMomentus .Item .Content .ItemC").click(function() {
        if ($(this).hasClass("Select") == false) {
            $(this).addClass("Select");
        }
        else {
            $(this).removeClass("Select");
        }
        ResetControl();
    });

    $(".SearchMomentusContent .Item .Title").click(function() {
                var $this = $(this);
                $this.parent().parent().find(".Item .Content").each(function() {
                $(this).parent().find(".CImage").attr("src", "Images/Arti.gif"); ;
                    if ($(this).parent().attr("id") != $this.parent().attr("id")) $(this).slideUp();
                });
        $(this).parent().find(".Content").slideToggle();
        var imgsrc = $(this).parent().find(".CImage");
        if (imgsrc.attr("src") == "Images/Arti.gif") {
            imgsrc.attr("src", "Images/Eksi.gif");
        }
        else {
            imgsrc.attr("src", "Images/Arti.gif");
        }
    });

    $("#FlipFlop").click(function() {
        $thisParent = $(this).parent().parent();
        if ($thisParent.css("width") == "335px") {
            $thisParent.animate({ width: "660px" }, 500);
            setTimeout(function() {
                $thisParent.find(".SearchMomentusContent").slideDown(500);
                $("#FlipFlop").removeClass("FlipFlop");
            }, 500);
        }
        else {
            $thisParent.find(".SearchMomentusContent").slideUp(500);
            setTimeout(function() {
                $thisParent.animate({ width: "335px" }, 500);
                $("#FlipFlop").addClass("FlipFlop");
            }, 500);

        }
    });

    setInterval(function() {
        var SearchMomentusItemTR = new Array();
        SearchMomentusItemTR[0] = "SENİN MOMENTUSUN <span class='White'>HANGİSİ?</span>";
        SearchMomentusItemTR[1] = "HAYALİNİZDEKİ MOMENTUSU <span class='White'>KOLAYCA BULUN!</span>";
        SearchMomentusItemTR[2] = "MOMENTUSUNU <span class='White'>SEÇ!</span>";

        var SearchMomentusItemEN = new Array();
        SearchMomentusItemEN[0] = "WHICH MOMENTUS <span class='White'>IS YOURS?</span>";
        SearchMomentusItemEN[1] = "CHOOSE WHITCH MOMENTUS IS <span class='White'>THE BEST FOR YOU!</span>";
        SearchMomentusItemEN[2] = "PICK UP YOUR <span class='White'>OWN MOMENTUS!</span>";

        var SearchMomentusItem = Lang == "tr" ? SearchMomentusItemTR : SearchMomentusItemEN;

        var $this = $(".FlipFlop");
        var thisRel = parseInt($this.attr("rel"));
        if (thisRel > 1) { thisRel = 0; }
        else { thisRel++; }
        $this.attr("rel", thisRel).html(SearchMomentusItem[thisRel]);
    }, 1500);


    if ($(".SearchMomentusContent .Item .Content .Select").size() == 0) {
        $("#SearchMomentusReset").hide();
        ResetControl();
    }

    $("#SearchMomentusReset").click(function() {
        $(".SearchMomentusContent .Item .Content .Select").removeClass("Select");
        ResetControl();
    });

    $("#SearchMomentus .Button .inputbutton").hover(function() {
    $(this).css("background-color", "#437007");
    }, function() {
        $(this).css("background-color", "");
    });

    $("#SearchItem").click(function() {
        $thisParent = $(this).parent().parent().parent();
        var Categories = ""; var Gender = ""; var CaseType = ""; var Shape = ""; var Material = ""; var Movement = ""; var Strap = "";
        //$(".SearchMomentusContent #Categories .Content .Select").each(function() { Categories += $(this).attr("name") + ","; });
        $(".SearchMomentusContent #Gender .Content .Select").each(function() { Gender += $(this).attr("name") + ","; });
        $(".SearchMomentusContent #CaseType .Content .Select").each(function() { CaseType += $(this).attr("name") + ","; });
        $(".SearchMomentusContent #Shape .Content .Select").each(function() { Shape += $(this).attr("name") + ","; });
        $(".SearchMomentusContent #Material .Content .Select").each(function() { Material += $(this).attr("name") + ","; });
        $(".SearchMomentusContent #Movement .Content .Select").each(function() { Movement += $(this).attr("name") + ","; });
        $(".SearchMomentusContent #Strap .Content .Select").each(function() { Strap += $(this).attr("name") + ","; });
        var Data = "Gender=" + Gender + "&CaseType=" + CaseType + "&Shape=" + Shape + "&Material=" + Material + "&Movement=" + Movement + "&Strap=" + Strap;
        $.ajax({
            type: "POST",
            data: Data,
            url: "Control/SearchProduct.aspx",
            success: function(reply) {
                //alert(reply);
                $thisParent.animate({ height: "23px" }, 500);
                $thisParent.animate({ width: "335px" }, 500);
                setTimeout(function() {
                    RedirectSearchProduct();
                }, 1000);
            },
            error: function(xhr, ajaxOptions, thrownError) { alert(xhr.status); alert(thrownError); }
        });
    });



    $("#SearchGridWiew").keyup(function() {
        var thisVal = $(this).val();
        $(".InTxt tbody tr").hide();
        if (thisVal != null) {
            var i = $(".InTxt tbody tr:containsIgnoreCase('" + thisVal + "')").show().size();
            if (i > 0) { $(".InTxt tbody #NoneItem").hide(); }
            else { $(".InTxt tbody #NoneItem").show(); }
        }
        else {
            $(".InTxt tbody tr").show();
            $(".InTxt tbody #NoneItem").hide();
        }
    }); //.val("Herhangi bir özelliği yazarak arama yapabilirsiniz");
    $("#SearchGridWiew").focusEmpty();
    $(".InTxt tbody").append("<tr id='NoneItem' class='Hide'><td class='Big' colspan='10'><div class='NoneItemPage'>Sonuç Bulunamadı.</div></td></tr>")



}



function RedirectSearchProduct() {
    var PageUrl = $("#PageUrl").val();
    if (Lang == "tr") {
        Redirect(PageUrl + "SearchProduct/");
    }
    else if (Lang == "en") {
        Redirect(PageUrl + "EN/SearchProduct/");
    }
}


function ResetControl() {
    if ($(".SearchMomentusContent .Item .Content .Select").size() == 0) {
        $("#SearchMomentusReset").hide();
    }
    else {
        $("#SearchMomentusReset").show();
    }
}


function CategoriesLoad() {

    
    $(".CollectionItems .Item").hover(function(){
        //$(this).find(".Txt").css("background-image","url('Images/CategoriesHoverEffect.png')");
        $(this).css("background-color", "#686868")
        $(this).find(".AllItem").css("background-color","#484848");
    },function(){
        //$(this).find(".Txt").css("background-image","none");
        $(this).css("background-color", "")
        $(this).find(".AllItem").css("background-color","");
    }).click(function(){
        Redirect($(this).find("a").attr("href"));
    });
    
    
    
}

function RefreshPrice() {
    reply = "";
}


function SalesPointLoad() {
    $(".SalesPointsContent .Content:eq(" + (parseInt($(".SalesPointsContent .Content").size()) - 1) + ")").css("border", "0")
}

function TecnicalSportsLoad() {
    $(".TecnicalSportsRight .Content:eq(" + (parseInt($(".TecnicalSportsRight .Content").size()) - 1) + ")").css("border", "0")
}

function FaqLoad() {
    $("#FaqRight .Item .Title").click(function() {
        $(this).parent().find(".Content").slideToggle();
    })
}

function GuarantyTermsLoad() {
    $("#GuarantyTermsRight .Item .Title").click(function() {
        $(this).parent().find(".Content").slideToggle();
    })
}

function ContactLoad() {
    $("#ContactForm input[type!=submit]").each(function() { $(this).focusEmpty(); });
    $("#ContactForm textarea").each(function() { $(this).focusEmpty(); }); ;
    $("#ctl00_Main_Subject").change(function() {
        if ($(this).val() != 0) {
            $("#ctl00_Main_Message").attr("disabled", "");
            $("#ctl00_Main_SendMessage").attr("disabled", "").click(function() { return SendContactMessage(); });
        }
        else {
            $("#ctl00_Main_Message").attr("disabled", "disabled");
            $("#ctl00_Main_SendMessage").attr("disabled", "disabled");
        }
    });
}

function RefreshPrice() {
    reply = "";
}

function SendContactMessage() {
    
    var Name = $("#ContactForm input.Name").val();
    var SurName = $("#ContactForm input.SurName").val();
    var Email = $("#ContactForm input.Email").val();
    var Message = $("#ContactForm textarea.Message").val();
    
    if ($("#ContactForm input.Name").val() == $("#ContactForm input.Name").attr("rel")) { Name = ""; }
    if ($("#ContactForm input.SurName").val() == $("#ContactForm input.SurName").attr("rel")) { SurName = ""; }
    if ($("#ContactForm input.Email").val() == $("#ContactForm input.Email").attr("rel")) { Email = ""; }
    if ($("#ContactForm textarea.Message").val() == $("#ContactForm textarea.Message").attr("rel")) { Message = ""; }
    
    if (Name == "") {$("#ContactForm input.Name").css("border", "solid 1px #5D941D");}
    else {$("#ContactForm input.Name").css("border", "solid 1px #F7F7F7"); }

    if (SurName == "") {$("#ContactForm input.SurName").css("border", "solid 1px #5D941D"); }
    else {$("#ContactForm input.SurName").css("border", "solid 1px #F7F7F7"); }
    
    if (Email == "" || EmailControl(Email) == false) {$("#ContactForm input.Email").css("border", "solid 1px #5D941D");}
    else {$("#ContactForm input.Email").css("border", "solid 1px #F7F7F7"); }

    if (Message == "") {$("#ContactForm textarea.Message").css("border", "solid 1px #5D941D");}
    else { $("#ContactForm textarea.Message").css("border", "solid 1px #F7F7F7"); }
    
    if (Name != "" && SurName != "" && Email != "" && EmailControl(Email) != false && Message != "") {return true;}
    else {return false;}

}

function SendRecommendUsMessage() {
    var Name = $("#ContactForm input.Name").val();
    var Email = $("#ContactForm input.Email").val();
    var RName = $("#ContactForm input.RName").val();
    var REmail = $("#ContactForm input.REmail").val();

    var Message = $("#ContactForm textarea.Message").val();
    if ($("#ContactForm input.Name").val() == $("#ContactForm input.Name").attr("rel")) { Name = ""; }
    if ($("#ContactForm input.Email").val() == $("#ContactForm input.Email").attr("rel")) { Email = ""; }
    if ($("#ContactForm input.RName").val() == $("#ContactForm input.RName").attr("rel")) { RName = ""; }
    if ($("#ContactForm input.REmail").val() == $("#ContactForm input.REmail").attr("rel")) { REmail = ""; }
    if ($("#ContactForm textarea.Message").val() == $("#ContactForm textarea.Message").attr("rel")) { Message = ""; }

    if (Name == "") { $("#ContactForm input.Name").css("border", "solid 1px #5D941D"); }
    else { $("#ContactForm input.Name").css("border", "solid 1px #F7F7F7"); }

    if (Email == "" || EmailControl(Email) == false) { $("#ContactForm input.Email").css("border", "solid 1px #5D941D"); }
    else { $("#ContactForm input.Email").css("border", "solid 1px #F7F7F7"); }

    if (RName == "") { $("#ContactForm input.RName").css("border", "solid 1px #5D941D"); }
    else { $("#ContactForm input.RName").css("border", "solid 1px #F7F7F7"); }

    if (REmail == "" || EmailControl(REmail) == false) { $("#ContactForm input.REmail").css("border", "solid 1px #5D941D"); }
    else { $("#ContactForm input.REmail").css("border", "solid 1px #F7F7F7"); }

    if (Message == "") { $("#ContactForm textarea.Message").css("border", "solid 1px #5D941D"); }
    else { $("#ContactForm textarea.Message").css("border", "solid 1px #F7F7F7"); }


    if (Name != "" && EmailControl(Email) != "" && RName != "" && EmailControl(REmail) != false && Message != "") {
        return true;
    }
    else {
        return false;
    }
    
}


function ShopingCartLoad() {

    function UpdateShopCartNumber(thisID, thisVal) {
        $(".InstallmentsPrice,.TransferPrice,.SinglePrice").html(Loading)
        $.ajax({
            type: "POST",
            data: "ID=" + thisID + "&ShoppingOne=" + parseInt(thisVal),
            url: "Control/RefreshShopCart.aspx",
            dataType: "json",
            success: function(reply) {
                $(".InstallmentsPrice").html(reply.InstallmentsPrice);
                $(".TransferPrice").html(reply.TransferPrice);
                $(".SinglePrice").html(reply.SinglePrice);
            }
        });
    }

    $(".ShopCartSizePlus").click(function() {
        var StockSize = parseInt($(this).parent().find(".StockSize").val());
        var thisVal = parseInt($(this).parent().find(".ShopCartSize").val());
        if (StockSize > thisVal) {
            $(this).parent().find("input[type=text]").val(thisVal + 1);
            var thisID = $(this).parent().parent().parent().find("#thisID").val();
            UpdateShopCartNumber(thisID, (thisVal + 1));
        }
        else {
            alert("Stokta " + StockSize + " üründen daha fazla yok");
        }
    })
    $(".ShopCartSizeNegative").click(function() {
        var thisVal = $(this).parent().find(".ShopCartSize").val();
        if (thisVal > 1) {
            $(this).parent().find("input[type=text]").val(parseInt(thisVal) - 1);
            var thisID = $(this).parent().parent().parent().find("#thisID").val();
            UpdateShopCartNumber(thisID, (thisVal - 1));
        }
    });

    $(".ShopCartSize").keyup(function() {
        var thisVal = $(this).val();
        if (thisVal == 0 || thisVal == "NAN" || thisVal == "undefined" || thisVal == "") {
            thisVal = 1;
            $(this).val(1);
        }
        thisVal = parseInt(thisVal);

        var StockSize = parseInt($(this).parent().find(".StockSize").val());
        var thisID = parseInt($(this).parent().parent().parent().find("#thisID").val());

        if (IsNumeric($(this).val()) == false) {
            $(this).val(1);
            UpdateShopCartNumber(thisID, 1);
        }
        else if (thisVal > StockSize) {
            $(this).val(StockSize);
            UpdateShopCartNumber(thisID, StockSize);
        }
        else {
            UpdateShopCartNumber(thisID, thisVal);
        }

    });
    

    
//    $(".ShopCartButtons_HirePurchaseButton").hover(function(){ /tmp
//        $(this).css("background-color","#505050");
//    },function(){
//        $(this).css("background-color","");
//    });
    $(".ShopCartButtons_Refresh").hover(function(){
        $(this).css("background-color","#2b4c00");
    },function(){
        $(this).css("background-color","");
    });
    $(".ShopCartButtons_ContinueShopping").hover(function(){
        $(this).css("background-color","#2b4c00");
    },function(){
        $(this).css("background-color","");
    });
    $(".ShopCartButtons_EndShopping").hover(function(){
        $(this).css("background-color","#508d00");
    },function(){
        $(this).css("background-color","");
    });
    
    $("#ContinueButton").click(function(){
        Redirect(PageUrl + "Categories/");
    });
    $("#RefreshButton").click(function(){
        Refresh();
    });

    $(".ShopCartDeleteButton").click(function() {
        if (confirm("Silmek İstediğinize Emin misiniz?")) {
            var thisID = $(this).parent().parent().parent().find("#thisID").val();
            var $this = $(this)
            $.ajax({
                type: "POST",
                data: "ID=" + thisID,
                url: "Control/ShopCartDeleteButton.aspx",
                dataType: "json",
                success: function(reply) {
                    $this.parent().parent().parent().slideUp(500);
                    setTimeout(function() {
                        $this.parent().parent().parent().remove();
                    }, 500);
                    $(".InstallmentsPrice").html(reply.InstallmentsPrice);
                    $(".TransferPrice").html(reply.TransferPrice);
                    $(".SinglePrice").html(reply.SinglePrice);
                },
                error:function(err){Refresh();}
            });
        }
    });



    $(".ShopCartButtons_HirePurchaseButton").click(function() {
        return false;
        var $this = $(this)
        var thisW = $this.css("width");
        if (thisW == "172px") {
            $this.html("");
            $this.animate({ width: "536px" }, 500);
            $("#HirePurchase").slideDown(500);
            setTimeout(function() {
                $this.html("<span class='Left'>Size en uygun ödeme seçeneğini belirleyin....</span><span class='Right'>TAKSİTLİ ÖDEME SEÇENEKLERİ TABLOSU</span>");
            }, 500);
        }
        else {
            $this.animate({ width: "172px" }, 500).animate({ marginLeft: "-0" }, 500);
            $("#HirePurchase").slideUp(500);
            $this.html("TAKSİTLİ ÖDEME<br />SEÇENEKLERİ TABLOSU");
        }
    });

    
}


function ProductDetailsLoad() {

    $("#ContactForm input[type!=submit]").each(function() { $(this).focusEmpty(); });
    $("#ContactForm textarea").each(function() { $(this).focusEmpty(); }); ;
    $(".AddToCartText").change(function() {
        var StockSize = parseInt($(this).parent().find("#StockSize").val());
        var thisVal = $(this).parent().find(".AddToCartText").val();
        if ( IsNumeric(thisVal) == false || StockSize < parseInt(thisVal) ) {
            $(this).val("0");
        }
    });
    $("#AddToCartTextPlus").click(function(){
        var StockSize = parseInt($(this).parent().find("#StockSize").val());
        var thisVal = parseInt($(this).parent().find(".AddToCartText").val());
        if ( StockSize > thisVal ) {
            $(this).parent().find(".AddToCartText").val(thisVal + 1);
        }
        else {
            alert("Stokta " + thisVal + " üründen daha fazla yok");
        }
    });
    $("#AddToCartTextNegative").click(function(){
        var thisVal = $(this).parent().find(".AddToCartText").val();
        if ( thisVal > 1 ) {
            $(this).parent().find(".AddToCartText").val(parseInt(thisVal) - 1);
        }
    });
    
    $(".AddToCartButton").hover(function(){
        $(this).css("background-color","#284700");
    },function(){
        $(this).css("background-color","");
    });




    $("#ProductInfoProductPic").click(function() {
        $("#FullGrade").show().animate({ opacity: 0.9 }, 300);
        $("#FullGradeClose").fadeIn(500);
        setTimeout(function() {
            $("#ProductPicImageContent").slideDown(500);
        }, 500);
        HeaderTopZIndex();
    });

    $("#PBPB1").click(function() {
//        $("#FullGrade").show().animate({ opacity: 0.9 }, 300);
//        $("#FullGradeClose").fadeIn(500);
//        HeaderTopZIndex();
//        setTimeout(function() {
//            $("#PBPB1_Content").slideDown(500);
//        }, 500);

    });

    $("#PBPB2").click(function() {
        $("#FullGrade").show().animate({ opacity: 0.9 }, 300);
        $("#FullGradeClose").fadeIn(500);
        HeaderTopZIndex();
        setTimeout(function() {
            $("#PBPB2_Content").slideDown(500);
        }, 500);
    });

    $("#PBPB3").click(function() {
        $("#FullGrade").show().animate({ opacity: 0.9 }, 300);
        $("#FullGradeClose").fadeIn(500);
        HeaderTopZIndex();
        setTimeout(function() {
            $("#PBPB3_Content").slideDown(500);
        }, 500);
    });

    $("#FullGrade,#FullGradeClose").click(function() {
        $("#ProductPicImageContent").slideUp(500);
        $("#PBPB1_Content").slideUp(500);
        $("#PBPB2_Content").slideUp(500);
        $("#PBPB3_Content").slideUp(500);
        $("#FullGradeClose").fadeOut();
        setTimeout(function() {
            $("#FullGrade").animate({ opacity: 0 }, 300);
            $("#FullGrade").hide();
            MainTopZIndex();
        }, 500);
    });
    
    $("#ProductInfoProductPic").hover(function(){
        $(this).parent().css("background-image","url('Images/ProductDetailsPreviewHover.jpg')");
    },function(){
        $(this).parent().css("background-image","url('Images/ProductDetailsPreview.jpg')");
    });
        
    $(".ProductPicImageContentImgGalery img").click(function(){
        $("#ProductInfoProductPic").attr("src", "SendBinary.aspx?path=" + $(this).attr("usemap") + "&width=422&height=423")
        $("#ProductPicImageContentImg").attr("src", $(this).attr("usemap"))
    });

    var liW = $("#CategoriesProducts .Item:eq(0)").width();
    var liSize = $("#CategoriesProducts .Item").size();
    var FullSize = parseInt("-" + ( ( liSize * liW) - ( 3 * liW ) ) );
    setInterval(function(){
    var thisIndent = parseInt($("#CategoriesProducts .Items").css("margin-left").replace("px", ""));
        if ( thisIndent > FullSize ) {
            var NowIndent = ( thisIndent - liW ) + "px"
            $("#CategoriesProducts .Items").animate({ marginLeft: NowIndent }, 750);
        }
        else {
            var NowIndent = "0px"
            $("#CategoriesProducts .Items").animate({ marginLeft: NowIndent }, 750);
        }
    },4000);


    $("#AddToCartButton").click(function() {

        var CurrentProductID = $("#ctl00_Main_CurrentProductID").val();
        var AddToCartText = $("#ctl00_Main_AddToCartText").val();

        $.ajax({
            type: "POST",
            data: "CurrentProductID=" + CurrentProductID + "&AddToCartText=" + AddToCartText,
            url: "Control/AddToCart.aspx",
            dataType: "json",
            success: function(reply) {
                if (reply.Return == 'True') {
                    $(".AddToCart").slideUp(500)
                    setTimeout(function() {
                        if (Lang == "tr") {
                            $(".AddToCart").html("Bu ürün sepetinizde mevcut - <a href='./ShoppingCart/'>Sepete Git</a>");
                        }
                        else if (Lang == "en") {
                            $(".AddToCart").html(" This product is already in your cart - <a href='./ShoppingCart/'>View Shopping Cart</a>");
                        }
                        $(".AddToCart").slideDown(500);
                        $("#HeaderBasket").animate({ backgroundColor: "#508D01" }, 500);
                        $("#HeaderBasketMain").fadeOut();
                        setTimeout(function() {
                            if (Lang == "tr") {
                                $("#HeaderBasketMain").html("<a href='./ShoppingCart/'>Sepetinizde " + reply.ShoppingFull + " Adet ürün var</a>");
                            }
                            else if (Lang == "en") {
                                $("#HeaderBasketMain").html("<a href='./ShoppingCart/'>You have " + reply.ShoppingFull + " items in your cart</a>");
                            }
                            $("#HeaderBasketMain").fadeIn();
                        }, 500);

                    }, 500);
                }
                else {
                    alert(reply.Message);
                }
            },
            error: function(xhr, ajaxOptions, thrownError) { alert(xhr.status + " - " + thrownError); }
        });

    });
}

function SelectAddresLoad() {
    $("#ctl00_ctl00_Main_Main_PostCode").mask("99999");
    $("#ctl00_ctl00_Main_Main_Phone").mask("(999) 999-9999");
    $("#ctl00_ctl00_Main_Main_MobilePhone").mask("(999) 999-9999");
    $("#ctl00_ctl00_Main_Main_TCIdentity").mask("99999999999");
}
function MyAddresLoad() {
    $("#ctl00_ctl00_Main_Main_AddPostCode").mask("99999");
    $("#ctl00_ctl00_Main_Main_AddPhone").mask("(999) 999-9999");
    $("#ctl00_ctl00_Main_Main_AddMobilePhone").mask("(999) 999-9999");
    $("#ctl00_ctl00_Main_Main_TCIdentity").mask("99999999999");
}
function PaymentDetailsLoad() {

}

function HeaderTopZIndex() {
    $("#Main").css("zIndex", 98000);
    $("#Header").css("zIndex", 97000);
}
function MainTopZIndex() {
    $("#Main").css("zIndex", 97000);
    $("#Header").css("zIndex", 98000);
}

function ProductsLoad() {
    $(".Products .Item").hover(function(){
        $(this).find(".Preview").show();
    },function(){
        $(this).find(".Preview").hide();
    }).click(function(){
        Redirect($(this).find("a").attr("href"));
    });

    $("#ProductsInfo .ProductsInfoTitle").click(function() {
        var ProductsInfoContent = $(this)
            .parent()
            .find(".ProductsInfoContent");
        if ( ProductsInfoContent.css("display") == "none" ) {
            $(this).removeClass("Select");
        }
        else {
            $(this).addClass("Select");
        }
        ProductsInfoContent
            .slideToggle();



    });
    
}


function EmailControl(elem) {
    var str = elem;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        return false;
    } else {
        return true;
    }
}

function IsNumeric(Text) {
  var ValidChars = "0123456789.,";
   var IsNumber=true;
   var Char;
   for (i = 0; i < Text.length && IsNumber == true; i++) 
      { 
      Char = Text.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}

function Refresh() {
    window.location.reload(false);
}

function Redirect(Url) {
    window.location.href = Url;
}

function TRefresh(time) {
	setTimeout("Refresh()",time);
}

function rand(MaxLen) {
          var now = new Date();
          var num =  now.getMilliseconds() * now.getDay() * 101511541541511854;
          return num ;
      }


function EmailControl(elem) {
    var str = elem;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        return false;
    } else {
        return true;
    }
}


/* zIndexFix */
$(function() {
    var zIndexNumber = 100000;
    var ImgContentIndex = 0
    var SearchMomentusIndex = 0
    $('div').each(function() {
        $(this).css('zIndex', zIndexNumber);
        zIndexNumber -= 10;
    });
    $("#Footer").css("zIndex", 1);
});
/* zIndexFix */


function AddToCart(CurrentProductID) {
    $.ajax({
        type: "POST",
        data: "CurrentProductID=" + CurrentProductID + "&AddToCartText=" + 1,
        url: "Control/AddToCart.aspx",
        dataType: "json",
        success: function(reply) {
            if (reply.Return == 'True') {
                setTimeout(function() {
                    $("#HeaderBasket").animate({ backgroundColor: "#508D01" }, 500);
                    $("#HeaderBasketMain").fadeOut();
                    setTimeout(function() {
                        $("#HeaderBasketMain").html("<a href='./ShoppingCart/'>Sepetinizde " + reply.ShoppingFull + " Adet ürün var</a>");
                        $("#HeaderBasketMain").fadeIn();
                    }, 500);

                }, 500);
            }
            else {
                alert(reply.Message);
            }
        }
    });
}



function PaymentLoad() {
    var PaymentInterval = setInterval(function() {
        $(".CCardNumber").unmask().mask("9999-9999-9999-9999");
        $(".CSecurtyNumber").unmask().mask("999");
        $(".CFullName,.CCardNumber,.CSecurtyNumber").focus(function() { clearInterval(PaymentInterval); });
    }, 200);
    $("#SalesContractCheck").click(function() {
        if ($("#SalesContractCheck").attr("checked") == true) {
            $("#ctl00_ctl00_Main_Button_CompleteOrder").attr("disabled", "");
        }
        else {
            $("#ctl00_ctl00_Main_Button_CompleteOrder").attr("disabled", "disabled");

        }
    });
}


function TNLoad() {
    $("#ctl00_ctl00_Main_Main_SendPrice").keyup(function() {
        var thisVal = $("#ctl00_ctl00_Main_Main_SendPrice").val();
        if (!IsNumeric(thisVal)) {
            $("#ctl00_ctl00_Main_Main_SendPrice").val("");
        }
    });
}

function confirmDelete(Txt) {
    if (Txt == undefined || Txt == "" || Txt == null) Txt = "Silmek İstediğinize eminmisiniz?";
    return confirm(Txt);
}


$.expr[':'].containsIgnoreCase = function(a, i, m) {
    return $(a).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0;
};

function AccountLoad() {
    $(".AccountItems .Item").click(function() {
        Redirect($(this).attr("href"));
    });
}
