<!--
var validated=true;  // global
//this form have not been submited before
var formSubmited=false;

// call this from onchange
function valid(vl,errm) // varying number of arguments
{
	var intCount;
	validated=true;
	// scan regular expressions
	for (intCount=2; intCount<valid.arguments.length; intCount++) 
	{
		var rx;
		//alert(valid.arguments[intCount]);
		rx=new RegExp(valid.arguments[intCount]);
		if ((a=rx.exec(vl))!=null && a[0].length==vl.length) {
			//alert("output:" + a[0]);
			return true;  // ok
		}
	}
	// no matches...
	if (errm != null) { alert(errm); }
	validated=false;  // tell onsubmit if necessary
	return false;
}

// This scans all the onchanged routines
function OnFrmSubmit(frm)
{	
	//The form has been submited before
	if (formSubmited)
		return false;
			
	// force validation of all fields	
	var intCount;
	validated=true;
	for (intCount=0;intCount<frm.elements.length && validated;intCount++) {
		if (frm.elements[intCount].type == "text" && frm.elements[intCount].onchange!=null) {			
			frm.elements[intCount].onchange();  // fake change
		}
	}
		
	//Validation pass, this form will be submitm, set the submitted flag = true
	if (validated)
		formSubmited = true;
			
	return validated;
}

function ValidLoginID(vl)
{
	rv=valid(vl,"Please enter a valid login ID",
			"[\\w-_][\\w-_][\\w-_][\\w-_]+");
	//if (rv)
	//	fld.value="(" + RegExp.$1 + ") " + RegExp.$2 + "-" + RegExp.$3;
	return rv;
}


function hideSearchOption(frmListByOption, frmPaging){
	document.getElementById("table1").style.display = "none";
	if(document.forms[frmPaging]){
	document.forms[frmPaging].HideOption.value = "true";
	}
	document.getElementById("HideOption1").value = "true";
	document.getElementById("Sp2").innerHTML = "<a href='' onClick='javascript:showSearchOption(\"frmListByOption\",\"frmPaging\");return false;'>More search options ...</a>";

}

function showSearchOption(frmListByOption, frmPaging){
	document.getElementById("table1").style.display = "";
	if(document.forms[frmPaging]){
	document.forms[frmPaging].HideOption.value = "false";
	}
	document.getElementById("HideOption1").value = "false";
	document.getElementById("Sp2").innerHTML = "<a href='' onClick='javascript:hideSearchOption(\"frmListByOption\",\"frmPaging\");return false;'>Hide search options ...</a>";	 
}

function ValidPassword(vl)
{
	rv=valid(vl,"Please enter a valid password",
			"[\\w-_][\\w-_][\\w-_][\\w-_][\\w-_][\\w-_]+");
	return rv;
}

function validJobID(v1)
{
	rv=valid(v1,"You have keyed in an incorrect Job ID. Please re-enter the Job ID, e.g. A1234","^[A-Za-z]?[0-9]*$");
	return rv;
}

function ValidJSEmail(vl)
{
	//return valid(vl, null, "[\\w-_]*[\\w-\\.]*\\@(jobstreet)\\.[\\w-_]*[\\w-\\.]*")
	return valid(vl, null, "[\\w-_\\.]+\\@(jobstreet)\\.[\\w-_\\.]+")
}

// Added function to allow enerpro email address in SNS
function ValidEnerProEmail(vl)
{
	return valid(vl, null, "[\\w-_\\.]+\\@(enerpro)\\.(com)\\.(sg)+")
}

