/********************************************************************* 
* ValidateData.js.                                                     *
* Form validation functions for validating entire forms (onSubmit)     *
* or on-the-fly validation. (onBlur / onChange)                        *
* Copyright 2005 Dotsquares Pvt.Ltd.                          *
*********************************************************************/

//THIS IS FUNCTION CountLetter() TO COUNT HOW MANY LETTERS ARE REST TO ENTER IN THE CONTTROL
//var FieldName is name of the field, whose length is to be count
//var MaxLen is max letters, to be entered in the field
//var DisplayField is the control to display the message
//var NextFocus is the control to which focus is transered on limit over.
function CountLetter(FieldName, MaxLen, DisplayField)
{
	var CurLen = eval(FieldName.value.length) + 1;
	
	//if max letters has been entered, don't accept the character
		if(CurLen >= MaxLen)
		{	
			//BisLen(FieldName,MaxLen);
			DisplayField.value = 'Limit over.';
			FieldName.value = FieldName.value.substring(0,MaxLen-1);
			//alert(FieldName.value);
			return;
		}
		else
		{
			DisplayField.value = (MaxLen-CurLen+1) + ' characters more.';		
		}
}
// Functions for onSubmit form validation.

function BisEmail(val, req) {
// Check for a properly formatted email address.
   if ((val.value.length == 0) && (req == "R")) {
      alert("This field is required.");
      val.focus();
      val.select();
      return false;
   }
   var email = val.value.toLowerCase();
   if (val.value.length != 0) 
   {
		  var emailformat = /^[^@\s]+@([-a-z0-9]+\.)+([a-z]{2}|com|net|edu|org|gov|mil|int|biz|pro|info|arpa|aero|coop|name|museum)$/;
		//var emailformat = /^.+@.+\..{2,3}$/;
	  	if (!emailformat.test(email)) {
         alert("Please enter a valid email Id.");
         val.focus();
         val.select();
         return false;
      }
   }
	val.value=email;
   return true;
}


function BisAlpha(val, len, req) {
// Check for "a-z", "A-Z", " ", and optionally length.
   if ((val.value.length == 0) && (req == "R")) {
      alert("This field is required.");
      val.focus();
      val.select();
      return false;
   }
   if (val.value.length != 0) {
      for (i = 0; i < val.value.length; i++) {
         var ch = val.value.charAt(i);
         if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z") || (ch == " ")) {
            continue;
         } else {
            alert("Please enter only alphabets");
            val.focus();
            val.select();
            return false;
         }
      }
      if (len != "0") {
         if (val.value.length != len) {
            alert("This field must contain " + len + " alphabets characters.");
            val.focus();
            val.select();
            return false;
         }
      }
   }
   return true;
}

//function to trim a string
function Trimmer(controlName) { 
	pVal = controlName.value;
    TRs=0; 
    for (i=0; i<pVal.length; i++) 
	{ 
        if (pVal.substr(i,1)==" ") 
		{
			TRs++;
		} 
		else 
			{break;} 
    } 

    TRe=pVal.length-1; 
    for (i=TRe; i>TRs-1;i--)
	{ 
        if (pVal.substr(i,1)==" ") 
		{
			TRe--;
		}
		else 
			{break;} 
    } 

    controlName.value=pVal.substr(TRs, TRe-TRs+1); 
} 
//end trim function

function BisURL(val, req) {
// Check for a properly formatted url.
   if ((val.value.length == 0) && (req == "R")) {
      alert("This field is required.");
      val.focus();
      val.select();
      return false;
   }
   var email = val.value.toLowerCase();
   var checkemail="";
    if (val.value.length >11) 
     {
	    	
		if(email.substring(0,11) == 'http://www.')
	   		checkemail = email.substring(11, email.length);
	

		var emailformat = /^(([-a-z0-9]+\.)+([a-z]{2}|com|net|edu|org|gov|mil|int|biz|pro|info|arpa|aero|coop|name|museum))$/;
		//var emailformat = /^.+\..{2,3}$/;
	  	if (!emailformat.test(checkemail)) {
         alert("Please enter a valid URL.");
         val.focus();
         val.select();
         return false;
      }
   }
	val.value=email;
   return true;
}

