<!--

function SetVariable(sFieldName,iVariableID) 
{
	var oField = eval("document.forms[0]." + sFieldName);
	oField.value = iVariableID;
}


function BreakItUp(sTextAreaName) 
{
	/*	This function assumes there is a second and third input objects of type hidden with the 
		same name with a number after it, i.e. txtLargeText and txtLargeText2 txtLargeText3 */
	
	var oTextArea = eval("document.forms[0]." + sTextAreaName + "1");  // Get the first TextArea	

	//the text area limit is documented as: 102399 but was still giving me probs.  GA
	var SizeLimit = 102000;  //Set the limit for textarea size.
  	
  	var TempValue = new String;
	TempValue = oTextArea.value;
	var RunningTotal = 0;
	var iCount = 1;
	
	//If the length of the object is greater than the limit, break it
	//into multiple objects.
	do
	{
		oTextArea = eval("document.forms[0]." + sTextAreaName + iCount);	
		oTextArea.value = TempValue.substr(RunningTotal, SizeLimit);
		RunningTotal = RunningTotal + SizeLimit;
		iCount++;
	} while (TempValue.length > RunningTotal)
	
}

function SetFieldFocus(sFieldName) {
	var oField = eval("document.forms[0]." + sFieldName);
	oField.focus();
}

function checkLength(oField,oLength)
	{
	//  Created to check the length of the textarea fields.
		if (oField.value.length >= oLength)
			return false;
		else
			return true;
	}

function restrictChars(iKeyPresses, sNumType, blnComma) {
	
		// This is the call to make this work: onkeypress="return restrictChars(event.which, 'posInt', false);"	
	
	/*
	This function will handle different types of numbers.  As they come along just add them below.
	
	posInt --  Postive Integers only, including 0 [,0123456789]
	allInt --  All integers, positive and negative, including 0 [-,01234567890]
	float  --  Allow real numbers. [.,-0123456789]
	posFloat -- Allow positive float numbers only [.,0123456789]
	date   --  Allow integers and forward slash [/0123456789] 
	alpha  --  Alpha characters only no commas, including period [.abcdXYZ]
	
	You can pass in whether to allow the comma or not.
	*/
	
	// Positve and Negative Integers Only
	if (sNumType == 'posInt') 
	{
		if (blnComma)
		{
			if (!(iKeyPresses == 8 || iKeyPresses == 9 ) && (iKeyPresses == 45 || iKeyPresses == 46 || iKeyPresses == 47 || iKeyPresses < 44 || iKeyPresses > 57))  
				return false; //Netscape
			else if (event.keyCode == 45 || event.keyCode == 46 || event.keyCode == 47 || event.keyCode < 44 || event.keyCode > 57)  
				return false;  //IE
			return true;
		}
		else
		{
			if (!(iKeyPresses == 8 || iKeyPresses == 9 ) && (iKeyPresses < 48 || iKeyPresses > 57))  
				return false; //Netscape
			else if (event.keyCode < 48 || event.keyCode > 57)  
				return false;  //IE
			return true;
		}
	}
	
	//  All integers
	if (sNumType == 'allInt') 
	{
		if (blnComma)
		{
			if (!(iKeyPresses == 8 || iKeyPresses == 9 ) && (iKeyPresses == 46 || iKeyPresses == 47 || iKeyPresses < 44 || iKeyPresses > 57))  
				return false; //Netscape
			else if (event.keyCode == 46 || event.keyCode == 47 || event.keyCode < 44 || event.keyCode > 57)  
				return false;  //IE
			return true;
		}
		else
		{
			if (!(iKeyPresses == 8 || iKeyPresses == 9 ) && (iKeyPresses == 46 || iKeyPresses == 47 || iKeyPresses < 45 || iKeyPresses > 57))  
				return false; //Netscape
			else if (event.keyCode == 46 || event.keyCode == 47 || event.keyCode < 45 || event.keyCode > 57)  
				return false;  //IE
			return true;
		}
	}
	
	//  Float
	if (sNumType == 'float') 
	{
		if (blnComma)
		{
			if (!(iKeyPresses == 8 || iKeyPresses == 9 ) && (iKeyPresses == 47 || iKeyPresses < 44 || iKeyPresses > 57))  
				return false; //Netscape
			else if (event.keyCode == 47 || event.keyCode < 44 || event.keyCode > 57)  
				return false;  //IE
			return true;
		}
		else
		{
			if (!(iKeyPresses == 8 || iKeyPresses == 9 ) && (iKeyPresses == 47 || iKeyPresses < 45 || iKeyPresses > 57))  
				return false; //Netscape
			else if (event.keyCode == 47 || event.keyCode < 45 || event.keyCode > 57)  
				return false;  //IE
			return true;
		}
	}
	
	//  posFloat
	if (sNumType == 'posFloat') 
	{
		if (blnComma)
		{
			if (!(iKeyPresses == 8 || iKeyPresses == 9 ) && (iKeyPresses == 45 || iKeyPresses == 47 || iKeyPresses < 44 || iKeyPresses > 57))  
				return false; //Netscape
			else if (event.keyCode == 47 || event.keyCode < 46 || event.keyCode > 57)  
				return false;  //IE
			return true;
		}
		else
		{
			if (!(iKeyPresses == 8 || iKeyPresses == 9 ) && (iKeyPresses == 47 || iKeyPresses < 46 || iKeyPresses > 57))  
				return false; //Netscape
			else if (event.keyCode == 47 || event.keyCode < 45 || event.keyCode > 57)  
				return false;  //IE
			return true;
		}
	}
	
	//  Date
	if (sNumType == 'date') 
	{
			if (!(iKeyPresses == 8 || iKeyPresses == 9 ) && (iKeyPresses == 45 || iKeyPresses == 46 || iKeyPresses < 44 || iKeyPresses > 57))  
				return false; //Netscape
			else if (event.keyCode == 45 || event.keyCode == 46 || event.keyCode < 44 || event.keyCode > 57)  
				return false;  //IE
			return true;
		
	}
	
	//  Date
	if (sNumType == 'alpha') 
	{
			if (!(iKeyPresses == 8 || iKeyPresses == 9 ) && (iKeyPresses < 64 || iKeyPresses > 90 || iKeyPresses < 44 || iKeyPresses > 57))  
				return false; //Netscape
			else if (event.keyCode == 45 || event.keyCode == 46 || event.keyCode < 44 || event.keyCode > 57)  
				return false;  //IE
			return true;
		
	}
}
function checkEmailFormat(oField)
{
if (oField.value.length != 0 && (oField.value.indexOf("@") == -1 || oField.value.indexOf(".") == -1))
  {
    alert("Please enter your E-mail address in 'john@company.com' format.");
    oField.focus();
    return false;
  }
}

