/*
 
Purpose:     Handle Posts to MediaFunnel's Sign-up and Login pages

Author name: Jeff Lambert
Author url:  http://www.jvhm.com
Authored on: 2010-03-07

Use in <HEAD> with DEFER keyword wrapped in conditional comments:
<!--[if lt IE 7]>
<script defer type="text/javascript" src="pngfix.js"></script>
<![endif]-->

*/

/* no longer used as standard menu button was added instead */
/* used to direct browser to MediaFunnel signup page */
function SignUpRequest() {

	window.location = "http://www.mediafunnel.com/signup/Beta";
	
}

/* used to clear the account field should someone click into it and it is still displaying "enter account" */
function clearAccount() {
	if (document.mediafunnellogin.mf_your_account.value == "enter account") {
		document.mediafunnellogin.mf_your_account.value = "";
		document.mediafunnellogin.mf_your_account.style.color = "#000000";
	}
}

/* used to set the account field to "enter account" if the user clicks out of it and it is empty */
function setBlankAccount() {

	if (document.mediafunnellogin.mf_your_account.value == "") {
		document.mediafunnellogin.mf_your_account.value = "enter account";
		document.mediafunnellogin.mf_your_account.style.color = "#CCC";
	}
	
}

/* used to
	1) validate that an account was entered
	2) concatenate the account entered with ".mediafunnel.com"
	3) validate the resulting url
	4) direct the browser to the constructed url
*/
function SignInRequest() {

	var strAccount = "";
	var tomatch = /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;
	
	strAccount = document.mediafunnellogin.mf_your_account.value;
	
	if ((strAccount != "") && (strAccount != "enter account")) {
		
		strAccount = "http://" + strAccount + ".mediafunnel.com";
		
		if (tomatch.test(strAccount)) {
			
			window.location = strAccount;
			
		} else {
			
			window.alert("Account invalid. Please try again.");
			document.mediafunnellogin.mf_your_account.focus();
			
		}
		
	} else {
		
		window.alert("Please specify your account to continue.");
		document.mediafunnellogin.mf_your_account.focus();
		
	}
}

