document.onhistoryback = mykeyhandler;
var embedstuff

function growBrow()
{
	infoshow = window.name;
	if(infoshow == 'videoPortal')
	{
		window.resizeTo(1020,800);
	}
	
}

function writeEmbed()
{
	embedstuff = "<OBJECT id='VIDEO' width='440' height='330' CLASSID='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' type='application/x-oleobject' VIEWASTEXT><PARAM NAME='URL' VALUE='radnor_hotel.wmv?n=" + randNum() + "'><PARAM NAME='Showcontrols' value='True'><PARAM NAME='SendPlayStateChangeEvents' VALUE='True'><PARAM NAME='AutoStart' VALUE='False'><PARAM name='uiMode' value='full'><PARAM name='PlayCount' value='9999'><embed type='application/x-mplayer2' src='radnor_hotel.wmv' name='MediaPlayer' width='440' height='330'></embed></OBJECT>";
	document.write(embedstuff);
}

function randNum()
{
	return(Math.round(Math.random() * 1000));
}

function mykeyhandler() {
    alert("backpressed");
}

var valmess = "";

function imageOver(id)
{
	document.images[id].src = "images/nav_" + id + "_on.gif";
}

function imageOut(id)
{
	document.images[id].src = "images/nav_" + id + ".gif";
}

function imageOverSec(id)
{
	document.images[id].src = secure_path + "images/nav_" + id + "_on.gif";
}

function imageOutSec(id)
{
	document.images[id].src = secure_path + "images/nav_" + id + ".gif";
}

