﻿//  Developed by Roshan Bhattarai 
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use

var SelectedOffset = 0;
var SelectedWidth = 0;

$(document).ready(function () {

    doSlideOpen($('.mnu-selected'));

    var clientW = document.body.clientWidth;
    var ybgLocation = clientW > 800 ? clientW / 2 - SelectedOffset.left : clientW / 2 - SelectedOffset.left;
   
    $(".ybg ").css('left', ybgLocation);

    //for the third menu, it uses easing plugin
    $('#nav2 li a').hover(function () {
        $('#nav2 li.ybg').animate({ height: "4px" }, 150);

        var offset = $(this).offset();
        var thiswidth = $(this).width() + 10;

        $('#nav2 li.ybg').stop().animate({ left: offset.left + 9 + "px", width: thiswidth + "px" }, 400, function () {
            $(this).animate({ height: "30px" }, 150);
        });
    },
    function () {
        $('#nav2 li.ybg').animate({ height: "4px" }, 150);
        doSlideOpen($('.mnu-selected'));
    });

});

function doSlideOpen(obj) {
    SelectedOffset = $(obj).offset();
    SelectedWidth = $(obj).width();
    //alert(SelectedWidth);

    $('#nav2 li.ybg').stop().animate({ left: SelectedOffset.left + "px", width: SelectedWidth + "px" }, 400, function () {
        $(this).animate({ height: "30px" }, 150);
    });
}