// function for checking that field is number
function BisNumber(val,req) {
// Check for "0-9", ".", "-", and optionally length.
   if ((val.value.length == 0) && (req == "R")) {
      alert("This field is required.");
      val.focus();
      val.select();
      return false;
   }
   if (val.value.length != 0) {
      for (i = 0; i < val.value.length; i++) {
         var ch = val.value.charAt(i);
         if ((ch >= "0" && ch <= "9")) {
            continue;
         } else {
            alert("Please enter numeric characters [0-9] only.");
            val.focus();
            val.select();
            return false;
         }
      }
   }
   return true;
}

// function for checking that field is number with dot
function BisNumberDot(val,req) {
// Check for "0-9", ".", "-", and optionally length.
  var Dotcount=0;
   if ((val.value.length == 0) && (req == "R")) {
      alert("This field is required.");
      val.focus();
      val.select();
      return false;
   }
   if (val.value.length != 0) {
      for (i = 0; i < val.value.length; i++) {
         var ch = val.value.charAt(i);
		 if(ch == ".")
		 {
		   Dotcount=Dotcount +1;
		   if(Dotcount>1)
		     {
              alert("Please enter valid numeric value.");
				val.focus();
				val.select();
				return false;
			 }
		 continue;
		 }
         if ((ch >= "0" && ch <= "9"))
		  {
            continue;
         } else {
            alert("Please enter valid numeric value.");
            val.focus();
            val.select();
            return false;
         }
      }
      /*if (len != "0") {
         if (val.value.length != len) {
            alert("This field must contain " + len + " NUMERIC characters.");
            val.focus();
            val.select();
            return false;
         }
      }*/
   }
   return true;
}



//-----------------------------------------------------
//function for date
//compare date
function DateComparison(date1, date2)
{
   var d1,d2,m1,m2,y1,y2;
    var fromdate=date1.split('-');
   var todate=date2.split('-');   
   
   d1=eval(fromdate[0]);
   d2=eval(todate[0]);
   m1=eval(fromdate[1]);
   m2=eval(todate[1]);
   y1=eval(fromdate[2]);
   y2=eval(todate[2]);
  
   //return true if second is greater  or equal to first date
   	if (y2 > y1)
	{
   		return true;
	}
	else
	{
		if(y1 > y2)
		{
			return false;
		}
		else
		{
			if(m2>m1)
			{
				return true;
			}
			else
			{
				if(m1>m2)
				{
					return false;
				}
				else
				{
					if(d2>=d1)
					{
						return true;
					}
					else
					{
						return false;
					}
				}
			}
		}
	}   
 }
 
 //compare date
function CheckNewDate(thedate)
{
   var d1,d2,m1,m2,y1,y2;
   var newdate=new Date();
   
   d1=eval(thedate.substring(0,2));
   d2=eval(newdate.getDate());
   m1=eval(thedate.substring(3,5));
   m2=eval(newdate.getMonth())+1;
   y1=eval(thedate.substring(6,10));
   y2=eval(newdate.getYear());
   
  
   //return true if second is greater  or equal to first date
   	if (y1 > y2)
	{
   		return true;
	}
	else
	{
		if(y1 < y2)
		{
			return false;
		}
		else
		{
			if(m1 > m2)
			{
				return true;
			}
			else
			{
				if(m2 > m1)
				{
					return false;
				}
				else
				{
					if(d1 >= d2)
					{
						return true;
					}
					else
					{
						return false;
					}
				}
			}
		}
	}   
 }
   

//============================================================   
//validate the Article form 
//============================================================
function Validate_ArticleForm(val)
{
var error=0;
var message='';

  if(val.authname.value=="")
    {
        if(error==0)
		 val.authname.focus();
       message=message+" Please enter author name. \n";
	   error=1;
	}
  
 /* if(val.email.value=="")
    {
        if(error==0)
	       val.email.focus();
       message=message+" Please enter your email id. \n";
	   error=1;
	}*/
  
 /* if(val.profession.value=="")
    {
        if(error==0)
	       val.profession.focus();
       message=message+" Please enter your profession. \n";
	   error=1;
	}*/
  
  if(val.title.value=="")
    {
        if(error==0)
	       val.title.focus();
       message=message+" Please enter article title. \n";
	   error=1;
	}
  
  if(val.articletypeid.value=="")
    {
        if(error==0)
	       val.artcatid.focus();
       message=message+" Please select article subject. \n";
	   error=1;
	}
  
if(val.name=='articlefrm' )
{
  if(val.article.value=="")
    {
        if(error==0)
	       val.article.focus();
       message=message+" Please upload article file. \n";
	   error=1;
	}
}	
	if(val.article.value!="")
	 { 
//check the extension of the uploaded file
     Ext=val.article.value.substring(val.article.value.lastIndexOf('.')+1);
	 Ext=Ext.toLowerCase();
		 if(Ext!='doc' && Ext!='pdf' && Ext!='txt' && Ext!='htm' && Ext!='html')
		  {
			error=1;
			message=message + "Please upload only doc,txt,pdf,html format file.\n";
		  }
	 }

 //display message on error

 if(error==1)
   {
    alert(message);
	return false;
   
   }

return true;
}   
//============================================================   
   