function ValidOneEmail(vl)
{
	// Common typo error for common domains :
	//	 - hotmail.com
	//   - yahoo.com, yahoo.co.uk, yahoo.co.in
	//   - rediffmail.com
	//   - tm.net.my
	var arrTypo = new Array();
	var i = 0;
	
	arrTypo[0] = "[\\w-\\.]{1,}\\@[\\w-\\.\\@]{0,}(rediff|htomail|htomil|htomai|htomal|htomial|hotmil)s*.co[m]{0,1}[\\w\\.\\@]{0,}"
	arrTypo[1] = "[\\w-\\.]{1,}\\@[\\w-\\.]{1,}(rediff|rediffmail|hotmail|hotm[ail]s?).com[\\w-\\.\\@]{0,}"
	arrTypo[2] = "[\\w-\\.]{1,}\\@[\\w-\\.]{1,}(rediffmail|hotmail|hotm[ail]s?)[\\w-\\.]{1,}.com[\\w\\.\\@]{0,}"
	arrTypo[3] = "[\\w-\\.]{1,}\\@(rediffmail|hotmail)[\\w-\\.]{1,}.co[m]{0,1}[\\w-\\.\\@]{0,}"
	arrTypo[4] = "[\\w-\\.]{1,}\\@(rediffmail|hotmail).com[\\w-\\.\\@]{1,}"
	arrTypo[5] = "[\\w-\\.]{1,}\\@[\\w-\\.\\@]{1,}yahoo[\\w\\.]{1,}.(com|co.uk|co.in)"
	arrTypo[6] = "[\\w-\\.]{1,}\\@[\\w-\\.\\@]{1,}yahoo.(com|co.uk|co.in)"
	arrTypo[7] = "[\\w\\.\\@]{1,}\\@yahoo[\\w-\\.]{1,}.(com|co.uk|co.in)"
	arrTypo[8] = "[\\w-\\.]{1,}\\@[\\w-\\.\\@]{0,}yahoo[\\w]{0,}.com.in"
	arrTypo[9] = "[\\w-\\.]{1,}\\@[\\w-\\.\\@]{0,}yahoo[\\w]{0,}.com.uk"
	arrTypo[10] = "[\\w-\\.]{1,}\\@[\\w-\\.\\@]{0,}y(o|a)*ho{3,}[\\w]{0,}.(com|co.uk|co.in)"
	arrTypo[11] = "[\\w-\\.]{1,}\\@[\\w-\\.\\@]{0,}yahoo.uk.co[\\w-\\.]{0,}"
	arrTypo[12] = "[\\w-\\.]{1,}\\@[\\w-\\.\\@]{1,}tm[.,]net[.,]my[\\w]{1,}"
	arrTypo[13] = "[\\w-\\.]{1,}\\@[\\w-\\.\\@]{1,}tm[.,]net[.,]my"
	arrTypo[14] = "[\\w-\\.]{1,}\\@tm[.,]net[.,]my[\\w]{1,}"
	arrTypo[15] = "[\\w-\\.]{1,}\\@[\\w-\\.\\@]{1,}tm[.,]com[.,]my[\\w]{1,}"
	arrTypo[16] = "[\\w-\\.]{1,}\\@tm[.,]com[.,]my[\\w]{1,}"
	arrTypo[17] = "[\\w-\\.]{1,}\\@usa[.,]net[\\w-\\.\\@]{1,}"
	arrTypo[18] = "[\\w-\\.\\@]{1,}\\@[\\w-\\.\\@]{1,}usa[.,]net[\\w-\\.\\@]{1,}"
	arrTypo[19] = "[\\w-\\.\\@]{1,}\\@[\\w-\\.\\@]{1,}usa[.,]net"
	arrTypo[20] = "[\\w-\\.]{1,}\\@pacific[.,]net[.,]sg[\\w-\\.\\@]{1,}"
	arrTypo[21] = "[\\w-\\.]{1,}\\@[\\w-\\.\\@]{1,}pacific[.,]net[.,]sg"
	arrTypo[22] = "[\\w-\\.]{1,}\\@[\\w-\\.\\@]{1,}pacific[.,]net[.,]sg[\\w-\\.\\@]{1,}"
	//arrTypo[23] = "[\\w-\\.\\@]{0,}www.[\\w-\\.\\@]{0,}"
	
	// check valid email format
	if (rv=valid(vl,"Invalid email. Please enter a valid email.",
		"('|[\\w-_])+((\\.|\\'|\\`)[\\w-_]+)*\\@[\\w-_]+(\\.[\\w-_]+)+") ) {
		// Valid domains for exclusion : i. @yahoo-inc.com
		if (!(valid(vl, null, "[\\w-_]*[\\w-\\.]*\\@yahoo\\-inc.com"))) {
			for (i = 0; i < arrTypo.length; i++) {
				// if can match expression, means contains typo error
				if (valid(vl, null, arrTypo[i])) {
					rv = false;
					break;
				}
			}
			if (rv == false) {
				alert ("Invalid email. Please correct the spelling mistake(s) and try again.");
			}
		}
	}
	// Check for hotmail/yahoo, pop-up reminder message that email may not reach if target mailbox is full
	if (valid(vl, null, "[\\w-_]*[\\w-\\.]*\\@(yahoo|hotmail)\\.[\\w-_]*[\\w-\\.]*")) {
		alert("Please ensure that the recipient's email is valid and has a large enough space in his/her mailbox " +
			"for receiving emails.\nOtherwise the emails will not reach the recipient.");
	}
	validated = rv;
	return validated;
}

function ValidMultipleEmail(emails) {
	//emails = emails.replace(",",";");	
	if (emails.indexOf(";") >= 0){
		var rSemi = /;/g;
		emails=emails.replace(rSemi,",")
	}
	
	emails = emails.split(",");	
	var res = /^\s+/ig;
	var ree = /\s+$/ig;
	for (e = 0; e < emails.length; e++) {
		emails[e] = emails[e].replace(res,"").replace(ree,""); 
		if (ValidOneEmail(emails[e]) == false) {
			return false;			
		} 
	}
	return true;
}

function ValidEmailsFormat(emails) {
	//emails = emails.replace(",",";");	
	if (emails.indexOf(";") >= 0){
		var rSemi = /;/g;
		emails=emails.replace(rSemi,",")
	}
	
	emails = emails.split(",");	
	var res = /^\s+/ig;
	var ree = /\s+$/ig;
	var blnValidFormat = true;
	for (e = 0; e < emails.length; e++) {
		emails[e] = emails[e].replace(res,"").replace(ree,"");
		
		// check valid email format
		if (valid(emails[e],"Invalid email. Please enter a valid email.",
			"('|[\\w-_])+(\\.[\\w-_]+)*\\@[\\w-_]+(\\.[\\w-_]+)+") == false ) {
			blnValidFormat = false;
			break;
		}
	}
	return blnValidFormat;
}

