

var phone_field_length=0;
var phone_field_name = null;
function CheckAutoTab(obj,event,len,nextControl) 
{
	if (event == "down") {
		phone_field_length=obj.value.length;
		phone_field_name=obj.name;
	}
	else if (event == "up") {
		if ((obj.value.length != phone_field_length) &&
		    (obj.name == phone_field_name)) {
			phone_field_length=obj.value.length;
			if (phone_field_length == len) {
				document.forms[0][nextControl].focus();
			}
		}
	}
}

function CheckNumeric()
{
    var keyCode = window.event.keyCode;
    if ((keyCode == 8) ||
        (keyCode == 13) ||
        (keyCode == 46))
    {
        return;
    }
    else if ((keyCode >= 48) && (keyCode <= 57))
    {
        return;
    }
    else
    {
        window.event.keyCode = 0;
        return;
    }
        
}

// Provides trim functionality to string
String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

// Returns true if the selected value of a drop down is not empty
function validateDropDownSelected(sourceField) {
	
	if(sourceField == null || 
		sourceField.selectedIndex == null ||
		sourceField.selectedIndex < 0) return false;
	 
	var selectedValue = sourceField.options[sourceField.selectedIndex].value;
	
	if(selectedValue == null || selectedValue.trim().length == 0)
	{
		return false;
	}
	else
	{
		return true;
	}
}

// Returns true if input is a currency value, or empty
function validateCurrency(inValue) {
    inValue = inValue.replace(",", "");
    if(isNaN(inValue.value))
		return false;
    if(inValue.value > 9999999.99)
		return false;
	// This allows for empty values
    return /^\d*(\.\d?\d?)?$/.test(inValue.value.trim());
}

// Returns true if input is a currency value and not empty
function validateCurrencyNotEmpty(inValue) {
    if (inValue.value == null || inValue.value.trim() == "")
        return false;
    inValue.value = inValue.value.replace(",", "");
    if(isNaN(inValue.value))
		return false;
    if(inValue.value > 9999999.99)
		return false;
    else
        return /^\d*(\.\d?\d?)?$/.test(inValue.value.trim());
}

// validate that if a field exists, it meet a minimum number of characters
function validateMinFieldLength(inValue) {	
	// its ok for the value to be empty
    if (!validateFieldNotEmpty(inValue))
    {
        return true;
    }
    // error if field length not empty but less than desired	
	else if(inValue.value.length < inValue.MinLength[inValue.CurrentIndex])
	{
		return false;
	}
	else {
		return true;
	}
}

function validateNothing(inValue)
{
	return true;
}

// can't be empty and minimum field length
function validateMinFieldLengthNotEmpty(inValue) {	

    if (!validateFieldNotEmpty(inValue))
    {
        return false;
    }
    // error if field length not empty but less than desired	
	else if(inValue.value.length < inValue.MinLength[inValue.CurrentIndex]) {
		return false;
	}
	else {
		return true;
	}
}

// can be empty, minimum field length and must be a number
function validateMinFieldLengthNumber(inValue) {	
	
	// if empty, its ok
	if(!validateFieldNotEmpty(inValue))
	{
        return true;
    }
	// if is not a number, fail validation
	else if(!validateNumberNotEmpty(inValue))
	{
        return false;
    }
    // error if field length not empty but less than desired	
	else if(inValue.value.length < inValue.MinLength[inValue.CurrentIndex]) 
	{
		return false;
	}
	else 
		return true;
}

// can't be empty, minimum field length and must be a number
function validateMinFieldLengthNumberNotEmpty(inValue) 
{		
	// if is not a number or its empty, fail validation
	if(!validateNumberNotEmpty(inValue))
	{
        return false;
    }
    // error if field length not empty but less than desired	
	else if(inValue.value.length < inValue.MinLength[inValue.CurrentIndex]) 
	{
		return false;
	}
	else 
		return true;
}

