function MM_findObj(n, d) { 
  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); return x;
}

function ValidateLogin(Control){
	var msg="";
	if (document.getElementById(Control+"lstIam").selectedIndex==0)
		msg+=" - I AM \n"
	if(document.getElementById(Control+"txtUsername").value=="")
		msg+=" - Username \n"
	if(document.getElementById(Control+"txtPassword").value=="")
		msg+=" - Password\n"
	if (msg!=""){
		alert("The following fields are required\n please be sure to fill them and try again:\n" +msg)
		return false
		}
	else{
		return true;
		}	
}

function ValidateLoginType(Control){
	var msg="";
	if (document.getElementById(Control+"lstIam").selectedIndex==0)
		msg+=" - I AM \n"
	if (msg!=""){
		alert("The following fields are required\n please be sure to fill them and try again:\n" +msg)
		return false
		}
	else{
		return true;
		}	
}

function HighlightMenu(ID){
	document.getElementById(ID).className="on";
}

function ValidateCreateInternship(){
    var msg="";
	if (document.getElementById("txtName").value=="")
		msg+=" - Company Name \n";
	if (document.getElementById("txtCompanyAddress").value=="")
		msg+=" - Company Address \n";
	if (document.getElementById("lstCompanyType").selectedIndex==0)
		msg+=" - Company Type\n";
	if(document.getElementById("txtContact").value=="")
		msg+=" - Contact Person \n";
	if(document.getElementById("txtStartDate").value=="")
		msg+=" - Start Date \n";
	if(document.getElementById("txtEndDate").value=="")
		msg+=" - End Date \n";
	if (document.getElementById("lstCountry").selectedIndex==0)
		msg+=" - Country \n";
	if(document.getElementById("txtFile").value=="")
		msg+=" - Company's Confirmation Letter (scanned)\n";
	if (msg!=""){
		alert("The following fields are required\n please be sure to fill them and try again:\n" +msg)
		return false;
		}
	else{
		return true;
		}	
}

function ValidateLetterRequest(){
    var msg="";
	if (document.getElementById("txtInstitution").value=="")
		msg+=" - Company Name \n";
	if (document.getElementById("txtName").value=="")
		msg+=" - Contact Person \n";
	if (document.getElementById("txtTitle").value=="")
		msg+=" - Title \n";
	if (document.getElementById("lstCompanyType").selectedIndex==0)
		msg+=" - Company Type\n";
	if(document.getElementById("txtDuration").value=="")
		msg+=" - Duration \n";
	if(document.getElementById("txtBC").value=="")
		msg+=" - Business Card \n";
	if (msg!=""){
		alert("The following fields are required\n please be sure to fill them and try again:\n" +msg)
		return false;
		}
	else{
		return true;
		}	
}
function ValidateAUBID(){
	if (Trim(document.getElementById("txtAUBID").value)==""){
		alert("Please enter your AUB ID\n")
		return false;
	}
	else
	return true;
	}
