jQuery(document).ready(function() {
	jQuery(".close-login").click(function () {
    	jQuery(".dialog").hide();
    	jQuery(".message-box").hide();
    	jQuery(".more a#forgot").css("color", "#ff7c0e");
    	jQuery(".more a#forgot").css("text-decoration", "underline");
    	jQuery(".more a#veri").css("color", "#ff7c0e");
    	jQuery(".more a#veri").css("text-decoration", "underline");
    	jQuery(".topbox").slideUp(300,function(){});
	});
	
	jQuery(".more a#forgot").click(function(){
		jQuery(".dialog").hide();
		jQuery(".message-box").hide();
		jQuery(".dialog#retrieve").css("display","inline");
		jQuery(this).css("color", "#375a83");
		jQuery(this).css("text-decoration", "none");
		jQuery(".more a#veri").css("color", "#ff7c0e");
		jQuery(".more a#veri").css("text-decoration", "underline");
	});
	
	jQuery(".more a#veri").click(function(){
	   jQuery(".dialog").hide();
	   jQuery(".message-box").hide();
	   jQuery(".dialog#veri").css("display","inline");
	   jQuery(this).css("color", "#375a83");
	   jQuery(this).css("text-decoration", "none");
	   jQuery(".more a#forgot").css("color", "#ff7c0e");
	   jQuery(".more a#forgot").css("text-decoration", "underline");
	});
	
	jQuery(".close-dialog").click(function(){
		jQuery(".dialog").hide();
		jQuery(".message-box").hide();
		jQuery(".more a#forgot").css("color", "#ff7c0e");
		jQuery(".more a#forgot").css("text-decoration", "underline");
		jQuery(".more a#veri").css("color", "#ff7c0e");
		jQuery(".more a#veri").css("text-decoration", "underline");
	});
	
	jQuery(".topbox").ajaxSend(function() {
		jQuery(".topbox .message-box").show();
		jQuery(".topbox .message-box p.message").html("Loading ...");
	});
	var locked = 0;
	jQuery("form#login").submit(function(){
		if(locked == 1)
				jQuery(".topbox .message-box p.message").html("Locked Out because of too many tries! Please wait 10 minutes.");
		else
		jQuery.post("/vendor/vendor_login.php", { loginname: jQuery("#loginname").val(), loginpwd: jQuery("#loginpwd").val() },
		   function(data){
				if(data.match("You have entered wrong username or password. Try again!"))
				     	jQuery(".topbox .message-box p.message").html("You have entered wrong username or password. Try again!");
				else if(data.match("Invalid Username and/or Password"))
						jQuery(".topbox .message-box p.message").html("Invalid Username and/or Password");
				else if(data.match("Locked Out")){
						jQuery(".topbox .message-box p.message").html("Locked Out because of too many tries!");
						locked = 1;
						}
				else
					window.location.href = "/vendor/index.php";
		   });
		
	});
	
	jQuery(".dialog#retrieve input#submit").click(function(){
		jQuery.post("/index.php?link=forgot", { emailaddr: jQuery(".dialog#retrieve #emailaddr").val(), submit: "Submit" },
		   function(data){
				if(data.match("That email address was not found in our database!"))
				     	jQuery(".topbox .message-box p.message").html("That email address was not found in our database!");
				else if(data.match("Your password has been sent to your email. Thank you."))
						jQuery(".topbox .message-box p.message").html("Your password has been sent to your email. Thank you.");
				
				
		   });
		
	});
	
	jQuery(".dialog#veri input#submit").click(function(){
		jQuery.post("/index.php?link=reqEmailVerify", { emailaddr: jQuery(".dialog#veri #emailaddr").val(), submit: "Submit" },
		   function(data){
				if(data.match("That email address was not found in our database!"))
				     	jQuery(".topbox .message-box p.message").html("That email address was not found in our database!");
				else if(data.match("An email verification request has been sent to your email. Thank you."))
						jQuery(".topbox .message-box p.message").html("An email verification request has been sent to your email. Thank you.");
				
				
		   });
		
	});
	
	
	
});

(function(f){function l(g,h){function d(a){if(!e){e=true;c.start&&c.start(a,b)}}function i(a,j){if(e){clearTimeout(k);k=setTimeout(function(){e=false;c.stop&&c.stop(a,b)},j>=0?j:c.delay)}}var c=f.extend({start:null,stop:null,delay:400},h),b=f(g),e=false,k;b.keypress(d);b.keydown(function(a){if(a.keyCode===8||a.keyCode===46)d(a)});b.keyup(i);b.blur(function(a){i(a,0)})}f.fn.typing=function(g){return this.each(function(h,d){l(d,g)})}})(jQuery);

