function validatecontactinfo() {
  
missinginfo = "";
if (document.contactform.name.value == "") {
missinginfo += "\n     -  Name";
}
if (document.contactform.telephone.value == "") {
missinginfo += "\n     -  Telephone";
}
if (document.contactform.email.value == "") {
missinginfo += "\n     -  Email";
}

if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You failed to correctly fill in your:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and submit again!";
alert(missinginfo);
return false;
}
else return true;
}

function validatedineclub() {
  
missinginfo = "";
if (document.dineclubform.title.value == "") {
missinginfo += "\n     -  Title";
}
if (document.dineclubform.firstname.value == "") {
missinginfo += "\n     -  First Name";
}
if (document.dineclubform.surname.value == "") {
missinginfo += "\n     -  Surname";
}
if (document.dineclubform.address.value == "") {
missinginfo += "\n     -  Address";
}
if (document.dineclubform.postcode.value == "") {
missinginfo += "\n     -  Post Code";
}
if (document.dineclubform.email.value == "") {
missinginfo += "\n     -  Email";
}

if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You failed to correctly fill in your:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and submit again!";
alert(missinginfo);
return false;
}
else return true;
}


function validatennewsletterinfo() {
missinginfo = "";
if (document.newsletterform.name.value == "") {
missinginfo += "\n     -  Name";
}
if (document.newsletterform.telephone.value == "") {
missinginfo += "\n     -  Telephone";
}
if (document.newsletterform.email.value == "") {
missinginfo += "\n     -  Email";
}

if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You failed to correctly fill in your:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and submit again!";
alert(missinginfo);
return false;
}
else return true;
}

function validateappform() {
  
missinginfo = "";
if (document.onlineapplication.name.value == "") {
missinginfo += "\n     -  Name";
}
if (document.onlineapplication.correspondenceaddress.value == "") {
missinginfo += "\n     -  Address";
}
if (document.onlineapplication.email.value == "") {
missinginfo += "\n     -  Email";
}
if (document.onlineapplication.positionappliedfor.value == "") {
missinginfo += "\n     -  Position Applied for";
}
if (document.onlineapplication.refereename1.value == "") {
missinginfo += "\n     -  Referee One Name";
}
if (document.onlineapplication.refereeoccupation1.value == "") {
missinginfo += "\n     -  Referee One Occupation";
}
if (document.onlineapplication.refereeaddress1.value == "") {
missinginfo += "\n     -  Referee One Address";
}
if (document.onlineapplication.refereetelephone1.value == "") {
missinginfo += "\n     -  Referee One Telephone";
}
if (document.onlineapplication.refereename2.value == "") {
missinginfo += "\n     -  Referee Two Name";
}
if (document.onlineapplication.refereeoccupation2.value == "") {
missinginfo += "\n     -  Referee Two Occupation";
}
if (document.onlineapplication.refereeaddress2.value == "") {
missinginfo += "\n     -  Referee Two Address";
}
if (document.onlineapplication.refereetelephone2.value == "") {
missinginfo += "\n     -  Referee Two Telephone";
}
if (document.onlineapplication.termsandconditions.checked != true) {
missinginfo += "\n     -  Certification that information entered is correct";
}

if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You failed to correctly fill in your:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and submit again!";
alert(missinginfo);
return false;
}
else return true;
}

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_validateForm() { //v4.0
  return true;
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += 'You must select your arrival date\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}

function Delete_Cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
        ( (path) ? ";path=" + path : "") +
        ( (domain) ? ";domain=" + domain : "") +
        ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function parse_parameters(str, plus) {
    param_len = str.length
    var ampsep = -1
    var tstr = str.substring(1,str.length)
    var validnames = "mobile" 
    while (ampsep != tstr.length) {
      tstr = tstr.substring(ampsep+1,tstr.length)
      ampsep = tstr.indexOf("&")
      if (ampsep == -1) {ampsep = tstr.length}
      param = tstr.substring(0,ampsep)
      eqsep = param.indexOf("=")
      pname = param.substring(0,eqsep)
      if (validnames.indexOf(pname) != -1) {
        pvalue = param.substring(eqsep+1,param.length)
        if (plus) {pvalue = conv_plus(pvalue)}
        pvalue = unescape(pvalue)
        eval(pname+'='+'"'+pvalue+'"')
      }
    }
}

function conv_plus(s) {
  ns = s
  while (ns.indexOf('+') != -1) {
    pp = ns.indexOf('+')
    ns = ns.substring(0,pp) + " " + ns.substring(pp+1,ns.length)
  }
  return ns
}

	var useragents =['palm', 'palmos', 'palmsource', 'iphone', 'blackberry', 'nokia', 'phone', 'midp', 'mobi', 'pda', 'wap',
'java', 'nokia', 'hand', 'symbian', 'chtml', 'wml', 'ericsson', 'lg', 'audiovox', 'motorola', 'samsung',
'sanyo', 'sharp', 'telit', 'tsm', 'mobile', 'mini', 'windows ce', 'smartphone', '240x320', '320x320',
'mobileexplorer', 'j2me', 'sgh', 'portable', 'sprint', 'vodafone', 'docomo', 'kddi', 'softbank', 'pdxgw', 'jphone',
'astel', 'minimo', 'plucker', 'netfront', 'xiino', 'mot-v', 'mot-e', 'portalmmm', 'sagem', 'sie-s',
'sie-m', 'android', 'ipod'];
	var agt=navigator.userAgent.toLowerCase();
	var is_mobile = false;
	for (i=0;i<useragents.length;i++) {
	  if(agt.indexOf(useragents[i])!=-1) {
	    is_mobile = true;
	    user_agent = agt;
	    break;
	  }
	}
	if (is_mobile) {
      var str = document.location.search
      param_len = 0
      mobile = ''
      if (str != '') {
        parse_parameters(str, true)
      }
	  if ((mobile=='no') || (Get_Cookie("noMobile"))) {
        var todays_date = new Date()
        // 2 years from now
        var expires_date = new Date(todays_date.getTime() + (2 * 365 * 24 * 60 * 60 * 1000))
        Set_Cookie("noMobile", 1, expires_date, "/")
	    is_mobile = false;
	  }
	}
	if (is_mobile) {
	  location.replace('https://mobile.ihotelier.com/mbe/mobile/75248?language=11')
	}


