var newWindow = null;
var viewResumeWindow = null;

function MM_openBrWindow(theURL,winName,features) 
{ 
   if (!newWindow || newWindow.closed) 
   {
		newWindow = window.open(theURL, winName, features);
		newWindow.moveTo(0,0);
   } 
   else 
   {
		newWindow.focus();
   }

	return false;
}

function UserInfoValidation()
{
    for (var i=0; i<document.myForm.elements.length; i++)
    {
        var e=document.myForm.elements[i].name;
        switch (e)
        {
			case "StartMonth":
				if (document.myForm.StartMonth.value > 0 && document.myForm.StartYear.value == -1)
				{
					alert("You need to Enter the Year");
					document.myForm.StartYear.focus();
					return false;
				}
				break;
			case "EndMonth":
				if (document.myForm.EndMonth.value > 0 && document.myForm.EndMonth.value < 14 && document.myForm.EndYear.value == -1)
				{
					alert("You need to Enter the Year");
					document.myForm.EndYearSel.focus();
					return false;
				}
				break;
			case "PubMonth":
				if (document.myForm.PubMonth.value > 0 && document.myForm.Year.value == -1)
				{
					alert("You need to Enter the Year");
					document.myForm.Year.focus();
					return false;
				}
				break;
			case "GradMonth":
				if (document.myForm.GradMonth.value > 0 && document.myForm.Year.value == -1)
				{
					alert("You need to Enter the Year");
					document.myForm.Year.focus();
					return false;
				}
				break;
			case "GPA":
		/******************Number Check*************************************/
				var valid = "0123456789.";
				for (var k=0; k < document.myForm.GPA.value.length; k++) 
				{
					temp = "" + document.myForm.GPA.value.substring(k, k+1);
					if (valid.indexOf(temp) == "-1") 
					{
						alert("Invalid characters in the GPA field.  Please try again.");
						return false;
					}
				}		
		/******************End of Number Check******************************/
				break;
			case "MajorGPA":
		/******************Number Check*************************************/
				var valid = "0123456789.";
				for (var k=0; k < document.myForm.MajorGPA.value.length; k++) 
				{
					temp = "" + document.myForm.MajorGPA.value.substring(k, k+1);
					if (valid.indexOf(temp) == "-1") 
					{
						alert("Invalid characters in the MajorGPA field.  Please try again.");
						return false;
					}
				}		
		/******************End of Number Check******************************/
				break;
		}
	}
	return true;
}

function popUpActionPhrasesWindow(togo)
{
  	 newWindow = window.open("ACTION_PHRASES_"+togo+".jsp", "AP", "scrollbars=yes,resizable=no,width=540,height=420");
	 newWindow.moveTo(0,0);
	 newWindow.focus();
	 
	 return false;
}

function popUpActionWordsWindow()
{
  	 newWindow = window.open("Resume_Words.jsp", "AP", "scrollbars=yes,resizable=no,width=570,height=420");
	 newWindow.moveTo(0,0);
	 newWindow.focus();

	 return false;
}

function popUpTipsWindow(togo)
{
  	 newWindow = window.open(togo, "AP", "toolbar=yes,location=yes,directories=yes,menubar=yes,scrollbars=yes,resizable=yes,width=740,height=500");
	 newWindow.moveTo(0,0);
	 newWindow.focus();
	 
	 return false;
}

function popUpSamplesWindow(togo)
{
  	 newWindow = window.open(togo, "AP", "toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,resizable=yes,width=740,height=500");
	 newWindow.moveTo(0,0);
	 newWindow.focus();
	 
	 return false;
}

function previewResume()
{
	newWindow = window.open("viewResume.jsp?SendAs="+document.myForm.hdnSendAs.value+"&emailMessage="+escape(document.myForm.EmailMessage.value), "Preview", "scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,menubar=no,width=640,height=480");
	newWindow.moveTo(0,0);
	return false;
}

function closeWindow()
{
   if (newWindow && ! newWindow.closed) 
   {
      newWindow.close()
   }
}

if (window !=window.top)
  top.location.href = location.href;

//tmtC_NNresizeFix
if (document.layers) 
{
	origWidth = innerWidth;
	origHeight = innerHeight;
}

function reDo() 
{
	if (innerWidth != origWidth || innerHeight != origHeight)
	location.reload();
}

if (document.layers) onresize = reDo;

function doAction(whichAction,actionData) 
{
     document.myForm.Action.value=whichAction;
     document.myForm.ActionData.value=actionData;
     document.myForm.submit();
 }
 
function editSectionTitle(tableName) 
{
	var winStats="toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,width=280,height=420";

	if (navigator.appName.indexOf("Microsoft")>=0) 
	{
		winStats+=",left=50,top=25";
	}
	else
	{
		winStats+=",screenX=50,screenY=25";
	}

	window.open("sectionTitle.jsp","SectionTitle",winStats);
	return false;
}

function editSectionName(whichAction, sectionName, sectionID)
{
	document.editSections.action.value = whichAction;
	document.editSections.sectionName.value = sectionName;
	document.editSections.sectionID.value = sectionID;
	document.editSections.submit();
}

function selectCurrentJob()
{
	if (document.myForm.ckCurrentPos.checked)
	{
		document.myForm.CurrentPos.value = 1;
		document.myForm.EndYear.value = -2;
		document.myForm.EndMonth.options[0].selected = true;
		document.myForm.EndYearSel.options[0].selected = true;
	}
	else
	{
		document.myForm.CurrentPos.value = 0;
		document.myForm.EndYear.value = 0;
		document.myForm.EndMonth.options[1].selected = true;
		document.myForm.EndYearSel.options[6].selected = true;
	}

}

