// JavaScript Document
//////html area function
function validate_noteInfo(s){
	if(trim(s.txtnotesubject.value)==""){
		alert("Plese enter subject")
		s.txtnotesubject.focus()
		return false
	
	}
	if(trim(s.txtdescription.value)==""){
		alert("Plese enter description")
		s.txtdescription.focus()
		return false
	
	}
}

function doc_validate()
{
	if(document.frm_doc.txtlocation.value=="")
	{
		alert("Choose the Location");
		document.frm_doc.txtlocation.focus();
		return false;
	}
	if(document.frm_doc.txtclient.value=="")
	{
		alert("Choose the Client");
		document.frm_doc.txtclient.focus();
		return false;
	}
	if(document.frm_doc.image_one.value=="")
	{
		alert("Upload the filename");
		document.frm_doc.image_one.focus();
		return false;
	}
	if(document.frm_doc.dn.value=="")
	{
		alert("Enter the description");
		document.frm_doc.dn.focus();
		return false;
	}
	if(document.frm_doc.startdate.value=="")
	{
		alert("Choose the date in date picker");
		document.frm_doc.startdate.focus();
		return false;
	}
}

function showsubcat(catid,comid){
	window.location.href = "documentinformation.php?task=add&locname="+catid+"&cid="+comid;
}

function editshowsubcat(catid,comid,did){
	//alert("hfhasdl");
	window.location.href = "documentinformation.php?task=editdocument&locname="+catid+"&cid="+comid+"&id="+did;
}


function showsubcat1(catid){
	if(catid!="")
		window.location.href = "index.php?locname="+catid;
	else
		window.location.href = "index.php?locname=";
}

function showsubcat2(catid1,audio){
	audio = "#aud";
	if(catid1!="")
		window.location.href = "index.php?locname2="+catid1+"&aud="+audio;
	else
		window.location.href = "index.php?locname2=";
}

function showclient_validate(locid){
alert(locid);
	if (document.frm_doc.txtlocation.value=="locid"){
		ap1=document.getElementById("client1");
		if(ap1){
		ap1.style.display="block";
		ap1.style.visibility="visible";
			}
		shipname1=document.getElementById("client2");
		if(shipname1){
		shipname1.style.display="none";
		shipname1.style.visibility="hidden";
		}				
	}
	else
	{
		ap1=document.getElementById("client1");
		if(ap1){
		ap1.style.display="none";
		ap1.style.visibility="hidden";
			}
		shipname1=document.getElementById("client2");
		if(shipname1){
		shipname1.style.display="block";
		shipname1.style.visibility="visible";
		}
	}
}

/*function shodetails(locid){
alert(locid);
	if (document.frm_doc.txtlocation.value=="locid") 
		{
			shipname1=document.getElementById("client1");
		    if(shipname1){
			shipname1.style.display="block";
			shipname1.style.visibility="visible";
			}
			shipname2=document.getElementById("client2");
			if(shipname2){
			shipname2.style.display="none";
			shipname2.style.visibility="hidden";
			}
		}
      else if (document.frm_doc.txtlocation.value=="locid") 
		{
           shipname1=document.getElementById("client1");
			if(shipname1){
			shipname1.style.display="none";
			shipname1.style.visibility="hidden";
			}
			shipname2=document.getElementById("client2");
			if(shipname2){
			shipname2.style.display="block";
			shipname2.style.visibility="visible";
			}
		}
		else
		{
			shipname1=document.getElementById("client1");
            shipname2=document.getElementById("client2");
            if(shipname1){
			shipname1.style.display="none";
			shipname1.style.visibility="hidden";
			}
			if(shipname2){
			shipname2.style.display="none";
			shipname2.style.visibility="hidden";
			}
		}
}*/

