$(document).ready( function() {
	$("#property-portal-login").css( "cursor", "pointer" ).click( function() {
		/*$( "#login-panel" ).toggle();
	});
	
	$("#login-btn").click( function() {
		var username = $("#username-fld").val();
		var password = $("#password-fld").val();
		if ( ( username == null || username == "" ) && ( password == null || password == "" ) ) {
			alert( "Please enter a username and password before clicking 'Login'." );
		}
		
		var xml =	"<Data>\r\n" + 
					"  <Action>Login</Action>\r\n" + 
					"  <UserName>" + username + "</UserName>\r\n" + 
					"  <UserPassword>" + password + "</UserPassword>\r\n" + 
					"</Data>\r\n";
		$.ajax({
			url: "http://www.dohertybainespropertyportal.com/Login/Login.asp",
			type: "post",
			data: xml,
			dataType: "text",
			async: true,
			cache: false,
			processData: false,
			crossDomain: true,
			success: function( data ) {
				alert( "Logging in" );
				if ( data.toLowerCase() == "success" )
					redirect();
				else
					alert( "Unable to log you in at this time.\n" + data );
			}
		}).fail( function() { alert( "We are unable to log you in at this time. Please try again later" ); });
		//.complete(function() { redirect(); });
		//jqxhr.complete(function(){ redirect(); });
		
		var l = (screen.width/2)-115;
		var t = (screen.height/2)-100;
		var cwin = window.open('http://www.dohertybainespropertyportal.com/Login/LoginDialog.htm','1322750105077','width=230,height=200,toolbar=0,menubar=0,location=0,status=0,scrollbars=0,resizable=0,left='+l+',top='+t);*/
		redirect();
	});
	
	function redirect() {
		window.location.href = "http://www.dohertybainespropertyportal.com/";
	}
});
