document.write("<script language='JavaScript' src='script/general.js'></script>");
document.write("<script language='JavaScript' src='script/calendar.js'></script>");
document.write("<script language='JavaScript' src='script/popcalendar.js'></script>");




/* Validation of the Login page.*/
function login(form)
{
	var str="";
	if(form.username.value=="")
	{
		str="Please provide your username.";
		alert(str);
		form.username.focus();
		return false;
	}
	if(form.password.value=="")
	{
		str = "Please provide your password."
		alert(str);
		form.password.focus();
		return false;
	}
	else
	{
		if(checkSpaces(form.password.value))
		{
			str = "Invalid password! Blank spaces are not allowed."
			alert(str);
			form.password.focus();
			return false;
		}
	}
	return true;
}

/* Change Password */
function changepass_validate(form)
{
	if(form.txtoldpass.value=='')
	{
		str = "Please enter old password.";
		alert(str);
		form.txtoldpass.focus();
		return false;
	}
	else
	{
		if(checkSpaces(form.txtoldpass.value))
		{
			str = "Invalid old password! Blank spaces are not allowed."
			alert(str);
			form.txtoldpass.focus();
			return false;
		}
		if(form.txtoldpass.value.length <4 || form.txtoldpass.value.length >10)
		{
			str = "Old password can be of 4-10 characters."
			alert(str);
			form.txtoldpass.focus();
			return false;
		}
	}
	
	if(form.txtnewpass.value=='')
	{
		str = "Please enter new password.";
		alert(str);
		form.txtnewpass.focus();
		return false;
	}
	if(form.txtnewpass.value!='')
	{
		if(checkSpaces(form.txtnewpass.value))
		{
			str = "Invalid new password! Blank spaces are not allowed."
			alert(str);
			form.txtnewpass.focus();
			return false;
		}
		if(form.txtnewpass.value.length <4 || form.txtnewpass.value.length >10)
		{
			str = "New password can be of 4-10 characters."
			alert(str);
			form.txtnewpass.focus();
			return false;
		}
		if(form.txtconfirm.value=='')
		{
			str = "Please enter confirm password.";
			alert(str);
			form.txtconfirm.focus();
			return false;
		}
		if(form.txtconfirm.value!='')
		{
			if(checkSpaces(form.txtconfirm.value)){
				str = "Invalid new password! Blank spaces are not allowed."
				alert(str);
				form.txtconfirm.focus();
				return false;
			}
			if(form.txtconfirm.value.length <4 || form.txtconfirm.value.length >10)
			{
				str = "Confirm password can be of 4-10 characters."
				alert(str);
				form.txtconfirm.focus();
				return false;
			}
			if(form.txtnewpass.value != form.txtconfirm.value)
			{
				str = "Confirm password mismatch with new password.";
				alert(str);
				form.txtconfirm.focus();
				return false;
			}
		}
	}
	return true;
}

/* Validation of the Banner page.*/
function banner(form,page)
{
	var str;
	if(page=='add')
	{
		if(form.logo1.value=="")
		{
			str="Please browse for an image file.";
			alert(str);
			form.logo1.focus();
			return false;
		}
	}
	if(form.txtdescription.value!="")
	{
		var val = form.txtdescription.value;
		if(val.length>250)
		{
			str="Please enter maximum of 250 characters.";
			alert(str);
			form.txtdescription.focus();
			return false;
		}
	}
	return true;
}




