
var lwr = 'abcdefghijklmnopqrstuvwxyz';
var upr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var dig = '1234567890';
var space= ' ';

function isValid(parm,val)
{
  for (i=0; i<parm.length; i++)
  {
    if (val.indexOf(parm.charAt(i),0) == -1) return false;
  }
  return true;
}

function isEmpty(textvalue) {
	textvalue=textvalue.replace(/\s/g,"");
	if(textvalue.length>0)
		return false;
	else
		return true;
}
function validURL(url){
	var elval= url.value.replace(/[\n\r\s]+/,"");
	if(elval =="") return true;
	var str=url.value;
	if(1){
		var filter=/^((ht|f)tp(s?))(:((\/\/)(?!\/)))(((w){3}\.)?)([a-zA-Z0-9\-_\.]+(\.(com|edu|gov|int|mil|net|org|biz|info|name|pro|museum|co\.uk|in)))((?!\/))(([a-zA-Z0-9\-_\/]*)?)$/i
	}
	if (filter.test(str))
		testresults=true;
	else
		testresults=false;

	return (testresults);
}

function viewToolTip(id,parentId,posX,posY)
{

	it = document.getElementById(id);
	 if ((it.style.top == '' || it.style.top == 0)
        && (it.style.left == '' || it.style.left == 0))
    {
        // need to fixate default size (MSIE problem)
        it.style.width = it.offsetWidth + 'px';
        it.style.height = it.offsetHeight + 'px';

        img = document.getElementById(parentId);

        // if tooltip is too wide, shift left to be within parent
        if (posX + it.offsetWidth > img.offsetWidth) posX = img.offsetWidth - it.offsetWidth;
        if (posX < 0 ) posX = 0;

        x = xstooltip_findPosX(img) + posX;
        y = xstooltip_findPosY(img) + posY;

        it.style.top = y + 'px';
        it.style.left = x + 'px';
    }



	it.style.visibility = 'visible';
}

function xstooltip_findPosX(obj)
{
  var curleft = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

/*******************************************
Script used to display current date.
********************************************/
function addToArray(ar, str)
{
	var l
	l = ar[0] + 1
	ar[l] = str
	ar[0] = l
}
function makeArray()
{
	array = new Object();
	array[0] = 0;
	return array;
}

var dayNames = makeArray()
addToArray(dayNames, " Sun")
addToArray(dayNames, " Mon")
addToArray(dayNames, " Tue")
addToArray(dayNames, " Wed")
addToArray(dayNames, " Thu")
addToArray(dayNames, " Fri")
addToArray(dayNames, " Sat")

function ShowDay()
{
	var ryear = document.add.Year.selectedIndex;
	if(ryear < 0)
		ryear= 0;
	ryear= document.add.Year.options[ryear].value - 0;
	var rmonth = document.add.Month.selectedIndex;
	var rdate = document.add.Day.selectedIndex + 1;
	var rnow = new Date(ryear,rmonth,rdate);
	var now = new Date();
	var rday = rnow.getDay() + 1;
	document.add.data[Timetable][dayweek].value = dayNames[rday]

}


Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 2000) NowYear += 1900; //for Netscape

//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear)
{
  var DaysInMonth = 31;
  if (WhichMonth == "Apr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30;
  if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
  if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
  ShowDay();
  return DaysInMonth;
}

//function to change the available days in a months
function ChangeOptionDays(Which)
{
  DaysObject = eval("document.add." + Which + "Day");
  MonthObject = eval("document.add." + Which + "Month");
  YearObject = eval("document.add." + Which + "Year");
  Month = MonthObject[MonthObject.selectedIndex].text;
  Year = YearObject[YearObject.selectedIndex].text;
  DaysForThisSelection = DaysInMonth(Month, Year);
  CurrentDaysInSelection = DaysObject.length;
  if (CurrentDaysInSelection > DaysForThisSelection)
  {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
      DaysObject.options[DaysObject.options.length - 1] = null
    }
  }
  if (DaysForThisSelection > CurrentDaysInSelection)
  {
    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
    {
      NewOption = new Option(DaysObject.options.length + 1);
      DaysObject.add(NewOption);
    }
  }
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
	ShowDay();
}