function validateEmail(sourceField) 
{
	var inValue = sourceField.value;

	// its ok for the value to be empty
    if (!validateFieldNotEmpty(sourceField))
        return true;
    
    var oRegExp = new RegExp(/^[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*$/);
	return oRegExp.test(inValue);    
}

function validatePhone(str1, str2, str3)
{
	if(str1 == null) str1 = "";
	else str1 = str1.trim();
	
	if(str2 == null) str2 = "";
	else str2 = str2.trim();
	
	if(str3 == null) str3 = "";
	else str3 = str3.trim();
	
	if(str1.length == 0 && str2.length == 0 && str3.length == 0)
	{
		return true;
	}
	else if(str1.length != 3 || str2.length != 3 || str3.length != 4)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function validatePhoneNotEmpty(str1, str2, str3)
{
	if(str1 == null) str1 = "";
	else str1 = str1.trim();
	
	if(str2 == null) str2 = "";
	else str2 = str2.trim();
	
	if(str3 == null) str3 = "";
	else str3 = str3.trim();
	
	if(str1.length == 0 && str2.length == 0 && str3.length == 0)
	{
		return false;
	}
	else
	{
		return true;
	}
}

// Returns true if input is an integer value, or empty
function validateNumber(inValue) {
    if(isNaN(inValue.value))
		return false;
	if(inValue.value > 2147483647)
		return false;
    // This allows empty values
    return /^\d*$/.test(inValue.value.trim());
}

function validateLargeNumber(inValue) {
    if(isNaN(inValue.value))
		return false;

    // This allows empty values
    return /^\d*$/.test(inValue.value.trim());
}

// Returns true if input is an integer value and not empty
function validateNumberNotEmpty(inValue) {

    if(!validateFieldNotEmpty(inValue))
    {
		return false;
	}
    if(isNaN(inValue.value))
    {
		return false;
	}
	/*
	if(inValue.value > 2147483647)
	{
		return false;
    }
    */
    
    return /^\d+$/.test(inValue.value.trim());
}

//Validates that a string contains 1 or more valid numbers to the left of the decimal and requires the
//decimal with the specified number of digits following it. Returns true if valid, otherwise false.
function validateNumericDecimal(strValue, intDecimalPlaces) {
    if(intDecimalPlaces == 2){
        var objRegExp = /^\d\d*\.\d{2}$/;
    }
    else if(intDecimalPlaces == 4){
        var objRegExp = /^\d\d*\.\d{4}$/;
    }
    //check for decimal characters
    return objRegExp.test(strValue);
}

function trimAll(strValue) {
    //Removes leading and trailing spaces. Returns source string with whitespaces removed.
    var objRegExp = /^(\s*)$/;

    //check for all spaces
    if(objRegExp.test(strValue)) {
        strValue = strValue.replace(objRegExp, '');
        if(strValue.length == 0) {
            return strValue;
        }
    }

    //check for leading & trailing spaces
    objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
    if(objRegExp.test(strValue)) {
        //remove leading and trailing whitespace characters
        strValue = strValue.replace(objRegExp, '$2');
    }
    return strValue;
}

//Validates for a valid US Zipcode (5 digit format or zip -4 format). Returns true if valid Zipcode,
//otherwise returns false.
function validateZipCode(strValue) {
    // If the length is 9 and value is numeric, then convert the string value to the 5 digit-4 format
    if(strValue.value.length == 9 && validateNumber(strValue)){
		strValue.value = strValue.value.substring(0,5) + "-" + strValue.value.substring(5,9);		
    }
	
    var objRegExp  = /^(\d{5}(\-\d{4})?)$/;
    //check for valid US Zipcode
    return objRegExp.test(trimAll(strValue.value));
}

// Returns true if input is a date value, or empty
// Date must be in form MM/dd/yy, MM/dd/yyyy
function validateDate(date_field) 
{
        if (!date_field.value || date_field.value == '//')  
                return true;
        var in_date = date_field.value;
        var date_is_bad = 0;  

        // Check that the field contains valid date formatting...
        if (!allowInString(in_date,"/0123456789"))
                date_is_bad = 1; // invalid characters in date
        if (!date_is_bad) {
                var date_pieces = new Array();
                date_pieces = in_date.split("/");
                if (date_pieces.length == 2) {
                        var d = new Date();
                        in_date = in_date + "/" + get_full_year(d);
                        date_pieces = in_date.split("/");
                }
                if (date_pieces.length != 3 || parseInt(date_pieces[0],10) < 1 || parseInt(date_pieces[0],10) > 12 
                                || parseInt(date_pieces[1],10) < 1 || parseInt(date_pieces[1],10) > 31
                                || (date_pieces[0].length != 1 && (date_pieces[0].length != 2))
                                || (date_pieces[1].length != 1 && (date_pieces[1].length != 2))
                                || (date_pieces[2].length != 2 && date_pieces[2].length != 4)) {
                        date_is_bad = 6;  // date is not in format of m[m]/d[d]/yy[yy]
                }
        }
        if (date_is_bad) {
                return (false);
        }
        
        return true;
}       

// checks to see if date is between yearsBefore and yearsAfter
function validateYearRange(in_date, yearsBefore, yearsAfter) {
        var ms = Date.parse(in_date);
        var d = new Date();
        d.setTime(ms);
    		var newDataString = d.toLocaleString();
    		var return_month = parseInt(d.getMonth() + 1).toString();
    		return_month = (return_month.length==1 ? "0" : "") + return_month; 
    		var newDataString =  parseInt(d.getDate()).toString();
    		newDataString = (newDataString.length==1 ? "0" : "") + newDataString; 
        newDataString = return_month + "/" + newDataString + "/" + get_full_year(d);

        var newDate = new Date(newDataString);
        var currentDate = new Date();
        var currentYear = currentDate.getFullYear();

    		if(newDate.getFullYear() > (currentYear + yearsAfter))
    			return false;
    		else if(newDate.getFullYear() < (currentYear - yearsBefore))
    			return false;

	return true;
}

// Returns a four digit year based on a passed date containing
// either a two or four digit year. For two digit years, uses 
// a pivot point of 1970 to determine the correct century.
function get_full_year(d) {
		var y = ""
		if (d.getFullYear() != null)
		{
			y = d.getFullYear();
			if (y < 1970) y+= 100;		
		} else
		{	
	        y = d.getYear();
	        if (y > 69  && y < 100) y += 1900;
	        if (y < 1000) y += 2000;
		}
        return y;
}
// Returns true if inString containes only characters in RefString
// Returns false otherwise
function allowInString (InString, RefString)  {
        if(InString.length==0) return (false);
        for (var Count=0; Count < InString.length; Count++)  {
        var TempChar= InString.substring (Count, Count+1);
      if (RefString.indexOf (TempChar, 0)==-1)  
        return (false);
   }
   return (true);
}


// Returns true if input is a date value and is not empty
// Uses validateDate function
function validateDateNotEmpty(inValue) {
    var d = new Date();
    
    if(inValue.value.trim() == "")
    		return false;    
    else 
        return validateDate(inValue);
}

function validateFieldNotEmpty(sourceField) {

    if (sourceField == null ||
        sourceField.value == null ||
        sourceField.value.trim().length <= 0) {
        return false;
    }
    else {
        return true;
    }
}

function validateSearchFields() {
    var allEmpty = true;
    
    for(var i=0; i < arguments.length && allEmpty; i++) {
        if(validateFieldNotEmpty(arguments[i])) {
            allEmpty = false;
        }
    }
    
    if(allEmpty) {
        alert('You must enter at least 1 search value.');
        return false;
    }
    else {
        return true;   
    }   
}

function validateDependentEqualsSource(sourceField, dependentSourceField) {

    if (sourceField == null) {
        return true;
    }
    else if ((dependentSourceField == null) || (dependentSourceField.value != sourceField.value)) {
		return false;
    }
    else {
		return true;
	}
}

function validateDependentFieldNotEmpty(sourceField, dependentSourceField) {

    if (sourceField == null ||
        sourceField.checked == false) 
    {        
        return true;
    }
    else 
    {
		if (dependentSourceField == null ||
			dependentSourceField.value.trim().length <= 0) 
	    {
			return false;	
		}
		else {
			return true;
		}
        
    }
}

function validateDependentRadioNotEmpty(sourceField, dependentSourceField) {

    if (sourceField == null) {        
        return true;
    }
    else if (sourceField.checked) {
		if (dependentSourceField == null || dependentSourceField.value.trim().length <= 0) {
			return false;	
		}
		else {
			return true;
		}
    }
    else {
		return true;
	}
}

function validateDependentZipCodeOfCheck(sourceCheckField, dependentSourceField) {
    if (sourceCheckField == null ||
        sourceCheckField.checked == false) {        
        return true;
    }

    return validateZipCode(dependentSourceField);
}


function validateDependentDropDownOfCheckNotEmpty(sourceCheckField, dependentSourceField) {

    if (sourceCheckField == null ||
        sourceCheckField.checked == false) {        
        return true;
    }
    else {
		if (dependentSourceField == null || 
			dependentSourceField.options == null ||
			dependentSourceField.selectedIndex == null ||
			dependentSourceField.selectedIndex == -1) {
			
			return false;	
		}
		else {
			var val = dependentSourceField.options[dependentSourceField.selectedIndex];
			if(val == null || val.value == null || val.value.length <=0)
				return false;
			else
				return true;
		}
    }
}

function validateDependentCheckOfCheck(sourceCheckField, dependentCheckField) {

    if ((sourceCheckField == null) ||
        (sourceCheckField.checked == false)) {        
        
        // return TRUE if The Dependent is checked.
        if ((dependentCheckField != null) &&
            (dependentCheckField.checked == true)) {
                return true;
        }
    }
    else {
        // return TRUE if The Dependent is not checked 
        if ((dependentCheckField == null) ||
            (dependentCheckField.checked == false)) {  
                return true;
        }
    }
    
    return false;
}

function validateToDateGreaterThenFromDate(fromDateField, toDateField) {

    if (fromDateField != null && toDateField != null) {
		if (!validateDate(toDateField))
			return false;
		if (validateDate(fromDateField)) {
			var fromDate = new Date(), toDate = new Date();
			fromDate.setTime(Date.parse(fromDateField.value));
			toDate.setTime(Date.parse(toDateField.value));
			fromDate.setFullYear(get_full_year(fromDate));
			toDate.setFullYear(get_full_year(toDate));

			if(fromDate > toDate) {
				return false;
			}				
		}
    }
    return true;
}

function validateToDecimalGreaterThenFromDecimal(fromCurrField, toCurrField) {

    if(!validateDependentFieldNotEmpty(fromCurrField, toCurrField)) {
        return false;
    }
    if (fromCurrField != null && toCurrField != null) {
		if (!validateCurrency(toCurrField))
			return false;
		if (validateCurrency(fromCurrField)) {
			var fromAmount, toAmount;
			fromAmount = parseFloat(fromCurrField.value);
			toAmount = parseFloat(toCurrField.value);

			if(fromAmount > toAmount) {
				return false;
			}				
		}
    }
    return true;
}

function validateFieldNotZero(sourceField) {

    if (sourceField == null ||
        sourceField.value == 0) {
        return false;
    }
    else {
        return true;
    }
}

function validateNotEmptyAlphaNumeric(sourceField) {
   if(!validateFieldNotEmpty(sourceField)) {
   	return false;
   }
   
   if(!validateAlphaNumeric(sourceField)) {
   	return false;	
   }

   return true;
}

function validateAlphaNumeric(sourceField) {
    var allowStr = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#% ";
    sourceField.value = sourceField.value.trim();
    if(sourceField.value.length > 0) { 
        if(!allowInString(sourceField.value,allowStr)) {
            return false;
        }
    }
    return true;
}

function validateAlpha(sourceField) {
    var allowStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz?% ";
    sourceField.value = sourceField.value.trim();
    if(sourceField.value.length > 0) { 
        if(!allowInString(sourceField.value,allowStr)) {
            return false;
        }
    }
    return true;
}

function CheckForMaxLength(theField)
{
    if (theField != null)
    {
        if (theField.value.length == theField.maxLength)
        {
            showValidationError(theField, "Max field size ( " + theField.maxLength + " ) reached.");
        }
        else
        {
            clearValidationError(theField);
        }
    }
}

var clickCounter = 0;
function SubmitOnce()
{
    clickCounter++;
    if (clickCounter > 1) {
        alert("Please submit the form only once.");
        return false;
    }
    else{
        return true;
    }
}

function SubmitReset()
{
    clickCounter = 0;
}

var skipFormValidation = false;

function validateForm() {
    return validateForm(false);
}

var pgValidatables = null;
function updatePgValidatables()
{
    pgValidatables = new Array();
    var lField = null;
    for(i=0; i<document.all.length; i++)
    {
        lField = document.all[i];
        if (lField.validate != null)
        {
            pgValidatables[pgValidatables.length] = lField;
        }
    }
}

function validateForm(isChildFrame) {
    if (!SubmitOnce()) {
        return true;
    }
    
	document.body.style.cursor='wait';

    clearValidationErrors();

    if (skipFormValidation == true) {
        return false;
    }
    
    var errFound;
    errFound = false;

    if (pgValidatables == null) {
        updatePgValidatables();
    }
    
    for(i=0; i<pgValidatables.length; i++) {
        if (!validateField(pgValidatables[i], isChildFrame))
        {
			document.body.style.cursor='default';
            errFound = true;
        }
    }

    if (errFound) 
    {
        SubmitReset();
    }
    // else enable all fields before the submission
    else
    {
        for(i=0; i<document.all.length; i++)
        {
            document.all[i].disabled=false;
        }
    }
    
	return errFound;
}

function validateField(rField, isChildFrame)
{
    var i;
    
    if (rField.UpdateDate != null)
    {
        rField.UpdateDate();
    }
    
    if (rField.validate != null)
    {
        for (i = 0; i < rField.validate.length; i++)
        {
            rField.CurrentIndex = i;
            if (!rField.validate[i]())
            {
                if (window[rField.name + "_val_icon"] != null) {
                    window[rField.name + "_val_icon"].style.visibility="visible";
                }

                if (isChildFrame)
                {
                    if (top.window["ErrorDesc"] != null &&
                        rField.errorMsg != null) {
                        top.window["ErrorDesc"].innerHTML += "<li>" + document.forms[0][i].errorMsg + "</li>";
                    }
                }
                else
                {
                    if (rField.errorMsg[i] != null) {
                        if (window["ErrorDesc"] != null) {
                            window["ErrorDesc"].innerHTML += "<li>" + rField.errorMsg[i] + "</li>";
                        }
                        window[rField.name + "_Err_Text"].innerHTML = rField.errorMsg[i];
                    }
                }

                return false;
            }
       }
    }
   
    if (rField.serverError != null)
    {
        showValidationError(rField, rField.serverError);
        return true;
    }
    else
    {
        return true;
    }
}

function showValidationError(rField, rErrMsg) {

    if (window["ErrorDesc"] != null) {
        window["ErrorDesc"].innerHTML += "<li>" + rErrMsg + "</li>";
    }
    window[rField.name + "_Err_Text"].innerHTML = rErrMsg;
    
    if (window[rField.name + "_val_icon"] != null) {
        window[rField.name + "_val_icon"].style.visibility="visible";
    }
}

function clearValidationError(rField) {
    if (window[rField.name + "_val_icon"] != null) {
        window[rField.name + "_val_icon"].style.visibility="hidden";
    }
}

function clearValidationErrors() {

    if (window["ErrorDesc"] != null) {
        window["ErrorDesc"].innerHTML = "";
    }

    if (pgValidatables == null) {
        updatePgValidatables();
    }

    for(i=0; i<pgValidatables.length; i++) {
        clearValidationError(pgValidatables[i])
    }
}

function validateFieldDoesNotContainPOBox(depField, sourceField) {

	if(sourceField.value == null) return true;

	var address = sourceField.value;
	
	while(true)
	{
		var pos = address.indexOf('.', 0);
		if(pos != -1 && (pos < address.length - 2))
			address = address.substring(0, pos) + address.substring(pos + 1, address.length);
		else
			break;
	}
	while(true)
	{
		var pos = address.indexOf(' ', 0);
		if(pos != -1 && (pos < address.length - 2))
			address = address.substring(0, pos) + address.substring(pos + 1, address.length);
		else
			break;
	}

	return (address.toUpperCase().indexOf("POBOX") != -1 ||
		address.toUpperCase().indexOf("PO BOX") != -1) ? false : true;
}








function openCalendar(calID)
{   
   openCalendar(calID, null, null);
}

function openCalendar(calID, startYearOffSet, endYearOffSet)
{
	 var urlSuffix;
    document.all[calID].UpdateDate();
    
    if (validateDate(document.all[calID]))
    {
        var mm = document.forms[0][calID+'MonthTextBox'].value;
        var dd = document.forms[0][calID+'DayTextBox'].value;
        var yyyy = document.forms[0][calID+'YearTextBox'].value;        
        
        urlSuffix = '&mm=' + mm + '&dd=' + dd + '&yyyy=' + yyyy;
        if (startYearOffSet != null)       
			urlSuffix += '&sYear=' + startYearOffSet;
			
		if (endYearOffSet != null)
			urlSuffix += '&eYear=' + endYearOffSet;
    }
    else
    {
        urlSuffix = '';
    }
    
    openWindowInner('/common/util/CalendarPopUp.aspx?calID=' + calID + urlSuffix, 'calendar', 240, 220, 'no', 'no');
}

function calendarUpdate(calID, calMonth, calDay, calYear) 
{
	if (calID == null)
	{
	    return;
	}
	
	document.forms[0][calID+'MonthTextBox'].value = calMonth;
	document.forms[0][calID+'DayTextBox'].value = calDay;
	document.forms[0][calID+'YearTextBox'].value = calYear;
	
	document.all[calID].UpdateDate();
	
	document.forms[0][calID+'YearTextBox'].focus();
}

function openWindowInner(url, name, newH, newW, scrollbars, resizable)
{
    isNav=(navigator.appName=="Netscape")?true:false;

    isIE=(navigator.appName.indexOf("Microsoft") != -1)?true:false;

    if (isNav)
    {
        newH = newH + 50;
        newW = newW + 50;
    }

    x = screen.width;
    y = screen.height;

    sX = (x/2)-(newW/2);
    sY = (y/2)-(newH/2);

    features='menubar=no,status=no,location=no,toolbar=no,directories=no,scrollbars=' + scrollbars + ',resizable=' + resizable;

    if (isNav)
    {
        features += ',outerHeight=' + newH + ',outerWidth=' + newW + ',screenX=' + sX + ',screenY=' + sY;
    }
    else
    {
        features += ',height=' + newH + ',width=' + newW + ',left=' + sX + ',top=' + sY;
    }

    if (name=='modal'||name=='modal2')
    {
        features += ',model=yes,unadorned=yes,directories=no,fullscreen=no';
    }

    newWin=window.open(url,name,features);

	// for modal windows, set the modal reference and call the check parent state
    if (name=='modal'||name=='modal2')
    {
        top.document.modalPopup=newWin;
        
        // we have to set timeout because it take a couple milliseconds to open the new window
		setTimeout ("callCheckParentState(newWin)", 1000);        
        return newWin;
    }
    // else if just window, set reference and call set window reference
    else if(name=='nonmodal')
    {
		top.document.nonmodalPopup=newWin;
		
        // we have to set timeout because it take a couple milliseconds to open the new window
		setTimeout ("callCheckNonModalState(newWin)", 1000);
		return newWin;
    }
}

// calls checkParentState on new window (which in turn will keep passing
// reference back to parent window)
function callCheckParentState(win)
{
	if(win && win.checkParentState)
		win.checkParentState();
}

// calls setWindowReference on new window (which in turn will keep passing
// reference back to parent window)
function callCheckNonModalState(win)
{
	if(win && win.checkNonModalState)
		win.checkNonModalState();
}

// if window popup open, set focus, show message and return true
function isPopupOpen()
{
	if(top.document.nonmodalPopup != null &&
		!top.document.nonmodalPopup.closed)
	{
		top.document.nonmodalPopup.focus();
		top.document.nonmodalPopup.alert('Please submit your comments & close out any remaining pop-up windows before leaving the current customer.');
		return true;
	}
	else if(top.document.modalPopup != null &&
		!top.document.modalPopup.closed)
	{
		top.document.modalPopup.focus();
		top.document.modalPopup.alert('Please submit your comments & close out any remaining pop-up windows before leaving the current customer.');
		return true;
	}
	else
	{
		return false;
	}
}

function setNonModalPopup(win)
{
	top.document.nonmodalPopup=win;
}

function setModalPopup(win)
{
	top.document.modalPopup=win;
}

function reOpenModel(modelH, modelW)
{
    var myModel = top.document.modalPopup;
    if (myModel != null)
    {
        var url = myModel.location;
        var modelName = myModel.name;
        openWindowInner(url, modelName, modelH, modelW, 'yes', 'yes');
    }
}

function openWindow(url, name)
{
    return openWindowInner(url, name, 600, 800, 'yes', 'yes');
}

function openSizedWindow(url, name, height, width)
{
	return openWindowInner(url, name, height, width, 'yes', 'yes');	
}

function setFocus()
{
	setTimeout ("focusOnModalPop()", 300);
    /*
    popupRef=getModalPopup();

    if (popupRef!=null)
    {
        setTimeout ("focusOnModalPop(popupRef)", 100);
    }
    */
}

function setPopupWindow(win)
{
	top.document.modalPopup=win;
}

function getModalPopup()
{
    popup=top.document.modalPopup;
	
	if(popup && popup != null && !popup.closed)
		return popup;
	else
		return null;
}

function focusOnModalPop()
{
    var popupRef=top.document.modalPopup;
    if(popupRef && popupRef != null && !popupRef.closed)
		popupRef.focus();
}

// in javascript, just make sure field is there; real validation in code behind
function validateExternalKeywords(sourceField) 
{ 
    return validateFieldNotEmpty(sourceField); 
} 

// validation in the code behind, not here
function validateBonusParent(sourceField)
{
    return true;
}

function confirmDelete()
{
   return confirm('This action will permenately delete this item. Click OK to confirm.');
}
