﻿var _currentShownMenu = '';
$(document).ready(function() {


    var options = {
        beforeSubmit: validateForm,
        target: '#form_result'
    }

    $('#contact_form_homepage').submit(function() {
        $(this).ajaxSubmit(options);
        return false;
    });

    var pageurl = window.location.toString();
    var baseUrl = $("#base_page_url").val();

    var thisPageUrl = pageurl.replace(baseUrl, '');

    $("a[href*='" + thisPageUrl + "']").parent("li").addClass("on");
    $("a[href*='" + thisPageUrl + "']").parent("li").parent("ul").parent("li").addClass("on");

    $("div.top_tabs_menu").children("ul").children("li").addClass("off");
    $("div.top_tabs_menu").children("ul").children("li").children("ul").hide();

    $("div.top_tabs_menu").children("ul").children("li").mouseenter(function() {
        $(this).addClass("on");
        $(this).children("ul").slideDown();
    }).mouseleave(function() {
        $(this).removeClass("on");
        $(this).children("ul").slideUp();
    });
    $("div.innerContentText").children("div").hide();
    $("div.innerContentText").children("div:last").show();

    $("ul.rightButtons").children("li").children("a").click(function() {
        var rel = $(this).attr("rel");
        if (_currentShownMenu != rel) {
            //$("div.innerContentText").children("div").animate({ right: '-2000px' }, 1000);
            $("div.innerContentText").children("div").hide();
            _currentShownMenu = rel;
            $("#" + rel).slideDown();
            //$("#" + rel).animate({ right: '0px' }, 1000);
        }
    });
    $("div.sub_menu").children("ul").children("li").addClass("off");
    $("div.sub_menu").children("ul").children("li").mouseenter(function() {
        $(this).addClass("on").removeClass("off");
    }).mouseleave(function() {
        $(this).removeClass("on").addClass("off");
    });
    $("div.client_telling").children("ul").newsTicker();
    $(".send_button").attr("value", "");
    swapValues = [];
    $(".watermark").each(
            function(i) {
                swapValues[i] = $(this).val();
                $(this).focus(function() {
                    if ($(this).val() == swapValues[i]) {
                        $(this).val("")
                    }
                }
                ).blur(function() {
                    if ($.trim($(this).val()) == "") {
                        $(this).val(swapValues[i])
                    }
                }
                )
            }
      )
});

function validateForm(formData, jqForm, options) {

}
