function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}


function application(){

	if (document.form1.personalfamilyname.value=='')
	{
		alert('enter your family name');
		document.form1.personalfamilyname.focus();
		return(false);
	}		

	if (document.form1.personalfirstname.value=='')
	{
		alert('enter your first name');
		document.form1.personalfirstname.focus();
		return(false);
	}		

	if (document.form1.personaladdress.value=='')
	{
		alert('enter your address');
		document.form1.personaladdress.focus();
		return(false);
	}		

	if (document.form1.personalcity.value=='')
	{
		alert('enter your city');
		document.form1.personalcity.focus();
		return(false);
	}		

	if (document.form1.personalcountry.value=='')
	{
		alert('enter your country');
		document.form1.personalcountry.focus();
		return(false);
	}		

	if (document.form1.personalpostcode.value=='')
	{
		alert('enter your post code');
		document.form1.personalpostcode.focus();
		return(false);
	}		

	if (document.form1.personaltel.value=='')
	{
		alert('enter your telephone');
		document.form1.personaltel.focus();
		return(false);
	}		

	if (document.form1.personalbirth.value=='')
	{
		alert('enter your date of birth');
		document.form1.personalbirth.focus();
		return(false);
	}	

	if (document.form1.personalnationality.value=='')
	{
		alert('enter your nationality');
		document.form1.personalnationality.focus();
		return(false);
	}		

	if (document.form1.personalpassportnumber.value=='')
	{
		alert('enter your passport numbet');
		document.form1.personalpassportnumber.focus();
		return(false);
	}		

	if (document.form1.personalemail.value=='')
	{
		alert('enter your e-mail');
		document.form1.personalemail.focus();
		return(false);
	}		

	if (document.form1.parentfamilyname.value=='')
	{
		alert('enter parent family name');
		document.form1.parentfamilyname.focus();
		return(false);
	}		

	if (document.form1.parentfirstname.value=='')
	{
		alert('enter parent first name');
		document.form1.parentfirstname.focus();
		return(false);
	}		

	if (document.form1.parentaddress.value=='')
	{
		alert('enter parent address');
		document.form1.parentaddress.focus();
		return(false);
	}		

	if (document.form1.parentcity.value=='')
	{
		alert('enter parent city');
		document.form1.parentcity.focus();
		return(false);
	}		

	if (document.form1.parentcountry.value=='')
	{
		alert('enter parent country');
		document.form1.parentcountry.focus();
		return(false);
	}		

	if (document.form1.parentpostcode.value=='')
	{
		alert('enter parent post code');
		document.form1.parentpostcode.focus();
		return(false);
	}		

	if (document.form1.parenttel.value=='')
	{
		alert('enter parent telephone');
		document.form1.parenttel.focus();
		return(false);
	}	

	if (document.form1.englishlevelreading.value=='')
	{
		alert('choose your english level');
		document.form1.englishlevelreading.focus();
		return(false);
	}

	if (document.form1.englishlevelwrighting.value=='')
	{
		alert('choose your english level');
		document.form1.englishlevelwrighting.focus();
		return(false);
	}

	if (document.form1.workexperience.value=='')
	{
		alert('tell about your work experience');
		document.form1.workexperience.focus();
		return(false);
	}
	
	if (document.form1.words100.value=='')
	{
		alert('tell about why you want to study hospitality management');
		document.form1.words100.focus();
		return(false);
	}
	
	if (document.form1.englishlevelspoken.value=='')
	{
		alert('choose your english level');
		document.form1.englishlevelspoken.focus();
		return(false);
	}
	
	if (document.form1.study.value=='')
	{
		alert('choose your type of study');
		document.form1.study.focus();
		return(false);
	}

	if (document.form1.studystart.value=='')
	{
		alert('enter your course start date');
		document.form1.studystart.focus();
		return(false);
	}	

	if (document.form1.subject.value=='')
	{
		alert('choose subject');
		document.form1.subject.focus();
		return(false);
	}
/*
	if (document.form1.time.value=='')
	{
		alert('choose time');
		document.form1.time.focus();
		return(false);
	}
*/
	//if (document.form1.terms.value=='')
	//{
		alert('you have to accept all of the rules and regulations of London Hotel School ');
		//document.form1.terms.focus();
		return(true);
	//}

}

function saveuserinfo(){

	_email=document.reg._email.value;
	if ((_email.indexOf('@', 0) == -1) ||  ( _email.indexOf('.', 0) == -1))
	{ alert("Please enter a valid email address"); document.reg._email.focus();;return(false); }

	if (document.reg.newpassword1.value != document.reg.newpassword2.value)
	{
		alert('Please check your password');
		document.reg.newpassword1.focus();
		return(false);
	}	


	if(trim(document.reg.newpassword1.value)=='' || document.reg.newpassword1.value.length < 4) {
			alert('Please enter a password at least 4 characters long');
			document.reg.newpassword1.focus();
		}



}
function addPage()
{
  if (document.Compose._title.value == "")
  { alert("Enter title"); document.Compose._title.focus(); return(false); }
  
  if ((document.Compose._img.value != "" || document.Compose._img2.value!="") && /%IMG%/.exec(document.Compose.Body.value)!="%IMG%")
  {
	  alert("choose image position in the text using  %IMG%");
	  return(false);
  }
}

