jQuery(document).ready(function()
    {
        setMenuHandlers();

        jQuery("#logo").click(function(){
            window.location = '/index.php';
        });

        jQuery("#LoginBtn").mouseover(function(){
            jQuery("#LoginBtn").attr("src","http://cdn.wibiya.com/Graphics_Website/login_btn_small_over.png")
        }).mouseout(function(){
            jQuery("#LoginBtn").attr("src","http://cdn.wibiya.com/Graphics_Website/login_btn_small_normal.png")
        });

    });

window.onload = function() {
    //var pagename = window.location.pathname.replace(/\//g,"");
    //if(pagename != "ToolbarSettings.php"){
      //  SetMainBodyHeight();
    //}
}

function SetMainBodyHeight()
{
    var agent= navigator.userAgent.toLowerCase();
    var ie = agent.indexOf("msie")>=0;
    var ie7=ie && agent.indexOf("msie 7")>=0;
    if (ie7){
        var body_height = getMainBodyHeight();
        jQuery("#main_body").css("height",body_height);
    }
} 

function setMenuHandlers()
{
    //main menu
    // Home Button
    //jQuery(".menu-item-selected").unbind("click");

    jQuery("#logo").click(function(){
    	window.location = '/index.php';
    });

    jQuery("#menu-homepage").filter(".menu-item-normal").click(function(){
        window.location = '/index.php';
    });


    jQuery("#menu-edit").filter(".menu-item-normal").click(function(){
        window.location = '/EditApps.php';
    });


    jQuery("#menu-support").filter(".menu-item-normal").click(function(){
        window.location = 'http://community.wibiya.com/wibiya';
    });


    jQuery("#menu-getitnow").filter(".menu-item-normal").click(function(){
        window.location = '/BasicRegistration.php';
    });

    jQuery("#menu-dashboard").filter(".menu-item-normal").click(function(){
        window.location = '/Dashboard.php';
    });

    jQuery("#menu-apps").filter(".menu-item-normal").click(function(){
        window.location = '/Applications.php';
    });

    jQuery("#menu-myaccount").filter(".menu-item-normal").click(function(){
        window.location = '/AccountSettings.php'
    })
    
    jQuery(".menu-item-normal").mouseover(function(){
        jQuery(this).removeClass().addClass("menu-item-over");
    }).mouseout(function(){
        jQuery(this).removeClass().addClass("menu-item-normal");
    });


    //top menu
    jQuery("#login_btn").click(function(){

        // check selected attribute and open answer if not selected
        if (jQuery(this).attr("opened")=="false")
        {
            jQuery(this).attr("opened","true");
            jQuery("#login_form").slideDown("fast",function(){
                jQuery("#UserEmailLogin").focus();
            });
        }
        else
        {
            jQuery(this).attr("opened","false");
            jQuery("#login_form").slideUp();
        }
    });



    jQuery(".clickitem").mouseover(function(){
        jQuery(this).removeClass().addClass("clickitemover");
    }).mouseout(function(){
        jQuery(this).removeClass().addClass("clickitem");
    });



}


function getMainBodyHeight()
{
    var height = 0;
    if (typeof window.innerWidth != "undefined")
    {
        height = window.innerHeight;
    }
    else if (typeof document.documentElement != "undefined"
        && typeof document.documentElement.clientWidth !=
        "undefined" && document.documentElement.clientWidth !== 0)
        {
        height = document.documentElement.clientHeight;
    }
    else
    {
        height = document.getElementsByTagName("body")[0].clientHeight;
    }
    //header 118, footer 50 , padding 30
    var abs_height = height-188;
    var measured_height = document.getElementById('main_body').clientHeight;
    var h =  Math.max(abs_height,measured_height);
    return h;
}