﻿function ValidateContactForm (theForm) {
  var fname = theForm.fullname.value;   
  var email = theForm.email.value;   

  if (!fname)	{
    alert("You must enter your full name.");
    return false;
	} else if (!email) {
		alert("You must enter your email.");
		return false;
	} else if ((email.indexOf('@') == -1) || (email.indexOf('.') == -1)) {
		alert("Wrong email format.");
		return false;
	} else {
		return true;
	}
}
function ValidateOnlineConsultationRequest(theForm, theLang) {
	var firstname = theForm.firstname.value; 
	var lastname = theForm.lastname.value; 
	var dateOfBirth = theForm.date_of_birth.value; 
	var sex = theForm.sex.value; 
	var country = theForm.country.value; 
	var contact_day_phone = theForm.contact_day_phone.value; 
	var email = theForm.email.value; 
	//var baldness_pattern =  theForm.baldness_pattern.value; 
	var interestedIn = theForm.what_are_you_interested_in.value;
	
	j = theForm.baldness_pattern.length;
	var baldness_pattern = "";
	for (i=0; i<j; i++){
		if(theForm.baldness_pattern[i].checked) {
			baldness_pattern = theForm.baldness_pattern[i].value;
		}
	}
	
	if ((!firstname)||(!lastname)||(!dateOfBirth)||(!sex)||(!country)
		||(!contact_day_phone)||(!email)||(!interestedIn)) {
		if (theLang == 'en') {
	    alert("Please fill up all compulsory fields with orange colour.");
		} else if (theLang == 'gr') {
	    alert("Παρακαλώ συμπληρώστε όλα τα πεδία με πορτοκαλί χρώμα.");
		} else if (theLang == 'sp') {
	    alert("Por favor, complete las casillas correspondientes que aparecen con color naranja.");
		} else {
	    alert("Please fill up all compulsory fields with orange colour.");
		}
    return false;
	} else if ((email.indexOf('@') == -1) || (email.indexOf('.') == -1)) {
		alert("Wrong email format.");
		return false;
	} else if (!baldness_pattern) {
		if (sex == 'Male') {
			alert("You must select baldness pattern for Men.");
		} else if (sex == 'Female') {
			alert("You must select baldness pattern for Women.");
		}
		return false;
	} else if (((baldness_pattern == 'Women_Grade_1')||(baldness_pattern == 'Women_Grade_2')||(baldness_pattern == 'Women_Grade_3'))&&(sex == 'Male')) {
		alert("You must select baldness pattern for Men.");
		return false;
	} else if (((baldness_pattern == 'Men_Class_1')||(baldness_pattern == 'Men_Class_2')||(baldness_pattern == 'Men_Class_3')||(baldness_pattern == 'Men_Class_3V')||(baldness_pattern == 'Men_Class_4')||(baldness_pattern == 'Men_Class_5')||(baldness_pattern == 'Men_Class_6')||(baldness_pattern == 'Men_Class_7'))&&(sex == 'Female')) {
		alert("You must select baldness pattern for Women.");
		return false;
	} else {
		return true;
	}
}
function ValidateAdditionalServicesForm (theForm) {
  var fname = theForm.fullname.value;   
	var country = theForm.country.value; 
	var phone = theForm.phone.value; 
	var email = theForm.email.value; 
	var arrival_day = theForm.arrival_day.value; 
	var arrival_month = theForm.arrival_month.value; 
	var arrival_year = theForm.arrival_year.value; 
	var departure_day = theForm.departure_day.value; 
	var departure_month = theForm.departure_month.value; 
	var departure_year = theForm.departure_year.value; 
	var persons_travelling = theForm.number_of_persons_travelling.value; 

	if (!fname)	{
    alert("You must enter your full name.");
    return false;
	} else if (!country) {
		alert("You must select your country.");
		return false;
	} else if (!phone) {
		alert("You must enter your telephone number.");
		return false;
	} else if (!email) {
		alert("You must enter your email.");
		return false;
	} else if ((email.indexOf('@') == -1) || (email.indexOf('.') == -1)) {
		alert("Wrong email format.");
		return false;
	} else if ((!arrival_day) || (!arrival_month) || (!arrival_year)) {
		alert("You must select your arrival date.");
		return false;
	} else if ((!departure_day) || (!departure_month) || (!departure_year)) {
		alert("You must select your departure date.");
		return false;
	} else if (!persons_travelling) {
		alert("You must enter the number of persons travelling.");
		return false;
	} else {
		return true;
	}
}
function showMap() {
	w_width = 640;
	w_height = 400;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=no,scrollbars=no';

	fparam = 'showmap.html';
  window.showMapWindow = open(fparam, 'showMapWindow', theWindowParam);
	setTimeout('if(showMapWindow&&!showMapWindow.closed)showMapWindow.focus()',100);
}
function showContact() {
	w_width = 640;
	w_height = 400;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=no,scrollbars=no';

	fparam = 'showcontact.html';
  window.showContactWindow = open(fparam, 'showContactWindow', theWindowParam);
	setTimeout('if(showContactWindow&&!showContactWindow.closed)showContactWindow.focus()',100);
}
function printPage() {
  lochref = '' + this.location;
	if (lochref.indexOf('?') > 0) {
		lochref = '?' + lochref.substring((lochref.indexOf('?')) + 1);
	} else {
		lochref = '';
	}

	w_width = 595;
	w_height = 500;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=no,scrollbars=yes';

	fparam = 'print.php'+lochref;
  window.showPrintWindow = open(fparam, 'showPrintWindow', theWindowParam);
	setTimeout('if(showPrintWindow&&!showPrintWindow.closed)showPrintWindow.focus()',100);
}
function emailPage() {
  lochref = '' + this.location;
	if (lochref.indexOf('?') > 0) {
		lochref = '?' + lochref.substring((lochref.indexOf('?')) + 1);
	} else {
		lochref = '';
	}

	w_width = 520;
	w_height = 300;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=no,scrollbars=yes';

	fparam = 'tools/emailpage/index.php'+lochref;
  window.showEmailWindow = open(fparam, 'showEmailWindow', theWindowParam);
	setTimeout('if(showEmailWindow&&!showEmailWindow.closed)showEmailWindow.focus()',100);
}
function popupWindow (theWindow, theParam) {

//	newLeft = screen.width
//	newTop = screen.height
	switch (theWindow)
	{
		case 'newmenu':
			window.open('menuform.php?'+theParam, 'NewMenu', 'toolbar=no,status=no,scrollbars=yes,resizable=yes,location=no,menubar=no,directories=no,width=500,height=500,left=50,top=50');
		break
		case 'editmenu':
			window.open('menuform.php?'+theParam, 'EditMenu', 'toolbar=no,status=no,scrollbars=yes,resizable=yes,location=no,menubar=no,directories=no,width=500,height=500,left=50,top=50');
		break
		default:
			return;
	}
}
function changeLangOrAlert(theLang) {

	if ((theLang == 'en') || (theLang == 'gr') || (theLang == 'sp') || (theLang == 'ro')) {
		changeLang(theLang);
	} else {
		changeLangAlert(theLang);
	}
}
function changeLangAlert(theLang) {
	alert('The '+theLang+' language is not published yet. Please check back soon.');
}
function changeLang(theLang) {
  lochref = '' + this.location;
	if (lochref.match('lang=') != null) {
		langPos = lochref.indexOf('lang=');
		lochref = lochref.substring(0,(langPos-1))+lochref.substring((langPos-1)+8);
	}
	// Check all parameters that 'index.php' files handles
	if ( (lochref.match("pageid=") == null) && (lochref.match("smpageid=") == null) ) {
		lochref = 'index.php?lang=' + theLang;
	} else {
		if (lochref.match("smpageid=") != null) {
			lochref = 'index.php?'+lochref.substring(lochref.indexOf('smpageid='))+'&lang=' + theLang;
		} else {
			lochref = 'index.php?'+lochref.substring(lochref.indexOf('pageid='))+'&lang=' + theLang;
		}
	}
//alert ('Location= '+lochref);
	location = lochref;
}
function goToSearch(theform) {
  var theSearchQuery = theform.searchquery.value;
	
  lochref = 'index.php?pageaction=search&searchquery=' + theSearchQuery;
	
	location = lochref;
}
function goToSitemap() {

  lochref = 'index.php?pageaction=sitemap';

	location = lochref;
}




//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

