<!--


function confirmDelete(item){
  if(item==""){
    item = "item";
  }
  
  var agree=confirm("Are you sure you wish to delete this " + item + "?");
  if (agree){
  	return true ;
  }else{
  	return false ;
  }
  
}//end confirmDelete


/* search the dom for the job named */
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document;
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) {
    x=d.all[n];
  }
  for (i=0;!x&&i<d.forms.length;i++) {
    x=d.forms[i][n];
  }
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) {
    x=MM_findObj(n,d.layers[i].document);
  }
  if(!x && d.getElementById) {
    x=d.getElementById(n);
  }
  // alert('object ' + n + ' is ' + x);
  return x;
}

function setLabel(name, value) {
	var obj;
	if ((obj = MM_findObj(name)) != null) {
		obj.innerHTML = value;
	}else{
	  alert('object not found');
	}
}

function menuSubmit(area){
	document.form.area.value = area;
	document.form.submit();
}

function submitHiddenForm(page_count){
	document.form.page.value = page_count;
	document.form.submit();
}

/*
 * Function to return the value of a select box's selected row.
 */
 function getSelectsSelectedId(selectArr){
  for(i = 0; i <=selectArr.length-1; i++){
    if(selectArr.options[i].selected){
    var id = selectArr.options[i].value;
      return id;
    }//end if (selected)
  }//end for
}//end getSelectedId 

function selectToView(tmpform,area,fa,id){
	tmpform.area.value = area;
	tmpform.id.value = id;
	tmpform.fa.value = fa;
	tmpform.submit();
	return true;
}

function submitForm() {
	if (validateForm()) {
		document.form.submit();
		return true; // never get to here
	}
	return false;
}

function trim(str){
	return str.replace(/^\s*|\s*$/g,"");
}

// Declaring valid date character, minimum year and maximum year
var dtCh= "-";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
	for (i = 0; i < s.length; i++){
		// Check that current character is number.
		var c = s.charAt(i);
		if (((c < "0") || (c > "9"))) return false;
	}
	// All characters are numbers.
	return true;
}

function stripCharsInBag(s, bag){
		var i;
		var returnString = "";
		// Search through string's characters one by one.
		// If character is not in bag, append to returnString.
		for (i = 0; i < s.length; i++){
				var c = s.charAt(i);
				if (bag.indexOf(c) == -1) returnString += c;
		}
		return returnString;
}
function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
	// EXCEPT for centurial years which are not also divisible by 400.
	return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
	}
	return this
}

function y2k(number) { return (number < 1000) ? number + 1900 : number; }

/**
* check the date format
*/
function checkDateFormat(object,value){
	var selLength = value.length;

	if(selLength == 6){
	  var day = value.substring(0,2);
	  var month = value.substring(2,4);
	  var year = value.substring(4,6);
	  year = '20' + year;
	  object.value = day + '-' + month + '-' + year;
	}else if (selLength == 8 || selLength == 10){
	    var pos1 = 0;
		var pos2 = 0;
		pos1 = value.indexOf('/');
		if(pos1 > 0){
		  pos2 = value.indexOf('/',pos1+1);
		}else{
		  pos1 = value.indexOf('.');
		  if(pos1 > 0){
			pos2 = value.indexOf('.',pos1+1);
		  }else{
				pos1 = value.indexOf('-');
				if(pos1 > 0){
					pos2 = value.indexOf('-',pos1+1);
			  }
			}
		}

		if(pos1 == 2 && pos2 == 5){
		  var day = value.substring(0,2);
		  var month = value.substring(3,5);
		  if(selLength == 8){
			var year = value.substring(6,8);
			year = '20' + year;
		  }else{
			var year = value.substring(6,10);
		  }
		  object.value = day + '-' + month + '-' + year;
		}else if (selLength == 8){
		  var day = value.substring(0,2);
		  var month = value.substring(2,4);
		  var year = value.substring(4,8);
		  //year = '20' + year;
		  object.value = day + '-' + month + '-' + year;
		}
	}else if (selLength == 1 || selLength == 2){
	  if(selLength == 1){
			if(value == 'T' || value == 't'){
				var date = new Date();
				var day = date.getDate();
				if (day-0 < 10){
					day = '0' + day;
				}
			}else{
				var day = '0' + value;
			}
	  }else{
			var day = value;
	  }

	  var date = new Date();
//	  var strDate = date.toGMTString();

      // get the day month and years
      var month    = date.getMonth()+1;
	  if(month-0 < 10){
		month = '0' + month;
	  }
      var year = y2k(date.getYear());

	  object.value = day + '-' + month + '-' + year;
	}
}

function showRow(name) {
  var obj;
  if ((obj = MM_findObj(name)) != null) {
    obj.style.display = "";
  }
}

function hideRow(name) {
  var obj;
  if ((obj = MM_findObj(name)) != null) {
    obj.style.display = "none";
  }
}