//============================================================   
//validate the BOOKS form 
//============================================================
function Validate_BookForm(val)
{
var error=0;
var message='';
  if(val.author.value=="")
    {
        if(error==0)
		 val.author.focus();
       message=message+" Please enter author name. \n";
	   error=1;
	}
  if(val.publisher.value=="")
    {
        if(error==0)
	       val.publisher.focus();
       message=message+" Please enter the publisher name. \n";
	   error=1;
	}
  if(val.price.value=="")
    {
        if(error==0)
	       val.price.focus();
       message=message+" Please enter the book price. \n";
	   error=1;
	}
  if(val.title.value=="")
    {
        if(error==0)
	       val.title.focus();
       message=message+" Please enter book title. \n";
	   error=1;
	}
  if(val.booktypeid.value=="")
    {
        if(error==0)
	       val.booktypeid.focus();
       message=message+" Please select book subject. \n";
	   error=1;
	}
if(val.name=='book' )
{
  if(val.book.value=="")
    {
        if(error==0)
	       val.book.focus();
       message=message+" Please upload book file. \n";
	   error=1;
	}
}	
  if(val.detail.value=="")
    {
        if(error==0)
	       val.detail.focus();
       message=message+" Please enter the book detail. \n";
	   error=1;
	}
	if(val.book.value!="")
	 { 
//check the extension of the uploaded file
     Ext=val.book.value.substring(val.book.value.lastIndexOf('.')+1);
	 Ext=Ext.toLowerCase();
		 if(Ext!='zip' && Ext!='pdf' && Ext!='htm' && Ext!='html' && Ext!='chm' && Ext!='doc' )
		  {
			error=1;
			message=message + "Please upload only pdf,zip,html,chm format file.\n";
		  }
	 }
 //display message on error
 if(error==1)
   {
    alert(message);
	return false;
   }
return true;
}   
//============================================================   
//validate the Glossary  form 
//============================================================
function Validate_GlossaryForm(val)
{

var error=0;
var message='';

  if(val.title.value=="")
    {
        if(error==0)
	       val.title.focus();
       message=message+" Please enter the word. \n";
	   error=1;
	}
  
  if(val.detail.value=="")
    {
        if(error==0)
	       val.detail.focus();
       message=message+" Please enter the detail. \n";
	   error=1;
	}
  
 if(error==1)
  {
    alert(message);
	 return false;
  }
 return true; 
}

