// Form Validation

function filterNumber(objText) {
	var objItem = document.getElementById(objText);
	if (objItem.value.match(/[^0-9]/i))
		objItem.value = objItem.value.replace(/[^0-9]/gi,'');
}

function filterNumberDot(objText) {
	var objItem = document.getElementById(objText);
	if (objItem.value.match(/[^0-9^.]/i))
		objItem.value = objItem.value.replace(/[^0-9^.]/gi,'');
}

function filterDate(objText) {
	var objItem = document.getElementById(objText);
	//if (objItem.value.match(/[^0-9^-]/i))
	if (objItem.value.match(/[^0-9^-]/i))
		objItem.value = objItem.value.replace(/[^0-9^-]/gi,'');
}

/**
 * Checking Password
 */
var lastpassword='';
var profile_passwd_illegal='Password is illegal.';
var profile_passwd_notmatch='Password is not matched.';

function checkpassword(confirm) {
	var password = document.getElementById('password_check').value;
	//var cp = document.getElementById('checkpassword');
	//warning(cp, 'testing');
	if(!confirm && password == lastpassword) {
		return;
	} else {
		lastpassword = password;
	}
	var cp = document.getElementById('checkpassword');	
	if(password == '' || /[\'\"\\]/.test(password)) {
		warning(cp, profile_passwd_illegal);
	return false;
	} else {
		cp.style.display = 'none';
		if(!confirm) {
			checkpassword2(true);
		}
		return true;
	}	
}

/**
 * Checking password retype
 */
function checkpassword2(confirm) {
	var password = document.getElementById('password_check').value;
	var password2 = document.getElementById('password_retype').value;
	var cp2 = document.getElementById('checkpassword2');
	if(password2 != '') {
		checkpassword(true);
	}
	if(password == '' || (confirm && password2 == '')) {
		cp2.style.display = 'none';
		return;
	}
	if(password != password2) {
		warning(cp2, profile_passwd_notmatch);
	} else {
		cp2.style.display = 'none';
	}
}

/**
 * Warning message
 */
function warning(obj, msg) {
	obj.style.display = '';
	obj.innerHTML = '<img src="images/check_error.gif">&nbsp;' + msg;
	obj.className = "smallfont";
}

/**
 * Check DOB
 */
function checkDob(){
	var ic1 = document.getElementById('ic1').value;
	var dob = document.getElementById('dob').value;
	var dobObj = document.getElementById('checkdob');
	// Validate DOB
	var validformat=/^\d{4}\-\d{1,2}\-\d{1,2}$/
	var today=new Date()
	var thisyear = today.getFullYear()
	var yearfield=dob.split("-")[0]
	var monthfield=dob.split("-")[1]
	var dayfield=dob.split("-")[2]
	
	var yearfield1 = yearfield.substring(2,4);
	var icyear = ic1.substring(0,2);
	var icmonth = ic1.substring(2,4);
	var icday = ic1.substring(4,6);
	
	var dayobj = new Date(yearfield, monthfield-1, dayfield)
	if (dob==""){
		//statusmsg = statusmsg + "\n -  Date of Birth";
		//warning(dobObj,'Cannot be emtpy.');
	}
	else if (!validformat.test(dob)){
		warning(dobObj,'Invalid Date Format.');
		return;
		//statusmsg = statusmsg + "\n -  Date of Birth";
		//statusmsg = statusmsg + "\n    (Invalid Date Format)";	
	}
	else if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield)) {
		warning(dobObj,'Invalid Day, Month, or Year range.');
		return;
		//statusmsg = statusmsg + "\n -  Date of Birth";
		//statusmsg = statusmsg + "\n    (Invalid Day, Month, or Year range)";		
	}
	else if (yearfield >= thisyear){
		warning(dobObj,'Invalid Year of birth.');
		return;
		//statusmsg = statusmsg + "\n -  Date of Birth";
		//statusmsg = statusmsg + "\n    (Invalid Year of birth)";		
	}
	else if (ic1.length==6 && (icyear!=yearfield1 || icmonth!=monthfield || icday!=dayfield)){
		warning(dobObj,'Wrong date of birth.');
		return;
	}
		
	dobObj.style.display = 'none';
}