function ValidateStudentRegister(){
	var msg="";
	var msg2="";
	/*if (document.getElementById("lstIam").selectedIndex==0)
		msg+=" - I AM \n"*/
	if (Trim(document.getElementById("txtAUBID").value)=="")
		msg+=" - AUB ID \n";
	if (Trim(document.getElementById("txtUsername").value)==""){
		msg+=" - Username \n";}
	else{
		msg2=CheckTextCombination(document.getElementById("txtUsername"),"Username")
		if (msg2!="")
			msg+=msg2;
	}
	if (Trim(document.getElementById("txtPassword").value)==""){
		msg+=" - Password\n"}
	else{
		msg2=CheckTextCombination(document.getElementById("txtPassword"),"Password")
		if (msg2!="")
			msg+=msg2;
		}
	if (Trim(document.getElementById("txtConfirm").value)=="")
		msg+=" - Confirm Password\n"	
	if (Trim(document.getElementById("txtPassword").value)!=Trim(document.getElementById("txtConfirm").value))
	    msg+=" - New password and its confirmation do not match.\n"	
	if (document.getElementById("txtFirstName").value=="")
		msg+=" - First Name \n";
	if (document.getElementById("txtMiddleName").value=="")
		msg+=" - Middle Name \n";
	if (document.getElementById("txtLastName").value=="")
		msg+=" - Last Name \n";
	if (document.getElementById("txtAUBEmail").value==""){
		msg+=" - AUB Email \n";	}
	else{
		var strvalmail=IsValidAUBEmail(document.getElementById("txtAUBEmail"),"AUB Email");
		if (strvalmail==false)
			msg+=" - Invalid AUB Email Address \n"
		} 
	if (document.getElementById("txtEmail1").value==""){
		msg+=" - Permanent Email 1 \n";}
	else{
		var strvalmail=IsValidEmail(document.getElementById("txtEmail1"),"Permanent Email 1");
		if (strvalmail.length>0)
			msg+=strvalmail
		}
	if (document.getElementById("txtAddress").value=="")
		msg+=" - Address \n";
	if (document.getElementById("txtMobile").value==""){
		msg+=" - Mobile \n";}
	else if(document.getElementById("txtMobile").value.length<8){
		msg+=" - Mobile must be at leat 8 characters \n";
		}
	if (document.getElementById("txtPhone").value!="" && document.getElementById("txtPhone").value.length<8){
		msg+=" - Phone must be at leat 8 characters \n";
		}	
	if (document.Form1.lstBirthMonth.selectedIndex==0 || document.Form1.lstBrithDay.selectedIndex==0 || document.Form1.lstBirthYear.selectedIndex==0)
		msg+=" - Birth Date\n"
	if (CheckRadioButtons(document.Form1.rdGender)==false)
		msg+=" - Gender\n"
	if (document.getElementById("txtPhoto").value=="")
		msg+=" - Photo \n";
	if (document.getElementById("lstGPA").selectedIndex==0)
		msg+=" - GPA range \n";
	msg+= CheckLanguages();
	if (msg!=""){
		alert("The following fields are required\n please be sure to fill them and try again:\n" +msg)
		return false;
		}
	else{
		return true;
		}	
	}
function ValidateCompanyRegister(){
	var msg="";
	var msg2="";
	if (Trim(document.getElementById("txtUsername").value)==""){
		msg+=" - Username \n";}
	else{
		msg2=CheckTextCombination(document.getElementById("txtUsername"),"Username")
		if (msg2!="")
			msg+=msg2;
	}
	if (Trim(document.getElementById("txtPassword").value)==""){
		msg+=" - Password\n"}
	else{
		msg2=CheckTextCombination(document.getElementById("txtPassword"),"Password")
		if (msg2!="")
			msg+=msg2;
		}
	if (Trim(document.getElementById("txtConfirm").value)=="")
		msg+=" - Confirm Password\n"	
	if (Trim(document.getElementById("txtPassword").value)!=Trim(document.getElementById("txtConfirm").value))
	    msg+=" - New password and its confirmation do not match.\n"	
	if (document.getElementById("txtCompanyName").value=="")
		msg+=" - Company Name \n";
	if (document.getElementById("txtCEO").value=="")
		msg+=" - CEO\n";
	if (document.getElementById("txtContact").value=="")
		msg+=" - Contact Person\n";
	if (document.getElementById("txtEmail").value==""){
		msg+=" - Email \n";}
	else{
		var strvalmail=IsValidEmail(document.getElementById("txtEmail"),"Email");
		if (strvalmail.length>0)
			msg+=strvalmail
		}
	if (document.getElementById("txtPhone").value!="" && document.getElementById("txtPhone").value.length<8){
		msg+=" - Phone must be at leat 8 characters \n";
		}	
	if (document.getElementById("txtFax").value=="")
		msg+=" - Fax \n";
	if (document.getElementById("txtHRName").value=="")
		msg+=" - HR Manager Name \n";
	if (document.getElementById("txtHREmail").value=="")
		msg+=" - HR Manager Email  \n";
	if (document.getElementById("txtHRPhone").value=="")
		msg+=" - HR Manager Phone  \n";
	if (document.getElementById("lstCompanyType").selectedIndex==0)
		msg+=" - Company Type \n";
	if (document.getElementById("lstIndustry").selectedIndex==0)
		msg+=" - Industry \n";
	if (document.getElementById("txtWebiste").value=="")
		msg+=" - Website \n";
	if (msg!=""){
		alert("The following fields are required\n please be sure to fill them and try again:\n" +msg)
		return false;
		}
	else{
		return true;
		}	
	}
	