//============================================================   
//validate the DOWNLOAD form 
//============================================================
function Validate_DownloadForm(val)
{

var error=0;
var message='';

  if(val.title.value=="")
    {
        if(error==0)
	       val.title.focus();
       message=message+" Please enter downloads title. \n";
	   error=1;
	}
  
  if(val.downloadtypeid.value=="")
    {
        if(error==0)
	       val.downloadtypeid.focus();
       message=message+" Please select download subject. \n";
	   error=1;
	}
  
if(val.name=='download' )
{
  if(val.download.value=="")
    {
        if(error==0)
	       val.download.focus();
       message=message+" Please upload download file. \n";
	   error=1;
	}
}	
  if(val.detail.value=="")
    {
        if(error==0)
	       val.detail.focus();
       message=message+" Please enter the downloads detail. \n";
	   error=1;
	}

	if(val.download.value!="")
	 { 

//check the extension of the uploaded file
     Ext=val.download.value.substring(val.download.value.lastIndexOf('.')+1);
	 Ext=Ext.toLowerCase();
		 if(Ext!='zip' && Ext!='pdf' && Ext!='chm' && Ext!='exe')
		  {
			error=1;
			message=message + "Please upload only pdf,zip,chm,exe format file.\n";
		  }
	 }
 //display message on error
 if(error==1)
   {
    alert(message);
	return false;
   
   }

return true;
}   
//============================================================   
//============================================================   
//validate the Game form (gamefrm) 
//============================================================
function Validate_GameForm(val)
{

var error=0;
var message='';

  if(val.title.value=="")
    {
        if(error==0)
	       val.title.focus();
       message=message+" Please enter the title. \n";
	   error=1;
	}
  if(val.gametypeid.value=="")
    {
        if(error==0)
	       val.gametypeid.focus();
       message=message+" Please select the subject. \n";
	   error=1;
	}
if(val.name=='gamefrm' )
{
  if(val.game.value=="")
    {
        if(error==0)
	       val.game.focus();
       message=message+" Please upload the file. \n";
	   error=1;
	}
}	
  if(val.detail.value=="")
    {
        if(error==0)
	       val.detail.focus();
       message=message+" Please enter the detail. \n";
	   error=1;
	}

	if(val.game.value!="")
	 { 
//check the extension of the uploaded file
     Ext=val.game.value.substring(val.game.value.lastIndexOf('.')+1);
	 Ext=Ext.toLowerCase();
		 if(Ext!='jar' && Ext!='html' && Ext!='pdf' && Ext!='htm' && Ext!='zip' &&  Ext!='exe')
		  {
			error=1;
			message=message + "Please upload only pdf,zip,jar,html,exe format file.\n";
		  }
	 }
 //display message on error
 if(error==1)
   {
    alert(message);
	return false;
   }
return true;
} 
//============================================================   
//============================================================   
//validate the Tutorial form (gamefrm) 
//============================================================
function Validate_TutorialForm(val,type)
{
alert(type);
return false;

var error=0;
var message='';
  if(val.title.value=="")
    {
        if(error==0)
	       val.title.focus();
       message=message+" Please enter the title. \n";
	   error=1;
	}
  if(val.tutorialtypeid.value=="")
    {
        if(error==0)
	       val.gametypeid.focus();
       message=message+" Please select the subject. \n";
	   error=1;
	}
if(val.name=='gamefrm' )
{
  if(val.game.value=="")
    {
        if(error==0)
	       val.game.focus();
       message=message+" Please upload the file. \n";
	   error=1;
	}
}	
  if(val.detail.value=="")
    {
        if(error==0)
	       val.detail.focus();
       message=message+" Please enter the detail. \n";
	   error=1;
	}

	if(val.game.value!="")
	 { 
//check the extension of the uploaded file
     Ext=val.game.value.substring(val.game.value.lastIndexOf('.')+1);
	 Ext=Ext.toLowerCase();
		 if(Ext!='jar' && Ext!='html' && Ext!='pdf' && Ext!='htm' && Ext!='zip' &&  Ext!='exe')
		  {
			error=1;
			message=message + "Please upload only pdf,zip,jar,html,exe format file.\n";
		  }
	 }
 //display message on error
 if(error==1)
   {
    alert(message);
	return false;
   }
return true;
} 
//============================================================   
//============================================================   
//validate the JOBFORM form 
//============================================================
function Validate_JobForm(val)
{

var error=0;
var message='';

  if(val.title.value=="")
    {
        if(error==0)
	       val.title.focus();
       message=message+" Please enter job title. \n";
	   error=1;
	}
  
  if(val.jobcatid.value=="")
    {
        if(error==0)
	       val.jobcatid.focus();
       message=message+" Please select job field. \n";
	   error=1;
	}
  if(val.expiredate.value=="")
    {
        if(error==0)
	       val.expiredate.focus();
       message=message+" Please enter/select the job close date . \n";
	   error=1;
	}
	
  if(val.summary.value=="")
    {
        if(error==0)
	       val.summary.focus();
       message=message+" Please enter the job summary. \n";
	   error=1;
	}
if(val.jobfile.value!="")
	 { 
//check the extension of the uploaded file
     Ext=val.download.value.substring(val.download.value.lastIndexOf('.')+1);
	 Ext=Ext.toLowerCase();
		 if(Ext!='txt' && Ext!='pdf' && Ext!='doc' )
		  {
			error=1;
			message=message + "Please upload only pdf,txt,doc format file.\n";
		  }
	 }
 //compare that
  if(CheckNewDate(val.expiredate.value)==false && val.expiredate.value!="")
  {
    message=message + "Close date must be greater than current date";
  } 

 //display message on error

 if(error==1)
   {
    alert(message);
	return false;
   
   }

return true;
}   
//============================================================   


