﻿$(document).ready(function() {

    InitMainImageAnimation();

});

// JScript File
function AutoSubmit() {
    var f = document.forms[0];
    if (f) {
        var w = document.getElementById("wait");
        if (w) w.style.display = "block";

        var m = document.getElementById("msg");
        if (m) m.style.display = "none";

        f.submit();
    }
}
function onkeydownsearch(txb,e,page)
{
  if (e) {
    if (e.keyCode == 13) {
        var url = root + "search.aspx?word=" + txb.value;
        if (page != "") {
            url += "&search=" + page;
        }
        document.location = url;
        return false;
    }
  }
}

//main images animation
function InitMainImageAnimation()
{
    var item = $(".mainimg");

    item.each(function() {

        //store original width and height
        $(this).attr("W", $(this).width());
        $(this).attr("H", $(this).height());

        $(this).attr("posY", $(this).position().top);
        $(this).attr("posX", $(this).position().left);

        $(this).children("img").css("height", "auto");

        $(this).attr("active", "no");

    });

    item.mouseover(function() {
        StopAnimation($(this));
        var w = parseInt($(this).attr("W")) + 20;
        var t = parseInt($(this).attr("posY")) - 10;
        var l = parseInt($(this).attr("posX")) - 10;

        $(this).attr("active", "yes");

        $(this).children("img").animate({ width: w }, 100, null);
        $(this).animate({ left: l, top: t }, 100, null);
        //$(".mainimg[active='no']").animate({ opacity: 0.5 }, 200, null);

    }).mouseout(function() {
        StopAnimation($(this));
        var w = parseInt($(this).attr("W"));
        var t = parseInt($(this).attr("posY"));
        var l = parseInt($(this).attr("posX"));

        $(this).attr("active", "no");
        
        $(this).children("img").animate({ width: w }, 100, null);
        $(this).animate({ left: l, top: t }, 100, null);
        //$(".mainimg[active='no']").animate({ opacity: 1 }, 200, null);

    });
}

function StopAnimation(item) {
    //stop animation if any
    item.stop();
    item.children().stop();
}
//fontsize
        var schem = {

            version: '1.0',

            Init: function() {
                var style = $Cookie("schem");

                this.Activate(style);

            },

            Activate: function(title) {
                for (var i = 0; (a = document.getElementsByTagName("link")[i]); i++) {

                    if (a.getAttribute("rel").indexOf("alt") > -1 && a.getAttribute("title")) {

                        a.disabled = true;

                        if (a.getAttribute("title") == title) {

                            a.disabled = false;

                            $Cookie("schem", title, 365);

                        }

                    }

                }

                if (title == "none") $Cookie("schem", "none", 365);

            }

        };

        //set or get cookie

        function $Cookie(n, v, d) {
            if (n && v) {//set cookie

                var expires;

                if (d) {

                    var date = new Date();

                    date.setTime(date.getTime() + (d * 24 * 60 * 60 * 1000));

                    expires = "; expires=" + date.toGMTString();

                }

                else expires = "";

                document.cookie = n + "=" + v + expires + "; path=/";

            }

            else if (n) {//get cookie

                n = n + "=";

                var ca = document.cookie.split(';');

                for (var i = 0; i < ca.length; i++) {

                    var c = ca[i];

                    while (c.charAt(0) == ' ') c = c.substring(1, c.length);

                    if (c.indexOf(n) == 0)

                        return c.substring(n.length, c.length);

                }

            }

            return null;

        }

        function OnSubmit(obj, validationgroup) {

            if ((typeof (Page_ClientValidate) != "function" || Page_ClientValidate(validationgroup)) && !$(obj).hasClass("disable")) {
                $(obj).siblings(".loader").show();
                $(obj).hide();
                return true;
            }
            return false;
        }
        function ReplaceImage(obj) {
            if (obj)
                obj.style.display = "none";
        }
        function ToCache() {
            document.location = "virtualstorecart.aspx";
        }
        function ToHistory() {
            document.location = "virtualstorehistory.aspx";
        }