function ValidateAlumniRegister(){
	var msg="";
	var msg2="";
	/*if (document.getElementById("lstIam").selectedIndex==0)
		msg+=" - I AM \n"*/
	if (Trim(document.getElementById("txtAUBID").value)=="")
		msg+=" - AUB ID \n";
	if (Trim(document.getElementById("txtUsername").value)==""){
		msg+=" - Username \n";}
	else{
		msg2=CheckTextCombination(document.getElementById("txtUsername"),"Username")
		if (msg2!="")
			msg+=msg2;
	}
	if (Trim(document.getElementById("txtPassword").value)==""){
		msg+=" - Password\n"}
	else{
		msg2=CheckTextCombination(document.getElementById("txtPassword"),"Password")
		if (msg2!="")
			msg+=msg2;
		}
	if (Trim(document.getElementById("txtConfirm").value)=="")
		msg+=" - Confirm Password\n"	
	if (Trim(document.getElementById("txtPassword").value)!=Trim(document.getElementById("txtConfirm").value))
	    msg+=" - New password and its confirmation do not match.\n"	
	if (document.getElementById("txtFirstName").value=="")
		msg+=" - First Name \n";
	if (document.getElementById("txtMiddleName").value=="")
		msg+=" - Middle Name \n";
	if (document.getElementById("txtLastName").value=="")
		msg+=" - Last Name \n";
	if (document.getElementById("txtAUBEmail").value==""){
		msg+=" - AUB Email \n";	}
	else{
		var strvalmail=IsValidAUBEmail(document.getElementById("txtAUBEmail"),"AUB Email");
		if (strvalmail==false)
			msg+=" - Invalid AUB Email Address \n"
		} 
	if (document.getElementById("txtEmail1").value==""){
		msg+=" - Permanent Email 1 \n";}
	else{
		var strvalmail=IsValidEmail(document.getElementById("txtEmail1"),"Permanent Email 1");
		if (strvalmail.length>0)
			msg+=strvalmail
		}
	if (document.getElementById("txtAddress").value=="")
		msg+=" - Address \n";
	if (document.getElementById("txtMobile").value==""){
		msg+=" - Mobile \n";}
	else if(document.getElementById("txtMobile").value.length<8){
		msg+=" - Mobile must be at leat 8 characters \n";
		}
	if (document.getElementById("txtPhone").value!="" && document.getElementById("txtPhone").value.length<8){
		msg+=" - Phone must be at leat 8 characters \n";
		}	
	if (document.Form1.lstBirthMonth.selectedIndex==0 || document.Form1.lstBrithDay.selectedIndex==0 || document.Form1.lstBirthYear.selectedIndex==0)
		msg+=" - Birth Date\n"
	if (CheckRadioButtons(document.Form1.rdGender)==false)
		msg+=" - Gender\n"
	if (document.getElementById("txtPhoto").value=="")
		msg+=" - Photo \n";
	if (document.getElementById("txtCV").value=="")
		msg+=" - CV \n";
	if (document.getElementById("lstGPA").selectedIndex==0)
		msg+=" - GPA range \n";
	msg+= CheckLanguages();
	msg+=CheckUniversities();
	msg+=CheckWorkExperience();
	msg+=CheckProfessionalCertifications();
	if (msg!=""){
		alert("The following fields are required\n please be sure to fill them and try again:\n" +msg)
		return false;
		}
	else{
		return true;
		}	
	}
	
