﻿$(document).ready(function () {

    $("#header .wrap #nav ul li").find("a[href='" + window.location.pathname + "']").each(function () {
        $(this).parent().parent().addClass("selected");
    });
    
    signInFormValidate();

    $("#ShowLogin").click(function () {
        $('#SigninForm').animate({ "width": 300 }, {
            queue: false,
            duration: 500,
            easing: "swing"
        });
    });

    $('#HideLogin').click(function () {
        $('#SigninForm').animate({ "width": 0 }, {
            queue: false,
            duration: 300,
            easing: "swing"
        });
    });

    ShowCountryDropdownList();
    SearchTitleText();

    if ($.browser.msie && $.browser.version <= 8) {
        $('input[type="text"], input[type="password"]').css('padding', '7px 5px 3px 5px');
    }
});


function ShowCountryDropdownList() {
    $("#CountrySelect").click(function () {
        $("#CountrySelector").fadeIn();
    });
}

function SearchTitleText() {

    $('input[title]').each(function () {
        if ($(this).val() === '') { $(this).val($(this).attr('title')); }

        $(this).focus(function () {
            if ($(this).val() === $(this).attr('title')) { $(this).val('').addClass('focused'); }
        });
        $(this).blur(function () {
            if ($(this).val() === '') { $(this).val($(this).attr('title')).removeClass('focused'); }
        });
    });
}

function signInFormValidate() {


    $("#sIF").validate({
        errorPlacement: function (error, element) {
            //element.addClass('error');
        },
        highlight: function (element) {
            $(element).css('border', '1px solid red');
        },
        unhighlight: function (element) {
            $(element).css('border', '1px solid #808080');
        }
    });
}