/*
Function description: -Trim the string that received
Input params: String to be trimmed
Created by: Hllim
Created on: 28 Sep 2001
Used in: General
Called by: General
*/
function Trim(str)
{	
	var res = /^\s+/ig;
	var ree = /\s+$/ig;
	var out = str.replace(res,"").replace(ree,"");	
	return out;
}

/*
Function description: -Check whether it is empty for required field
Input params: -Form's text field
			  -Message (The text box name, such as Position Name, ...)
Created by: Hllim
Created on: 28 Sep 2001
Used in: General
Called by: General
*/
function CheckEmptyString(TextControl, Message)
{
	if (Trim(TextControl.value) == "")
	{
		alert (Message + " cannot be empty.");	
		TextControl.focus();	
		validated = false;
		return validated;		
	}	
	else
		validated = true;
		return validated;	
}

/*
Function description: -Check whether it is empty for required select list field
Input params: -Form's select list field
			  -Message (The text box name, such as Position Name, ...)
Created by: Hllim
Created on: 03 Oct 2001
Used in: General
Called by: General
*/
function CheckEmptySelectList(TextControl, Message)
{		
	if (GetValueFromCtl(TextControl) == "-" || GetValueFromCtl(TextControl) == 0 || GetTextFromCtl(TextControl) == "-")
	{
		alert ("Please select " + Message + ".");
		TextControl.focus();
		validated = false;
		return validated;
	}		
	else
		validated = true;
		return validated;
}

/*
Function description: -Check whether it is empty for required checkboxes field
Input params: -Form's checkboxes
			  -Message (The text box name, such as Position Name, ...)
Created by: Hllim
Created on: 03 Oct 2001
Used in: General
Called by: General
*/
function CheckEmptyCheckbox(TextControl, Message)
{
	var blnChkboxSelected = false;
	var intCount
	if (TextControl.length)	
		for (intCount = 0;  intCount < TextControl.length;  intCount++)
		{
			if (TextControl[intCount].checked)
				blnChkboxSelected = true;
		}
	// To cater for those single checkboxes
	else	
		if (TextControl.checked)
			blnChkboxSelected = true;
	
	if (!blnChkboxSelected)
	{
		if (Message.length > 0)
			alert("Please select " + Message + ".");
		return false;
	}
	return true;
}

/*
Function description: -Check whether it is a valid date takes empty String as well.
Input params: -Form's Day select list control, Month select list control, Year select list control
			  -Message 
Created by: Kian Wai
Created on: 11 Jan 2006
Used in: listAd.asp, listJob.asp, listCustomFolder.asp, listPrivateFolder.asp
Called by: listAd.asp, listJob.asp, listCustomFolder.asp, listPrivateFolder.asp
*/
function CheckValidDateFormat(ctl)
{	
	if(ctl.value != "") {
		var tmpDate, arrDate;
		arrDate = ctl.value.split("/");
		if(arrDate.length == 3) {
		tmpDate = arrDate[1] + "/" + arrDate[0] + "/" + arrDate[2];
			if(IsDate(tmpDate) == false || arrDate[2] > 2100) {
				alert("You have keyed in an incorrect Date format. Please use DD/MM/YYYY");
				ctl.focus();
				return false;
			}
		return true;
		}
		else {
			alert("You have keyed in an incorrect Date format. Please use DD/MM/YYYY");
			ctl.focus();
			return false;
		}
	}
	else {
		return true;
	}
}

/*
Function description: - Check whether it is a valid date
Input params: - Form's date control (textfield)
			  - Message
Created by: Vsiang
Created On: 24 May 2005
Used in: General
Called by: General
*/
function ValidateDate(ctl, message) {
	if (CheckEmptyString(ctl, message) == true) {
		var tmpDate, arrDate;
		arrDate = ctl.value.split("/");
		if (arrDate.length == 3) {
			tmpDate = arrDate[1] + "/" + arrDate[0] + "/" + arrDate[2];
			if (IsDate(tmpDate) == false || arrDate[2] > 2100) {
				alert(message + " is invalid. Please use (dd/mm/yyyy) format.");
				ctl.focus();
				return false;
			}
		}
		else {
			alert(message + " is invalid. Please use (dd/mm/yyyy) format.");
			ctl.focus();
			return false;
		}
	}
	else {
		return false;
	}
	return true;
}

function CheckLaterThanTodaysDate(ControlDay, ControlMonth, ControlYear, Message)
{
	if (CheckValidDate(ControlDay, ControlMonth, ControlYear, Message)) {
		var dtSelected = GetValueFromCtl(ControlMonth) + "/" + GetValueFromCtl(ControlDay) + "/" + GetValueFromCtl(ControlYear)
		if (Date.parse(dtSelected) < Date.parse(Date())) {
			alert(Message + " must be later than today's date.");
			ControlDay.focus();
			return false;
		}
		else {
			return true;
		}
	}
	else
		return false;
}

