$("document").ready(function(){    
    if($("#txtpassword").val()!="") {
        $('#fake_password').hide();
        $('#txtpassword').show();
    }
    $("#txtusername").focus(function() {
        if($("#txtusername").val()=="Username") {
            $("#txtusername").val('');
        }
    });
    $("#txtusername").blur(function() {
        if($("#txtusername").val()=="") {
            $("#txtusername").val('Username');
        }
    });
    $("#fake_password").focus(function() {
        $('#fake_password').hide();
        $('#txtpassword').show();
        $('#txtpassword').focus();
    });
    $("#txtpassword").blur(function() {
        if($("#txtpassword").val()=="") {
            $('#txtpassword').hide();
            $('#fake_password').show();
        }
    });
    $("#login_frm").unbind("submit").bind("submit", function(){
        $.post(baseUrl+'/login/ajax',{
            username:$("#txtusername").val(),
            password:$("#txtpassword").val()
        },function(data){
            if(data==1){
                location.href=baseUrl+"/member";
            }
            else
            {
                $("#invalid_credential").css('display','');
            }
        });
        return false;
    });

    $("#loginBox_link").fancybox({
        onStart: function(){
            /*$("#txtusername").val("Username");
            $("#invalid_credential").css("display","none");
            $("#txtpassword").val("");
            $('#txtpassword').hide();
            $('#fake_password').show();*/
        },
        'width'		: 430,
        'height'	: 290,
        'autoScale'	: false,
        'transitionIn'	: 'none',
        'transitionOut'	: 'none',
        'type'		: 'iframe',
        'padding'       :0
    });
    $(".loginBox_link").fancybox({
        onStart: function(){
        },
        'width'		: 430,
        'height'	: 315,
        'autoScale'	: false,
        'transitionIn'	: 'none',
        'transitionOut'	: 'none',
        'type'		: 'iframe',
        'padding'       :0
    });
    $("#loginBox_link_Thanks").fancybox({
        'titlePosition'		: 'inside',
        'transitionIn'		: 'none',
        'transitionOut'		: 'none',
        'opacity'		: true,
        'padding'		: 0,
        'hideOnOverlayClick'    :false,
        'titleShow'             :false
    });
    $("#forgotBox_link").fancybox({
        onStart: function(){
            $("#txtemail").val("Email Address");
            $("#invalid_email").html("");
            $("#email_sent").hide();
        },
        'titlePosition'		: 'inside',
        'transitionIn'		: 'none',
        'transitionOut'		: 'none',
        'opacity'		: true,
        'padding'		: 0,
        'hideOnOverlayClick'    :false,
        'titleShow'             :false,
        'onComplete'            : function(){
         $("#txtemail").focus();
        }
    });

    $("#txtemail").bind("blur", function(){
        if($.trim($("#txtemail").val())==""){
            $("#txtemail").val("Email Address");
        }
    });
    $("#txtemail").bind("focus", function(){
        if($.trim($("#txtemail").val())=="Email Address"){
            $("#txtemail").val("");
        }
    });
    $("#txtemail").bind("click", function(){
        if($.trim($("#txtemail").val())=="Email Address"){
            $("#txtemail").val("");
        }
    });
    $("#forgot_frm").submit(function(){
        $("#email_sent").hide();
        $("#invalid_email").html("");
        $.post($(this).attr("action") + "",{
            email:$("#txtemail").val()
        },function(data){
            if(data=="success"){
                $("#email_sent").show();
            // $.fancybox.close();
            }
            else
            {
                $("#invalid_email").css('display','');
                $("#invalid_email").html(data);
            }
        });
        return false;
    });

    $("#quickstart").fancybox({
        'width'		: 560,
        'height'	: 315,
        'autoScale'	: false,
        'transitionIn'	: 'none',
        'transitionOut'	: 'none',
        'type'		: 'iframe',
        
        'onStart'       : function(){
            $("#fancybox-close").css("top","");
            $("#fancybox-close").css("right","");
        },
        'onClosed'      : function(){
            $("#fancybox-close").css("top","99px");
            $("#fancybox-close").css("right","202px");
        }
    });
     $(".quicktour").attr("href", "http://www.youtube.com/embed/kN6uLuicqoM")


    $(".quicktour").fancybox({
        'width'		: 560,
        'height'	: 315,
        'autoScale'	: false,
        'transitionIn'	: 'none',
        'transitionOut'	: 'none',
        'type'		: 'iframe',
        
        'onStart'       : function(){
            $("#fancybox-close").css("top","");
            $("#fancybox-close").css("right","");
        },
        'onClosed'      : function(){
            $("#fancybox-close").css("top","99px");
            $("#fancybox-close").css("right","202px");
        } 
    });
});
