$(document).ready(function(){
	var cookiestring = document.cookie;
	if(cookiestring.match(/showc=true/)){
		$('.displaynone').show();
		$('#thinkspot_login_captcha_code').toggleClass('required',true);
	}
});


function fnDosubmit(){
	if ($("#form").valid()){
		$('#dialog').jqmShow();
		$.postJSON("services/auth.php",$("#form").serialize(),
			function(data){
				if(data.status=='0'){
					document.cookie = data.settings;
					if ($('#rtnpth').val()==''){
						window.location = 'memberhome.php';
					}else{
						window.location = $('#rtnpth').val();
					}
				}else if(data.status=='1'){
					alert('Invalid code. Please try again.');
					document.getElementById('captcha').src = 'includes/securimage/securimage_show.php?' + Math.random();
					$('#dialog').jqmHide();
				}else if(data.status=='2'){
					alert('Invalid email address or password. Please try again.');
					document.getElementById('captcha').src = 'includes/securimage/securimage_show.php?' + Math.random();
					$('#dialog').jqmHide();
				}
				if(data.showc=="true"){
					document.cookie = 'showc=true';
					$('.displaynone').show();
					$('#thinkspot_login_captcha_code').toggleClass('required',true);
					$('#dialog').jqmHide();
				}
			});
	}else{
		alert("Please correct errors before trying again");
	}
}
$.postJSON = function(url, data, callback) {
	$.post(url, data, callback, "json");
};