/*
Function description: -Check whether it is a valid date
Input params: -Form's Day select list control, Month select list control, Year select list control
			  -Message 
Created by: Hllim
Created on: 28 Sep 2001
Used in: General
Called by: General
*/
function CheckValidDate(ControlDay, ControlMonth, ControlYear, Message)
{	
	  if (IsDate(GetValueFromCtl(ControlMonth) + "-" + GetValueFromCtl(ControlDay) + "-" + GetValueFromCtl(ControlYear)) == false)
	  {
		alert("Please select a valid " +  Message);
		ControlMonth.focus();
		return (false);
	  }
	  else
		return true;
}

/*
Function description: - Check whether it is a valid date
Input params: -Date string
Created by: andrewlim
Created on: 3 October 2001
Used in: newAd_Step2.asp
Called by: CheckValidDate
*/
	  
function IsDate(dtStr) {
    var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
    var matchArray = dtStr.match(datePat); // is the format ok?

    if (matchArray == null) {
        return false;
    }

    month = matchArray[1]; // parse date into variables
    day = matchArray[3];
    year = matchArray[5];

//alert("month=" + month)
//alert("day=" + day)
//alert("year=" + year)

    if (month < 1 || month > 12) { // check month range
        return false;
    }

    if (day < 1 || day > 31) {
        return false;
    }

    if ((month==4 || month==6 || month==9 || month==11) && day==31) {
        return false;
    }

    if (month == 2) { // check for february 29th
        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
        if (day > 29 || (day==29 && !isleap)) {
            return false;
        }
    }
    return true; // date is valid
}	


/*
Function description: -Check whether it is valid number for number field
Input params: -Form's text field
			  -Message (The text box name, such as Position Name, ...)
Created by: Hllim
Created on: 28 Sep 2001
Used in: General
Called by: General
*/
function CheckValidNum(TextControl, Message)
{
	if (isNaN(TextControl.value))
	{
	  alert("Please enter only digits for " + Message + ".");
	  TextControl.focus();
	  return false;
	}  
	else
		return true;
}
/*
Function description: -Check whether it is valid character for text field
Input params: -Form's text field
			  -Message (The text box name, such as Position Name, ...)
Created by: Hllim
Created on: 03 Oct 2001
Used in: General
Called by: General
*/
function CheckValidChar(TextControl, Message)
{
	var CharExp = /[a-z]/i
	if  (!(CharExp.test(TextControl.value))) {
		alert("Please type in only character for " + Message);
		TextControl.focus();
		return false;
	}
	else
		return true;	
}

/*
Function description: -Get value for selected item from select list
Input params: -Form's select list control			  
Output: -Return the selected index's value
Created by: Hllim
Created on: 28 Sep 2001
Used in: General
Called by: General
*/
function GetValueFromCtl (ctl) {
	return parseInt((ctl.options[ctl.options.selectedIndex].value));
	
	for (var i=0; i < ctl.options.length; i++) {			
		if(ctl.options[i].selected ) {
			if (ctl.options[i].value == null ) {			
				return "";
			} else
				return ctl.options[i].value;
				
		}
	}
	return "";
}

/*
Function description: -Get text for selected item from select list
Input params: -Form's select list control			  
Output: -Return the selected index's text
Created by: Hllim
Created on: 28 Sep 2001
Used in: General
Called by: General
*/
function GetTextFromCtl (ctl) {
	if (ctl){
		for (var i=0; i < ctl.options.length; i++) {
			if(ctl.options[i].selected ) {
				return ctl.options[i].text;
			}
		}
	}
	return "";
}

/* Function description: -Check all checkboxes under that category
 Input params: Form name 
 Created by: Hllim
 Created on: 03 Oct 2001
 Used in: updateAd1.asp
 Called by: updateAd1.asp*/
function CheckAll(TextControl)
{
	var intCount;
	// added for show hide fields - Kian Wai
	if(TextControl){
		if (isNaN(TextControl.length)) {
			TextControl.checked = true
		} else {
			for (intCount = 0;  intCount < TextControl.length;  intCount++)	
				TextControl[intCount].checked = true	       	
		}
	}
}

function UncheckAll(TextControl)
{
	var intCount;
	// added for show hide fields - Kian Wai
	if(TextControl){
		if (isNaN(TextControl.length)) {
			TextControl.checked = false
		} else {
			for (intCount = 0;  intCount < TextControl.length;  intCount++)	
				TextControl[intCount].checked = false
		}
	}
}

function EnableAll(TextControl)
{
	var intCount;
	// added for show hide fields - Kian Wai
	if(TextControl){
		if (isNaN(TextControl.length)) {
			TextControl.disabled = false
		} else {
			for (intCount = 0;  intCount < TextControl.length;  intCount++)	
				TextControl[intCount].disabled = false
		}
	}
}

function DisabledAll(TextControl)
{
	var intCount;
	// added for show hide fields - Kian Wai
	if(TextControl){
		if (isNaN(TextControl.length)) {
			TextControl.disabled = true
		} else {
			for (intCount = 0;  intCount < TextControl.length;  intCount++)	
				TextControl[intCount].disabled = true
		}
	}
}


/* Function description: -Confirm modes: Advanced or Simple before switching
 Input params: Url, Mode
 Created by: JoAn
 Created on: 14 Feb 2002
 Called by: welcome.asp, main.asp*/