function val_login(form)
{

	userid=trim(form.userid.value);
	if(form.agencyname.value == "")
	{
		alert ("Please enter Agency Name");
		form.agencyname.focus();
		return false;
	}
	if(userid == "")
	{
		alert ("Please enter User Name");
		form.userid.focus();
		return false;
	}
   if(userid.length < 3)
    {
       alert("Please enter at least 3 characters for User Name");
	   form.userid.focus();
	   return false;
    }
	else if(userid.length > 15)
    {
       alert("Maximum of 15 characters are allowed for User Name");
	   form.userid.focus();
	   return false;
    }
	
			
	//check for special characters in First Name validation
	check=0;
	/*for(i=0;i<userid.length;i++)
	{
		if(userid.charCodeAt(i)>=65 && userid.charCodeAt(i)<=90)
		{
			check++;
		}
		else if(userid.charCodeAt(i)>=97 && userid.charCodeAt(i)<=122)
		{
			check++;
		}
		else if(userid.charCodeAt(i)==46 ||  userid.charCodeAt(i)==95)  // 46->.  95-> _
		{
			check++;
		}
	}
	if(check<userid.length)
	{
		alert("Please provide valid User Name");
		form.userid.focus();
		return false;
	} */
	
	// validation for password
	password=trim(form.password.value);
	if(password == "")
	{
		alert ("Please enter Password");
		form.password.focus();
		return false;
	}
	 if(isNaN(password)==false)
	{
				alert("Password should not be a number, please try again");
				form.password.focus();				
				return false;
	}
	else if(!isNaN(password.charAt(0)))
	{
		alert("First letter must not be a number, please enter valid Password");
		form.password.focus();
		return false;
	}
	else if(password.length < 4)
    {
       alert("Please enter at least 4 characters for Password");
	   form.password.focus();
	   return false;
    }
	else if(password.length > 15)
    {
       alert("Maximum of 15 characters are allowed, please enter valid Password");
	   form.password.focus();
	   return false;
    }
	
			
	//check for special characters in First Name validation
	check=0;
	for(i=0;i<password.length;i++)
	{	
		if(password.charCodeAt(i)>=65 && password.charCodeAt(i)<=90)	// A to Z
		{
			check++;
		}
		else if(password.charCodeAt(i)>=97 && password.charCodeAt(i)<=122)  //a to z
		{
			check++;
		}
		else if(password.charCodeAt(i)>=48 && password.charCodeAt(i)<=97)	// 0 to 9
		{
			check++;
		}
	}
	if(check<password.length)
	{
		alert("Please enter valid Password");
		form.password.focus();
		return false;
	}

}
function checkEmail(str, msg)
{
	 //alert(str.value)
	if(trim(str.value)=="")
	{
	// alert("please enter the "+msg+" email address");
	alert("Invalid email address");
	 str.focus();
	 return false;
	}
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str.value))
	{
		
		return true
	}
	else
	{
		alert("Please enter the valid " +msg+" email address");
		 str.focus();
		return false
	}
}


function isUrl(s) {
	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	return regexp.test(s);
}


function validateURL(url)
{
lengthValue = trim(url);
lengthValue = lengthValue.length;
	if(lengthValue != 0)
	{
	var j = new RegExp();
	j.compile("https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?"); 
	lengthValue = trim(url);
		if (!j.test(lengthValue))
		{ 
		alert("Please enter valid URL in new fun.");
		return false;
		}
	}
}

