function openWin(url,alias,opts) {
	window.open(url,alias,opts);
}

function paintLogin() {
	jQuery.post("/private/check_logged_in.php",{},function(data){
		jQuery("dl#login").fadeOut('2000',function(){
			jQuery("dl#login").html(data);
			jQuery("dl#login").fadeIn('2000');
		});

		if (data.match(/Welcome:/)) {
			jQuery("dl#controls").fadeIn('2000');
			if (!data.match(/cevt\|true/)) {
				jQuery("dt#dtReg").css("display","none");
			} else {
				jQuery("dt#dtReg").css("display","block");
			}
		} else {
			jQuery("dl#controls").fadeOut('2000');
		}

	});	
}	

function ctrlBtn(which) {
	if (which == 'off') {
		jQuery("input#submit").attr("disabled","true");
		jQuery("input#submit").attr("value","Please wait...");
	} else {
		jQuery("input#submit").attr("disabled","");
		jQuery("input#submit").attr("value","Submit");
	}
}

function logout() {
	jQuery.post("/private/logout.php",{},function(){
		paintLogin();
	});
}

function login() {
	ctrlBtn('loginSubmit','off');
	var i=0;
	jQuery('input.requiredLogin').filter(function() {
		if (jQuery(this).val() == "") {
			jQuery(this).css("backgroundColor","#fcc");
			jQuery(this).css("border","1px solid #999");
			jQuery(this).css("padding","1px");
			i++;
		} else {
			jQuery(this).css("backgroundColor","#fff");
			jQuery(this).css("border","1px solid #999");
		}
	});
	if (i > 0) {
		alert("Please complete the required fields.");
		ctrlBtn('loginSubmit','on');
		return false;
	} else {
		jQuery.post("/login_process.php",{ username : jQuery("#username").val(), password : jQuery("#password").val() }, function(data) {
			if (data == '0') {
				alert('Your login was not recognized.  You may use the "Forgot Password" form to have your password emailed to you or register a new account.');
				self.location = 'http://www.vetlearn.com/AccountLogin/tabid/89/ctl/SendPassword/Default.aspx?returnurl=%2fHome.aspx';
			} else {
				paintLogin();
			}
		});
		ctrlBtn('loginSubmit','on');
		return false;
	}
}	