function CheckUniversities(){
	var msg="";
	for (var i=1;i<=3;i++){
		if (document.getElementById("txtUniversityName"+i).value!=""){
			if (document.getElementById("txtUniversityDegree"+i).value=="")
				msg+=" - University "+ i +" Degree Received  \n";
			if (document.getElementById("lstUniversity"+ i +"Month").selectedIndex==0 || document.getElementById("lstUniversity"+ i +"Year").selectedIndex==0)
				msg+=" - University "+ i +" Date of Graduation \n";
		}
	}
	return msg;
}
function CheckProfessionalCertifications(){
	var msg="";
	for (var i=1;i<=3;i++){
		if (document.getElementById("txtQualificationName"+i).value!=""){
			if (document.getElementById("lstQualification"+ i +"Month").selectedIndex==0 || document.getElementById("lstQualification"+ i +"Year").selectedIndex==0)
				msg+=" - Qualification "+ i +" Date Received \n";
		}
	}
	return msg;
	
}
function CheckWorkExperience(){
	var msg="";
	for (var i=1;i<=3;i++){
		if (document.getElementById("txtCompanyName"+i).value!=""){
			if (document.getElementById("txtJobTitle"+i).value=="")
				msg+=" - Company "+ i +" Job Title  \n";
			if (document.getElementById("lstWork"+ i +"StartMonth").selectedIndex==0 || document.getElementById("lstWork"+ i +"StartYear").selectedIndex==0)
				msg+=" - Company "+ i +" Start Date \n";
	        if (document.getElementById("lstWork"+ i +"EndMonth").selectedIndex==0 || (document.getElementById("lstWork"+ i +"EndYear").selectedIndex==0 && document.getElementById("lstWork"+ i +"EndMonth").selectedIndex!=1 ) )
				msg+=" - Company "+ i +" End Date \n";	
		}
	}
	return msg;
	
}
function validateforgot()
{
    var msg="";
	if (document.getElementById("txtAUBEmail").value==""){
		msg=" - Please enter your AUB Email address \n";	}
	else{
		var strvalmail=IsValidAUBEmail(document.getElementById("txtAUBEmail"),"AUB Email");
		if (strvalmail==false)
			msg=" - Invalid AUB Email Address \n"
		}
	if (msg!=""){
		alert(msg)
		return false;
		}
	else{
		return true;
		}	
}
function validateforgotcompany()
{
    var msg="";
	if (document.getElementById("txtEmail").value==""){
		msg+=" - Please enter your email address \n";}
	else{
		var strvalmail=IsValidEmail(document.getElementById("txtEmail"),"Email");
		if (strvalmail.length>0)
			msg=" - Invalid Email Address \n"
		}
	if (msg!=""){
		alert(msg)
		return false;
		}
	else{
		return true;
		}	
}
function ValidateStudentEdit(){
	var msg="";
	var msg2="";
	/*if (document.getElementById("lstIam").selectedIndex==0)
		msg+=" - I AM \n"*/
	if (document.getElementById("txtFirstName").value=="")
		msg+=" - First Name \n";
	if (document.getElementById("txtMiddleName").value=="")
		msg+=" - Middle Name \n";
	if (document.getElementById("txtLastName").value=="")
		msg+=" - Last Name \n";
	if (document.getElementById("txtAUBEmail").value==""){
		msg+=" - AUB Email \n";	}
	else{
		var strvalmail=IsValidAUBEmail(document.getElementById("txtAUBEmail"),"AUB Email");
		if (strvalmail==false)
			msg+=" - Invalid AUB Email Address \n"
		} 
	if (document.getElementById("txtEmail1").value==""){
		msg+=" - Permanent Email 1 \n";}
	else{
		var strvalmail=IsValidEmail(document.getElementById("txtEmail1"),"Permanent Email 1");
		if (strvalmail.length>0)
			msg+=strvalmail
		}
	if (document.getElementById("txtAddress").value=="")
		msg+=" - Address \n";
	if (document.getElementById("txtMobile").value=="")
		msg+=" - Mobile \n";
	if (document.Form1.lstBirthMonth.selectedIndex==0 || document.Form1.lstBrithDay.selectedIndex==0 || document.Form1.lstBirthYear.selectedIndex==0)
		msg+=" - Birth Date\n"
	if (CheckRadioButtons(document.Form1.rdGender)==false)
		msg+=" - Gender\n"
	if (document.getElementById("lstGPA").selectedIndex==0)
		msg+=" - GPA range \n";
	if (msg!=""){
		alert("The following fields are required\n please be sure to fill them and try again:\n" +msg)
		return false;
		}
	else{
		return true;
		}	
	}
	
function ValidateCommittmentForm(){
 	var msg="";
	if (document.getElementById("txtName").value=="")
		msg+=" - Full Name \n";
	if (document.getElementById("txtAUBID").value=="")
		msg+=" - AUB ID \n";
	if (document.getElementById("txtName2").value=="")
		msg+=" - Name \n";
	if(document.getElementById("txtEmail").value=="")
		msg+=" - Email \n";
	if(document.getElementById("txtMobile").value=="")
		msg+=" - Mobile \n";
	 if (document.Form1.agree.checked==false)
	   msg+=" - You should agree on the terms before submitting the form \n"	
	if (msg!=""){
		alert("The following fields are required\n please be sure to fill them and try again:\n" +msg)
		return false;
		}
	else{
		return true;
		}		
	}

	