//function to set options to today
function SetToToday(Which)
{
  DaysObject = eval("document.add." + Which + "Day");
  MonthObject = eval("document.add." + Which + "Month");
  YearObject = eval("document.add." + Which + "Year");

  YearObject[0].selected = true;
  MonthObject[NowMonth].selected = true;

  ChangeOptionDays(Which);

  DaysObject[NowDay-1].selected = true;
  ShowDay();
}

//function to write option years plus x
function WriteYearOptions(YearsAhead)
{
  line = "";
  for (i=0; i<YearsAhead; i++)
  {
    line += "<OPTION>";
    line += NowYear + i;
  }
  return line;
}

window.onload=function(){
SetToToday('');
ShowDay();
}

function xstooltip_findPosY(obj)
{
    var curtop = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}


function hideToolTip(id)
{
    it = document.getElementById(id);
    it.style.visibility = 'hidden';
}

function get_subcategories(){
	var d=document.getElementById('subcategories');
	 d.style.display = 'block';
}
/*
function get_subknife(){
	var d=document.getElementById('subknife');
	 d.style.display = 'block';
}
*/


function checkAll(chk) {

	for (var i=0;i < document.forms[0].elements.length;i++)
	{
		var e = document.forms[0].elements[i];
		if (e.type == "checkbox")
		{
			e.checked = chk.checked;
		}
	}
}

function checkAllNew(chk,frm,frm2) {

	var formelements = eval("document."+frm+".elements");

 	//alert(formelements.length);
 	for (var i=0;i < formelements.length;i++)
	{
		//alert(formelements[i].type);
		var e = formelements[i];
		if (e.type == "checkbox")
		{
			e.checked = chk.checked;
		}
	}
 }



 function selectActionNew(frm1,frm2) {

	var formelements1 = eval("document."+frm1);
	var formelements2 = eval("document."+frm2);



 	if (isEmpty(document.getElementById('selAction').value)) {
		 alert("Please select the action to be performed.");
		 document.getElementById('selAction').focus();
		 return false;
	 }


	 if (checkFormNew(frm1 ,frm2) == true) {
		formelements1.selectedAction.value = formelements2.selAction.value;
		//document.forms[0].mode.value = "performAction";

		if (formelements1.selectedAction.value != "delete") {
			formelements1.mode.value = "performAction";
		}
		else {
			formelements1.mode.value = "performDelete";
		}

		formelements1.submit();
	 }
	 else {
		 return false;
	 }
 }

function checkFormNew(frm1, frm2)
{

	var formelements1 = eval("document."+frm1);
	var formelements2 = eval("document."+frm2);

	var count=0;
	var msg;
	for (var i=0;i < formelements1.elements.length;i++)
	{
		var e = formelements1.elements[i];
		if (e.type == "checkbox")
		{
			if(e.checked)
				count=count+1;
		}
	}

	if(count==0)
	{
		alert("Please select atleast one record.");
		return false;
	}
	else
	{
		if (formelements2.selAction.value != "delete"){
			msg="Are you sure that you want to change the status?";
		}
		else {
			msg="Are you sure that you want to delete the selected record(s)?";
		}
		return confirm(msg);
	}

}//checkform

function selectAction() {
	 if (isEmpty(document.getElementById('selAction').value)) {
		 alert("Please select the action to be performed.");
		 document.getElementById('selAction').focus();
		 return false;
	 }


	 if (checkForm() == true) {
		document.forms[0].selectedAction.value = document.forms[1].selAction.value;
		//document.forms[0].mode.value = "performAction";

		if (document.forms[0].selectedAction.value != "delete") {
			document.forms[0].mode.value = "performAction";
		}
		else {
			document.forms[0].mode.value = "performDelete";
		}

		document.forms[0].submit();
	 }
	 else {
		 return false;
	 }
 }

function checkForm()
{
	var count=0;
	var msg;
	for (var i=0;i < document.forms[0].elements.length;i++)
	{
		var e = document.forms[0].elements[i];
		if (e.type == "checkbox")
		{
			if(e.checked)
				count=count+1;
		}
	}

	if(count==0)
	{
		alert("Please select atleast one record");
		return false;
	}
	else
	{
		if (document.forms[1].selAction.value != "delete"){
			msg="Are you sure that you want to change the status?";
		}
		else {
			msg="Are you sure that you want to delete the selected record(s)?";
		}
		return confirm(msg);
	}

}//checkform




