function docTag() {
	var args = docTag.arguments;
	if (args.length == 0) return document;
	if (args.length == 2 || args.length == 3) { 
		switch(args[1]) {
		case 'n':
			if (args.length == 3) 
				return document.getElementsByName(args[0]).item(args[2]);
			else 
				return document.getElementsByName(args[0])
			break;
		case 't':
			if (args.length == 3) 
				return document.getElementsByTagName(args[0]).item(args[2]);
			else 
				return document.getElementsByTagName(args[0])
			break;
		}
	} else return document.getElementById(args[0]);
}

function tagN(id) {
	return docTag(id,"n",0);
}

function tagTN(id) {
	return docTag(id,"t",0);
}

function tagI(id) {
	return docTag(id);
}

function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate)
}

function getCookie(c_name) {
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=")
		if (c_start!=-1) { 
			c_start=c_start + c_name.length+1 
			c_end=document.cookie.indexOf(";",c_start)
			if (c_end==-1) c_end=document.cookie.length
			cstr = unescape(document.cookie.substring(c_start,c_end))
			return cstr.replace(/\+/g," ")
		} 
	}
	return null
}

function checkData() {
	var args = checkData.arguments;
	var field = "";
	for (i=1; i<args.length; i++) {
		field = eval("document." + args[0].name + "." + args[i])
		if (args[i] == "ea") {
			var re = /^[a-zA-Z0-9]+[a-zA-Z0-9\._-]*@[a-zA-Z0-9]+[a-zA-Z0-9\._-]*\.[a-zA-Z]+$/;
			var str = field.value;
			if (!re.test(str)) {
				alert("Please check your email address");
				return false;
			}
		}
		if (args[i] == "pwd1") code1 = field.value;
		if (args[i] == "pwd2") { code2 = field.value;
			if (code1.length < 6) {
				alert("Please make sure that you have at least 6 characters set as your password.");
				return false;
			}
			if (code1 != code2) {
				alert("Please make sure that you have re-typed the password correctly.");
				return false;
			}
		}
		if (field.type == "select-one") {
			if(field.value == "0")  {
				if (args[i] == "jtype")
				alert("Please choose the Job Type");
				else alert("Please make sure that the mandatory* fields are filled in.");
				return false;
			}
		} else if (args[i] == "yn") {
			if (!field[0].checked && !field[1].checked) {
				alert("Please make sure that you selected Yes or No.");
				return false;
			}
		} else if (args[i] == "terms") {
			if (!field.checked) {
				alert("You must check the box to agree with the terms and conditions.");
				return false;
			}
		} else if (args[i] == "loc") {
			if (field.value == "" && args[0].lpcode.value == "") {
				alert("Please make sure that the mandatory* fields are filled in.");
				return false;
			}
		} else if (args[i] == "srange") {
			if (field.value == "" || field.value == "0") {
				alert("Please make sure that the mandatory* fields are filled in.");
				return false;
			}
		} else if (field.value == "" || field.value == "<P>&nbsp;</P>" ||
					field.value == "<P align=left>&nbsp;</P>" ||
					field.value == "<P align=right>&nbsp;</P>" ||
					field.value == "<P align=center>&nbsp;</P>") {
			alert("Please make sure that the mandatory* fields are filled in.");
			return false;
		}
	}
	return true;
}