/**
* Check Graduation
*/
function checkGraduation(){	
	var graduation = document.getElementById('graduation').value;
	var graduationObj = document.getElementById('checkgraduation');
	// Validate Graduation
	var validformat=/^\d{4}\-\d{1,2}\-\d{1,2}$/
	var today=new Date()
	var thisyear = today.getFullYear()
	var yearfield=graduation.split("-")[0]
	var monthfield=graduation.split("-")[1]
	var dayfield=graduation.split("-")[2]
	
		
	var dayobj = new Date(yearfield, monthfield-1, dayfield)
	if (!validformat.test(graduation)){
		warning(graduationObj,'Invalid Date Format.');
		return;
		//statusmsg = statusmsg + "\n -  Date of Birth";
		//statusmsg = statusmsg + "\n    (Invalid Date Format)";	
	}
	else if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield)) {
		warning(graduationObj,'Invalid Day, Month, or Year range.');
		return;
		//statusmsg = statusmsg + "\n -  Date of Birth";
		//statusmsg = statusmsg + "\n    (Invalid Day, Month, or Year range)";		
	}		
		
	graduationObj.style.display = 'none';
}

/**
* Name: validateForm
* @Remarks: Located at submit button of registration form
*/
function validateForm()
{
	var themessage = "You are required to complete the following fields: ";
	
	var statusmsg = themessage;
	
	var returnVal = false;
	
	var focusVal = 0;	

	// Form 1
	var getUser = document.getElementById('username')
	var getPass = document.getElementById('password_check') 
	var getPassR = document.getElementById('password_retype')	
	var getName = document.getElementById('name')
	var getSurname = document.getElementById('surname')
	var getIc1 = document.getElementById('ic1')
	var getIc2 = document.getElementById('ic2')
	var getIc3 = document.getElementById('ic3')
	var getDob = document.getElementById('dob')
	var getGender1 = document.getElementById('gender1')
	var getGender2 = document.getElementById('gender2')
	var getNationality = document.getElementById('nationality')
	var getPpno = document.getElementById('ppno')
	var getRace= document.getElementById('race')
	var getOtherrace= document.getElementById('otherrace')
	var getMaritalstatus= document.getElementById('maritalstatus')
	var getAddress1= document.getElementById('address1')
	var getPostcode= document.getElementById('postcode')
	var getCity= document.getElementById('city')
	var getState= document.getElementById('state')
	var getState2= document.getElementById('state2')
	var getCountry= document.getElementById('country')
	var getMobile1= document.getElementById('mobile1')
	var getMobile2= document.getElementById('mobile2')
	var getTelno1= document.getElementById('telno1')
	var getTelno2= document.getElementById('telno2')
	var getEmail = document.getElementById('email') 	
	var at1 = getEmail.value.indexOf("@")
	var getAltemail = document.getElementById('altemail') 	
	var at2 = getAltemail.value.indexOf("@")
	
	// Form 2
	var getExplevel1= document.getElementById('explevel1')
	var getExplevel2= document.getElementById('explevel2')
	var getExplevel3= document.getElementById('explevel3')
	var getExplevel4= document.getElementById('explevel4')
	var getWorkingperiod= document.getElementById('workingperiod')
	var getHqlevel= document.getElementById('hqlevel')
	var getOtherqual= document.getElementById('otherqual')
	var getInstitutetype= document.getElementById('institutetype')
	var getInstitute= document.getElementById('institute')
	var getOtherinst= document.getElementById('otherinst')
	var getStudyfield= document.getElementById('studyfield')
	var getOtherstudy= document.getElementById('otherstudy')
	var getGraduation= document.getElementById('graduation')
	var getGrade= document.getElementById('grade')
	var getCgpa= document.getElementById('cgpa')
	var getResult= document.getElementById('result')
	var getMultimedia1= document.getElementById('multimedia1')
	var getMultimedia2= document.getElementById('multimedia2')
	var getMultimedia3= document.getElementById('multimedia3')
	var getProgramming1= document.getElementById('programming1')
	var getProgramming2= document.getElementById('programming2')
	var getProgramming3= document.getElementById('programming3')
	var getItnet1= document.getElementById('itnet1')
	var getItnet2= document.getElementById('itnet2')
	var getItnet3= document.getElementById('itnet3')
	var getTraininglocation= document.getElementById('traininglocation')
	
	
	
	if (getUser.value=="") {
		statusmsg = statusmsg + "\n -  Desired Username";	
	}
	if (getPass.value==""){
		statusmsg = statusmsg + "\n -  Desired Password";
	}
	if (getPassR.value==""){
		statusmsg = statusmsg + "\n -  Confirm Password";
	}
	if (getName.value==""){
		statusmsg = statusmsg + "\n -  First Name";		
	}
	if (getSurname.value==""){
		statusmsg = statusmsg + "\n -  Last Name";			
	}
	if (getPpno.value=="" && (getIc1.value.length<6 || getIc2.value.length<2 || getIc3.value.length<4)){
		statusmsg = statusmsg + "\n -  NRIC. / Passport No.";	
	}
	else if (getPpno.value!="" && (getIc1.value!="" || getIc2.value!="" || getIc3.value!="")){
		if (getIc1.value.length<6 || getIc2.value.length<2 || getIc3.value.length<4){
			statusmsg = statusmsg + "\n -  NRIC / Passport No.";	
		} 
	}
	// Validate DOB
	var validformat=/^\d{4}\-\d{1,2}\-\d{1,2}$/
	var today=new Date()
	var thisyear = today.getFullYear()
	var yearfield=getDob.value.split("-")[0]
	var monthfield=getDob.value.split("-")[1]
	var dayfield=getDob.value.split("-")[2]
	var dayobj = new Date(yearfield, monthfield-1, dayfield)
	
	var yearfield1 = yearfield.substring(2,4);
	var icyear = getIc1.value.substring(0,2);
	var icmonth = getIc1.value.substring(2,4);
	var icday = getIc1.value.substring(4,6);
	if (getDob.value==""){
		statusmsg = statusmsg + "\n -  Date of Birth";
	}
	else if (!validformat.test(getDob.value)){
		statusmsg = statusmsg + "\n -  Date of Birth";
		statusmsg = statusmsg + "\n    (Invalid Date Format)";	
	}
	else if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield)) {
		statusmsg = statusmsg + "\n -  Date of Birth";
		statusmsg = statusmsg + "\n    (Invalid Day, Month, or Year range)";		
	}
	else if (yearfield >= thisyear){
		statusmsg = statusmsg + "\n -  Date of Birth";
		statusmsg = statusmsg + "\n    (Invalid Year of birth)";		
	}
	else if (getIc1.value.length==6 && (icyear!=yearfield1 || icmonth!=monthfield || icday!=dayfield)){
		statusmsg = statusmsg + "\n -  Date of Birth";
		statusmsg = statusmsg + "\n    (Wrong date of birth)";		
	}
	
	// Validate Gender
	if (getGender1.checked==false && getGender2.checked==false){
		statusmsg = statusmsg + "\n -  Gender";	
	}
	if (getRace.value==""){
		statusmsg = statusmsg + "\n -  Race";	
	} else if (getRace.value=="12" && getOtherrace.value==""){
		statusmsg = statusmsg + "\n -  Race";
	}
	if (getNationality.value==""){
		statusmsg = statusmsg + "\n -  Nationality";	
	}
	if (getMaritalstatus.value==""){
		statusmsg = statusmsg + "\n -  Marital Status";	
	}
	if (getAddress1.value==""){
		statusmsg = statusmsg + "\n -  Correspondence Address";
	}
	if (getPostcode.value.length<5){
		statusmsg = statusmsg + "\n -  Postal Code";	
	}
	if (getCity.value==""){
		statusmsg = statusmsg + "\n -  City";	
	}
	if ((getState.disabled==false && getState.value=="") || (getState2.disabled==false && getState2.value=="") ){
		statusmsg = statusmsg + "\n -  State/Region";	
	}
	if (getCountry.value==""){
		statusmsg = statusmsg + "\n -  Country";	
	}
	if (getMobile1.value=="" || getMobile2.value==""){
		statusmsg = statusmsg + "\n -  Mobile No.";	
	}
	if (getTelno1.value=="" || getTelno2.value==""){
		statusmsg = statusmsg + "\n -  Telephone No.";	
	}
	
	if (getEmail.value==""){
		statusmsg = statusmsg + "\n -  Email";				
	} 
	else if (at1 == -1){
		statusmsg = statusmsg + "\n -  Email";
		statusmsg = statusmsg + "\n    (Not a valid email)";	
	} 
	
	if (getAltemail.value!="" && at2 == -1){
		statusmsg = statusmsg + "\n -  Alternative Email";			
		statusmsg = statusmsg + "\n    (Not a valid email)";			
	}
	
	// Check Form 2
	if (getExplevel1.checked==false && getExplevel2.checked==false && getExplevel3.checked==false && getExplevel4.checked==false){
		statusmsg = statusmsg + "\n -  Experience Level";	
	}
	if (getExplevel4.checked==true && getWorkingperiod.value==""){
		statusmsg = statusmsg + "\n -  Experience Level (Working Period)";
	}
	if (getHqlevel.value==""){
		statusmsg = statusmsg + "\n -  Qualification";	
	} else if (getHqlevel.value=="10" && getOtherqual.value==""){
		statusmsg = statusmsg + "\n -  Qualification (Others)";
	}
	
	if (getInstitutetype.value=="" || (getInstitutetype.value!=3 && getInstitute.value=="") || (getInstitutetype.value==3 && getOtherinst.value=="") ){
		statusmsg = statusmsg + "\n -  University/Institute";	
	}
	
	if (getStudyfield.value==""){
		statusmsg = statusmsg + "\n -  Field of Study";	
	} else if (getStudyfield.value=="33" && getOtherstudy.value==""){
		statusmsg = statusmsg + "\n -  Field of Study (Others)";
	}
	// Validate DOB
	var validformat=/^\d{4}\-\d{1,2}\-\d{1,2}$/
	var today=new Date()
	var thisyear = today.getFullYear()
	var yearfield=getGraduation.value.split("-")[0]
	var monthfield=getGraduation.value.split("-")[1]
	var dayfield=getGraduation.value.split("-")[2]
	var dayobj = new Date(yearfield, monthfield-1, dayfield)
	if (getGraduation.value==""){
		statusmsg = statusmsg + "\n -  Graduation Date";
	}
	else if (!validformat.test(getGraduation.value)){
		statusmsg = statusmsg + "\n -  Graduation Date";
		statusmsg = statusmsg + "\n    (Invalid Date Format)";	
	}
	else if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield)) {
		statusmsg = statusmsg + "\n -  Graduation Date";
		statusmsg = statusmsg + "\n    (Invalid Day, Month, or Year range)";		
	}	
	
	if (getGrade.value==""){
		statusmsg = statusmsg + "\n -  Grade";				
	}
	if (getGrade.value!=6 &&getGrade.value!=7 &&getGrade.value!=8 && getCgpa.value==""){
		statusmsg = statusmsg + "\n -  CGPA";				
	}
	else if ((getGrade.value==6 ||getGrade.value==7 ||getGrade.value==8) && getResult.value==""){
		statusmsg = statusmsg + "\n -  Result";				
	}
	
	if (getMultimedia1.checked==false && getMultimedia2.checked==false && getMultimedia3.checked==false){
		statusmsg = statusmsg + "\n -  Training Program";	
	} 
	else if (getProgramming1.checked==false && getProgramming2.checked==false && getProgramming3.checked==false){
		statusmsg = statusmsg + "\n -  Training Program";	
	} 
	else if (getItnet1.checked==false && getItnet2.checked==false && getItnet3.checked==false){
		statusmsg = statusmsg + "\n -  Training Program";	
	} 
	if (getTraininglocation.value==""){
		statusmsg = statusmsg + "\n -  Training Location";				
	}
	
	if (themessage == statusmsg) {
	returnVal = true;
	}
	else {
	alert(statusmsg);	
	}
	return returnVal
	
}