function setUsageCharge() {
	newKnifeCost = parseFloat(document.getElementById('KniferegisterNewCost').value);
	oneTwentithCost = parseFloat(newKnifeCost/20);
	// 25 is hardcoded as per the client's document Knife Register Brief 3.
	// if 1/20th cost of new knife is less than 25 then the minimum usage charge will be $25;
	if (oneTwentithCost > 25) {
		document.getElementById('KniferegisterUsageCharge').value = oneTwentithCost;
	}
	else {
		document.getElementById('KniferegisterUsageCharge').value = 25;
	}
}

function hideShowKnifeAdvanceSearch()
{
	showStatus = document.getElementById('searchKnifeDiv').style.display;
	if(showStatus == 'block')
	{
		document.getElementById('hidIsDivBlock').value = "No";
		document.getElementById('advanceSearch').innerHTML = "Advance Search";
		document.getElementById('advanceSearch').title = "Advance Search";
		document.getElementById('searchKnifeDiv').style.display = "none";
	}
	else
	{
		document.getElementById('hidIsDivBlock').value = "Yes";
		document.getElementById('advanceSearch').innerHTML = "Simple Search";
		document.getElementById('advanceSearch').title = "Simple Search";
		document.getElementById('searchKnifeDiv').style.display = "block";
	}
}

function hideShowProcurementAdvanceSearch()
{
	showStatus = document.getElementById('searchProcurementDiv').style.display;
	if(showStatus == 'block')
	{
		document.getElementById('hidIsDivBlock').value = "No";
		document.getElementById('advanceSearch').innerHTML = "Advance Search";
		document.getElementById('advanceSearch').title = "Advance Search";
		document.getElementById('searchProcurementDiv').style.display = "none";
	}
	else
	{
		document.getElementById('hidIsDivBlock').value = "Yes";
		document.getElementById('advanceSearch').innerHTML = "Simple Search";
		document.getElementById('advanceSearch').title = "Simple Search";
		document.getElementById('searchProcurementDiv').style.display = "block";
	}
}


//----------------------- Miscellaneous functions ---------------------//

// This function is used to validate a given e-mail
// address for the proper syntax

function validateEmail(email)
{

	if (email == ""){
		return false;
	}
	badStuff = ";:/,' \"\\";
	for (i=0; i<badStuff.length; i++){
		badCheck = badStuff.charAt(i)
		if (email.indexOf(badCheck,0) != -1){
			return false;
		}
	}
	posOfAtSign = email.indexOf("@",1)
	if (posOfAtSign == -1){
		return false;
	}
	if (email.indexOf("@",posOfAtSign+1) != -1){
		return false;
	}
	posOfPeriod = email.indexOf(".", posOfAtSign)
	if (posOfPeriod == -1){
		return false;
	}
	if (posOfPeriod+2 > email.length){
		return false;
	}
	return true
}

//The function is to check the extension of the file.

function checkFileExtension(file)
{

	if(file != "") {
		extArray = new Array(".pdf", ".indd");
		while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);
		ext = file.slice(file.indexOf(".")).toLowerCase();

		for (var i = 0; i < extArray.length; i++) {
			if (extArray[i] == ext) {
				allowSubmit =1 ; break;
			}
			else {
				allowSubmit=2;
			}
	}

	if(allowSubmit==2) {
		alert("Only files with following extensions are allowed:  "
		+ (extArray.join("  ")));
		return false;
	}
	  return true;
	}
	else {
		return false;
	}
}


//The function is to check the specified extension of the file.

function checkFileExtensionArray(file, extArray)
{

	if(file != "") {
		//extArray = new Array(".pdf", ".indd");
		while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);
		ext = file.slice(file.indexOf(".")).toLowerCase();

		for (var i = 0; i < extArray.length; i++) {
			if (extArray[i] == ext) {
				allowSubmit =1 ; break;
			}
			else {
				allowSubmit=2;
			}
	}

	if(allowSubmit==2) {
		alert("Only files with following extensions are allowed:  "
		+ (extArray.join("  ")));
		return false;
	}
	  return true;
	}
	else {
		return false;
	}
}