function checkDomain(nname)
{
var arr = new Array(
'.com','.net','.org','.biz','.coop','.info','.museum','.name',
'.pro','.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag',
'.ai','.al','.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw',
'.az','.ba','.bb','.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm',
'.bn','.bo','.br','.bs','.bt','.bv','.bw','.by','.bz','.ca','.cc',
'.cd','.cf','.cg','.ch','.ci','.ck','.cl','.cm','.cn','.co','.cr',
'.cu','.cv','.cx','.cy','.cz','.de','.dj','.dk','.dm','.do','.dz',
'.ec','.ee','.eg','.eh','.er','.es','.et','.fi','.fj','.fk','.fm',
'.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh','.gi','.gl','.gm',
'.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy','.hk','.hm',
'.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io','.iq',
'.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li',
'.lk','.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg',
'.mh','.mk','.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt',
'.mu','.mv','.mw','.mx','.my','.mz','.na','.nc','.ne','.nf','.ng',
'.ni','.nl','.no','.np','.nr','.nu','.nz','.om','.pa','.pe','.pf',
'.pg','.ph','.pk','.pl','.pm','.pn','.pr','.ps','.pt','.pw','.py',
'.qa','.re','.ro','.rw','.ru','.sa','.sb','.sc','.sd','.se','.sg',
'.sh','.si','.sj','.sk','.sl','.sm','.sn','.so','.sr','.st','.sv',
'.sy','.sz','.tc','.td','.tf','.tg','.th','.tj','.tk','.tm','.tn',
'.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug','.uk','.um',
'.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu','.ws',
'.wf','.ye','.yt','.yu','.za','.zm','.zw');

var mai = nname.value;
var val = true;
//alert("url test");
var dot = mai.lastIndexOf(".");
var dname = mai.substring(0,dot);
var ext = mai.substring(dot,mai.length);
//alert(ext);
	
if(dot>2 && dot<57)
{
	for(var i=0; i<arr.length; i++)
	{
	  if(ext == arr[i])
	  {
	 	val = true;
		break;
	  }	
	  else
	  {
	 	val = false;
	  }
	}
	if(val == false)
	{
	  	 alert("Your domain extension "+ext+" is not correct");
		 return false;
	}
	else
	{
		for(var j=0; j<dname.length; j++)
		{
		  var dh = dname.charAt(j);
		  var hh = dh.charCodeAt(0);
		  //alert(dh + " " +hh)
		  if((hh >= 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || hh==45 || hh==46)
		  {
			 if((j==0 || j==dname.length-1) && hh == 45)	
		  	 {
		 	  	 alert("Domain name should not begin are end with '-'");
			      return false;
		 	 }
		  }
		else	{
		  	 alert("Your domain name should not have special characters");
			 return false;
		  }
		}
	}
}
else
{
 alert("Invalid URL format");
 nname.focus();
 return false;
}	

return true;
}

function validate_companyInfo(s){
	if(trim(s.txtname.value)==""){
		alert("Please enter Company name")
		s.txtname.focus()
		return false
	
	}
	if(s.txtemail.value!=""){
		
			str=checkEmail(s.txtemail,"");
			if(str==false){
				s.txtemail.focus();
				return false
			
			}
		
	}
	   
	   
	if(trim(s.txtsusername.value)==""){
		alert("Please enter Admin user 'User Name' ")
		s.txtsusername.focus()
		return false
	
	}
	str=s.txtsusername.value
	if(str.indexOf(" ")>0){
		alert("Invalid User Name")
		return false
	}
	if(trim(s.txtsuserpassowrd.value)==""){
		alert("Please enter Admin user 'User Password' ")
		s.txtsuserpassowrd.focus()
		return false
	
	}
	
	if(trim(s.txtausername1.value)!=""){
		str=s.txtausername1.value
		if(str.indexOf(" ")>0){
			alert("Invalid User Name")
			s.txtausername1.focus()
			return false
		}
		
		if(trim(s.txtauserpassowrd1.value)==""){
			alert("Please enter Normal user 'Password' ")
			s.txtauserpassowrd1.focus()
			return false
	
		}
	}
	
	if(trim(s.txtausername2.value)!=""){
		str=s.txtausername2.value
		if(str.indexOf(" ")>0){
			alert("Invalid User Name")
			s.txtausername2.focus()
			return false
		}
		
		
		if(trim(s.txtauserpassowrd2.value)==""){
			alert("Please enter Normal user 'Password' ")
			s.txtauserpassowrd2.focus()
			return false
	
		}
	}
}
function validate_search(s){
	if(trim(s.renumber.value)==""){
		alert("Please enter registration number")
		s.renumber.focus()
		return false
	}
	/*if(isNaN(s.renumber.value)){
		alert("Please enter valid registration number")
		s.renumber.focus()
		return false
	} */

}
function functionalertlogin(){

	alert("Please login to proceed")
	
	return false
}
function validate_login(s){
	if(trim(s.uid.value) == "")
	{
		alert("please enter your userid");
		s.uid.focus();
		return false;
	}
	
	if(trim(s.pwd.value) == "")
	{
		alert("please enter password");
		s.pwd.focus();
		return false
	}
}
function validate_addprofile(s){
	if(trim(s.pname.value)==""){
	
		alert("Please enter Profile display Name")
		s.pname.focus()
		return false
	}
	if(trim(s.realname.value)==""){
	
		alert("Please enter Real Name")
		s.realname.focus()
		return false
	}
	if(trim(s.height.value)==""){
	
		alert("Please select height")
		s.height.focus()
		return false
	}
	if(trim(s.day.value)==""){
	
		alert("Please select day")
		s.day.focus()
		return false
	}
	if(trim(s.month.value)==""){
	
		alert("Please select month")
		s.month.focus()
		return false
	}
	if(trim(s.year.value)==""){
	
		alert("Please select year")
		s.year.focus()
		return false
	}
	if(trim(s.timeofbirth.value)==""){
	
		alert("Please enter Time of Birth")
		s.timeofbirth.focus()
		return false
	}
	if(trim(s.placeofbirth.value)==""){
	
		alert("Please enter Place of Birth")
		s.placeofbirth.focus()
		return false
	}
	if(trim(s.contactaddr.value)==""){
	
		alert("Please enter Address")
		s.contactaddr.focus()
		return false
	}
	if(trim(s.contactcity.value)==""){
	
		alert("Please enter City")
		s.contactcity.focus()
		return false
	}
	if(trim(s.contactphone.value)==""){
	
		alert("Please enter contact Phone")
		s.contactphone.focus()
		return false
	}

}
function validate_edit(s){
	
	
	if(trim(s.c_name.value)==""){
	
		alert("Please enter Profile title")
		s.c_name.focus()
		return false
	}
	if(trim(s.prof.value)==""){
	
		alert("Please enter describe your self")
		s.prof.focus()
		return false
	}

	if(trim(s.prof.value)==""){
	
		alert("Please enter describe your self")
		s.prof.focus()
		return false
	}
	
	
	
	//return false
	
}
function validate_staff(s){
	if(trim(s.c_name.value)==""){
		alert("Please enter profile name")
		s.c_name.focus()
		return false
	}
	if(trim(s.imagename1.value)==""){
		alert("Please upload profile image")
		s.imagename1.focus()
		return false
	}
	if(trim(s.description.value)==""){
		alert("Please upload profile description")
		s.description.focus()
		return false
	}
	if(trim(s.quote.value)==""){
		alert("Please upload profile quote")
		s.quote.focus()
		return false
	}
	if(trim(s.likes.value)==""){
		alert("Please upload profile likes")
		s.likes.focus()
		return false
	}
	if(trim(s.dislikes.value)==""){
		alert("Please upload profile dislikes")
		s.dislikes.focus()
		return false
	}
	if(trim(s.drink_story.value)==""){
		alert("Please upload profile drink story")
		s.drink_story.focus()
		return false
	}
}
function check(s,id,id1,pagename){
	alert(s.value)
	if(s.value=="Left Panel"){
			location.href="add_new_page_content.php?header=Left Panel&id="+id+"&id1="+id1+"&pagename="+pagename
	}else{
		location.href="add_new_page_content.php?id="+id+"&id1="+id1+"&pagename="+pagename
	}
}
function valid_registration(regis)
{
	if(trim(regis.name.value) == "")
	{
		alert("please enter first name");
		regis.name.focus();
		return false;
	}
	
	if(trim(regis.add.value) == "")
	{
		alert("please enter Address");
		regis.add.focus();
		return false
	}
	
	if(trim(regis.city.value) == "")
	{
		alert("please enter City");
		regis.city.focus();
		return false
	}
	
	if((regis.state.value == "")&&(trim(regis.other.value) ==""))
	{
		alert("please enter State");
		regis.state.focus();
		return false
	}
	
	if((regis.country.value == "")&&(trim(regis.othrcountry.value) == ""))
	{
		alert("please enter country");
		regis.country.focus();
		return false
	}
	
	if(trim(regis.zpcode.value) == "")
	{
		alert("please enter Zipcode");
		regis.zpcode.focus();
		return false
	}
	
	if(isNaN(regis.zpcode.value))
	{
		alert("please enter valid Zipcode");
		regis.zpcode.focus();
		return false
	}
	
	if(trim(regis.phone.value) == "")
	{
		alert("please enter Phone Number");
		regis.phone.focus();
		return false
	}
	
	/*if(isNaN(regis.phone.value))
	{
		alert("please enter valid Phone Number");
		regis.phone.focus();
		return(false);
	}*/
	
	if(trim(regis.email.value) == "")
	{
		alert("please enter email");
		regis.email.focus();
		return false
	}	
	if(checkEmail(regis.email.value)==false)
	{
		alert("please enter valid email");
		regis.email.focus();
		return false
	}	

	if(trim(regis.userid.value) == "")
	{
		
		alert("please enter user Id");
		regis.userid.focus();
		return false
	}
	if ( containsSpace(regis.userid.value)) 
	{
		alert("Your User ID should not contain any spaces. Please check the User ID");
		return false;
	}

	
	if(trim(regis.password.value) == "")
	{
		alert("please enter Password");
		regis.password.focus();
		return false
	}
	
	if(regis.password.value != regis.cpass.value)
	{
		alert("Password and Confirm Password are not same");
		regis.cpass.focus();
		return false
	}
	return true;
}
function validate_listing(s){
	if(trim(s.adv_capacity.value)==""){
		alert("enter advertiser capacity")
		s.adv_capacity.focus()
		return false
	}
	if(trim(s.p_type.value)==""){
		alert("select property type")
		s.p_type.focus()
		return false
	}
	if(trim(s.pname.value)==""){
		alert("enter property name")
		s.pname.focus()
		return false
	}
	
	if(trim(s.pname.value)==""){
		alert("enter property name")
		s.pname.focus()
		return false
	}
	
	if(trim(s.area.value)==""){
		alert("\ select area")
		s.area.focus()
		return false
	}
	if(trim(s.p_city.value)==""){
		alert("\ select city")
		s.p_city.focus()
		return false
	}
	if(trim(s.cost.value)==""){
		alert(" enter cost")
		s.cost.focus()
		return false
	}
	if(trim(s.p_community.value)==""){
		alert("select community")
		s.p_community.focus()
		return false
	}
	
	if(trim(s.b_rooms.value)==""){
		alert("select no of bed rooms")
		s.b_rooms.focus()
		return false
	}
	if(trim(s.Beds.value)==""){
		alert("select no of beds")
		s.Beds.focus()
		return false
	}
	
	if(trim(s.bathrooms.value)==""){
		alert("select no of beds")
		s.bathrooms.focus()
		return false
	}
	
	if(trim(s.sleeps.value)==""){
		alert("select no of sleeps")
		s.sleeps.focus()
		return false
	}
	if(trim(s.p_title.value)==""){
		alert("enter property brief description")
		s.p_title.focus()
		return false
	}
	if(trim(s.p_desc.value)==""){
		alert("enter property description")
		s.p_desc.focus()
		return false
	}
	if(trim(s.loc_desc.value)==""){
		alert("enter property location description")
		s.loc_desc.focus()
		return false
	}
	if(trim(s.attr_dist.value)==""){
		alert("enter property attraction description")
		s.attr_dist.focus()
		return false
	}
	if(trim(s.cemail.value)==""){
		alert("enter email id")
		s.cemail.focus()
		return false
	}else{
	
		st=s.cemail.value;
			if(checkEmail(st)==false)
			{
					alert("Invalid Email Id \n"+st);
					s.cemail.focus();
					return false;
			}
	}
	
	if(trim(s.phone.value)==""){
		alert("enter phone no.")
		s.phone.focus()
		return false
	}
	
}
var editor = null;
function initEditor() {
  // create an editor for the "ta" textbox
  editor = new HTMLArea("textdesc");

  // register the TableOperations plugin with our editor
  editor.registerPlugin("TableOperations");

  editor.generate();
  return false;
}

function insertHTML() {
  var html = prompt("Enter some HTML code here");
  if (html) {
    editor.insertHTML(html);
  }
}
function highlight() {
  editor.surroundHTML('<span style="background-color: yellow">', '</span>');
}

///////////
function preview_prepare(s1)
{
  features='toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=550,height=500';
  theURL="profile_preview.php?name="+s1.m_type_name.value+"&thum="+s1.imagename1.value+"&main_img="+s1.imagename2.value+"&desc="+s1.desc.value+"&addinf="+s1.textarea.value
  window.open(theURL,"Preview",features);
}
function openpopup(s){
	if(s.value=="new"){
		features='toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=550,height=500';
		  window.open("addnew_account.php","Preview",features);
	}

}
function validate_discount(s1)
{
	
}
function validate_profile(s1)
{
	if (trim(s1.m_type_name.value)=="")
	{	
		alert("Please Enter Profile Name")
		s1.m_type_name.focus()
		return false
	}
	
	if (trim(s1.desc.value)=="")
	{	
		alert("Please Enter Profile Description")
		s1.desc.focus()
		return false
	}
}

function dele_confirm(s1,s2)
{
	a1=confirm("Are you sure to delete")
	if (a1)
	{
		location.href='adm_tasks1.php?work='+s2+'&id='+s1
	}
}
function validate_login(s)
{
	if(s.uid.value=="")
	{
		alert("Please enter your User ID")
		s.uid.focus()
		return false
	}
	if(s.pwd.value=="")
	{
		alert("Please enter your Password")
		s.pwd.focus()
		return false
	}
}

function validate_changepwd(s)
{
	//alert(s.o_pwd.value)
	if(trim(s.o_pwd.value)=="")
	{
		alert("Please enter your old password")
		s.o_pwd.focus()
		return false
	}
	//alert("ok")
	if(trim(s.pwd.value)=="")
	{
		alert("Please enter your new password")
		s.pwd.focus()
		return false
	}
	
	if(trim(s.pwd.value)==trim(s.o_pwd.value))
	{
		alert("Old password and new password same, Please choose another password")
		s.pwd.focus()
		return false
	}
	if(trim(s.c_pwd.value)=="")
	{
		alert("Please confirm your new password again")
		s.c_pwd.focus()
		return false
	}
	if(s.pwd.value!=s.c_pwd.value)
	{
		//alert(trim(s.pwd.value))
		//alert(trim(s.c_pwd.value))
		alert("Password and confirm password valures are not same")
		s.c_pwd.focus()
		return false
	}	
}
function validate_account(s){
	if(trim(s.pass.value)==""){
		alert("Please enter password")
		s.pass.focus()
		return false
	}
	if(trim(s.c_name.value)==""){
		alert("Please enter full name")
		s.c_name.focus()
		return false
	}
	if(trim(s.addr.value)==""){
		alert("Please enter address")
		s.addr.focus()
		return false
	}
	if(trim(s.phone.value)==""){
		alert("Please enter phone")
		s.phone.focus()
		return false
	}
	if(trim(s.email_id.value)==""){
		alert("Please enter email id")
		s.email_id.focus()
		return false
	}else{
		if(checkEmail(s.email_id.value)==false)
		{
			alert("please enter valid email");
			s.email_id.focus();
			return false
		}
	}
}
function validate_account_add(s){


	if(trim(s.uid.value)==""){
		alert("Please enter userid")
		s.uid.focus()
		return false
	}
	if(trim(s.pass.value)==""){
		alert("Please enter password")
		s.pass.focus()
		return false
	}
	if(trim(s.c_name.value)==""){
		alert("Please enter full name")
		s.c_name.focus()
		return false
	}
	if(trim(s.addr.value)==""){
		alert("Please enter address")
		s.addr.focus()
		return false
	}
	if(trim(s.phone.value)==""){
		alert("Please enter phone")
		s.phone.focus()
		return false
	}
	if(trim(s.email_id.value)==""){
		alert("Please enter email id")
		s.email_id.focus()
		return false
	}else{
		if(checkEmail(s.email_id.value)==false)
		{
			alert("please enter valid email");
			s.email_id.focus();
			return false
		}
	}
}

function validate_menutype1(s)
{
	if(trim(s.m_type_name.value)=="")
	{
		alert("Please Enter Name")
		s.m_type_name.focus()
		return false
	}
}
function validate_pricing(s){
	if(trim(s.m_type_name.value)=="")
	{
		alert("Please Enter Pricing Flag")
		s.m_type_name.focus()
		return false
	}
	if(trim(s.incall.value)=="")
	{
		alert("Please Enter In Call Rate")
		s.incall.focus()
		return false
	}
	if(trim(s.outcall.value)=="")
	{
		alert("Please Enter Out Call Rate")
		s.outcall.focus()
		return false
	}
}
function validate_menutype(s)
{
	if(trim(s.c_name.value)=="")
	{
		alert("Please Enter Company Name")
		s.c_name.focus()
		return false
	}
	
	if(trim(s.cp_name2.value)=="")
	{
		alert("Please Enter Webstie URL")
		s.cp_name2.focus()
		return false
	}
	 
	if(trim(s.cp_name.value)=="")
	{
		alert("Please Enter Email")
		s.cp_name.focus()
		return false
	}
	else(trim(s.cp_name.value)!="")
	{
		st=s.cp_name.value;
			if(checkEmail(st)==false)
			{
					alert("Invalid Email Id \n"+st);
					s.cp_name.focus();
					return false;
			}
	}
	
	if(trim(s.description.value)=="")
	{
		alert("Please Enter Mail Signature")
		s.description.focus()
		return false
	}
	
	
}
function validate_newpage_conent(s)
{

		updateRTE('textdesc');
	
/*	if(trim(editor.getInnerHTML())=="")
	{
		alert("Please Page Content")
		//s1.textdesc.focus()
		return false
	} */
}
function validate_news(s)
{
	if(trim(s.imagename1.value)=="")
	{
		alert("Please upload an image")
		s.imagename1.focus()
		return false
	}
	
	
}
function validate_newpage(s)
{
	if(trim(s.c_name.value)=="")
	{
		alert("Please Enter Page Name")
		s.c_name.focus()
		return false
	}
	if(trim(s.c_name2.value)=="")
	{
		alert("Please Enter Page Title")
		s.c_name2.focus()
		return false
	}
	
}
function validate_test(s)
{
	if(trim(s.c_name.value)=="")
	{
		alert("Please Enter Name")
		s.c_name.focus()
		return false
	}
	
	if(trim(s.description.value)=="")
	{
		alert("Please Enter Gallery Description")
		s.description.focus()
		return false
	}
}
function validate_gallery(s)
{
	if(trim(s.name.value)=="")
	{
		alert("Please Enter Name")
		s.name.focus()
		return false
	}
	if(trim(s.escortname.value)=="")
	{
		alert("Please Enter Work Name")
		s.escortname.focus()
		return false
	}
	if(trim(s.age.value)=="")
	{
		alert("Please Enter age")
		s.age.focus()
		return false
	}
	if(trim(s.height.value)=="")
	{
		alert("Please Enter Height")
		s.height.focus()
		return false
	}
	if(trim(s.weight.value)=="")
	{
		alert("Please Enter Weight")
		s.weight.focus()
		return false
	}
	if(trim(s.email.value)!="")
	{
		if(checkEmail(s.email.value)==false)
		{
				alert("please enter valid email");
				s.email.focus();
				return false
		}
	}
	
	
	
	if(trim(s.statistics.value)=="")
	{
		alert("Please Enter size")
		s.statistics.focus()
		return false
	}
	if(trim(s.hair.value)=="")
	{
		alert("Please Enter hair")
		s.hair.focus()
		return false
	}
	if(trim(s.nationality.value)=="")
	{
		alert("Please Enter nationality")
		s.nationality.focus()
		return false
	}
	
	if(trim(s.eyes.value)=="")
	{
		alert("Please Enter eyes")
		s.eyes.focus()
		return false
	}
	if(trim(s.orientation.value)=="")
	{
		alert("Please Enter Orientation")
		s.orientation.focus()
		return false
	}
	if(trim(s.languages.value)=="")
	{
		alert("Please Enter languages")
		s.languages.focus()
		return false
	}
	if(trim(s.country.value)=="")
	{
		alert("Please Enter Where Your Are Located")
		s.country.focus()
		return false
	}
	if(trim(s.currency.value)=="")
	{
		alert("Please Select Currency")
		s.currency.focus()
		return false
	}
	
	if(trim(s.bio.value)=="")
	{
		alert("Please Enter Describe Your Self")
		s.bio.focus()
		return false
	}
		
	
	
}
function validate_email(s)
{
	if(trim(s.m_type_name.value)=="")
	{
		alert("Please Enter Email ID")
		s.m_type_name.focus()
		return false
	}
}



function MM_openBrWindow(theURL,winName,features) { //v2.0
  features='toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=350,height=200';
  window.open(theURL,winName,features);
}

function MM_openBrWindow2(theURL,winName,features) { //v2.0
  features='toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no,width=800,height=600';
  window.open(theURL,winName,features);
}
function LTrim(str)
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
      // We have a string with leading blank(s)...

      var j=0, i = s.length;

      // Iterate from the far left of string until we
      // don't have any more whitespace...
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      // Get the substring from the first non-whitespace
      // character to the end of the string...
      s = s.substring(j, i);
   }
   return s;
}
/*
function checkEmail(str)
	{
		if((str.indexOf("@")==-1) || (str.indexOf(".")==-1))
		{
			fstr="Please Enter @ or .";
			return false;
		}
		else
		{
		if((str.indexOf("@") == 0) || (str.indexOf(".") == 0))
		{
			fstr="@ or . Cannot Be first";
			return false;
		}
		if((str.indexOf("@") == (str.length-1)) || (str.indexOf(".") == (str.length-1)))
		{
			fstr="@ or . Cannot Be Last";
			return false;
		}

		if(str.indexOf("@") > str.indexOf("."))
		{
			fstr="@ Should be After .";
			return false;
		}
		if((str.indexOf("@")+1) == str.indexOf("."))
		{
			fstr="@. IS Invalid Email";
			return false;
		}
		}
		var cp=0;					
		for(i=0;i<str.length;i++)
		{
			c=str.charAt(i);
			b=(((c >= "0") && (c <= "9")) || ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) || (c == ".") || (c == "@") || (c == "_")|| (c == "-"))
			if(c=="@") cp++;
			if(b==true)
			   continue;
			else
			{
				fstr="Cannot include "+c;
				return false;
			}
		}
		if(cp==2)
		{
			fstr="@ cannnot be repetaed";
			return false;

		}
		return true;
	}

*/