//============================================================      
//=======FUNCTION FOR VALIDATE CHAGEPASSWORD FORM=============      
function Validate_Changepass_Form(val)
{
  var error=0;
  var message='';
  if(val.oldpassword.value=="")
    {
       val.oldpassword.focus();
       message=message+" Please enter the password. \n";
	   error=1;
	}
  if(val.newpassword.value=="")
    {
        if(error==0)
		 val.newpassword.focus();
       message=message+" Please enter the newpassword. \n";
	   error=1;
	}
  if(val.confirmpassword.value=="")
    {
        if(error==0)
		 val.confirmpassword.focus();
       message=message+" Please confirm the new password. \n";
	   error=1;
	}
	//check that newpassword and confirm password values are same or not
	if(val.confirmpassword.value!="" && val.confirmpassword.value!=val.newpassword.value)
	 {
		if(error==0)
			 val.confirmpassword.focus();
		   message=message+" Confirm password not match with new password.\n";
		   error=1;
		 
	 }

	if(error==1)
	{
	 alert(message);
	 return false;
	}
	return true;

}


//============================================================         
 //function for redirecting the page   

function valid_login_admin(val)
{
  var error=0;
  var message='';
  if(val.loginid.value=="")
    {
       val.loginid.focus();
       message=message+" Please enter the login id. \n";
	   error=1;
	}
  if(val.password.value=="")
    {
        if(error==0)
		 val.password.focus();
       message=message+" Please enter the password. \n";
	   error=1;
	}
if(error==1)
 {
  alert(message);
   return false;
 }	
   return true;

}


//============================================================         
   
//function for redirecting the page   

function CallPage(PageName)
{
	
	location.href = PageName;
}
//============================================================    
//function for pagination
//============================================================  

//THIS IS SetPageCounter() FUNCTION TO INCREASE VALUE OF PAGE COUNTER
function SetPageCounterInc()
{
	//document.enableurl.PageCounter.value = document.enableurl.PageCounter.value +1;
	document.FormPage.PageCounter.value = eval(document.FormPage.PageCounter.value) + 1  ;
	document.FormPage.submit();
}
			
	//function to send form to the next page
function NextPageLink(val)
{
		document.FormPage.PageCounter.value = eval(val)  ;
		document.FormPage.submit();
}
		
//THIS IS SetPageCounter() FUNCTION TO DECREASE VALUE OF PAGE COUNTER
function SetPageCounterDec()
{
	document.FormPage.PageCounter.value = eval(document.FormPage.PageCounter.value) - 1  ;
	document.FormPage.submit();
}

 
//============================================================    
function DomainCheck(val)
{
 
// Check for a properly formatted url.
   
   var email = val.value.toLowerCase();
   var checkemail="";
    if (val.value.length >0) 
     {
	    if(val.value.substr(0,4)=='www.')
		 {
		   alert("Please don't prefix * www * in domain name ");
		    val.focus();
            val.select();
		    return false;
		 }
		
		var emailformat = /^(([-a-z0-9])+(.com|.net|.edu|.org|.gov|.mil|.int|.biz|.pro|.info|.arpa|.aero|.coop|.name|.museum|(\.{1}+[a-z]{2})+((\.{1}+[a-z]{2,3})))+(|(\.{1}+[a-z]{2,3})))$/;
		//var emailformat = /^(([-a-z0-9])+(|(\.{1}+[a-z]{2})|.com|.net|.edu|.org|.gov|.mil|.int|.biz|.pro|.info|.arpa|.aero|.coop|.name|.museum)+(|(\.{1}+[a-z]{2,3})))$/;
		//var emailformat = /^(([-a-z0-9])+(|.com|.net|.edu|.org|.gov|.mil|.int|.biz|.pro|.info|.arpa|.aero|.coop|.name|.museum))$/;
		//var emailformat = /^.+\..{2,3}$/;
	  	if (!emailformat.test(email)) {
         alert("Please enter a valid domain name.");
         val.focus();
         val.select();
         return false;
      }
   }
	val.value=email;
   return true;


}

//=====================================================================================