//The function is to open the popup window of given width and height for a given URL

function openPopUpWindow(url, width, height) {
	window.open(url, 'popupwindow', 'width=' + width + ', height=' + height + ', scrollbars = yes, statusbar = no');
}

// The function add the option in a drop down list.

function addOption(selectBoxId, text, value) {
	 var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	elementId = eval("document.getElementById('" + selectBoxId + "')");
	elementId.options.add(optn);
}


function redirectToPage(pagePath) {
	window.location.href = pagePath;
}


function getGoingTOPoscodesForCity(path,cityId)
{
	new Ajax.Updater('going_postcode_div',''+ path +'/bookingdetails/getpostcodeforcity/'+cityId, {asynchronous:true, evalScripts:true});
}

function getCollectionPoscodesForCity(path,cityId)
{
	new Ajax.Updater('colection_postcode_div',''+ path +'/bookingdetails/getpostcodeforcollectioncity/'+cityId, {asynchronous:true, evalScripts:true});
}

function getGoingTOPoscodesForCityForHome(path,cityId)
{
	new Ajax.Updater('going_postcode_div',''+ path +'/chauffeurs/getpostcodeforcity/'+cityId, {asynchronous:true, evalScripts:true});
}

function getCollectionPoscodesForCityForHome(path,cityId)
{
	new Ajax.Updater('colection_postcode_div',''+ path +'/chauffeurs/getpostcodeforcollectioncity/'+cityId, {asynchronous:true, evalScripts:true});
}


//Validation for country.
function validate_countries(){

	//Validations for country name.
	if (isEmpty(document.getElementById('CountryCountryName').value)) {
		alert("Please enter country name.");
		document.getElementById('CountryCountryName').focus();
		return false;
	}

}

//Validation for city.
function validate_cities(){

	if (isEmpty(document.getElementById('CityCountryId').value)) {
		alert("Please select the country.");
		document.getElementById('CityCountryId').focus();
		return false;
	}

	if (isEmpty(document.getElementById('CityCityName').value)) {
		alert("Please enter the city name.");
		document.getElementById('CityCityName').focus();
		return false;
	}


}

function getCityForCountry(path,countryId)
{
	new Ajax.Updater('update_city_id',''+ path +'/airports/getcityforcountry/'+countryId, {asynchronous:true, evalScripts:true});
}

function getCityForCountryForGoingOffer(path,countryId)
{
	new Ajax.Updater('update_city_id',''+ path +'/goingtoairports/getcityforcountry/'+countryId, {asynchronous:true, evalScripts:true});
}

function getPostcodesForCity(path,cityId)
{
	new Ajax.Updater('update_postcode_id',''+ path +'/goingtoairports/getpostcodesforcity/'+cityId, {asynchronous:true, evalScripts:true});
}

function getCityForCountryForCollection(path,countryId)
{
	new Ajax.Updater('update_city_id',''+ path +'/airportcollections/getcityforcountry/'+countryId, {asynchronous:true, evalScripts:true});
}

function getPostcodesForCityForCollection(path,cityId)
{
	new Ajax.Updater('update_postcode_id',''+ path +'/airportcollections/getpostcodesforcity/'+cityId, {asynchronous:true, evalScripts:true});
}

//Validation for faqs.
function validate_faqs(){

	if (isEmpty(document.getElementById('FaqTitle').value)) {
		alert("Please enter title.");
		document.getElementById('FaqTitle').focus();
		return false;
	}

	if (isEmpty(document.getElementById('FaqQuestion').value)) {
		alert("Please enter question.");
		document.getElementById('FaqQuestion').focus();
		return false;
	}

	if (isEmpty(document.getElementById('FaqAnswer').value)) {
		alert("Please enter answer.");
		document.getElementById('FaqAnswer').focus();
		return false;
	}

}

//Validation for news.
function validate_news(){

	if (isEmpty(document.getElementById('NewsupdateNewsTitle').value)) {
		alert("Please enter news title.");
		document.getElementById('NewsupdateNewsTitle').focus();
		return false;
	}

	if (isEmpty(document.getElementById('NewsupdateShortDescription').value)) {
		alert("Please enter short description.");
		document.getElementById('NewsupdateShortDescription').focus();
		return false;
	}

	if (isEmpty(document.getElementById('NewsupdateLongDescription').value)) {
		alert("Please enter long description.");
		document.getElementById('NewsupdateLongDescription').focus();
		return false;
	}

	if (isEmpty(document.getElementById('date_news_added').value)) {
		alert("Please enter news date.");
		document.getElementById('date_news_added').focus();
		return false;
	}

}