function SwitchMode(url,mode) {	
	if (mode==1) {
		if (confirm('Switching to Advanced SiVA will enable access to all SiVA functions. Change mode now?')) {
			location.href=url + mode; 
		}
	} else {
		if (confirm('Switching to Simple SiVA will allow access to the basic SiVA functions only. Are you sure you want to change to Simple SiVA now?')) {
			location.href=url + mode;		
		}	
	}
	//return true;
}

// Display a message on the status bar.
function ShowStatus(Message) {window.status = Message; return(true);}

// Clear messages on the status bar.
function ClearStatus() {window.status = ""; return(true);}

//Replaces an image with another when an event occurs, eg. onMouseOver
// Name = name of the image tag
// Source = source of image, eg. "../_pics/back.gif"
function ChangeImage(Name, Source){
  var objStr;
  var obj;
  
  // Check to make sure that images are supported in the DOM.
  if(document.images){
    // Check to see whether you are using a name, number, or object
    if (typeof(Name) == 'string') {
      // This whole objStr nonesense is here solely to gain compatability
      // with ie3 for the mac.
      objStr = 'document.' + Name;
      obj = eval(objStr);
      obj.src = Source;
    } else if ((typeof(Name) == 'object') && Name && Name.src) {
      Name.src = Source;
    }
  }
}

//Help window
function GoHelpWin(source,winwidth,winheight) {
	window.open(source,"_help","toolbar=0,location=0,directories=0,menubar=0,scrollbars=1,resizable=1,width=" + winwidth + ",height=" + winheight);
	return false;
}

/*Function description: -Check for Minimum and Maximum characters
  Input params: form element, minimum, maximum, message
  Created by: Siew Ping
  Created on: 14 March 2002
  Called by : General
*/
function ValidateTextLimit(ctl,minChars, maxChars, message) {
	var strTemp = Trim(ctl.value);	
	if (strTemp.length < minChars || strTemp.length > maxChars) {
	  alert(message);
	  ctl.focus();
	  validated = false;	  
	  return validated;
	}
	else {
	  ctl.value = strTemp;
	  validated = true;
	  return validated;
	}
}
/*Function description: Define a numeric array and initialize the elements
  Input params: number of array elements
  Created by: JoAn
  Created on: 22 March 2002
*/
function createArray(num) {
	this.length = num;
	for (var j = 0; j < num; j++) {
		this[j] = 0;
	}
}

/*Function description: New Custom Search for SiVA.
  Input params: path and form name
  Created by: Kian Wai
  Created on: 11 Jan 2006
  User By : ListAd.asp , ListJobs.asp, ListCustomFolder.asp, ListPrivateFolder.asp
*/
function customSearch(path, strForm){

	var blnDateFrom = false, blnDateTo = false;
	var frm = document.forms[strForm];
	frm.action = "../"+path;
	//check if JobID field exist.
	
	if(document.getElementById("job")){
		if(validJobID(document.getElementById("job").value)){
		}
		else {
			document.getElementById("job").value = "";
			document.getElementById("job").focus();
			return false;
		} 
	}
		
	if(document.getElementById("createDateFrom")){
		if(CheckValidDateFormat(document.getElementById("createDateFrom"))){
			if(document.getElementById("createDateTo").value != ""){
			blnDateFrom = true;
			}
		}
		else {
			document.getElementById("createDateFrom").focus();
			document.getElementById("createDateFrom").select();
			return false;
		}
	}
		
	if(document.getElementById("createDateTo")){
		if(CheckValidDateFormat(document.getElementById("createDateTo"))){
			if(document.getElementById("createDateTo").value != ""){
			blnDateTo = true;
			}
		}
		else {
			document.getElementById("createDateTo").focus();
			document.getElementById("createDateTo").select();
			return false;
		}
	}
	
	if(blnDateFrom && blnDateTo) {
		if (checkValidDateRange(document.getElementById("createDateFrom"),document.getElementById("createDateTo"),"You have keyed in the Dates in an incorrect sequence. The second Date must come after the first Date. Please re-enter.")){}
		else return false;
	}
	
	frm.action = frm.action + "&Orig=" + "&Submit=1";
	frm.submit();
}

/*Function description: Check Date Range.
  Input params: Control Field 1, Control Field 2, Alert Message.
  Created by: Kian Wai
  Created on: 11 Jan 2006
  User By : ListAd.asp , ListJobs.asp, ListCustomFolder.asp, ListPrivateFolder.asp
*/

function checkValidDateRange(ctl1,ctl2,message){
	var arrDate = ctl1.value.split("/");
	var date = parseInt(arrDate[0]);
	var month = parseInt(arrDate[1]) - 1;
	var year = parseInt(arrDate[2]);
	var myDateFrom = new Date(year,month,date);
	arrDate = ctl2.value.split("/");
	date = parseInt(arrDate[0]);
	month = parseInt(arrDate[1]) - 1;
	year = parseInt(arrDate[2]);
	var myDateTo = new Date(year,month,date);
	if (myDateFrom > myDateTo) {
		alert (message);
		document.getElementById("createDateFrom").focus();
		return false;
	}
	return true;
}