function validateForm(type)
{
	var docstring = document.forms[0];
	
	if(type == 1)
	{
		if(docstring.t_fname.value.length < 1)
		{
			alert("Please enter your first name.");
			docstring.t_fname.focus();
			return false;
		}
		else if(docstring.t_lname.value.length < 1)
		{
			alert("Please enter your last name.");
			docstring.t_lname.focus();
			return false;
		}
		else if(docstring.t_email.value.length < 1 || docstring.t_email.value.indexOf("@") == -1 || docstring.t_email.value.indexOf(".") == -1)
		{
			alert("Please enter a valid email address.");
			docstring.t_email.focus();
			return false;
		}
		else if(docstring.t_addr1.value.length < 1)
		{
			alert("Please enter your address.");
			docstring.t_addr1.focus();
			return false;
		}
		else if(docstring.t_city.value.length < 1)
		{
			alert("Please enter your city.");
			docstring.t_city.focus();
			return false;
		}
		else if(docstring.d_state.selectedIndex == 0)
		{
			alert("Please select your state.");
			docstring.d_state.focus();
			return false;
		}
		else if(docstring.t_zip1.value.length < 5)
		{
			alert("Please enter your full zip code.");
			docstring.t_zip1.focus();
			return false;
		}
		else if(validateZip() == false)
		{
			alert("Please enter only numbers for your zip code.");
			docstring.t_zip1.focus();
			return false;
		}
		else if(docstring.t_schname.value.length < 1)
		{
			alert("Please enter the name of the school that you attend.");
			docstring.t_schname.focus();
			return false;
		}
		else if(docstring.d_year.selectedIndex == 0)
		{
			alert("Please select your current year in school.");
			docstring.d_year.focus();
			return false;
		}
		else if(validateUname() == false)
		{
			alert(valmess);
			docstring.t_uname.focus();
			return false;
		}
		else if(validateUpass() == false)
		{
			alert(valmess);
			docstring.t_upass.focus();
			return false;
		}
		else if(docstring.d_secquest.selectedIndex == 0)
		{
			alert("Please select a security question.");
			docstring.d_secquest.focus();
			return false;
		}
		else if(docstring.t_secans.value.length < 1)
		{
			alert("Please enter the answer to your security question.");
			docstring.t_secans.focus();
			return false;
		}
		else if(!docstring.termspolicy.checked)
		{
			alert("You must accept CareerSpots.com's privacy policy and terms and conditions of use.");
			docstring.termspolicy.focus();
			return false;
		}
		else if(docstring.t_sch_uname.value.length < 1)
		{
			if(confirm("You did not enter a username that would affiliate you with a career center. Would you like to continue anyway?"))
			{
				return true;
			}
			else
			{
				docstring.t_sch_uname.focus();
				return false;
			}
		}
		else if(docstring.t_sch_upass.value.length < 1)
		{
			if(confirm("You did not enter a password that would affiliate you with a career center. Would you like to continue anyway?"))
			{
				return true;
			}
			else
			{
				docstring.t_sch_upass.focus();
				return false;
			}
		}
		else
		{
			return true;
		}
	}
	else if(type == 0)
	{
		if(docstring.t_fname.value.length < 1)
		{
			alert("Please enter your first name.");
			docstring.t_fname.focus();
			return false;
		}
		else if(docstring.t_lname.value.length < 1)
		{
			alert("Please enter your last name.");
			docstring.t_lname.focus();
			return false;
		}
		else if(docstring.t_email.value.length < 1 || docstring.t_email.value.indexOf("@") == -1 || docstring.t_email.value.indexOf(".") == -1)
		{
			alert("Please enter a valid email address.");
			docstring.t_email.focus();
			return false;
		}
		else if(docstring.t_addr2.value.length < 1)
		{
			alert("Please enter your school's name.");
			docstring.t_addr2.focus();
			return false;
		}
		else if(docstring.t_city.value.length < 1)
		{
			alert("Please enter your city.");
			docstring.t_city.focus();
			return false;
		}
		else if(docstring.d_state.selectedIndex == 0)
		{
			alert("Please select your state.");
			docstring.d_state.focus();
			return false;
		}
		else if(validateUname() == false)
		{
			alert(valmess);
			docstring.t_uname.focus();
			return false;
		}
		else if(validateUpass() == false)
		{
			alert(valmess);
			docstring.t_upass.focus();
			return false;
		}
		else if(docstring.t_secans.value.length < 1)
		{
			alert("Please enter your video views.");
			docstring.t_secans.focus();
			return false;
		}
		else if(validateAvail() == false)
		{
			alert("Please enter only numbers for your video views.");
			docstring.t_secans.focus();
			return false;
		}
		else
		{
			return true;
		}
	
	}
	else
	{
		if(docstring.t_fname.value.length < 1)
		{
			alert("Please enter your first name.");
			docstring.t_fname.focus();
			return false;
		}
		else if(docstring.t_lname.value.length < 1)
		{
			alert("Please enter your last name.");
			docstring.t_lname.focus();
			return false;
		}
		else if(docstring.t_email.value.length < 1 || docstring.t_email.value.indexOf("@") == -1 || docstring.t_email.value.indexOf(".") == -1)
		{
			alert("Please enter a valid email address.");
			docstring.t_email.focus();
			return false;
		}
		else if(docstring.t_addr1.value.length < 1)
		{
			alert("Please enter your title.");
			docstring.t_addr1.focus();
			return false;
		}
		else if(docstring.t_addr2.value.length < 1)
		{
			alert("Please enter your school's name.");
			docstring.t_addr2.focus();
			return false;
		}
		else if(docstring.t_city.value.length < 1)
		{
			alert("Please enter your city.");
			docstring.t_city.focus();
			return false;
		}
		else if(docstring.d_state.selectedIndex == 0)
		{
			alert("Please select your state.");
			docstring.d_state.focus();
			return false;
		}
		else if(docstring.t_zip1.value.length < 5)
		{
			alert("Please enter your full zip code.");
			docstring.t_zip1.focus();
			return false;
		}
		else if(validateZip() == false)
		{
			alert("Please enter only numbers for your zip code.");
			docstring.t_zip1.focus();
			return false;
		}
		else if(docstring.t_schname.value.length < 1)
		{
			alert("Please enter your phone number.");
			docstring.t_schname.focus();
			return false;
		}
		else if(validateUname() == false)
		{
			alert(valmess);
			docstring.t_uname.focus();
			return false;
		}
		else if(validateUpass() == false)
		{
			alert(valmess);
			docstring.t_upass.focus();
			return false;
		}
		else if(docstring.t_secans.value.length < 1)
		{
			alert("Please enter your video views.");
			docstring.t_secans.focus();
			return false;
		}
		else if(validateAvail() == false)
		{
			alert("Please enter only numbers for your video views.");
			docstring.t_secans.focus();
			return false;
		}
		else
		{
			return true;
		}
	}
}