//Validation for users.
function validate_user(){

	if (isEmpty(document.getElementById('UserUsername').value)) {
		alert("Please enter username.");
		document.getElementById('UserUsername').focus();
		return false;
	}

	if (isEmpty(document.getElementById('UserPassword').value)) {
		alert("Please enter password.");
		document.getElementById('UserPassword').focus();
		return false;
	}

	if (isEmpty(document.getElementById('UserFirstName').value)) {
		alert("Please enter first name.");
		document.getElementById('UserFirstName').focus();
		return false;
	}

	if (isEmpty(document.getElementById('UserLastName').value)) {
		alert("Please enter last name.");
		document.getElementById('UserLastName').focus();
		return false;
	}

	if (isEmpty(document.getElementById('UserEmail').value)) {
		alert("Please enter email address.");
		document.getElementById('UserEmail').focus();
		return false;
	}

	if(!validateEmail(document.getElementById('UserEmail').value))
	{
		alert("Please enter valid email address.");
		document.getElementById('UserEmail').focus();
		return false;
	}

	if (isEmpty(document.getElementById('UserPhone').value)) {
		alert("Please enter phone.");
		document.getElementById('UserLastName').focus();
		return false;
	}

}


//Validation for static pages.
function validate_staticpages(){

	if (isEmpty(document.getElementById('StaticpagePageTitle').value)) {
		alert("Please enter page title.");
		document.getElementById('StaticpagePageTitle').focus();
		return false;
	}

	if (isEmpty(document.getElementById('StaticpageShortDescription').value)) {
		alert("Please enter short description.");
		document.getElementById('StaticpageShortDescription').focus();
		return false;
	}

	if (isEmpty(document.getElementById('StaticpageLongDescription').value)) {
		alert("Please enter long description.");
		document.getElementById('StaticpageLongDescription').focus();
		return false;
	}

}

function validate_postcode(){

	if (isEmpty(document.getElementById('PostcodePostcode').value)) {
		alert("Please enter postcode.");
		document.getElementById('PostcodePostcode').focus();
		return false;
	}
}


function validate_gallerycategories(){

	if (isEmpty(document.getElementById('GallerycategoryCategoryName').value)) {
		alert("Please enter category name.");
		document.getElementById('GallerycategoryCategoryName').focus();
		return false;
	}
}

function validate_categories(){

	if (isEmpty(document.getElementById('CategoryCategoryName').value)) {
		alert("Please enter category name.");
		document.getElementById('CategoryCategoryName').focus();
		return false;
	}
}

function validate_galleryimages(add){

	if (isEmpty(document.getElementById('GalleryimageCategoryId').value)) {
		alert("Please select image category.");
		document.getElementById('GalleryimageCategoryId').focus();
		return false;
	}


	//alert(add);
	if(add == 'yes')
	{
		if (isEmpty(document.getElementById('GalleryimageuploadImageName').value)) {
			alert("Please enter image to upload.");
			document.getElementById('GalleryimageuploadImageName').focus();
			return false;
		}
	}

}

function validate_categoryimages(add){

	if (isEmpty(document.getElementById('CategoryimageCategoryId').value)) {
		alert("Please select image category.");
		document.getElementById('CategoryimageCategoryId').focus();
		return false;
	}


	//alert(add);
	if(add == 'yes')
	{
		if (isEmpty(document.getElementById('CategoryimageuploadImageName').value)) {
			alert("Please enter image to upload.");
			document.getElementById('CategoryimageuploadImageName').focus();
			return false;
		}
	}

}

function validate_frontvideos(add){

	if(add == 'yes')
	{
		if (isEmpty(document.getElementById('FrontvideoVideoTitle').value)) {
			alert("Please enter video title.");
			document.getElementById('FrontvideoVideoTitle').focus();
			return false;
		}

		if (isEmpty(document.getElementById('FrontvideoVideoUrl').value)) {
			alert("Please enter video URL.");
			document.getElementById('FrontvideoVideoUrl').focus();
			return false;
		}
	}

}

