	function pop(url)
	{
	    var w=window.open(url,'pop','toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=650,height=400');
	    w.focus();
	}
	function popMax(url)
	{
		var page=new pageSize();
	    var w=window.open(url,'pop','toolbar=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+page.width-40+',height='+page.height-40);
	    w.focus();
	}
	
	function confirm_delete(url,file_name)
	{
	    var go_ahead=confirm('Are you certain you want to delete \" '+file_name+'\"?\n\nThe information you are deleting will not be recoverable.');
	    if(go_ahead)window.location=url;
	    else
	      alert('\" '+file_name+' \" was not deleted.');
	}
		
	var validationChecks=new Array();
	function addValidationCheck(formFieldName,formFieldLabel,validationKey,parameter)
	{
		validationChecks[validationChecks.length]=new validationCheck(formFieldName,formFieldLabel,validationKey,parameter);
	}
	
	function validationCheck(ffn,ffl,vk,p)
	{
		this.formFieldName=ffn;
		this.formFieldLabel=ffl;
		this.validationKey=vk;
		this.parameter=p;
	}

	function validateAndSubmit()
	{		
        var valid=validateForm(document.forms[0]);
        if(valid)document.forms[0].submit();
	}

	function validateForm(form)
	{
		valid=true;
		for(var i=0;i<validationChecks.length;i++)
		{
			var thisCheck=validationChecks[i];
			//alert('key='+thisCheck.validationKey);
			if(thisCheck.validationKey=='length')
			{
				if( !checkLength(thisCheck.formFieldName,thisCheck.parameter) )
				{
					valid=false;
					alert(thisCheck.formFieldLabel+' needs to at least '+thisCheck.parameter+' characters long.');
					break;
				}
			}
			else if(thisCheck.validationKey=='notblank')
			{
				if( !checkLength(thisCheck.formFieldName,1 ) )
				{
					valid=false;
					alert(thisCheck.formFieldLabel+' can not be left blank.');
					break;
				}
			}
			else if(thisCheck.validationKey=='alphanumeric')
			{
				if( !checkAlphanumeric(thisCheck.formFieldName) )
				{
					valid=false;
					alert(thisCheck.formFieldLabel+" can only be made up of alphabetic and numeric characters.\nThis means symbols($,#,*) and spaces cannot be a part of this field.");
					break;
				}
			}
			else if(thisCheck.validationKey=='fileEnding')
			{
				if( !checkUploadFileType(thisCheck.formFieldName,thisCheck.parameter) )
				{
					valid=false;
					alert("The file you are attempting to upload is of the wrong file type.");
					break;
				}
			}
		}
		return valid;
	}

	function checkUploadFileType(formFieldName,validTypesList)
	{
		// parse list into array
		var startIndex=0;
		var endIndex=0;
		var typesArray=new Array();
		while(startIndex<validTypesList.length)
		{
			endIndex=validTypesList.indexOf(',',endIndex+1);
			if(endIndex==-1)
			{
				endIndex=validTypesList.length;
			}
			typesArray[typesArray.length]=validTypesList.substring(startIndex,endIndex);
			startIndex=endIndex+1;
		}
		
		var filePath=document.forms[0].elements[formFieldName].value;//get FileUpload string value
		var l=filePath.length;
		if(l==0)
		{
			return true;
		}
		ending=filePath.substring(l-3,l);
		
		var valid=false;
		
		var length=typesArray.length;
		for(var x=0;x<length;x++)
		{
			//alert('ending='+ending+'  -  typesArray[x]='+typesArray[x]);
			if( (ending.toLowerCase())==(typesArray[x].toLowerCase()) )
			{
				valid=true;
			}
		}
		return valid;		
	}
	
	function checkLength(formFieldName,requiredLength)
	{
		var text=document.forms[0].elements[formFieldName].value;
        
        var valid=true;
        if(text.length < requiredLength)
        {
        	valid=false;
        } 
		return valid;
	}
	
	function checkAlphanumeric(formFieldName)
	{
		var text=document.forms[0].elements[formFieldName].value;
        var charpos = text.search("[^A-Za-z0-9]"); 
        
        var valid=true;
        if(charpos >= 0)
        {
        	valid=false;
        } 
		return valid;
	}

	function pageSize()
	{ 
		this.width=document.body&&document.body.offsetWidth?document.body.offsetWidth-20:document.body&&document.body.innerWidth?document.body.innerWidth:innerWidth?innerWidth:0;
		this.height=document.body&&document.body.offsetHeight?document.body.offsetHeight-5:document.body&&document.body.innerHeight?document.body.innerHeight:innerHeight?innerHeight:0;
	}

        var hasPleaseWaitBox=false;
	function writePleaseWaitBox()
	{
		document.write('<div id="pleaseWaitBox" style="position:absolute;z-index:200;top:200px;left:-300px;visibility:hidden;width:300px;margin:0px;padding:20px;text-align:center;border: 3px solid #e0e0e0;background-color:#ffffff;" ');
		document.write('<h3>Please Wait While The Server Processes Your Submission...</h3>');	
		document.write('</div>');
		hasPleaseWaitBox = true;	
	}
        function CheckBoxManager()
	{
		this.superCheckBoxes = [];
	}

	CheckBoxManager.prototype.addSuperCheckBox = function( formName , newSuperCheckBoxName )
	{
		// ================================
		// search for pre-existing checkBox
		// ================================
		for(var x=0;x<this.superCheckBoxes.length;x++)
		{
			if(this.superCheckBoxes[x].checkBoxName==newSuperCheckBoxName)
			{
				alert(newSuperCheckBoxName+' already added to CheckBoxManager');
				return;
			}
		}
		// ================================
		// add new checkBox
		// ================================
		var newSuperCheckBox = new SuperCheckBox( formName , newSuperCheckBoxName);
		this.superCheckBoxes[this.superCheckBoxes.length] = newSuperCheckBox
		return newSuperCheckBox;
	}
	
	CheckBoxManager.prototype.addSubCheckBox = function( superCheckBoxName , newSubCheckBox )
	{
		// ================================
		// search for supercheckBox
		// ================================
		for(var x=0;x<this.superCheckBoxes.length;x++)
		{
			if(this.superCheckBoxes[x].checkBoxName==superCheckBoxName)
			{
				this.superCheckBoxes[x].addSubCheckBox(newSubCheckBox);
				return;
			}
		}
		alert(superCheckBoxName+' not found in CheckBoxManager');
	}
	
	CheckBoxManager.prototype.updateSubCheckBoxes = function( thisSuperCheckBoxName )
	{
		// ================================
		// search for pre-existing checkBox
		// ================================
		for(var x=0;x<this.superCheckBoxes.length;x++)
		{
			if(this.superCheckBoxes[x].checkBoxName==thisSuperCheckBoxName)
			{
				this.superCheckBoxes[x].updateSubCheckBoxes();
				return;
			}
		}
		alert(thisSuperCheckBoxName+' not found in CheckBoxManager');
	}
	
	function SuperCheckBox( submittedFormName , submittedName )
	{
		this.formName 			= submittedFormName;
		this.checkBoxName 		= submittedName;
		this.subCheckBoxNames 	= [];
	}

	SuperCheckBox.prototype.addSubCheckBox = function( newSubCheckBoxName )
	{
		// ================================
		// search for pre-existing checkBox
		// ================================
		for(var x=0;x<this.subCheckBoxNames.length;x++)
		{
			if(this.subCheckBoxNames[x].name==newSubCheckBoxName)
			{
				alert(newSubCheckBoxName+' already added to '+this.checkBoxName);
				return;
			}
		}
		// ================================
		// add new checkBox
		// ================================
		this.subCheckBoxNames[this.subCheckBoxNames.length] = newSubCheckBoxName;
	}
	
	SuperCheckBox.prototype.updateSubCheckBoxes = function()
	{
		var setting = eval('document.forms[0].'+this.checkBoxName+'.checked');
		for(var x=0;x<this.subCheckBoxNames.length;x++)
		{
			//alert('x='+x);
			var thisSubCheckBoxName = this.subCheckBoxNames[x];
			eval('document.forms[0].'+thisSubCheckBoxName+'.checked='+setting);
		}		
	}

