var is_Action = "false";
$(document).ready(function() {
    //  trading menu scripts start
    var tab_padding = 20


    function make_menu_tab(tname) {
        var new_title = $("#" + tname + "_mid_div").html().replace(/[\s\n\r]+/g, " ");
        var spliter = $(new_title.split(" "));
        new_title = "";
        var before_all = "true"
        for (i = 0; i < spliter.length; i++) {
            if (before_all == "true" && spliter[i] != ' ') {
                new_title = spliter[i];
                before_all = "false";
            }
            else if (before_all == "false" && spliter[i] != " ") {
                new_title += "&nbsp;" + spliter[i];
            }
        }
        $("#" + tname + "_mid_div").html(new_title);
        var width = $("#" + tname + "_mid_div").width();
        width = width + (tab_padding * 1);
        $("#" + tname).css('width', width);
        $("#" + tname + "_tab").css('width', width);
        if (page_name == tname) {
            $("#" + tname + "_tab").css('background-image', 'url(../images/selected_mid.jpg)');
            $("#" + tname + "_left_div").css('background-image', 'url(../images/selected_left.jpg)');
            $("#" + tname + "_mid_div").css('color', 'white');
            $("#" + tname + "_right_div").css('background-image', 'url(../images/selected_right.jpg)');
            $("#" + tname + "_tab").css('color', 'white');
        }
        $("#" + tname).mouseover(function() {


            //alert("ok");
            //$(this).stop().animate({ height: "275px" }, { queue: false, duration: 1000, easing: 'linear' });
            //$("#strategies_subs").animate({ height: "275px" }, { queue: false, duration: 1000, easing: 'linear' });
            //alert("ok");
            $("#" + tname + "_subs").stop().animate({ height: "275px" }, { queue: false, duration: 1000, easing: 'linear' });
            if ($("#" + tname + "_subs").height() == "1") {
                $("#" + tname + "_tab").css('background-image', 'url(../images/selected_mid.jpg)');
                $("#" + tname + "_left_div").css('background-image', 'url(../images/selected_left.jpg)');
                $("#" + tname + "_mid_div").css('color', 'white');
                $("#" + tname + "_right_div").css('background-image', 'url(../images/selected_right.jpg)');
                $("#" + tname + "_tab").css('color', 'white');
            }
        });
        //When mouse is removed
        $("#" + tname).mouseout(function() {
            $("#" + tname + "_subs").stop().animate({ height: '1px' }, 100, function() {
                if ($("#" + tname + "_subs").height() == "1" || page_name != "partners") {
                    $("#" + tname + "_subs").hide()
                    if (page_name != tname) {
                        $("#" + tname + "_tab").css('background-image', 'url()');
                        $("#" + tname + "_left_div").css('background-image', 'url()');
                        $("#" + tname + "_mid_div").css('color', '#747474');
                        $("#" + tname + "_right_div").css('background-image', 'url()');
                        $("#" + tname + "_tab").css('color', '#747474');
                    }
                }
                //alert($(this).height());
            });
        });
    }
    //Fix Errors - http://www.learningjquery.com/2009/01/quick-tip-prevent-animation-queue-buildup/

    make_menu_tab('trading');
    make_menu_tab('Solution');
    make_menu_tab('news');
    make_menu_tab('Education');
    make_menu_tab('about');

    //  trading menu scripts end











    //  languages menu scripts
    if (page_name == "lang") {

    }

    $("#lang").click(function() {


        //alert("ok");
        $(this).stop().animate({ height: "275px" }, { queue: false, duration: 1000, easing: 'linear' });

    });

    $("#lang").mouseover(function() {

        if ($(this).height() > "25") {
            //alert("ok");
            $(this).stop().animate({ height: "275px" }, { queue: false, duration: 1000, easing: 'linear' });

            // $(this).css('background-image', 'url(../images/selected_mid.jpg)');
            //$("#about_left_div").css('background-image', 'url(../images/selected_left.jpg)');
            //$("#about_mid_div").css('color', 'white');
            //$("#about_right_div").css('background-image', 'url(../images/selected_right.jpg)');
            //$(this).css('color', 'white');



        }
    });

    //When mouse is removed
    $("#lang").mouseout(function() {

        if ($(this).height() > "25") {
            $(this).stop().animate({ height: '25px' }, 600, function() {

                //$(this).css('background-image', 'url()');
                //$("#about_left_div").css('background-image', 'url()');
                //$("#about_mid_div").css('color', '#747474');
                //$("#about_right_div").css('background-image', 'url()');
                //$(this).css('color', '#747474');

                //alert($(this).height());
            });
        }





    });
    //  drop platform

    $("#drop_platform").mouseover(function() {


        //alert("ok");
        $(this).stop().animate({ height: "1000px" }, { queue: false, duration: 1000, easing: 'linear' });

    });

    $("#drop_platform").mouseover(function() {

        if ($(this).height() > "25") {
            //alert("ok");
            $(this).stop().animate({ height: "1000px" }, { queue: false, duration: 1000, easing: 'linear' });

            // $(this).css('background-image', 'url(../images/selected_mid.jpg)');
            //$("#about_left_div").css('background-image', 'url(../images/selected_left.jpg)');
            //$("#about_mid_div").css('color', 'white');
            //$("#about_right_div").css('background-image', 'url(../images/selected_right.jpg)');
            //$(this).css('color', 'white');



        }
    });

    //When mouse is removed
    $("#drop_platform").mouseout(function() {

        if ($(this).height() > "25") {
            $(this).stop().animate({ height: '25px' }, 600, function() {

                //$(this).css('background-image', 'url()');
                //$("#about_left_div").css('background-image', 'url()');
                //$("#about_mid_div").css('color', '#747474');
                //$("#about_right_div").css('background-image', 'url()');
                //$(this).css('color', '#747474');

                //alert($(this).height());
            });
        }





    });


    $("#drop_update").mouseover(function() {


        //alert("ok");
        $(this).stop().animate({ height: "275px" }, { queue: false, duration: 1000, easing: 'linear' });
        if ($(this).height() == "25") {
            // $(this).css('background-image', 'url(../images/selected_mid.jpg)');
            //$("#about_left_div").css('background-image', 'url(../images/selected_left.jpg)');
            //$("#about_mid_div").css('color', 'white');
            //$("#about_right_div").css('background-image', 'url(../images/selected_right.jpg)');
            //$(this).css('color', 'white');



        }
    });



    //When mouse is removed
    $("#drop_update").mouseout(function() {


        $(this).stop().animate({ height: '25px' }, 600, function() {
            if ($(this).height() == "25" && page_name != "lang") {
                //$(this).css('background-image', 'url()');
                //$("#about_left_div").css('background-image', 'url()');
                //$("#about_mid_div").css('color', '#747474');
                //$("#about_right_div").css('background-image', 'url()');
                //$(this).css('color', '#747474');
            }
            //alert($(this).height());
        });






    });


    //  end of the jquery before ready end.

});