//this is CheckSubmit() function to check whether any record is selected or not
function CheckSubmit(RecordCount, theField, OldStatusValue, ChangedStatus)
{
	
	var statusFlag = 0; //keeps track that atleast one record is selected to change the status
	
	
	if(RecordCount.value == 1)
	{ 
		if(theField.checked == true && OldStatusValue.value != ChangedStatus)
				statusFlag = 1;
			else
				theField.checked = false;
	}
	else
	{
		for (i=0; i < RecordCount.value; i++) 
		{
			if(theField[i].checked == true && OldStatusValue[i].value != ChangedStatus)
				statusFlag = 1;
			else
				theField[i].checked = false;
		}
	}
	if(statusFlag == 0)
	{
		alert("Please select atleast one record to change status.");
		return false;
	}
//on delete button click confirm for deletion
	if(ChangedStatus=='D')
	 {
	  result=confirm('Are u sure? \n It will delete all  its related entries.');
	  if(!result)
	   return false;
	 
	 }


	return true;
}

// function for ordering 
function OrderFunction(orderstr,type)
{
	//alert(orderstr + type);
    document.FormPage.order.value = "order by " + orderstr +" " + type ;
	document.FormPage.submit();
}
/***************************************************************/
//THIS IS CheckAll() FUNCTION TO MARK ALL CHECK BOXES AS CHECKED---USED IN FORM ENABLE URL
function CheckAll(count,val)
{
	
	
	if(count == 1)
	{ 
		val.checked = true;
	}
	else
	{
		for (i=0; i < count; i++) 
		{
			val[i].checked = true;
		}
	}
}
//THIS IS UnCheckAll() FUNCTION TO MARK ALL CHECK BOXES AS  UNCHECKED--USED IN FORM ENABLE URL
function UnCheckAll(count,val)
{

	if(count == 1)
	{ 
		val.checked = false;
	}
	else
	{
		for (i=0; i < count; i++) 
		{
			val[i].checked = false;
		}
	}
}
// function for ordering 

///function for both check uncheclk
//THIS IS CheckAll() FUNCTION TO MARK ALL CHECK BOXES AS CHECKED---USED IN FORM ENABLE URL
function CheckUncheckAll(count,val)
{
	
//	alert(count);
var cuflag=false;
	if(count == 1)
	{ 
		if(val.checked)
		  val.checked =false;
		 else 
		    val.checked = true;
	}
	else
	{
		
		for (i=0; i < count; i++) 
		{
		   
		   if(val[i].checked)
		      cuflag=true;
		}
		//UPDATE THE STATUS
		for (i=0; i < count; i++) 
		{
		   if(cuflag)
		      val[i].checked=false;
		   else
		      val[i].checked=true;
		}
	}
}



//=============================================================================

