function newSizewin(page,W,H){
         /*Popwin = window.open(page,'', 
            'width='+ W+ ',height='+ H+',scrollbars=0,'+
            'resizable=1,status=0,menubar=0,toolbar=0,'+
            'location=0,directories=0,copyhistory=0'); */
		popImg = window.open(page, '',
       "toolbar=yes,scrollbars=yes,menubar=yes,addressbar=yes,resizable=yes,width=" 
       + (parseInt(W))  + ",height=" 
       + (parseInt(H))) 
      }
function deleteConfirm(flID, ctID, ctty) {
	var msg;
	msg = "Are you sure you want to delete this content?";
	
	var emEdit;
	emEdit = document.add_Content.emEdit.value;
	if (confirm(msg)) {
		location.href="deletePermanent.asp?fl=" + flID + "&ct=" + ctID + "&ctty=" + ctty + "&emEdit=" + emEdit;
	} else {
		//return false;
	}
}
function lockUnlock(flID, ct, willLock) {
	var msg;
	var locationhref;
	var emEdit1;
	emEdit1 = document.add_Content.emEdit.value;
	if(willLock == 1) {
		msg = "Are you sure you want to lock this content?"
		locationhref = "lock_Content.asp?fl=" + flID + "&ct=" + ct + "&emEdit=" + emEdit1;
	} else {
		msg = "Are you sure you want to un-lock this content?"
		locationhref = "lock_UnContent.asp?fl=" + flID + "&ct=" + ct + "&emEdit=" + emEdit1;
	}
	if(confirm(msg)) {
		location.href = locationhref;
	}
}

function updateFileAttr() {
	var msg;
	msg = "This will update both the preview and the live sites.";
	if (confirm(msg)) {
		document.add_Content.cmdHidUpdatePrint.value = "updateFile";
		document.add_Content.submit();
	}
}

function printPage(fl, isBP) {
			var optionCounter;
			window.open("printerFriendly.asp?fileID=" +fl+"&isBP="+isBP);
	   }
	   
var newWin;
function popWindow(url,wwidth,wheight,wprint,wscroll) {
	newWin = open(url,"pop_up","toolbar="+wprint+",titlebar=no,directories=0,status=0,menubar=0,scrollbars="+wscroll+",resizable=1,width="+wwidth+",height="+wheight+",screenX=20,screenY=20,top=20,left=20");
}

// Disables on-Enter key : disabled on 4/26/2004
//============================================================
/* function kH(e) {
	
	var pK = document.all? window.event.keyCode:e.which;
	return pK != 13;
	
}
document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS);
*/
// End
//============================================================


//================================================================
// Handles The "Enter key, it moves the cursor to the next field
//================================================================

/*
function handleEnter (field,event) {}
	*/
function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			//i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	}      
	

//===============================================================



function  validateNumeric( strValue ) {
/******************************************************************************
DESCRIPTION: Validates that a string contains only valid numbers.

PARAMETERS:
   strValue - String to be tested for validity
   
RETURNS:
   True if valid, otherwise false.
******************************************************************************/
  var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/; 
 
  //check for numeric characters 
  return objRegExp.test(strValue);
}

function isEmail(elm) {
	if (elm.value.indexOf("@") != "-1" &&
		elm.value.indexOf(".") != "-1" &&
		elm.value != "")
	return true;
	else return false;
}