/*
	Name: nextValidateForm
	Remarks: Located at "Next" button of registration form
*/
function nextValidateForm()
{
	var themessage = "You are required to complete the following fields: ";
	
	var statusmsg = themessage;
	
	//var returnVal = false;
	
	var focusVal = 0;

	// Form 1
	var getUser = document.getElementById('username')
	var getPass = document.getElementById('password_check') 
	var getPassR = document.getElementById('password_retype')	
	var getName = document.getElementById('name')
	var getSurname = document.getElementById('surname')
	var getIc1 = document.getElementById('ic1')
	var getIc2 = document.getElementById('ic2')
	var getIc3 = document.getElementById('ic3')
	var getDob = document.getElementById('dob')
	var getGender1 = document.getElementById('gender1')
	var getGender2 = document.getElementById('gender2')
	var getNationality = document.getElementById('nationality')
	var getPpno = document.getElementById('ppno')
	var getRace= document.getElementById('race')
	var getOtherrace= document.getElementById('otherrace')
	var getMaritalstatus= document.getElementById('maritalstatus')
	var getAddress1= document.getElementById('address1')
	var getPostcode= document.getElementById('postcode')
	var getCity= document.getElementById('city')
	var getState= document.getElementById('state')
	var getState2= document.getElementById('state2')
	var getCountry= document.getElementById('country')
	var getMobile1= document.getElementById('mobile1')
	var getMobile2= document.getElementById('mobile2')
	var getTelno1= document.getElementById('telno1')
	var getTelno2= document.getElementById('telno2')
	var getEmail = document.getElementById('email') 	
	var at1 = getEmail.value.indexOf("@")
	var getAltemail = document.getElementById('altemail') 	
	var at2 = getAltemail.value.indexOf("@")
	
		
	// Check Form 1
	if (getUser.value=="") {
		statusmsg = statusmsg + "\n -  Desired Username";	
	}
	if (getPass.value==""){
		statusmsg = statusmsg + "\n -  Desired Password";
	}
	if (getPassR.value==""){
		statusmsg = statusmsg + "\n -  Confirm Password";
	}
	if (getName.value==""){
		statusmsg = statusmsg + "\n -  First Name";		
	}
	if (getSurname.value==""){
		statusmsg = statusmsg + "\n -  Last Name";			
	}
	if (getPpno.value=="" && (getIc1.value.length<6 || getIc2.value.length<2 || getIc3.value.length<4)){
		statusmsg = statusmsg + "\n -  NRIC / Passport No.";	
	}
	else if (getPpno.value!="" && (getIc1.value!="" || getIc2.value!="" || getIc3.value!="")){
		if (getIc1.value.length<6 || getIc2.value.length<2 || getIc3.value.length<4){
			statusmsg = statusmsg + "\n -  NRIC / Passport No.";	
		} 
	}
	// Validate DOB
	var validformat=/^\d{4}\-\d{1,2}\-\d{1,2}$/
	var today=new Date()
	var thisyear = today.getFullYear()
	var yearfield=getDob.value.split("-")[0]
	var monthfield=getDob.value.split("-")[1]
	var dayfield=getDob.value.split("-")[2]
	var dayobj = new Date(yearfield, monthfield-1, dayfield)
	
	var yearfield1 = yearfield.substring(2,4);
	var icyear = getIc1.value.substring(0,2);
	var icmonth = getIc1.value.substring(2,4);
	var icday = getIc1.value.substring(4,6);
	if (getDob.value==""){
		statusmsg = statusmsg + "\n -  Date of Birth";
	}
	else if (!validformat.test(getDob.value)){
		statusmsg = statusmsg + "\n -  Date of Birth";
		statusmsg = statusmsg + "\n    (Invalid Date Format)";	
	}
	else if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield)) {
		statusmsg = statusmsg + "\n -  Date of Birth";
		statusmsg = statusmsg + "\n    (Invalid Day, Month, or Year range)";		
	}
	else if (yearfield >= thisyear){
		statusmsg = statusmsg + "\n -  Date of Birth";
		statusmsg = statusmsg + "\n    (Invalid Year of birth)";		
	}
	else if (getIc1.value.length==6 && (icyear!=yearfield1 || icmonth!=monthfield || icday!=dayfield)){
		statusmsg = statusmsg + "\n -  Date of Birth";
		statusmsg = statusmsg + "\n    (Wrong date of birth)";		
	}
	
	// Validate Gender
	if (getGender1.checked==false && getGender2.checked==false){
		statusmsg = statusmsg + "\n -  Gender";	
	}
	if (getRace.value==""){
		statusmsg = statusmsg + "\n -  Race";	
	} else if (getRace.value=="12" && getOtherrace.value==""){
		statusmsg = statusmsg + "\n -  Race";
	}
	if (getNationality.value==""){
		statusmsg = statusmsg + "\n -  Nationality";	
	}
	if (getMaritalstatus.value==""){
		statusmsg = statusmsg + "\n -  Marital Status";	
	}
	if (getAddress1.value==""){
		statusmsg = statusmsg + "\n -  Correspondence Address";
	}
	if (getPostcode.value.length<5){
		statusmsg = statusmsg + "\n -  Postal Code";	
	}
	if (getCity.value==""){
		statusmsg = statusmsg + "\n -  City";	
	}
	if ((getState.disabled==false && getState.value=="") || (getState2.disabled==false && getState2.value=="") ){
		statusmsg = statusmsg + "\n -  State/Region";	
	}
	if (getCountry.value==""){
		statusmsg = statusmsg + "\n -  Country";	
	}
	if (getMobile1.value=="" || getMobile2.value==""){
		statusmsg = statusmsg + "\n -  Mobile No.";	
	}
	if (getTelno1.value=="" || getTelno2.value==""){
		statusmsg = statusmsg + "\n -  Telephone No.";	
	}
	
	if (getEmail.value==""){
		statusmsg = statusmsg + "\n -  Email";				
	} 
	else if (at1 == -1){
		statusmsg = statusmsg + "\n -  Email";
		statusmsg = statusmsg + "\n    (Not a valid email)";	
	} 
	
	if (getAltemail.value!="" && at2 == -1){
		statusmsg = statusmsg + "\n -  Alternative Email";			
		statusmsg = statusmsg + "\n    (Not a valid email)";			
	}
	
	
	
	if (themessage == statusmsg) {
		document.getElementById('step1').style.display = 'none'; 
		document.getElementById('step2').style.display = '';
	}
	else {
	alert(statusmsg);	
	}
	
	
}