function validateAvail()
{
	var docstring = document.forms[0];
	var statusval = true;
	for(i=0;i<docstring.t_secans.value.length;i++)
	{
		if(docstring.t_secans.value.charCodeAt(i) < 48 || docstring.t_secans.value.charCodeAt(i) > 57)
		{
			statusval = false;
			break;
		}
	}
	return statusval;
}

function validateZip()
{
	var docstring = document.forms[0];
	var statusval = true;
	for(i=0;i<docstring.t_zip1.value.length;i++)
	{
		if(docstring.t_zip1.value.charCodeAt(i) < 48 || docstring.t_zip1.value.charCodeAt(i) > 57)
		{
			statusval = false;
			break;
		}
	}
	return statusval;
}

function validateUname()
{
	var docstring = document.forms[0];
	var statusval = true;
	if(docstring.t_uname.value.length < 1)
	{
		valmess = "Please enter a username.";
		statusval = false;
	}
	if(docstring.t_uname.value.length >= 1 && docstring.t_uname.value.length < 7)
	{
		valmess = "The username that you entered is too short.";
		statusval = false;
	}
	if(docstring.t_uname.value.length > 20)
	{
		valmess = "The username that you entered is too long.";
		statusval = false;
	}
	return statusval;
}

function validateUpass()
{
	var docstring = document.forms[0];
	var statusval = true;
	if(docstring.t_upass.value.length < 1)
	{
		valmess = "Please enter a password.";
		statusval = false;
	}
	if(docstring.t_upass.value.length >= 1 && docstring.t_upass.value.length < 7)
	{
		valmess = "The password that you entered is too short.";
		statusval = false;
	}
	if(docstring.t_upass.value.length > 20)
	{
		valmess = "The password that you entered is too long.";
		statusval = false;
	}
	if(docstring.t_upass.value != docstring.t_repass.value )
	{
		valmess = "Your retyped password does not match your original password.";
		statusval = false;
	}
	
	return statusval;
}

function validateOpass()
{
	var docstring = document.forms[0];
	var statusval = true;
	if(docstring.t_oldupass.value.length < 1)
	{
		valmess = "Please enter your old password.";
		statusval = false;
	}
	
	return statusval;
}

function validatePass()
{
	var docstring = document.forms[0];

	if(validateOpass() == false)
	{
		alert(valmess);
		docstring.t_oldupass.focus();
		return false;
	}
	else if(validateUpass() == false)
	{
		alert(valmess);
		docstring.t_upass.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function pricing()
{
	var docstring = document.forms[0];
	var checkedCount = 0;
	for(i=0;i<docstring.elements.length;i++)
	{
		if(docstring.elements[i].checked)
		{
			checkedCount ++;
		}
	}
	if(checkedCount == 10 && vidavail_amount > 10)
	{
		if(confirm("You have selected " + checkedCount + " videos. You are eligible for a free video.  If you would like to go back and choose your free video, click OK. To continue with your purchase as is, click CANCEL"))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	if(checkedCount >= 15 && checkedCount < 18)
	{
		if(vidavail_amount >= 18)
		{
			if(confirm("You have selected " + checkedCount + " videos. You are eligible to receive all 18 videos for the same price.  If you would like to go back and choose " + (18 - checkedCount) + " more, click OK. To continue with your purchase as is, click CANCEL"))
			{
				return false;
			}
			else
			{
				return true;
			}
		}
	}
}

function CheckAllDataGridCheckBoxes(aspCheckBoxID, checkVal)
{

	re = new RegExp(':' + aspCheckBoxID + '$')  //generated control name starts with a colon
	//alert('checked: ' + document.forms[0].elements.length);
	for(i = 0; i < document.forms[0].elements.length; i++)
	{
		elm = document.forms[0].elements[i]
		//alert('elmname: ' + re.test(elm.name));
		if (elm.type == 'checkbox' && elm.name.indexOf('vidCheckBox') != -1)
		{
			elm.checked = checkVal
		}
	}
}



function checkemall(option)
{
	var docstring = document.forms[0];
	for(i=0;i<docstring.elements.length;i++)
	{
	
		if(docstring.elements[i].type == "checkbox")
		{
			if(option == 0)
			{
				docstring.elements[i].checked = false;
			}
			else
			{
				docstring.elements[i].checked = true;
			}			
		}
		
	}
}

function confirmDelete(url,name)
{
	if(confirm("Are you sure you would like to delete " + name + "."))
	{
		document.location = url;
	}
}