function getNumOfDays(startDate,endDate){
  var dtCh= "-";
	var pos1=startDate.indexOf(dtCh);
	var pos2=startDate.indexOf(dtCh,pos1+1);
	var strStartDay=startDate.substring(0,pos1);
	var strStartMonth=startDate.substring(pos1+1,pos2);
	var strStartYear=startDate.substring(pos2+1);

	StartMonth= strStartMonth - 0 ;
	StartDay= strStartDay - 0;
	StartYear= strStartYear - 0;

	var endPos1=endDate.indexOf(dtCh);
	var endPos2=endDate.indexOf(dtCh,endPos1+1);
	var strEndDay=endDate.substring(0,endPos1);
	var strEndMonth=endDate.substring(endPos1+1,endPos2);
	var strEndYear=endDate.substring(endPos2+1);

	EndDay = strEndDay - 0;
	EndMonth= strEndMonth - 0;
	EndYear= strEndYear - 0;

	date2 = new Date(StartYear,StartMonth,StartDay);
	date1 = new Date(EndYear,EndMonth,EndDay);

	var difference =
			Date.UTC(EndYear,EndMonth-1,EndDay,0,0,0)
		- Date.UTC(StartYear,StartMonth-1,StartDay,0,0,0);
	return difference/1000/60/60/24;
}

function addOption(theSel, theText, theValue){
	var newOpt = new Option(theText, theValue);
	var selLength = theSel.length;
	theSel.options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex){
	var selLength = theSel.length;
	if(selLength>0)
	{
		theSel.options[theIndex] = null;
	}
}

function moveOptions(theSelFrom, theSelTo){

	var selLength = theSelFrom.length;
	var selectedText = new Array();
	var selectedValues = new Array();
	var selectedCount = 0;

	var i;
	// Find the selected Options in reverse order
	// and delete them from the 'from' Select.
	for(i=selLength-1; i>=0; i--)
	{
		if(theSelFrom.options[i].selected)
		{
			if(theSelFrom.options[i].value != "")
			{ selectedText[selectedCount] = theSelFrom.options[i].text;
				selectedValues[selectedCount] = theSelFrom.options[i].value;
				deleteOption(theSelFrom, i);
				selectedCount++;
			}
		}
	}

	// Add the selected text/values in reverse order.
	// This will add the Options to the 'to' Select
	// in the same order as they were in the 'from' Select.
	for(i=selectedCount-1; i>=0; i--)
	{
		addOption(theSelTo, selectedText[i], selectedValues[i]);
	}
}

function emptyOptions(theSelFrom, theSelTo){
	var selLength = theSelFrom.length;
	var selectedText = new Array();
	var selectedValues = new Array();
	var selectedCount = 0;

	var i;
	// Find the selected Options in reverse order
	// and delete them from the 'from' Select.
	for(i=selLength-1; i>=0; i--){
		if(theSelFrom.options[i].value != ""){
			selectedText[selectedCount] = theSelFrom.options[i].text;
			selectedValues[selectedCount] = theSelFrom.options[i].value;
			deleteOption(theSelFrom, i);
			selectedCount++;
		}
	}
	// Add the selected text/values in reverse order.
	// This will add the Options to the 'to' Select
	// in the same order as they were in the 'from' Select.
	for(i=selectedCount-1; i>=0; i--){
		addOption(theSelTo, selectedText[i], selectedValues[i]);
	}
}

	//parse the selected list items to the hidden input type
function setSelectedItems(theSelList, theTextOutput){

	var selLength = theSelList.length;
	var selectedText = new Array();
	var selectedValues = new Array();
	var selectString = '';

	var i;
	// Find the selected Options in order
	// and add them to the selected text array .
	if(selLength > 0){
	 for(i = 0; i < selLength; i++){
		 selectedText[i] = theSelList.options[i].value;
	 }
	}
	selLength = selectedText.length;
	if(selLength > 0){
	 for(j = 1; j < selLength; j++){
		 selectString += (j < (selLength -1)) ?  selectedText[j] + ',' : selectedText[j];
	 }
	}
	theTextOutput.value = selectString;
}


function isDate(dtStr){
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strDay=dtStr.substring(0,pos1);
	var strMonth=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1){
		//alert("The date format should be : dd-mm-yyyy")
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Please enter a valid month")
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Please enter a valid day")
		return false;
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		//alert("Please enter a valid date")
		return false;
	}
	return true;
}

function isDate2(dtStr){
    var daysInMonth = DaysArray(12);
    var pos1=dtStr.indexOf(dtCh);
    var pos2=dtStr.indexOf(dtCh,pos1+1);
    var strDay=dtStr.substring(0,pos1);
    var strMonth=dtStr.substring(pos1+1,pos2);
    var strYear=dtStr.substring(pos2+1);
    strYr=strYear;
    if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
    if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
    for (var i = 1; i <= 3; i++) {
        if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
    }
    month=parseInt(strMonth);
    day=parseInt(strDay);
    year=parseInt(strYr);
    if (pos1==-1 || pos2==-1){
        return "The date format should be : dd-mm-yyyy";
    }
    if (strMonth.length<1 || month<1 || month>12){
        return "Please enter a valid month";
    }
    if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
        return "Please enter a valid day";
    }
    if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
        return "Please enter a valid 4 digit year between "+minYear+" and "+maxYear;
    }
    if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
        return "Please enter a valid date";
    }
return 0;
}

function isNumeric(sText){
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}
-->