function validate_bollywoodmasterclassvideos(add){

	if(add == 'yes')
	{
		if (isEmpty(document.getElementById('BollywoodmasterclassvideoVideoTitle').value)) {
			alert("Please enter video title.");
			document.getElementById('BollywoodmasterclassvideoVideoTitle').focus();
			return false;
		}

		if (isEmpty(document.getElementById('BollywoodmasterclassvideoVideoUrl').value)) {
			alert("Please enter video URL.");
			document.getElementById('BollywoodmasterclassvideoVideoUrl').focus();
			return false;
		}
	}

}

function validate_frontimages(add){

	if(add == 'yes')
	{
		if (isEmpty(document.getElementById('FrontimageuploadImageName').value)) {
			alert("Please enter image to upload.");
			document.getElementById('FrontimageuploadImageName').focus();
			return false;
		}
	}
}

function validate_testimonial(add){

	if (isEmpty(document.getElementById('TestimonialTitle').value)) {
		alert("Please enter testimonial title.");
		document.getElementById('TestimonialTitle').focus();
		return false;
	}

	if (isEmpty(document.getElementById('TestimonialClientName').value)) {
		alert("Please enter client name.");
		document.getElementById('TestimonialClientName').focus();
		return false;
	}

	if (isEmpty(document.getElementById('TestimonialDescription').value)) {
		alert("Please enter description.");
		document.getElementById('TestimonialDescription').focus();
		return false;
	}

	if (isEmpty(document.getElementById('date_submitted').value)) {
		alert("Please enter date submitted.");
		document.getElementById('date_submitted').focus();
		return false;
	}
}

function validate_adminlogin()
{
	if (isEmpty(document.getElementById('AdminUsername').value)) {
		alert("Please enter Username.");
		document.getElementById('AdminUsername').focus();
		return false;
	}
	if (!isValid(document.getElementById("AdminUsername").value,lwr+upr+dig))
	 {
	 alert("Enter correct username");
	 document.getElementById('AdminUsername').focus();
	 return false;
	 }

	if (isEmpty(document.getElementById('AdminPassword').value)) {
		alert("Please enter Password.");
		document.getElementById('AdminPassword').focus();
		return false;
	}
	if (!isValid(document.getElementById("AdminPassword").value,lwr+upr+dig))
	 {
	 alert("Enter correct password");
	 document.getElementById('AdminPassword').focus();
	 return false;
	 }

}

function validate_register()
 {
	//Validations for register student
	if (isEmpty(document.getElementById('UserUsername').value))
	{
		alert("Please enter username");
		document.getElementById('UserUsername').focus();
		return false;
	}
	if (!isValid(document.getElementById("UserUsername").value,lwr+upr+dig))
	 {
	 alert("Enter only alphabets and digits in username");
	 document.getElementById('UserUsername').focus();
	 return false;
	 }
	 if (document.getElementById("UserUsername").value.length<5)
	 {
	 alert("Enter Username of length more than 4 characters ");
	 document.getElementById('UserUsername').focus();
	 return false;
	 }

	if (isEmpty(document.getElementById('UserPassword').value))
	{
		alert("Please enter password");
		document.getElementById('UserPassword').focus();
		return false;
	}
	if (document.getElementById('UserPassword').value.length<5)
	{
		alert("Enter password of length more than 4 characters ");
		document.getElementById('UserPassword').focus();
		return false;
	}

	if (isEmpty(document.getElementById('UserName').value))
	{
		alert("Please enter name");
		document.getElementById('UserName').focus();
		return false;
	}
	if (!isValid(document.getElementById("UserName").value,lwr+upr+space))
	 {
	 alert("Enter only alphabets in name");
	 document.getElementById('UserName').focus();
	 return false;
	 }
	if (isEmpty(document.getElementById('UserEmail').value))
	{
		alert("Please enter email id");
		document.getElementById('UserEmail').focus();
		return false;
	}
	if(!validateEmail(document.getElementById('UserEmail').value))
	{
		alert("Please enter valid email address.");
		document.getElementById('UserEmail').focus();
		return false;
	}


 }