function contactForm(){
	if (document.form1._subject.value=='')
	{
		alert('Enter subject');
		document.form1._subject.focus();
		return(false);
	}

	if (document.form1._name.value=='')
	{
		alert('Enter name');
		document.form1._name.focus();
		return(false);
	}

	if (document.form1._surname.value=='')
	{
		alert('Enter surname');
		document.form1._surname.focus();
		return(false);
	}

	if (document.form1._message.value=='')
	{
		alert('Enter message');
		document.form1._message.focus();
		return(false);
	}

	_email=document.form1._email.value;
	if ((_email.indexOf('@', 0) == -1) ||  ( _email.indexOf('.', 0) == -1))
	{ alert("Please enter a valid email address"); document.form1._email.focus();;return(false); }

}

function addLocation(){

	if (document.form1._location.value=='')
	{
		alert('Enter location name');
		document.form1._location.focus();
		return(false);
	}
}
function addpricerange(){

	if (document.form1._pricerange.value=='')
	{
		alert('Enter price range');
		document.form1._pricerange.focus();
		return(false);
	}
}
function addStyle(){

	if (document.form1._style.value=='')
	{
		alert('Enter Style name');
		document.form1._style.focus();
		return(false);
	}
}

function addHotProperty(){

	if (document.form1._hotproperty.value=='')
	{
		alert('Enter REFERENCE number');
		document.form1._hotproperty.focus();
		return(false);
	}
}

function addParking(){

	if (document.form1._parking.value=='')
	{
		alert('Enter type name');
		document.form1._parking.focus();
		return(false);
	}
}

function addProperty(){
	if (document.form1._location.value=='20')
	{
		alert('Select location');
		document.form1._location.focus();
		return(false);
	}

	if (document.form1.price.value=='')
	{
		alert('Enter price');
		document.form1.price.focus();
		return(false);
	}

	if (document.form1.short_desc.value=='')
	{
		alert('Enter short description');
		document.form1.short_desc.focus();
		return(false);
	}
}
/*
function checksearch(){
	if (document.searchForm.string.value=="" || document.searchForm.string.value==" Haber ara"){
		alert("Lütfen aradığınız kelimeyi yazınız"); return(false); 
	}
}

function checksearch1(){
	if (document.searchForm1.string.value=="" || document.searchForm1.string.value==" Haber ara"){
		alert("Lütfen aradığınız kelimeyi yazınız"); return(false); 
	}
}

function setVote()
{
	document.form1.choosed.value=true
}

function ValidateVote()
{
	if (document.form1.choosed.value=="false"){
		alert("Henüz seçiminizi yapmadınız"); return(false); 
	}
}

function ValidateForm()
{

_name = document.signUp.name.value;
_surname = document.signUp.surname.value;
_company = document.signUp.company.value;
_address = document.signUp.address.value;
_postcode = document.signUp.postcode.value;
_country = document.signUp.country.value;
_tel = document.signUp.tel.value;
_fax = document.signUp.fax.value;
_website = document.signUp.website.value;
_text = document.signUp.text.value;
_email = document.signUp.email.value;

  if (_name == "")
  { alert("Lütfen isminizi yazınız"); return(false); }

  if (_surname == "")
  { alert("Lütfen soy isminizi yazınız"); return(false); }

  if (_company == "")
  { alert("Lütfen firma ismini yazınız"); return(false); }

  if (_address == "")
  { alert("Lütfen adresinizi yazınız"); return(false); }

  if (_postcode == "")
  { alert("Lütfen posta kodunu yazınız"); return(false); }

  if (_country == "")
  { alert("Lütfen ülkenizi yazınız"); return(false); }

  if (_tel == "")
  { alert("Lütfen telefon numaranızı yazınız"); return(false); }

  if (_fax == "")
  { alert("Lütfen fax numaranızı yazınız"); return(false); }

  if (_website == "")
  { alert("Lütfen web adresinizi yazınız"); return(false); }

  if (_text == "")
  { alert("Lütfen mesajınızı yazınız"); return(false); }

  if (_email == "")
  { alert("Lütfen elektronik postanızı yazınız"); return(false); }

  if ((_email.indexOf('@', 0) == -1) ||  ( _email.indexOf('.', 0) == -1))
  { alert("Please enter a valid email address"); return(false); }

}

*/

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function FullscreenLoad(url){
	if (window.screen){
	var hori=screen.availWidth;
	var verti=screen.availHeight;
	// window.open(url,'vollesBildchen', 'width='+hori+',height='+verti+',fullscreen=1, scrollbars=1,left='+(0)+',top='+(0));
	}
}

function FullscreenClose(url){
	parent.location.href=url;
	window.close();
}