//Search by position title
function SearchByPT(path) {	
	message=window.prompt("Please enter position title.","");
	if(message==null || message=="null" || message=="") {	
	return;
	}
	location.href = "../" + path + "PT=" + escape(message) + "&Orig=" + escape(strOrig);	
}

function OthFolders(jid,pf,advid) {
	var selectedFolder = frmFolders.OtherFolders;
	var FolderValue = selectedFolder.options[selectedFolder.selectedIndex].value;
	if (FolderValue == "") {
	}
	else {		
		location.href="../applications/viewJobFolder.asp?ASC=" + FolderValue + "&JID=" + jid + "&PF=" + pf + "&AdvID=" + advid;	
	}
}

function NotAsc(Text,Len, Desc, Obj){
	var lngCount, lngLine;
	lngLine = 1;
	for (lngCount=0;lngCount<Len;lngCount++){			
		lngCode = Text.charCodeAt(lngCount);
		/*8217='
		8211 = -
		8212 = longer -
		8220="(start)
		8221="(end)*/			
		if ((lngCode<0 || lngCode > 255) && lngCode != 8217 && lngCode != 8211 && lngCode != 8212 && lngCode != 8220 && lngCode != 8221) {
			//alert(lngCode);
			if(confirm("There is invalid character found in " + Desc + ".\nDo you want to omit this violationg character and proceed?")){
				return true;	
			}
			else{
				Obj.focus();
				return false;
			}
		}
		if (lngCode == 13)
			lngLine = lngLine + 1;		
	}	
	return true;
}

function GoPopUpWindow(url, win, options) {
	var a = window.open(url, win, options);
	a.opener=this;
	a.focus();
	return false;
}

/*
  Function description: Check Date Range in mm/dd/yyyy format
  Input params: Control Field, Alert Message, Compulsary flag
  Created by: Lee Yin
  Created on: 23 Feb 2006
  User By : UpdateSearhPerFolder.asp
*/
function ValidateDateFormat(Control, Message, CompulsaryFlag){	
	if (Control.value == ""){
		if(CompulsaryFlag){
			alert("Please enter " + Message + ".");
			Control.focus();
			validated = false;
			return validated;
		}
	}else{
		if(IsDate(Control.value) == false){
			alert("Please enter a valid " + Message + ".");
			Control.focus();
			validated = false;
			return validated;
		}
	}
	return true;
}

function  GetValueFromRadio(Control){
	if (Control) {
		if (Control.length) {
			for (var i=0; i < Control.length; i++) {
				if(Control[i].checked) 
					return Control[i].value;
			}
		}else{
			if(Control.checked)
				return Control.value;
		}
	}
	return "";
}

/* ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
*/
function filterListBox(checkboxname){
	var isIE = (window.navigator.userAgent.indexOf("MSIE") > 0);
	var elem = document.getElementsByName(checkboxname);
	var i;
	var j = elem.length;
	var block = "block";
	var none = "none";
	var em = document.getElementById(checkboxname + "_filter");
	var strFilter = document.getElementById(checkboxname + "_filter").value.toLowerCase();

	if (em.attributes.getNamedItem("em").value == strFilter) {}
	else
	{
		var method = 0;
		if (strFilter.search(em.attributes.getNamedItem("em").value) >= 0)
		{
			method = 1;
		}
		else
		{
			if (isIE) {
				if (em.attributes.getNamedItem("em").value.toLowerCase().search(strFilter) >= 0)
					{method = 2;}
			}
			else
			{
				if (em.attributes.getNamedItem("em").textContent.toLowerCase().search(strFilter) >= 0)
					{method = 2;}
			}
		}
		
		if (method == 0)
		{
			if (isIE)
			{
				for (i=0;i<j;i++){
					if (elem[i].parentNode.innerText.toLowerCase().search(strFilter) >= 0)
						elem[i].parentNode.style.display = block;
					else
						elem[i].parentNode.style.display = none;}
			}
			else
			{
				for (i=0;i<j;i++){
					if (elem[i].parentNode.textContent.toLowerCase().search(strFilter) >= 0)
						elem[i].parentNode.style.display = block;
					else
						elem[i].parentNode.style.display = none;}
			}
		}
		if (method == 1)
		{
			if (isIE)
			{
				for (i=0;i<j;i++){
					if (elem[i].parentNode.style.display == block)
					{
						if (elem[i].parentNode.innerText.toLowerCase().search(strFilter) >= 0)
							{}
						else
							elem[i].parentNode.style.display = none;
					}
				}
			}
			else
			{
				for (i=0;i<j;i++){
					if (elem[i].parentNode.style.display == block)
					{
						if (elem[i].parentNode.textContent.toLowerCase().search(strFilter) >= 0)
							{}
						else
							elem[i].parentNode.style.display = none;
					}
				}
			}
		}
		if (method == 2)
		{
			if (isIE)
			{
				for (i=0;i<j;i++){
					if (elem[i].parentNode.style.display == none)
					{
						if (elem[i].parentNode.innerText.toLowerCase().search(strFilter) >= 0)
							{elem[i].parentNode.style.display = block;}
					}
				}
			}
			else
			{
				for (i=0;i<j;i++){
					if (elem[i].parentNode.style.display == none)
					{
						if (elem[i].parentNode.textContent.toLowerCase().search(strFilter) >= 0)
							{elem[i].parentNode.style.display = block;}
					}
				}
			}
		}
		em.attributes.getNamedItem("em").value = strFilter;
	}
}