function CheckLanguages(){
	var langSelected=false
	var msgLang="";
	var index=""
	var rdLanguage;
	//check if language is selected
	for (j=1;j<=3;j++){
		if (document.getElementById("lstLanguage"+j).selectedIndex>0){
			langSelected=true;
			break;
			}	
		}
	if (langSelected==false){
		msgLang+=" - Languages\n"
		}
	// check if lang. Prof. is selected
	else{
		for (var i=1;i<=3;i++){
			if (document.getElementById("lstLanguage"+i).selectedIndex>0 && CheckRadioButtons(eval("document.Form1.rdLanguage"+i))==false){
				msgLang +=" - Language " + i + " Proficiency\n";
			}
		}// end for
	}// end if lang selected
return msgLang;	
}
function CheckTextCombination(txt, fieldname){
	var ischar=false;
	var isnumber=false;
	var msg="";
	var ValidChars = "0123456789";
	if (txt.value.length<3){
		msg=" - " +fieldname+ " must be at least 3 characters\n"
		}
	else{
		for (var i = 0; i <=txt.value.length ; i++){ 
		Char = txt.value.charAt(i); 
		if (ValidChars.indexOf(Char) == -1){
			ischar=true;
			}
		else{
			isnumber=true;
			}
	}
	if (isnumber==true && ischar==true)
		msg=""
	else{
		msg=" - "+fieldname+" must be a combination of numbers and characters\n";
		//alert(isnumber +"-"+ ischar)
	}
		
	}
	return msg
}
	
function ValidateChangePassword(){
	if (document.Form1.txtOldpwd.value=="" || document.Form1.txtNewPwd.value=="" || document.Form1.txtConfirm.value=="")
	{
		alert("The following fields are required:\n - Old Password \n - New Password \n - Confirm New Password");
	    return false;
	  }
	else{
		if (document.Form1.txtNewPwd.value!=document.Form1.txtConfirm.value){
			alert("New Password and Confirm New Password do not match");
			return false;
			}
		else{
			return true;
		}
	}
}

function ValidateInternshipsSearch(){
    if (Trim(document.getElementById("txtKeyword").value)=="" && document.getElementById("lstCountry").selectedIndex==0){
		alert("Please enter your search keyword or select a country\n" )
		return false;
		}
	else{
	    return true
	}
}

function ShowPhotoUpload(){
	document.getElementById('txtPhoto').style.visibility='visible';
}
function ShowCVUpload(){
	document.getElementById('txtCV').style.visibility='visible';
}
function openIT(u,W,H, sc) {
		var x = (screen.width - W) / 2;
		var y = (screen.height - H) / 2;
		//window.open(u, '',"width="+W+",height="+H+",scrollbars="+(sc ? "yes" : "no")+",resizable=Yes, left="+x+",top="+y);
		window.open(u, '',"width="+W+",height="+H+",scrollbars=yes,resizable=Yes, left="+x+",top="+y);
}
function popStudentPhoto(myPhoto){
	openIT('pop_gl.htm?img=StudentsDocuments/Photos/'+myPhoto+"&caption=",800,550);
	}
function popStudentUpload(myType){
	openIT("InternshipUpload.aspx?type="+myType,800,550);
	}
function popStudentReportUpload(Week){
	openIT("InternshipUpload.aspx?type=Report&Week="+Week,800,550);
	}
function CloseWindow(){
	window.opener.location.reload()
	window.close();
	}
function ShowHideInfoDiv(div_id,visibility){
	document.getElementById(div_id).style.visibility=visibility;
	}	