//validate config settings
function valid_configsetting(form)
{
   var message="", error=0;
	var FocusField = '';

   if (form.title.value=='') { message+="Please enter title.\n"; error=1;   if(FocusField == '')FocusField =form.title;}
   if (form.mailfooter.value=='') { message+="Please enter mail footer.\n"; error=1;   if(FocusField == '')FocusField =form.mailfooter;}

  if (form.emailadv.value=='') { message+="Please enter advertisement email account.\n"; error=1;   if(FocusField == '')FocusField =form.emailadv;}
  if (form.subjectadv.value=='') { message+="Please enter advertisement email subject.\n"; error=1;   if(FocusField == '')FocusField =form.subjectadv;}
  if (form.messageadv.value=='') { message+="Please enter advertisement email message.\n"; error=1;   if(FocusField == '')FocusField =form.messageadv;}

   if (form.emailtellfriend.value=='') { message+="Please enter tell a friend email account.\n"; error=1;   if(FocusField == '')FocusField =form.emailtellfriend;}
   if (form.subjecttellfriend.value=='') { message+="Please enter tell a friend email subject.\n"; error=1;   if(FocusField == '')FocusField =form.subjecttellfriend;}
   if (form.messagetellfriend.value=='') { message+="Please enter tell a friend email message.\n"; error=1;   if(FocusField == '')FocusField =form.messagetellfriend;}

   if (form.emailmember.value=='') { message+="Please enter confirm member Id email account.\n"; error=1;   if(FocusField == '')FocusField =form.emailmember;}
   if (form.subjectmember.value=='') { message+="Please enter comfirm member Id email subject.\n"; error=1;   if(FocusField == '')FocusField =form.subjectmember;}
   if (form.messagemember.value=='') { message+="Please enter confirm member Id email message.\n"; error=1;   if(FocusField == '')FocusField =form.messagemember;}

   if (form.emailmemenable.value=='') { message+="Please enter member enable email account.\n"; error=1;   if(FocusField == '')FocusField =form.emailmemenable;}
   if (form.subjectmemenable.value=='') { message+="Please enter member enable email subject.\n"; error=1;   if(FocusField == '')FocusField =form.subjectmemenable;}
   if (form.messagememenable.value=='') { message+="Please enter member enable email message.\n"; error=1;   if(FocusField == '')FocusField =form.messagememenable;}

   if (form.emailfeedback.value=='') { message+="Please enter feedback email account.\n"; error=1;   if(FocusField == '')FocusField =form.emailfeedback;}
   if (form.subjectfeedback.value=='') { message+="Please enter feedback email subject.\n"; error=1;   if(FocusField == '')FocusField =form.subjectfeedback;}
   if (form.messagefeedback.value=='') { message+="Please enter feedback email message.\n"; error=1;   if(FocusField == '')FocusField =form.messagefeedback;}
   if (form.emailalertvisitor.value=='') { message+="Please enter alert visitor email account.\n"; error=1;   if(FocusField == '')FocusField =form.emailalertvisitor;}
   if (form.subjectalertvisitor.value=='') { message+="Please enter alert visitor email subject.\n"; error=1;   if(FocusField == '')FocusField =form.subjectalertvisitor;}
   if (form.messagealertvisitor.value=='') { message+="Please enter alert visitor email message.\n"; error=1;   if(FocusField == '')FocusField =form.messagealertvisitor;}

   if (form.footer.value=='') { message+="Please enter footer.\n"; error=1;   if(FocusField == '')FocusField =form.footer;}
//   if (form.disclaimer.value=='') { message+="Please enter disclaimer.\n"; error=1;   if(FocusField == '')FocusField =form.disclaimer;}

   if (error==1) { FocusField.focus(); alert(message); return false; }
   return true;
}
//=========================================================================================

/********************************************************************************************
	THIS IS SetSelectedValue() FUNCTION, TO PUT VALUE OF SELECTED FIELD INTO ANOTHER FIELD
*********************************************************************************************/
function SetSelectedValue(SelectedField, AnotherField)
{
	AnotherField.value = SelectedField.options[SelectedField.selectedIndex].text;
}
/************************************************************
end function
************************************************************/
/********************************************************************************************
	THIS IS SetFieldLabel() FUNCTION, TO PUT VALUE OF SELECTED FIELD INTO FIELD LABEL
*********************************************************************************************/
function SetFieldLabel(SelectedField, FieldLabel1, FieldLabel2)
{
	var FieldValue = SelectedField.options[SelectedField.selectedIndex].text.toLowerCase() + " : ";

	if(FieldValue == '--please select--')
	{
		FieldLabel1.value = 'value(s) : ';
		FieldLabel2.value = 'value : ';
	}
	else
	{
		FieldLabel1.value = FieldValue;
		FieldLabel2.value = FieldValue;
	}
}
/************************************************************
end function
************************************************************/
//THIS IS AddCategoryType() FUNCTION, TO ADD CATEGORY TYPE
function AddCategoryType(CatgType,  VarType)
{

			//remove all types from type select control
			VarType.length = 0;
			//select all type from array, related with  category
			var thecount = 0;
			var optcount = 0;

			if(CatgType != '')//if any hotel selected, then selected type  
			{
					
					while(thecount < CountArr)
					{
						if(TypeArray[thecount] == CatgType)
						{
							var option = new Option(NameArray[thecount], IdArray[thecount]);
							VarType.options[optcount] = option;
							optcount = optcount + 1;
						}
						thecount = thecount + 1;
					}//end while
					if(optcount ==0)
					{
						var option = new Option();
						VarType.options[0] = option;
						VarType.options[0].text='Value does not exist';
						VarType.options[0].value='0';
					}
			}//end if
			else
			{
					var option = new Option();
					VarType.options[0] = option;
					VarType.options[0].text='Please select';
					VarType.options[0].value='0';
			}
}
//END FUNCTION 
