//Opens a New Window
var newWin = null;
function popUp(strURL, strType, strHeight, strWidth){  
	if (newWin != null && !newWin.closed)    
		newWin.close();  
	var strOptions="";  
	if (strType=="console")    
		strOptions="resizable,height="+
		strHeight+",width="+strWidth;  
	if (strType=="fixed")    
		strOptions="status,height="+
		strHeight+",width="+strWidth;  
	if (strType=="elastic")    
		strOptions="toolbar,menubar,scrollbars,"+
		"resizable,location,height="+
		strHeight+",width="+strWidth;  
	if (strType=="scrollable")    
		strOptions="scrollbars,status,height="+
		strHeight+",width="+strWidth;
	newWin = window.open(strURL, 'newWin', strOptions);  
	newWin.focus();
}

// Example:
// var b = new BrowserInfo();
// alert(b.version); 
function BrowserInfo()
{
  this.name = navigator.appName;
  this.codename = navigator.appCodeName;
  this.version = navigator.appVersion.substring(0,4);
  this.platform = navigator.platform;
  this.javaEnabled = navigator.javaEnabled();
  this.screenWidth = screen.width;
  this.screenHeight = screen.height;
}
var browser = new BrowserInfo();
/*
// JavaScript Document
//Functionality: Validate required form entries
//Name:    formValidate(formname,fields,propernames)
//Arguments: formname -  Name of the form needing validation
//           field    - comma separated list of form field names that need to be validate.               
//           propernames - comma separated list of the Display names corresponding to each item in
//                         'fields' list 
// Usage: formValidate(formname,'FieldName1,FieldName2,...,FieldName6','ProperName1,ProperName2,...,ProperName6');														
// Example: 
// <form name="test" onsubmit="return formValidate(this.name,'fname,ssn','Firstname,Social Security Number')">
*/
function formValidate(formname,fields,propernames){
	var arrayOfFields = fields.split(",");
	var arrayOfNames  = propernames.split(",");
	var message="The following fields are required.\nPlease provide a value for each. \n\n";
	var i=0;
	var isValid=true;
	
	for(i=0; i <arrayOfFields.length; i++)
	{
		if(document.forms[formname].elements[arrayOfFields[i]].value == "")
		{
			message+=" \t"+ arrayOfNames[i] + " \n";
			isValid = false;
		}//End IF	
	}//End For
		
	if(isValid)
		return true;
	else		
	{
		alert(message);		
		return false;
	}

}

function validDate(formField,fieldLabel){
   	result = false;
	var elems = formField.value.split("/");   
   	result = (elems.length == 3); // should be three components
   	if (result) {
   		var month = parseInt(elems[0],10);
       	var day = parseInt(elems[1],10);
   		var year = parseInt(elems[2],10);

   		result = !isNaN(month) && (month > 0) && (month < 13) && !isNaN(day) && (day > 0) && (day < 32) && !isNaN(year) && (elems[2].length == 4);
   	}
   	if (!result&&formField.value.length >0) {
   	alert('Please enter a date in the format MM/DD/YYYY for the "' + fieldLabel +'" field.');
   	formField.focus();    
    }
	return result;
}
//Delete Conformation
function ConfirmDelete(url){
	question = confirm("Are you sure you want to delete this?")
	if (question !="0"){
		self.location = url
	}
}


		function CountOccurences(obj,val){
    
      var i = 0
      var count = 0
      var CheckMe = obj.value
      
      while((CheckMe.indexOf(val, i) != -1) && i <= CheckMe.length)
      {
        count = count + 1
        i = CheckMe.indexOf(val, i) + 1            
      }
      return count
      
    }  
    
   
    function CheckNumbers(obj){
      var i = 0
      var count = 0
      
      //More than 1 decimal point    
      if (CountOccurences(obj,".") > 1 )
      {
        alert("This Number has more than 1 decimal point.  Please correct this.")
        obj.focus()
      }
      //More than 1 - sign
      else if (CountOccurences(obj,"-") > 1 )
      {
        alert("This Number has more than 1 negative sign (-) .  Please correct this.")
        obj.focus()
      }
      //- sign not firt character  
      else if(obj.value.indexOf("-") > 0)
      {
        alert("Negative signs must be on the left.  Please correct this")
        obj.focus()
      }
      //Field is Blank
      else if(obj.value == "")
      {        
        obj.value = ""            
      }   
      
    }
  function CheckKey(KeyPressed, objField) {

  if (((KeyPressed < 48) || (KeyPressed > 57)) && (KeyPressed != 46) && (KeyPressed !=45))  {
    event.returnValue = false;
  }
  
    if ((objField.indexOf(".") != -1) && (KeyPressed == 46)) {
  	event.returnValue = false;
  
  }
  
}

function CustomConfirmation(msg,url){
	if (msg)
		question = confirm(msg)
	else	
		question = confirm("Are you sure you want to delete this?")
		
	if (url && question){
			
			self.location = url;
			return false;
  } else
			return question;
}