// JavaScript Document
$(document).ready(function() {
    tabdropdown.init("mainmenu", 0);
    $(".dropmenudiv").mouseover(function() {

    $("." + preMenu).removeClass("active");
        if ($(this).attr("id") == "dropmenuHome")
            $(".menu_home").addClass("active");
        if ($(this).attr("id") == "dropmenuAbout")
            $(".menu_about").addClass("active");
        if ($(this).attr("id") == "dropmenuService")
            $(".menu_service").addClass("active");
        if ($(this).attr("id") == "dropmenuPortfolio")
            $(".menu_portfolio").addClass("active");
        if ($(this).attr("id") == "dropmenuContact")
            $(".menu_contact").addClass("active");
    });
    $(".dropmenudiv").mouseout(function() {
        if ($(this).attr("id") == "dropmenuHome")
            $(".menu_home").removeClass("active");
        if ($(this).attr("id") == "dropmenuAbout")
            $(".menu_about").removeClass("active");
        if ($(this).attr("id") == "dropmenuService")
            $(".menu_service").removeClass("active");
        if ($(this).attr("id") == "dropmenuPortfolio")
            $(".menu_portfolio").removeClass("active");
        if ($(this).attr("id") == "dropmenuContact")
            $(".menu_contact").removeClass("active");

        $("." + preMenu).addClass("active");

    });

    var preMenu;
    var activeText = "active";
    $('#mainmenu a').each(function(index) {
        if ($(this).hasClass("active")) {
            preMenu = $(this).attr("class");
        }
    });

    try {
        preMenu = jQuery.trim(preMenu.substring(0, preMenu.length - activeText.length));
    }
    catch (err) { }

    $("#mainmenu a").hover(
					function() {
					    $("." + preMenu).removeClass("active");
					    $(this).addClass("active");
					},
					function() {
					    $(this).removeClass("active");
					    $("." + preMenu).addClass("active");
					}
				);
});