function changepass_validate(form)
{
	if(form.txtoldpass.value=='')
	{
		str = "Please enter old password.";
		alert(str);
		form.txtoldpass.focus();
		return false;
	}
	else
	{
		if(checkSpaces(form.txtoldpass.value))
		{
			str = "Invalid old password! Blank spaces are not allowed."
			alert(str);
			form.txtoldpass.focus();
			return false;
		}
		if(form.txtoldpass.value.length <4 || form.txtoldpass.value.length >10)
		{
			str = "Old password can be of 4-10 characters."
			alert(str);
			form.txtoldpass.focus();
			return false;
		}
	}
	
	if(form.txtnewpass.value=='')
	{
		str = "Please enter new password.";
		alert(str);
		form.txtnewpass.focus();
		return false;
	}
	if(form.txtnewpass.value!='')
	{
		if(checkSpaces(form.txtnewpass.value))
		{
			str = "Invalid new password! Blank spaces are not allowed."
			alert(str);
			form.txtnewpass.focus();
			return false;
		}
		if(form.txtnewpass.value.length <4 || form.txtnewpass.value.length >10)
		{
			str = "New password can be of 4-10 characters."
			alert(str);
			form.txtnewpass.focus();
			return false;
		}
		if(form.txtconfirm.value=='')
		{
			str = "Please enter confirm password.";
			alert(str);
			form.txtconfirm.focus();
			return false;
		}
		if(form.txtconfirm.value!='')
		{
			if(checkSpaces(form.txtconfirm.value)){
				str = "Invalid new password! Blank spaces are not allowed."
				alert(str);
				form.txtconfirm.focus();
				return false;
			}
			if(form.txtconfirm.value.length <4 || form.txtconfirm.value.length >10)
			{
				str = "Confirm password can be of 4-10 characters."
				alert(str);
				form.txtconfirm.focus();
				return false;
			}
			if(form.txtnewpass.value != form.txtconfirm.value)
			{
				str = "Confirm password mismatch with new password.";
				alert(str);
				form.txtconfirm.focus();
				return false;
			}
		}
	}
	return true;
}

// CMS validation

function validate_aboutus(form)
{
	/*
	if(form.txtdesc.value=="")
	{   
		str = "Please enter the content [use Editor].";
		alert(str);
		return false;
	}*/
	return true;
}

function validate_service(form)
{
	if(form.txttitle.value=='')
	{   
		str = "Please enter the title.";
		alert(str);
		form.txttitle.focus();
		return false;
	}
	if(form.txtshortdesc.value=='')
	{   
		str = "Please enter short descripiton.";
		alert(str);
		form.txtshortdesc.focus();
		return false;
	}
	if(form.txtdesc.value=='')
	{   
		str = "Please enter the description [use Editor].";
		alert(str);
		return false;
	}
	return true;
}

function validate_recruitment(form)
{
	//alert("hello");
	if(form.txtfirstname.value=='')
	{
		str = "Please enter first name.";
		alert(str);
		form.txtfirstname.focus();
		return false;
	}
	
	if(form.txtsurname.value=='')
	{
		str = "Please enter surname.";
		alert(str);
		form.txtsurname.focus();
		return false;
	}
	
	if(form.txtemail.value=='')
	{
		str = "Please enter your email address.";
		alert(str);
		form.txtemail.focus();
		return false;
	}
	else
	{
		var result = checkEmail(form.txtemail.value);
		if(!result)
		{
			str="Invalid email address! Please re-enter.";
			alert(str);
		    form.txtemail.focus();
			return false;
		}
	}
	
	if(form.txtphone.value=='')
	{
		str = "Please enter your phone number.";
		alert(str);
		form.txtphone.focus();
		return false;
	}
	if(checkPhone(form.txtphone.value))
	{
		alert("Phone number must contain only digits,-,(,),+.");
		form.txtphone.focus();
		return false;
	}
	
	if(form.txtfax.value!='')
	{
		if(checkPhone(form.txtfax.value))
		{
			alert("Fax number must contain only digits,-,(,),+.");
			form.txtphone.focus();
			return false;
		}
	}
	
	if(form.txtaddress.value=='')
	{
		str = "Please enter your address.";
		alert(str);
		form.txtaddress.focus();
		return false;
	}
	
	if(form.lstcountry.value=='')
	{
		str = "Please enter country.";
		alert(str);
		form.lstcountry.focus();
		return false;
	}
	
	if(form.txtpostalcode.value=='')
	{
		str = "Please enter postal code.";
		alert(str);
		form.txtpostalcode.focus();
		return false;
	}
	
	if(form.txtcity.value=='')
	{
		str = "Please enter city.";
		alert(str);
		form.txtcity.focus();
		return false;
	}
	return true;
}


function validate_enquiry(form)
{
	if(form.txtemail.value!='')
	{
		var result = checkEmail(form.txtemail.value);
		if(!result)
		{
			str="Invalid email address! Please re-enter.";
			alert(str);
		    form.txtemail.focus();
			return false;
		}
	}
	return true;
}