//popupbox
function popup(path,width,height,scroll)
{
	if (path != "")
	{
		window.open(path, "_blank", "width="+width+",height="+height+", top=100, left=100, titlebar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars="+scroll+", status=no, toolbar=no");
	}
}

/*Reset Date*/
/***********************************************************************/
// Validate Date/Time
function isDate(y, m, d) {   
	with(new Date(y, m, d)) { 
		return(getDate() == d && getMonth() == m); 
	} 
}

// Reset Date
function ResetDate(YearFieldID, MonthFieldID, DayFieldID) {   
	var intOriginalDay, intMaxDay;
	
	objYearSelected = document.getElementById(YearFieldID);
	objMonthSelected = document.getElementById(MonthFieldID);
	objDaySelected = document.getElementById(DayFieldID);
	
	var SelectedYearValue = objYearSelected.options[objYearSelected.selectedIndex].value;
	if (SelectedYearValue == "Nothing") {
		SelectedYearValue = objYearSelected.options[1].value;
	}

	if (objMonthSelected.options[objMonthSelected.selectedIndex].value != "Nothing") {

		if (isDate(SelectedYearValue, objMonthSelected.selectedIndex - 1, 31)) {  
 			intMaxDay = 31; 
		} else if (	isDate(SelectedYearValue, objMonthSelected.selectedIndex - 1, 30)) {  
 			intMaxDay = 30; 
		} else if (isDate(SelectedYearValue, objMonthSelected.selectedIndex - 1, 29)) {  
 			intMaxDay = 29; 
		} else if (isDate(SelectedYearValue, objMonthSelected.selectedIndex - 1, 28)) {  
 			intMaxDay = 28; 
		}
	} else {
		intMaxDay = 31;
	}
	
 	intOriginalDay = objDaySelected.selectedIndex;   
		
 	for (var i = objDaySelected.length; i > 0; i--)  
 		objDaySelected.options[0] = null;

	objDaySelected.options[0] = new Option("-", "Nothing", false, false);
	for (var i = 1; i <= intMaxDay; i++)  
		objDaySelected.options[objDaySelected.length] = new Option(i, i, false, false);    

	if ((intOriginalDay) > intMaxDay) {  
		intOriginalDay = 0; 
	} 
	
	objDaySelected.selectedIndex = intOriginalDay; 
}  

/*String Trim Function*/
/***********************************************************************/
function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function

/*Tools*/
/********************************************************************/
// Browser Detection
function checkIt(string)
{
	// Return True for FireFox
	// Return False for IE
	
	var detect = navigator.userAgent.toLowerCase();
	var OS,browser,version,total,thestring;

	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

// Trap Enter Key for text box
function trapEnter(e, enterFunction){
     if (!e) e = window.event;
     if (e.keyCode == 13){
          e.cancelBubble = true;
          if (e.returnValue) e.returnValue = false;
          if (e.stopPropagation) e.stopPropagation();
          if (enterFunction) eval(enterFunction);
          return false;
     } else {
          return true;
     }     
}
/********************************************************************/
function getElementsByClass(searchClass,node,tag) {
  var classElements = new Array();
  if (node == null)
    node = document;
  if (tag == null)
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if (pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}

// Function:    interceptEnterKeyPress
/********************************************************************/
function interceptEnterKeyPress(e, sButtonId)
{
    var unicode=e.keyCode? e.keyCode : e.charCode
    if (unicode == 13)
    {                               
        document.getElementById(sButtonId).click();
        return false;
    }
}