var cnt = 0;
var cnt_max;



var local = {};



$(function(){
    $("input.placeholder").watermark({
        observer: 'watermark_login'
    });
});




$(document).ready(function(){

    search_text = $("#search").val();
    $("#login_link").click(function(){
        $("#login_box").show();
    }, function(){
        $("#login_box").hide();
    });
    
    
    $("#weather_city").click(function(){
        $("#weather_select").show();
		return false;
    })


	
    $("#weather_select").hover(function(){
    }, function(){
        $("#weather_select").hide();
    }).click(function(){
        $("#weather_select").hide();
    })
    
    $(".errorSummary").prepend($('<a href="#" class="close"></a>').click(function(){
        $(this).parent().hide();
        return false;
    }));
});


function moveMenu(){
    if (parseInt($("#menu_in").css('left')) == 0) {
        $("#menu_in").stop().animate({
            left: -1 * parseInt($("#menu_in").css('width')) + 965
        }, 500, null);
        $("#menu_outer").addClass('moved');
    }
    else {
        $("#menu_in").stop().animate({
            left: 0
        }, 500, null);
        $("#menu_outer").removeClass('moved');
    }
}

function InputTextInfo(inputClass, active_class){
    $("." + inputClass).each(function(){
        local[$(this).attr("name")] = $(this).val();
        $(this).focus(function(){
            if ($(this).val() == local[$(this).attr("name")]) {
                $(this).val("");
                $(this).addClass(active_class);
            }
        });
        $(this).blur(function(){
            if ($(this).val() == "") {
                $(this).val(local[$(this).attr("name")]);
                $(this).removeClass(active_class);
            }
        });
    })
}


function isEmail(str){
    var result1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
    var result2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,8}|[0-9]{1,3})(\\]?)$");
    return (!result1.test(str) & result2.test(str));
}

function movePageTo(e, pos, duration){
    if (e) {
        scroll_val = $(e).offset().top + (pos != 'top' ? $(e).height() - $("body").height() + 1 : 0);
        scrolltop = $("body").scrollTop() || $("html").scrollTop();
        if (scrolltop < scroll_val) 
            $("html:not(:animated),body:not(:animated)").animate({
                scrollTop: scroll_val
            }, (duration ? duration : 500));
    }
    else {
        $("html:not(:animated),body:not(:animated)").animate({
            scrollTop: pos + 'px'
        }, (duration ? duration : 500));
    }
}

function showLogin(){
    $('#registration_box').hide();
    $('#login_box').slideDown();
}

function showRegistration(){
    $('#login_box').hide();
    $('#registration_box').slideDown();
}
