$(function() {
  
  $("#carticon").click(function() {
								
								
  $("#carts").dialog({

			modal: true,

			overlay: {

				backgroundColor: '#000',

				opacity: 0.5

			}});
			
			$('#carts').dialog('open');
  
  
   });
   
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $(".loginBtn").click(function() {
								
				/*setCookie('osCsid', '', -1, '/', '216.21.47.139');*/
				
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	/*  var name = $("input#name").val();
		if (name == "") {
      $("label#name_error").show();
      $("input#name").focus();
      return false;
    }*/
		var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
	//var on = $("input#on").val();
    if ($('#on').attr('checked')) {
     // do something
     var on = $("input#on").val();
}else
{
var on =0;
}
		var phone = $("input#phone").val();
		if (phone == "") {
      $("label#phone_error").show();
      $("input#phone").focus();
      return false;
    }
		
		var dataString = 'email_address=' + email + '&password=' + phone+ '&action=' + 'process'+ '&on=' + on;
		//alert (dataString);return false;
		
		if (dataString!=''){
		$(document).ajaxStart(function(){ 
 $('#contact_form2').html("<div id='message'></div>");
 
  $('#lid').hide();
/* $('#message').html("<img src='images/ajax-loader.gif' />")*/

 });	
		}
		
		$.ajax({
      type: "POST",
      url: "alogin.php",
      data: dataString,
      success: function(data) {
        var resp = data
		//alert(data);
		  var resp = data;
		   if(resp==2){
		   window.location.replace("guest_accounts.php");
		   }
   if(resp==1){
       var m= "";
	//	alert(resp+"1");
	
	
	$('#testme2').attr('title', 'User login');
	
	
	window.location.replace("account.php");

	
			/*$("#testme2").dialog({
			modal: true,
			overlay: {
				backgroundColor: '#000',
				opacity: 0.5
			}});			
			$('#testme2').dialog('open');*/

	
	$('#lid').hide();
	 var m= "";
	m='<div class="reqLogin"><div style=" float:right"><a href="logoff.php"><img src="images/logoff_btn.jpg" alt="logoff"/></a></div><div style="margin:5px 10px 0px 30px; float:right"><em>Welcome,</em></div></div>';
	  $('#mya').html("My Account")
		}
		if(resp=="" || resp==3){
			// $('#message').html("<h2>Check ur username or password!</h2>")
			 var m= "";
			//alert(resp+"2");
			$('#testme').attr('title', '<font color="#000000">User login</font>');
			
						
			$("#testme").dialog({

			modal: true,
			

			buttons: {
						Continue: function() {
						$(this).dialog('close');
						}
						}});
			
			$('#testme').dialog('open');
			 $('#lid').show();
		}
		
		
		
		
        $('#message').html(""+m+"")
        .append("<p></p>")
        .hide()
        .fadeIn(1500, function() {
         /* $('#message').append("<img id='checkmark' src='images/check.png' />");*/
        });
      }
     });
    return false;
	});
  
  
});
/*runOnLoad(function(){
  $("input#name").select().focus();
});*/






$(document).ajaxError(function(event, request, settings){
   $('#message').html("<h2>oops error!</h2>")
 });




/*$(document).ajaxSuccess(function(request){
  var resp = request;
   if(resp==1){
        $('#message').html("<h2>Your Logged-in!</h2>")
		alert(resp+"1");
		}
		if(resp!=1){
			 $('#message').html("<h2>Check ur username or password!</h2>")
			 alert(resp+"2");
		}
 });
*/

