//function will determine the length of a project description text area box
function ValidateLength(oSrc, args)
{
	return true;
	//args.IsValid = (args.Text.length <= 5000);
}
function ValidateAgreeCheckBox(oSrc, args)
{
	var objCheckBox = window.document.getElementById("chkAgree");
	args.IsValid = objCheckBox.checked;
}

function RemoveSpaces(value)
{
	return value.replace(/\s*|\s*/g,"");
}


function SaveScrollLocation () 
{
	var top = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
	window.document.getElementById('__SCROLLLOC').value = top;
}

function SetScrollLocation() 
{
	var objectDocumentElement = document.documentElement;
	var objectDocumentBody	  = document.body;
	
	if (window.document.getElementById('lblErrorMessage').innerText.length <= 0)
	{
		if (objectDocumentBody != null)
		{
			objectDocumentBody.scrollTop = window.document.getElementById('__SCROLLLOC').value;
		}
		
		if (objectDocumentElement != null)
		{
			objectDocumentElement.scrollTop = window.document.getElementById('__SCROLLLOC').value;
		}
	}
	else
	{
		if (objectDocumentBody != null)
		{
			objectDocumentBody.scrollTop = 0;
		}
		
		if (objectDocumentElement != null)
		{
			objectDocumentElement.scrollTop = 0;
		}
	}
	
	window.onscroll=SaveScrollLocation;
	
}

function ReroutePostback(ctrlId,textBoxList)
{
	var blnSubmit = "true";
	ctrl = document.all[ctrlId];
	if (textBoxList != null) // current call is from for the quick add
	{
		//13 = Enter Key - 32 = Space Bar - 9 - Tab
		if ((event.keyCode == 13 || event.keyCode == 32 || event.keyCode == 9 ) && (IsEmptyTextBoxes(textBoxList)))
		{
			ctrl.style.display="none";
			blnSubmit = "false";
		}
		else if (event.keyCode == 8) //Handling BackSpace Key
		{
			var textValue = event.srcElement.value.replace(/^\s*|\s*$/g,"");
			if (textValue.length <= 1 && IsEmptyTextBoxes(textBoxList.replace(event.srcElement.id,"")))
			{
				ctrl.style.display="none";
				blnSubmit = "false";
			}
		}
		else
		{
			ctrl.style.display="";
			blnSubmit = "true";
		}
	}
	
	if (event.keyCode == 13 && blnSubmit == "true")
	{
		event.returnValue = false;
		ctrl.click();
	}
}

function Trim(value)
{	
	return value.replace(/^\s*|\s*$/g,"");
}

// ------------------------------------------------------------------
// isDate ( date_string, format_string )
// Returns true if date string matches format of format string and
// is a valid date. Else returns false.
// It is recommended that you trim whitespace around the value before
// passing it to this function, as whitespace is NOT ignored!
// ------------------------------------------------------------------
function ValidateDateFormat(oSrc, format) 
{
	var objBirthDate = window.document.getElementById(oSrc);
	
	var input = objBirthDate.value;
	
	if (format = 'MM/dd')
	{
		input = input + '/2004';
		format = format + '/yyyy';
	}
	//if user has entered something, then only verify the input
	if (Trim(input).length > 0)
	{
		 return isDate(input,format);
	}else
	{
		return true;
	}
}

function JobSearchPost(inJobId)
{
	//alert(inJobId);
	window.document.getElementById('hidpostid').value='';
	window.document.getElementById('hidpostid').value=inJobId;
	__doPostBack('hidpostid','');
	return false;
}

function switchMenu(obj) {
	var el = document.getElementById(obj);
	//alert(el.style.display);
	//window.location.pathname
	//alert(url.href);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
	
}