function checkForWhiteSpace(oString)
{
var sString = oString

if  (sString.search(/\s/) > 0)
	return true;
else
	return false;
}

function replaceIt(oString,sLookingFor,sReplaceWith) {
/*
Replaces text with by in string- Call replace(this.form.myField.value,' ','')
	For URLs replace spaces with %20
*/

    var strLength = oString.length;
    var txtLength = sLookingFor.length;
    //alert("strLength: " + strLength + " txtLength: " + txtLength); //testing only
    
    if ((strLength == 0) || (txtLength == 0)) return oString;

    var i = oString.indexOf(sLookingFor);
    if ((!i) && (sLookingFor != oString.substring(0,txtLength))) return oString;
    if (i == -1) return oString;

    var newstr = oString.substring(0,i) + sReplaceWith;
	//alert ("newstr: " + newstr);  //testing only
    if (i+txtLength < strLength)
        newstr += replaceIt(oString.substring(i+txtLength,strLength),sLookingFor,sReplaceWith);

    return newstr;
}


function SubmitFormAction(sAction)
{
	var sTarget;
	sTarget = parent.window.name;
	
	if (arguments.length > 1) 
	{
		sTarget = arguments[1];
	}
	
	document.forms[0].target = sTarget;
	if (sAction != "") {
		document.forms[0].action = sAction;
	}
	document.forms[0].submit();
}


///////target Parent
function SubmitFormActionParent(sAction) {
	sTarget = window.opener.name;
	document.forms[0].target = sTarget;
	window.focus();
	
	if (sAction != "") {
		document.forms[0].action = sAction;
	}
	document.forms[0].submit();
}


function OpenInParentWindow(sAction) 
{
	//wPopTarget=window.open("","winTarget","toolbar=" + blnToolbar + ",directories=no,height=" + iHeight + ",width=" + iWidth + ",titlebar=no,location=no,status=no,scrollbars=yes,resizable=yes,resize=yes,menubar=" + blnMenubar)
	//parent.window.close;
	//window.parent.close;
	//document.forms[0].target = '../Dashboard.asp';
	//window.location.href = '../Dashboard.asp';
	//document.forms[0].target = window.parent;
	//alert(parent.window);
	document.forms[0].target = parent.window.name;
	document.forms[0].action = sAction;
	document.forms[0].submit();
	self.close();
}
//-->