function setupListItemStyle(Name){
	var elem = document.getElementsByName(Name);
	for(i=0;i<elem.length;i++){
		elem[i].parentNode.style.display = "block";
		if (elem[i].checked) {
			elem[i].parentNode.style.backgroundColor = '#0a246a';
			elem[i].parentNode.style.color = "#fff";
		}
	}
}

function displayCheckboxContent(checkbox_node,checkBoxName,areaId,maxSelection)
{
	var isIE = (window.navigator.userAgent.indexOf("MSIE") > 0);
	var checkbox_name = "";
	var checkboxes = document.getElementsByName(checkBoxName);
	var textArea = document.getElementById(areaId);
	var checkboxAll = document.getElementById(checkBoxName + "_all");
	var i;
	var j = checkboxes.length;
	var numChecked=0;
	var strSeparated = " ; ";
	var strAllChecked = "value all checked"	
	
	var strBlue = "#0a246a"
	var strYellow = "#fff"
	var strWhite = "#000"
		
    label_node = checkbox_node.parentNode;

    if (checkbox_node.checked) {
		label_node.style.backgroundColor=strBlue;
		label_node.style.color=strYellow;
	}
    else {
		label_node.style.backgroundColor=strYellow;
		label_node.style.color=strWhite;
		if (checkboxAll != null && checkboxAll != undefined) checkboxAll.checked=false;
	}	

	if(isIE)
	{
		for(i=0;i<j;i++)
		{
			if(checkboxes[i].checked==true)
			{
				checkbox_name = checkbox_name + checkboxes[i].parentNode.innerText + strSeparated ;
				numChecked++ ;
			}
		}
	}
	else
	{
		for(i=0;i<j;i++)
		{
			if(checkboxes[i].checked==true)
			{
				checkbox_name = checkbox_name + checkboxes[i].parentNode.textContent + strSeparated ;
				numChecked++ ;
			}
		}
	}
	
	if (textArea != null && textArea != undefined)
	{
		if(numChecked==j)
			textArea.value = strAllChecked;
		else
			textArea.value = checkbox_name;
	}
	
	if (maxSelection != null && maxSelection != undefined && maxSelection != '' && numChecked > maxSelection) {
		alert("You have selected the maximum limit of " + maxSelection + ", please remove the extra.");
		label_node.style.backgroundColor=strYellow;
		label_node.style.color=strWhite;
		checkbox_node.checked = false;
		if (checkboxAll != null && checkboxAll != undefined) checkboxAll.checked=false;
	}
}

function checkall(checkall_node, checkboxname, areaId, maxSelection){
	var allcheckbox = document.getElementsByName(checkboxname);
	var i;
	var j = allcheckbox.length;
	var strBlue = "#0a246a";
	var strSilver = "#c0c0c0";
	var strYellow = "#fff";
	var strWhite = "#000";
	var textArea = document.getElementById(areaId);
	var numChecked = 0;
	
	if (checkall_node.checked)
	{
		if (textArea != null && textArea != undefined) textArea.value =  "value all checked";
		for (i=0;i<j;i++)
		{
			allcheckbox[i].checked = true;
			allcheckbox[i].parentNode.style.backgroundColor = strBlue;
			allcheckbox[i].parentNode.style.color = strYellow;
			numChecked++;
		}
		
		if (maxSelection != null && maxSelection != undefined && maxSelection != '' && numChecked > maxSelection)
		{
			alert("You have selected the maximum limit of " + maxSelection + ", please re-select.");
			
			for (i=0;i<j;i++)
			{	
				allcheckbox[i].checked = false;
				allcheckbox[i].parentNode.style.backgroundColor=strYellow;
				allcheckbox[i].parentNode.style.color=strWhite;
			}
			checkall_node.checked = false;
			return false;
		}
	}
	else
	{
		if (textArea != null && textArea != undefined) textArea.value = "";
		for (i=0;i<j;i++)
		{
			allcheckbox[i].checked = false;
			allcheckbox[i].parentNode.style.backgroundColor = strYellow;
			allcheckbox[i].parentNode.style.color = strWhite;
		}
	}
}

