$(document).ready(function() {
	
	$("#start_emb").hide();
	$("#start_reg").hide();
	$("#start_forgot").hide();
	
	$("#create").click(function() {
		
		$("#start_emb").slideToggle("slow");

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();

		//Set heigth and width to hide to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight,backgroundColor:"black"});

		//transition effect
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);

	});
	
	$("#IDMyLinks").click(function() {
		
		$("#start_emb").slideToggle("slow");

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();

		//Set heigth and width to hide to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight,backgroundColor:"black"});

		//transition effect
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);

	});

	$("#loginlink").click(function() {
		
		$("#start_forgot").hide();
		$("#start_emb").slideToggle("slow");

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();

		//Set heigth and width to hide to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight,backgroundColor:"black"});

		//transition effect
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);

	});
	
	$("#reglink").click(function() {
	
		$("#start_reg").slideToggle("slow");

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();

		//Set heigth and width to hide to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight,backgroundColor:"black"});

		//transition effect
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);

	});
	
	$("#forgotlink").click(function() {
		
		$("#start_emb").hide();
		$("#start_forgot").slideToggle("slow");

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();

		//Set heigth and width to hide to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight,backgroundColor:"black"});

		//transition effect
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);

	});
	
	//if close button is clicked
	$("#cls").click(function(){
		$('#mask').hide();
		$("#start_emb").hide();
		$("#start_reg").hide();		
	}); 

	//if close button is clicked
	$("#closeit").click(function(){
		$('#mask').hide();
		$("#start_reg").hide();		
	}); 	
	
	//if close button is clicked
	$("#forgotit").click(function(){
		$('#mask').hide();
		$("#start_forgot").hide();		
	});    
});	

// signup form validation
$(document).ready(function() { $("#frmsignin").validate(); });


// forgot password form validate
$(document).ready(function() { $("#frmforgot").validate(); });

// links submit for validation
$(document).ready(function() { $("#submitlink").validate(); });

// register validation check
$(document).ready(function() {
	var validator = $("#frmregister").validate({
		rules: {
			yemailid: { required: true, minlength: 5, usernameCheck:true },
			password: { password:"#user_name_id" },
			cpassword: { required: true, equalTo: "#password" }
		},
		messages: {
			yemailid: {
				required: "Enter a username",
				minlength: jQuery.format("Enter at least {0} characters"),
				usernameCheck:" This username is already in use."
			},
			cpassword: {
				required: "Repeat your password",
				minlength: jQuery.format("Enter at least {0} characters"),
				equalTo: "Enter the same password as above"
			}
		}
	});
});

// extend the validation plugin to do remote username and email dupe checking
jQuery.validator.addMethod('usernameCheck', function(username) {
    var postURL = "validateuser.php";
    $.ajax({
        cache:false,
        async:false,
        type: "POST",
        data: "username=" + username,
        url: postURL,
        success: function(msg) {
        	var username = document.frmregister.yemailid.value;

		var userval = ( msg == 'TRUE' ) ? username : "";
		document.frmregister.user_name_id.value = userval;

		result = ( msg == 'TRUE' ) ? true : false;
        }
    });
    return result;
}, '');



$(document).ready(function() { 
	$(".links_logos").hover( 
		function() { $(this).children('.link_actions').show(); }, 
		function() { $(this).children('.link_actions').hide(); } 
	); 
  
});