//============================================ DATE FUNCTION : Start ================================================
function validateUSDate( strValue ) {
/************************************************
DESCRIPTION: Validates that a string contains only 
    valid dates with 2 digit month, 2 digit day, 
    4 digit year. Date separator can be ., -, or /.
    Uses combination of regular expressions and 
    string parsing to validate date.
    Ex. mm/dd/yyyy or mm-dd-yyyy or mm.dd.yyyy
    
PARAMETERS:
   strValue - String to be tested for validity
   
RETURNS:
   True if valid, otherwise false.
   
REMARKS:
   Avoids some of the limitations of the Date.parse()
   method such as the date separator character.
*************************************************/
  var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
 
  //check to see if in correct format
  if(!objRegExp.test(strValue)){
    return false; //doesn't match pattern, bad date
    
  } else{
    var arrayDate = strValue.split(RegExp.$1); //split date into month, day, year
    
	var intDay = parseInt(arrayDate[1],10); 
	var intYear = parseInt(arrayDate[2],10);
    var intMonth = parseInt(arrayDate[0],10);
    //alert("Month=" + intMonth + "\nday=" + intDay + "\nYear=" +  intYear );
    
	
	//check for valid month
	if(intMonth > 12 || intMonth < 1) {
		return false;
	}
	
    //create a lookup for months not equal to Feb.
    var arrayLookup = { '01' : 31,
						'03' : 31,
						'04' : 30,
						'05' : 31,
						'06' : 30,
						'07' : 31,
                        '08' : 31,
                        '09' : 30,
                        '10' : 31,
                        '11' : 30,
                        '12' : 31,
                        '1' : 31,
						'3' : 31,
						'4' : 30,
						'5' : 31,
						'6' : 30,
						'7' : 31,
                        '8' : 31,
                        '9' : 30}
                        
    //check if month value and day value agree
    if(arrayLookup[arrayDate[0]] != null) {
      if(intDay <= arrayLookup[arrayDate[0]] && intDay != 0)
        return true; //found in lookup table, good date
    } 
		
    //check for February
	var booLeapYear = (intYear % 4 == 0 && (intYear % 100 != 0 || intYear % 400 == 0));
    if( ((booLeapYear && intDay <= 29) || (!booLeapYear && intDay <=28)) && intDay !=0)
      return true; //Feb. had valid number of days
  }
  return false; //any other values, bad date
}
//============================================ DATE FUNCTION : End ================================================



//==============================================================================
//===============================================================
 //==== GENERIC FUNCTIONS FOR CHECBOX AND RADIO BUTTONS===========
 //===============================================================
 function getSelectedCheckbox(buttonGroup) {
// Go through all the check boxes. return an array of all the ones
// that are selected (their position numbers). if no boxes were checked,
// returned array will be empty (length will be zero)
	var retArr = new Array();
	var lastElement = 0;
	if (buttonGroup[0]) { // if the button group is an array (one check box is not an array)
	   for (var i=0; i<buttonGroup.length; i++) {
	      if (buttonGroup[i].checked) {
	         retArr.length = lastElement;
	         retArr[lastElement] = i;
	         lastElement++;
	      }
	   }
	} else { // There is only one check box (it's not an array)
	   if (buttonGroup.checked) { // if the one check box is checked
	      retArr.length = lastElement;
	      retArr[lastElement] = 0; // return zero as the only array value
	   }
	}
	return retArr;
} // Ends the "getSelectedCheckbox" function

function getSelectedCheckboxValue(buttonGroup) {
   // return an array of values selected in the check box group. if no boxes
   // were checked, returned array will be empty (length will be zero)
   var retArr = new Array(); // set up empty array for the return values
   var selectedItems = getSelectedCheckbox(buttonGroup);
   if (selectedItems.length != 0) { // if there was something selected
      retArr.length = selectedItems.length;
      for (var i=0; i<selectedItems.length; i++) {
         if (buttonGroup[selectedItems[i]]) { // Make sure it's an array
            retArr[i] = buttonGroup[selectedItems[i]].value;
         } else { // It's not an array (there's just one check box and it's selected)
            retArr[i] = buttonGroup.value;// return that value
         }
      }
   }
   return retArr;
} // Ends the "getSelectedCheckBoxValue" function



	function getSelectedRadio(buttonGroup) {
	   // returns the array number of the selected radio button or -1 if no button is selected
	   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
	      for (var i=0; i<buttonGroup.length; i++) {
	         if (buttonGroup[i].checked) {
	            return i
	         }
	      }
	   } else {
	      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
	   }
	   // if we get to this point, no radio button is selected
	   return -1;
	} // Ends the "getSelectedRadio" function

	function getSelectedRadioValue(buttonGroup) {
	   // returns the value of the selected radio button or "" if no button is selected
	   var i = getSelectedRadio(buttonGroup);
	   if (i == -1) {
	      return "";
	   } else {
	      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
	         return buttonGroup[i].value;
	      } else { // The button group is just the one button, and it is checked
	         return buttonGroup.value;
	      }
	   }
	} // Ends the "getSelectedRadioValue" function
//============================================================================================
