$(document).ready(function()
{
	$("#frm_login").submit(function()
	{
		$("#msgbox").text('Validating....').fadeIn(1000);
		$.post(ajax_url+"login.html",{ username:$('#lgnusername').val(),password:$('#lgnpassword').val(),script_url:$('#script_url').val()} ,function(data)
				{					
				  if(data!='false') {				 
					$("#msgbox").fadeTo(200,0.1,function() { 
					  $(this).html('Logging in.....').fadeTo(900,1,
					  function() { 
						document.location=data;
					  });
					});
				  } else {				  
					$("#msgbox").fadeTo(200,0.1,function() {
					  $(this).html('Invalid Login ID or Password').fadeTo(900,1);
					});		
				  }
		});

		return false;
	});
	$("#password_form").submit(function()
		{
			$("#msgboxfp").text('Please wait....').fadeIn(1000);
			$.post(ajax_url+"forgotpassword.html",{ user_email:$('#user_email').val(),script_url:$('#script_url1').val()} ,function(data)
			{
			  if(data!='false') {
				$("#msgboxfp").fadeTo(200,0.1,function() { 
				  $(this).html('Checking details.....').addClass('messageboxok').fadeTo(900,1,
				  function() { 
					$("#msgboxfp").fadeTo(200,0.1,function() {
					  $(this).html(data).addClass('messageboxerror').fadeTo(900,1);
					});
				  });
				});
			  } else {
				$("#msgboxfp").fadeTo(200,0.1,function() {
				  $(this).html('Invalid email').addClass('messageboxerror').fadeTo(900,1);
				});
			  }
			});
			return false;
		});

		$("#forgot_password").submit(function()
		{			
			$("#msgboxfp_myzee").text('Please wait....').fadeIn(1000);
			$.post(ajax_url+"forgotpassword.html",{ user_email:$('#myzee_user_email').val(),script_url:$('#myzee_script_url1').val()} ,function(data)
			{
			  if(data!='false') {
				$("#msgboxfp_myzee").fadeTo(200,0.1,function() { 
				  $(this).html('Checking details.....').addClass('messageboxok').fadeTo(900,1,
				  function() { 
					$("#msgboxfp_myzee").fadeTo(200,0.1,function() {
					  $(this).html(data).addClass('messageboxerror').fadeTo(900,1);
					});
				  });
				});
			  } else {
				$("#msgboxfp_myzee").fadeTo(200,0.1,function() {
				  $(this).html('Invalid email').addClass('messageboxerror').fadeTo(900,1);
				});
			  }
			});
			return false;
		});

		$("#comment_frm_login").submit(function()
		{
			$("#comment_msgbox").text('Validating.....').fadeIn(1000);
			$.post(ajax_url+"login.html",{ username:$('#comment_username').val(),password:$('#comment_password').val(),script_url:$('#script_url').val()} ,function(data)
			{
				 if(data!='false') {				 
					$("#comment_msgbox").fadeTo(200,0.1,function() { 
					  $(this).html('Logging in.....').fadeTo(900,1,
					  function() { 
						document.location=data;
					  });
					});
				  } else {				  
					$("#comment_msgbox").fadeTo(200,0.1,function() {
					  $(this).html('Invalid Login ID or Password').fadeTo(900,1);
					});		
				  }
			});
			return false;
		});
	
		$("a.imgurl").click(function () { 
			url = $(this).attr('href');
			top.location=url;
			return false;
		 });

		 $("#contestants a").click(function () { 
			id = $(this).text();
			$.post(ajax_url+"contestant-pic.html",{ name:$(this).text()} ,function(data)
			{
				 if(data!='false') {				 
					$('span').removeClass('titbox selected');
					$('span').addClass('titbox');
					$('#'+id).addClass('titbox selected');
					$("#contestant-pic").fadeTo(200,0.1,function() { 
					  $(this).html(data).fadeTo(900,1);
					  show_next();
					});
				  }
			});
			return false;
		 });



	});

function show_next(){
	jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel();
});
}
function toggle_login() {
	if($('#login-form').css('display')=='none')
   {
   		//clear previously entered data
		document.getElementById('msgbox').innerHTML = '';
		document.getElementById('lgnusername').value = '';
		document.getElementById('lgnpassword').value = '';

		//$('#forgot-passward').css('display','none');   		
		//$('#msgboxfp').css('display','none');
		$('#login-form').fadeIn(function(){$('#lgnusername').focus();});
   }else{
	   document.getElementById('lgnusername').value = '';
	   document.getElementById('lgnpassword').value = '';
	   
        $('#login-form').fadeOut();
   }
   return false;
}