﻿/**
*
*  /assets/js/main.js
*
*/

/* window ready */

$(document).ready(function () {

    $('ul.sf-menu').superfish({
        pathClass: "current",
        animation: { opacity: 'show', height: 'show' },   // an object equivalent to first parameter of jQuery’s .animate() method 
        speed: "fast",           // speed of the animation. Equivalent to second parameter of jQuery’s .animate() method 
        autoArrows: false,            // if true, arrow mark-up generated automatically = cleaner source code at expense of initialisation performance 
        dropShadows: false,           // completely disable drop shadows by setting this to false 
        disableHI: false,
        delay: 0,
        
        onBeforeShow: function () {
            //var sub = $("li", $(this) );
            //sub.css("width", (wparent >= w_subitm ? wparent - 3: w_subitm ) + "px" )
        },
        
        onShow: function () {

            var sub = $("li", $(this) );
            var w1 = sub.width()//css("width");
            var w0 = $( $(this).parent("li") ).width()

            var wparent = w0//.substring(0, w0.length - 2);
            var w_subitm = w1//.substring(0, w1.length - 2);

            if (w1 <= w0)
            {
                sub.animate({ "width":  ( w1+3 ) + "px" }, "slow");
            }
            else
            {
                sub
                   .css("width",(190)+"px")
                   .animate({ "width":  Math.round( w0* 1.7) + "px" }, "slow");   
            }

        }

    });

    $("#nav-menu a").each(function (i, item) {

        if (item.getAttribute("data-enable") == "0") {
            $(item)
               .css({ "cursor": "default" })
               .bind("click", function (e) {
                   e.preventDefault();
                   return false;
               });
        }
        else {
            $(item)
                .css({ "cursor": "pointer" });
        }

    });
});



/* window load */

$(window).load(function () {

    var t = 100;
    //footer social
    if ($.browser.msie) {
        t = 0;
    }

    $('a.fadeImgLink').find('span.fade').hover(function () {
        $(this).stop(true, false).hide(t);
    }, function () {
        $(this).stop(true, false).show(t);
    });

    $("span.continue").hover(function () {
        $(this).stop(true, false).fadeTo(500, .5);
    }, function () {
        $(this).stop(true, false).fadeTo(500, 1);
    });

    $("#footer")
            .find("span")
            .each(function (i, elem) {
                $(elem).bind("mouseenter", function () {
                    $(this).stop(true, false).fadeTo(500, .5);
                });

                $(elem).bind("mouseleave", function () {
                    $(this).stop(true, false).fadeTo(500, 1);
                });
            });

    $("#footer")
            .find("li")
            .each(function (i, elem) {
                $(elem).bind("mouseenter", function () {
                    $(this).stop(true, false).fadeTo(500, .5);
                });

                $(elem).bind("mouseleave", function () {
                    $(this).stop(true, false).fadeTo(500, 1);
                });
            });
});
