
	function Check(e,mode)
	{
		if (mode == "check")
		{
			e.checked = true;
		}
		else
		{
			e.checked = false;
		}
		Highlight(e,mode);
	}
	
	function SetAll(mode)
	{
		var dl = document.dumpList;
		var len = dl.elements.length;
		for (var i = 0; i < len; i++) 
		{
			var e = dl.elements[i];
			if (e.name.indexOf("chk") == 0)
			{
				Check(e,mode);
			}
		}
	}
	
	function Highlight(e,mode)
	{
		var r = null;
		r = e.parentElement.parentElement;
		if (r)
		{
			if (mode == "check")
			{
				r.className = "rowhighlighted";
			}
			else
			{
				r.className = "rownormal";
			}
		}
	}

	function Toggle(e)
	{
		if (e.checked)
		{
			Highlight(e,"check");
		}
		else
		{
			Highlight(e,"clear");
		}
	}
	
	function SetAction1Chosen ()
	{
		if (document.frmAction1.listAction1.value != "")
		{
			var dl = document.dumpList;
			dl.actionchosen.value = document.frmAction1.listAction1.value;
			dl.submit();
		}
		else
		{
			alert("Please select an action");
		}
	}

	function SetAction2Chosen ()
	{
		if (document.frmAction2.listAction2.value != "")
		{
			var dl = document.dumpList;
			dl.actionchosen.value = document.frmAction2.listAction2.value;
			dl.submit();
		}
		else
		{
			alert("Please select an action");
		};
	}

  function submitViaEnter(evt)
  {
    evt = (evt) ? evt : event;
    var target = (evt.target) ? evt.target : evt.srcElement;
    var form = target.form;
    var charCode = (evt.charCode) ? evt.charCode:
      ((evt.which) ? evt.which : evt.keyCode);
    if (charCode == 13 || charCode == 3) {
      form.submit();
      return false;
    }
  }

  function pause(numberMillis) {
    //var dialogScript =
    //       'window.setTimeout(' +
    //       ' function () { window.close(); }, ' + numberMillis + ');';
    //var result =
    //window.showModalDialog(
    //       'javascript:document.writeln(' +
    //        '"<script>' + dialogScript + '<' + '/script>")');
  }

  function pokeList(iListNo,cListDetail) {
    if (iListNo == 1) {
      parent.frmLists.list1.value=cListDetail;
    } else if (iListNo == 2) {
      parent.frmLists.list2.value=cListDetail;
    } else if (iListNo == 3) {
      parent.frmLists.list3.value=cListDetail;
    }
  }

  function alter(object) {
    object.target = "postframe";
    return true;
  }

  function trimAll(sString) {
    while (sString.substring(0,1) == ' ') {
      sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ') {
      sString = sString.substring(0,sString.length-1);
    }
    return sString;
  }

  function insertFlash(cDivId, iWidth, iHeight, cSwf, cFlashVars) {
    var d = document.getElementById(cDivId);
    d.innerHTML =
      '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width=' + iWidth + ' height=' + iHeight +'><param name="movie" value="' + cSwf + '"><param name="quality" value="high"><param name="FlashVars" value="' + cFlashVars + '"><embed src="' + cSwf + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width=' + iWidth + ' height=' + iHeight + '></embed></object>';
  }

  var isLoaded = false;
  function init() {
    isLoaded = true;
  }

  function showHideElement(source,img,target) {
    sourceElem = document.getElementById(source);
    imgElem = document.getElementById(img);
    targetElem = document.getElementById(target);
    if (imgElem.src.match("hide")) {
      targetElem.style.display = "none";
      imgElem.src = "images/website/icon_show.jpg";
    } else {
      targetElem.style.display = "";
      imgElem.src = "images/website/icon_hide.jpg";
    }
  }

  function returnToTab() {
    //alert(event.keyCode);
    if(event.keyCode==13) event.keyCode=9;
  }

var dv_dtCh= "/";
var dv_minYear=1900;
var dv_maxYear=2100;

function dv_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 dv_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 dv_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 dv_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 dv_isDate(dtStr){
	var daysInMonth = dv_daysArray(12)
	var pos1=dtStr.indexOf(dv_dtCh)
	var pos2=dtStr.indexOf(dv_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 2
	}
	if (strMonth.length<1 || month<1 || month>12){
		return 3
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>dv_daysInFebruary(year)) || day > daysInMonth[month]){
		return 4
	}
	if (strYear.length != 4 || year==0 || year<dv_minYear || year>dv_maxYear){
		return 5
	}
	if (dtStr.indexOf(dv_dtCh,pos2+1)!=-1 || dv_isInteger(dv_stripCharsInBag(dtStr, dv_dtCh))==false){
		return 6
	}
  return 1
}

function dv_validateDate(dateFld,label){
  if (dateFld == "dd/mm/yyyy") {
    return true
  }
  validnum = dv_isDate(dateFld.value)
  if (validnum==1)
    return true
  switch (validnum) {
    case 2:
  		alert("The date format in '" + decodeURI(label) + "' should be : dd/mm/yyyy")
  		dateFld.focus()
      return false
      break
    case 3:
  		alert("Please enter a valid month in '" + decodeURI(label) + "'")
  		dateFld.focus()
      return false
      break
    case 4:
  		alert("Please enter a valid day in '" + decodeURI(label) + "'")
  		dateFld.focus()
      return false
      break
    case 5:
  		alert("Please enter a valid 4 digit year between " + dv_minYear + " and " + dv_maxYear + " in '" + decodeURI(label) + "'")
  		dateFld.focus()
      return false
      break
    case 6:
  		alert("Please enter a valid date in '" + decodeURI(label) + "'")
  		dateFld.focus()
      return false
      break
    default:
  		return false
	}
}