function checkEUWorkAuth(CountryList, EUCheckBox, EUArea) 
{ 
	var isIE = (window.navigator.userAgent.indexOf("MSIE") > 0);
	var i=0; 
	var strCodeList = ',AT,BE,CY,CZ,DE,DK,EE,ES,FI,FR,GB,GR,HU,IE,IT,LT,LU,LV,MT,NL,PL,PT,SE,SI,SK,'; 
	var strBlue = "#0a246a";
	var strYellow = "#fff";
	var strWhite = "#000";
	var textArea = document.getElementById(EUArea);
	var checkbox_name = "";
	var strSeparated = " ; ";
	
	if(isIE) 
	{
		for (i=0;i<CountryList.length;i++) 
		{ 
			var strCode = CountryList[i].value.toUpperCase(); 
			if (strCodeList.indexOf(',' + strCode + ',') > -1) 
			{			
				if (EUCheckBox.checked)
				{
					CountryList[i].checked = true;
					CountryList[i].parentNode.style.backgroundColor = strBlue;
					CountryList[i].parentNode.style.color = strYellow;
					checkbox_name = checkbox_name + CountryList[i].parentNode.innerText + strSeparated ;
				}
				else
				{
					CountryList[i].checked = false;
					CountryList[i].parentNode.style.backgroundColor = strYellow;
					CountryList[i].parentNode.style.color = strWhite;
				}
			}
		}
	}		
	else
	{
		for (i=0;i<CountryList.length;i++) 
		{ 
			var strCode = CountryList[i].value.toUpperCase(); 
			if (strCodeList.indexOf(',' + strCode + ',') > -1) 
			{			
				if (EUCheckBox.checked)
				{
					CountryList[i].checked = true;
					CountryList[i].parentNode.style.backgroundColor = strBlue;
					CountryList[i].parentNode.style.color = strYellow;
					checkbox_name = checkbox_name + CountryList[i].parentNode.textContent + strSeparated ;
				}
				else
				{
					CountryList[i].checked = false;
					CountryList[i].parentNode.style.backgroundColor = strYellow;
					CountryList[i].parentNode.style.color = strWhite;
				}
			}
		}
	} 
	if (textArea != null && textArea != undefined)
		textArea.value = checkbox_name;
}

//--------- HM --------------
function lookup(ctrlid, param){
	//var retval = window.showModalDialog("lookup.htm");
	//var retval = window.showModalDialog("mlist.htm");
	//var src = "single_lookup.asp";
	var retval = window.showModalDialog("default_lookup.asp?src=single_lookup.asp?paramval=" + param, "","dialogHeight: 640px;");
	if (retval){
		document.all(ctrlid).value = retval[0];
		document.all(ctrlid + "_desc").innerText = retval[1];}
}

function removeitem(ctrlid){
	var xlist = document.all(ctrlid);
	var x = xlist.options.length;
	var i;
	for (i=xlist.length-1;i>=0;i--){
		if (xlist.options[i].selected)
			xlist.remove(i);
	}
}

//By Jeremiah (23 Jan 2007)

function showSelectedItems(checkboxname) {
	var allcheckbox = document.getElementsByName(checkboxname);
	var i, displayStatus;
	var j = allcheckbox.length;
	
	var chkSelected = document.getElementById(checkboxname + "_showSelected");
		if (chkSelected.checked)
		{
			for (i=0;i<j;i++)
			{
				if (allcheckbox[i].checked)
					allcheckbox[i].parentNode.style.display = "block";
				else
					allcheckbox[i].parentNode.style.display = "none";
			}
		}
		else
		{
			for (i=0;i<j;i++)
			{
				allcheckbox[i].parentNode.style.display = "block";
			}
		}
}

/*
Created by: Kian Wai
Created on: 7 Jun 2007
Used in: Agena
Called by: UpdateAd1Validation3.js
*/

function getCtrl(ctrlName){
	if ( document.getElementById(ctrlName)){
		return  document.getElementById(ctrlName);
	}
	else if (document.all){
		return document.all.ctrlName;
	}
	else {
		return null;
	}

}


function CheckEmptySinglePopup(TextControlName, Message)
{
	var ctrlValue = getCtrl(TextControlName);
	var ctrlDesc = getCtrl(TextControlName + '_desc');

	if (Trim(ctrlValue.value) == "")
	{
		alert (Message + " cannot be empty.");	
		ctrlDesc.disabled = false;
		ctrlDesc.focus();
		ctrlDesc.disabled = true;	
		validated = false;
		return validated;		
	}	
	else
		validated = true;
		return validated;	
}

function CheckEmptyMultiplePopup(TextControlName, Message)
{
	var ctrlValue = getCtrl(TextControlName);
	var ctrlDesc = getCtrl(TextControlName + '_sel');

	if (Trim(ctrlValue.value) == "")
	{
		alert (Message + " cannot be empty.");	
		ctrlDesc.focus();
		validated = false;
		return validated;		
	}	
	else
		validated = true;
		return validated;	
}

/*
Created by: Kien Yit
Created on: 4 Jun 2009
Used in: Multiple files
Called by: Multiple files
Description: Function to automatically resize IFrame window to fit the screen size
*/
function autoResizeIFrame(iframeElement, heightPadding)
{
	iframeElement.style.height =  (iframeElement.contentWindow.document.body.offsetHeight) + heightPadding + "px";
}

/*
Created by: Kien Yit
Created on: 24 Oct 2008
Function to show section by Element ID
*/
function showSectionByElementID (showElementID)
{
	var ctl = document.getElementById(showElementID);
	ctl.style.display = "";
	ctl.style.visibility = "visible";
}

/* 
Created by: Kien Yit
Created on: 24 Oct 2008
Function to hide section by Element ID
*/
function hideSectionByElementID (hideElementID)
{
	var ctl = document.getElementById(hideElementID);
	ctl.style.display = "none";
	ctl.style.visibility = "hidden";
}
// -->