function RTrim(str)
{
   // We don't want to trip JUST spaces, but also tabs,
   // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...

      var i = s.length - 1;       // Get length of string

      // Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;


      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }

   return s;
}


function trim(str)
{
   return RTrim(LTrim(str));
}

function email_validate(s)
{
	flag=false
//	alert("ok")
//	alert()
	//return false
	ids="0";
	if(s.slno!=null)
	{
		a1=s.slno.length
		if(a1>1)
		{
			for(i=0;i<a1;i++)
			{
				if(s.slno[i].checked)
				{
					flag=true
					ids=ids+","+s.slno[i].value
				}
			}
		}
		else
		{
			//alert("ok")
			if(s.slno.checked)
			{
				ids=ids+","+s.slno.value
				flag=true
			}
		}
	}
	if(flag==false)
	{
		alert("Select Email Ids to Send News Letter")
		return false
	}
	else
	{
		s.id.value=ids
	}
}
function validate_email1(s)
{
	if(s.m_type_name.value=="")
	{
		alert("Please Enter Mail Ids")
		s.m_type_name.focus()
		return false
	}
	if(s.subject.value=="")
	{
		alert("Please Enter Subject")
		s.subject.focus()
		return false
	}
	if(s.textarea.value=="")
	{
		alert("Please Enter News Letter Body")
		s.textarea.focus()
		return false
	}
}