function ValidatePostJob(){
    var msg="";
	if (document.getElementById("txtTitle").value=="")
		msg+=" - Job Title \n";
	if (document.getElementById("txtDeadline").value=="")
		msg+=" - Deadline \n";
	if (document.getElementById("lstLocation").selectedIndex==0)
		msg+=" - Location\n";
	if (document.getElementById("lstIndustry").selectedIndex==0)
		msg+=" - Industry\n";
	
	if (msg!=""){
		alert("The following fields are required\n please be sure to fill them and try again:\n" +msg)
		return false;
		}
	else{
		return true;
		}	
}	
function ValidateJobsSearch(){
	var msg="";
	var msgIndustry=ValidateMultiSelection(document.getElementById("lstIndustry"),10);
	if (Trim(document.getElementById("txtKeyword").value)=="" &&  msgIndustry=="empty"){
		msg="Please enter your search criteria\n" 
		}
	else if (msgIndustry !="empty" && msgIndustry!=""){
		msg="Industry: " + msgIndustry
	}
	
	if (msg!=""){
		alert(msg)
		return false;
		}
	else{
		return true;
		}		
	}

function ValidateJobsAdvancedSearch(){
	var msg="";
	var msgLocation=ValidateMultiSelection(document.getElementById("lstLocation"),10);
	var msgIndustry=ValidateMultiSelection(document.getElementById("lstIndustry"),10);
	if (Trim(document.getElementById("txtKeyword").value)=="" && msgLocation=="empty" && msgIndustry=="empty" && CheckRadioButtons(document.Form1.rbtnEmplymentStatus)==false ){
		msg="Please enter your search criteria\n" 
		}
	else if (msgLocation !="empty" && msgLocation!=""){
		msg="Location: " + msgLocation
	}
	else if (msgIndustry !="empty" && msgIndustry!=""){
		msg="Industry: " + msgIndustry
	}
if (msg!=""){
		alert(msg)
		return false;
		}
	else{
		return true;
		}		
	}
function ValidateProfilesSearch(){
	/*var msg="";
		if (Trim(document.getElementById("txtKeyword").value)=="" &&  document.getElementById("lstMinAge").selectedIndex==0 && document.getElementById("lstMaxAge").selectedIndex==0  && document.getElementById("lstGender").selectedIndex==0  && document.getElementById("lstNationality").selectedIndex==0  && document.getElementById("lstConcentration").selectedIndex==0 && document.getElementById("lstGPA").selectedIndex==0 && Trim(document.getElementById("txtUniveristyKeyword").value)==""){
		msg="Please enter your search criteria\n" 
		}
	if (msg!=""){
		alert(msg)
		return false;
		}
	else{
		return true;
		}		*/
		return true;
	}
//---------------------------------------------------------------------------GENERAL FUNCTIONS-----------------------------------------------------------	

//-----------------------------------------MULTI SELECTION LIST
function ValidateMultiSelection(lst, maxSelect){
	var counter = 0;
	var msg="";
	for (var i = 0; i < lst.length; i++) {
		if (lst.options[i].selected ) counter = counter + 1;
	}
	if(counter==0){
		msg="empty";
		}
	else if (counter>maxSelect){
		msg="Too many selections: "+ counter +" options are selected out of a limit of " + maxSelect;
		}
	return msg
}

//-----------------------------------------RADIOBUTTONS
function CheckRadioButtons(rbtn){
	   var check=false;
   for (i=0;i<rbtn.length;i++){
	  if(rbtn[i].checked==true) {
       return true;
	  }
   }
   return false;
}
//-------------------------------------------EMAIL FORMAT
function IsValidEmail(txt,Emailname){
    var stremail="";
	if(txt.value !=""){ 
		var goodEmail = txt.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
		if (goodEmail){
		    return true;
		} else {
			stremail=" - " + Emailname + " is not a valid email address\n";
			return stremail;
		}
	}
}
function IsValidAUBEmail(txt){
    return txt.value.indexOf("@") == -1;
}
//-------------------------------------------TRIM
function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
		}
	else{
		return TRIM_VALUE;
		}
} //End Function

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
		}
		var iTemp = v_length -1;
		while(iTemp > -1){
			if(VALUE.charAt(iTemp) == w_space){
			}
			else{
				strTemp = VALUE.substring(0,iTemp +1);
				break;
			}
			iTemp = iTemp-1;
			} //End While
			return strTemp;
} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";
	var iTemp = 0;
	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
	}
	else{
		strTemp = VALUE.substring(iTemp,v_length);
		break;
	}
	iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function
//end TRIM functions