function raceCheck(optValue){
	if (optValue==12)
	showHide('otherrace','inline');	
	else {
	showHide('otherrace','none');	
	document.getElementById('otherrace').value="";
	}
}

function hqlevelCheck(optValue,part){
	if (part==2){
		if (optValue==10)
			showHide('s_otherqual','inline');	
		else {
			showHide('s_otherqual','none');	
			document.getElementById('s_otherqual').value="";
		}
	}
	else {
		if (optValue==10)
			showHide('otherqual','inline');	
		else {
			showHide('otherqual','none');	
			document.getElementById('otherqual').value="";
		}
	}
}

function studyfieldCheck(optValue,part){
	if (part==2){
		if (optValue==33)
			showHide('s_otherstudy','inline');	
		else{
			showHide('s_otherstudy','none');	
			document.getElementById('s_otherstudy').value="";
		}
	}else {
		if (optValue==33){
			showHide('otherstudy','inline');
		}
		else {
			showHide('otherstudy','none');	
			document.getElementById('otherstudy').value="";
		}
	}
}

function gradeCheck(optValue){	
	if (optValue==6 || optValue==7 || optValue==8){
		showHide('resulttitle','inline');
		showHide('result1','inline');
		showHide('cgpatitle','none');
		showHide('cgpa1','none');		
		document.getElementById('cgpa').value="";
	}
	else{
		showHide('resulttitle','none');
		showHide('result1','none');
		showHide('cgpatitle','inline');
		showHide('cgpa1','inline');		
		document.getElementById('result').value="";
	}	
}

function countryCheck(optValue){
	if (optValue=="Malaysia"){
	showHide('state','inline');	
	showHide('state2','none');
	document.getElementById('state').disabled=false;
	document.getElementById('state2').disabled=true;
	}else {
	showHide('state','none');	
	showHide('state2','inline');
	document.getElementById('state2').disabled=false;
	document.getElementById('state').disabled=true;
	//document.getElementById('').value="";
	}
}

function r_countryCheck(optValue){
	if (optValue=="Malaysia"){
	showHide('r_state','inline');	
	showHide('r_state2','none');
	document.getElementById('r_state').disabled=false;
	document.getElementById('r_state2').disabled=true;
	}else {
	showHide('r_state','none');	
	showHide('r_state2','inline');
	document.getElementById('r_state2').disabled=false;
	document.getElementById('r_state').disabled=true;
	//document.getElementById('').value="";
	}
}


function setFocus(focusObj) {
	focusObj.focus();	
}