﻿function ValidateContactForm (form) { 
  var fname = form.fullname.value;   
  var country = form.country.value;  
  var email = form.email.value;   
  var phone = form.phone.value;
  var scode = form.security_code.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 ((!email)&&(!phone)) {
		alert("You must enter your email address or your phone number.");
		return false;
	} else if ((email)&&((email.indexOf('@') == -1) || (email.indexOf('.') == -1))) {
		alert("Wrong email format.");
		return false;
	} else if (!scode) {
		alert("Type the code shown.");
		return false;
	} else {
		return true;
	}
}

function ValidateFreeConsultationForm (form) { 
  var fname = form.fullname.value;   
  var country = form.country.value;  
  var email = form.email.value;   
  var phone = form.phone.value;
  var scode = form.security_code.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 ((!email)&&(!phone)) {
		alert("You must enter your email address or your phone number.");
		return false;
	} else if ((email)&&((email.indexOf('@') == -1) || (email.indexOf('.') == -1))) {
		alert("Wrong email format.");
		return false;
	} else if (!scode) {
		alert("Type the code shown.");
		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 = 410;
	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') || (theLang == 'it')) {
		changeLang(theLang);
	} else {
		changeLangAlert(theLang);
	}
}
function changeLangAlert(theLang) {
	alert('The '+theLang+' language is not published yet. Please check back soon.');
}
function changeLang(theLang, theQueryString) {
  lochref = '';
	// Check if already lang parameter is sent
	if (theQueryString.match('lang=') != null) {
		langPos = theQueryString.indexOf('lang=');
		theQueryString = theQueryString.substring(0,(langPos-1))+theQueryString.substring((langPos-1)+8);
	}
	// Check all parameters that 'index.php' files handles
	if (theQueryString != '') {
		lochref = 'index.php?'+theQueryString+'&lang='+theLang;
	} else {
		lochref = 'index.php?lang='+theLang;
	}
	location = lochref;
}
function changeLang2(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 goToSearchNews(theform) {
  var theSearchQuery = theform.searchquery.value;
	
  lochref = 'index.php?pageaction=search_news&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;
}

function findPosY(obj) {
  var curtop = 0;
  if(obj.offsetParent)
	  while(1)
	  {
		curtop += obj.offsetTop;
		if(!obj.offsetParent)
		  break;
		obj = obj.offsetParent;
	  }
  else if(obj.y)
	  curtop += obj.y;
  return curtop;
}

function findPosX(obj) {
  var curleft = 0;
  if(obj.offsetParent)
	  while(1) 
	  {
		curleft += obj.offsetLeft;
		if(!obj.offsetParent)
		  break;
		obj = obj.offsetParent;
	  }
  else if(obj.x)
	  curleft += obj.x;
  return curleft;
}


function ClearSearchField(theForm) {
 theForm.searchquery.value = '';
}

function ChangeHyperlinkImg(theCase, theId, theLang) {
	if (theCase == '1') {
		document.getElementById("hyp_" + theId).src = "assets/blocks/12/editor/hyperlink_" + theId + "_over_btn_" + theLang + ".gif";
	} else if (theCase == '2') {
		document.getElementById("hyp_" + theId).src = "assets/blocks/12/editor/hyperlink_" + theId + "_on_btn_" + theLang + ".gif";
	}
}

/* MainMenu Functions */

function DisplayMMSubMenu(theId,event) {
	
	var mmLeftPos = findPosX(document.getElementById("mm_"+theId+"_pos"));
	
	/*website limits*/
	var mmRightLimit = parseInt(findPosX(document.getElementById("mm_right_limit")),10);
	var sbBlockW = parseInt($("#mm_"+theId+"_submenu").width(),10);
	var BlockRightEnd = parseInt(mmLeftPos,10)+sbBlockW;
	if (BlockRightEnd > mmRightLimit) {
		mmLeftPos = mmLeftPos-((BlockRightEnd-mmRightLimit));
	}
	/****************/
	
	document.getElementById("mm_"+theId+"_submenu").style.left = mmLeftPos;
	$("#mm_"+theId+"_pos").css("background-color","#2C3C33");
	document.getElementById("mm_"+theId+"_submenu").style.display = "block";
	
}

function HideMMSubMenu(theId, event) {
	var toElement = null;

	if (event.relatedTarget) {
		toElement = event.relatedTarget;
	} else if (event.toElement) {
		toElement = event.toElement;
	}
	
	while (toElement && toElement.id != "mm_"+theId+"_submenu") {
		toElement = toElement.parentNode;
	}
	if (!toElement) {
		document.getElementById("mm_"+theId+"_submenu").style.display = "none";	
		$("#mm_"+theId+"_pos").css("background-color","transparent");
	}
}

function ChangeLangImg(theCase, theLang) {
	if (theCase == '1') {
		document.getElementById("flag_" + theLang).src = "layout/images/flag_" + theLang + "_over.png";
	} else if (theCase == '2') {
		document.getElementById("flag_" + theLang).src = "layout/images/flag_" + theLang + "_on.png";
	}
}

function ChangeMoreImg(theCase, theId, theLang) {
	if (theCase == '1') {
		document.getElementById("more_" + theId).src = "layout/images/viewmore_over_" + theLang + "_btn.png";
	} else if (theCase == '2') {
		document.getElementById("more_" + theId).src = "layout/images/viewmore_on_" + theLang + "_btn.png";
	}
}

function ChangeApplyImg(theCase, theId, theLang) {
	if (theCase == '1') {
		document.getElementById("apply_" + theId).src = "layout/images/applynow_over_btn_" + theLang + ".png";
	} else if (theCase == '2') {
		document.getElementById("apply_" + theId).src = "layout/images/applynow_on_btn_" + theLang + ".png";
	}
}

function ChangeCustResultsImg(theCase, theId, theLang) {
	if (theCase == '1') {
		document.getElementById("custres_" + theId).src = "layout/images/viewcustomersresults_over_" + theLang + "_btn.png";
	} else if (theCase == '2') {
		document.getElementById("custres_" + theId).src = "layout/images/viewcustomersresults_on_" + theLang + "_btn.png";
	}
}

function ChangeViewTestImg(theCase, theId, theLang) {
	if (theCase == '1') {
		document.getElementById("viewtest_" + theId).src = "layout/images/viewtestimonials_over_" + theLang + "_btn.png";
	} else if (theCase == '2') {
		document.getElementById("viewtest_" + theId).src = "layout/images/viewtestimonials_on_" + theLang + "_btn.png";
	}
}

function ChangeMoreTestImg(theCase, theId, theLang) {
	if (theCase == '1') {
		document.getElementById("moretest").src = "layout/images/moretestim_over_" + theLang + "_btn.png";
	} else if (theCase == '2') {
		document.getElementById("moretest").src = "layout/images/moretestim_on_" + theLang + "_btn.png";
	}
}

function ChangeViewResultsImg(theCase, theId, theLang) {
	if (theCase == '1') {
		document.getElementById("viewres").src = "layout/images/viewresults_over_" + theLang + "_btn.png";
	} else if (theCase == '2') {
		document.getElementById("viewres").src = "layout/images/viewresults_on_" + theLang + "_btn.png";
	}
}

function ChangeAllVidImg(theCase, theId, theLang) {
	if (theCase == '1') {
		document.getElementById("allvid").src = "layout/images/viewallvideos_over_" + theLang + "_btn.png";
	} else if (theCase == '2') {
		document.getElementById("allvid").src = "layout/images/viewallvideos_on_" + theLang + "_btn.png";
	}
}

function ChangeContactImg(theCase, theLang) {
	if (theCase == '1') {
		document.getElementById("contact").src = "layout/images/contactformore_over_" + theLang + "_btn.png";
	} else if (theCase == '2') {
		document.getElementById("contact").src = "layout/images/contactformore_on_" + theLang + "_btn.png";
	}
}

function ExpandCollapseLangBody() {
	if(document.getElementById('selectLangBody').style.display == 'none') {
		document.getElementById('selectLangBody').style.display = 'block';
	} else {		
	  document.getElementById('selectLangBody').style.display = 'none';
	}
}

function ExpandBody (theId) {
  document.getElementById('CollapsedBody_' + theId).style.display = 'none';
  document.getElementById('ExpandedBody_' + theId).style.display = 'block';
}

function CollapseBody (theId) {
  document.getElementById('ExpandedBody_' + theId).style.display = 'none';
  document.getElementById('CollapsedBody_' + theId).style.display = 'block';
}

function ShowLangBody() {
	document.getElementById('selectLangBody').style.display = 'block';
}

function HideLangBody() {
	document.getElementById('selectLangBody').style.display = 'none';
}

/* POP UP WINDOW FUNCTIONS*/
function getScrollHeight()
{
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
           
   return h ? h : 0;
}

function DisplayPopUpBlock(FileCallPathAndQueryString, WindowWidth, WindowHeight) { 
  var new_block_h = getScrollHeight();
	document.getElementById("popup_block_content").style.marginTop = new_block_h;
	document.getElementById("popup_block_bg").style.marginTop = new_block_h;
	
	if (document.getElementById("popup_block_bg")) {
	  document.getElementById("popup_block_bg").style.display = "block";
	}
	
	if (document.getElementById("popup_block_content")) {
	  document.getElementById("popup_block_content").style.display = "block";
	}
	    
	if (document.getElementById("popup_block_content_fr")) {
		var objFrame = document.getElementById("popup_block_content_fr"); 
		objFrame.src= FileCallPathAndQueryString; 
		objFrame.style.width = WindowWidth + "px";
		objFrame.style.height = WindowHeight + "px";
	}
}

function HidePopUpBlock() {
	var objFrame = document.getElementById("popup_block_content_fr"); 
	objFrame.src = ''; 
	  
  if (document.getElementById("popup_block_bg")) {
	  document.getElementById("popup_block_bg").style.display = "none";
  }
  if (document.getElementById("popup_block_content")) {
	  document.getElementById("popup_block_content").style.display = "none";
  }
}
/* POP UP WINDOW FUNCTIONS END */


function topic_DefaultSlideDelay(thePageId, theLang, rotate, theSlideDelay) {
	var DefSlideNumFindDelay = ShowSlideNum+1;
	var theDefNextSlideDelay = 4000;
	setTimeout("topic_UpdateSlide('"+thePageId+"', '"+theLang+"', '"+rotate+"', '', "+theDefNextSlideDelay+")", theSlideDelay);
}

function topic_UpdateSlide(thePageId, theLang, rotate, theSlideNum, theSlideDelay) {
	
	/* setup loading block */
	var new_block_h = parseInt(document.getElementById("SlideBlock").scrollHeight, 10);
	var new_block_w = parseInt(document.getElementById("SlideBlock").scrollWidth, 10);
	//new_block_h = new_block_h-33;//paging row height
	document.getElementById("block_loading").style.width = new_block_w+"px";
	document.getElementById("block_loading").style.height = new_block_h+"px";
	
	document.getElementById("block_loading").style.display = "block";
	setTimeout('document.images["block_loading_img"].src = "layout/images/loading.gif"', 10); 
	document.getElementById("block_loading_img").style.marginTop = ((new_block_h/2)-32);
	/* */
	
	/* Slide Conf */
	var TotalSlides = parseInt(document.getElementById("total_slides").value,10);	
	TotalSlides = TotalSlides-1; //because slides num starts from 0
	
	var SlideNumParam = parseInt(theSlideNum,10);
	if ((SlideNumParam >= 0)&&(SlideNumParam<=TotalSlides)) {
		ShowSlideNum = SlideNumParam;
	} else {
		if (ShowSlideNum < TotalSlides) {
			ShowSlideNum++;
		} else {
			ShowSlideNum = 0;
		}
	}

  /*
	if (TotalSlides > 0) {
	  for(var c=0;c<=TotalSlides;c++) {
		  if (c == ShowSlideNum) {
		    document.getElementById("nav_"+c).src = "layout/images/sshow_sel_btn.png";
		  } else {
		    document.getElementById("nav_"+c).src = "layout/images/sshow_on_btn.png";
		  }
	  }
	}
	*/
	
	/** NEXT SLIDE NUM TO FIND DELAY ***/
	var SlideNumFindDelay = ShowSlideNum+1;
	if (SlideNumFindDelay > TotalSlides) {
		SlideNumFindDelay = 0;
	}
	var theNextSlideDelay = 4000;
	/****/
	
	clearTimeout(timeout);
		
	if (rotate) {
	  timeout = setTimeout("topic_UpdateSlide('"+thePageId+"', '"+theLang+"', '"+rotate+"', '', "+theNextSlideDelay+")", theSlideDelay);
	}	
		
	var ajaxRequest; 
	try {
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try {
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Something is wrong with your browser!");
				return false;
			}
		}
	}
	
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4) {
			$("#SlideBlock").fadeOut(0, function() {
			  var Res = ajaxRequest.responseText;
				var ResArr = Res.split("|");
				var ResLink = ResArr[0];
				var ResBody = ResArr[1];
				/**/
				if (ResLink) {
				  if (document.getElementById('photo_link')) {
				    document.getElementById('photo_link').setAttribute("href", ResLink);
					}
				} else {
				  if (document.getElementById('photo_link')) {
				    document.getElementById('photo_link').removeAttribute("href");
          }
				}
				/**/
				$("#SlideBlock").html(ResBody);
			});
			$("#SlideBlock").fadeIn('slow');
			/*
			var ajaxDisplay = document.getElementById("SlideBlock");
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
			*/
		}
	}
		
	var queryString = "?pageid="+thePageId+"&lang="+theLang+"&slide="+ShowSlideNum;
	ajaxRequest.open("GET", "templates/ws_bl_featuredarticle_02/update_slide.php"+queryString, true);
	ajaxRequest.send(null); 
}

function TopicNavigation(thePageId, NextOrPrev, theLang) {
	theSlideNum = 0;
	if (NextOrPrev == 'P') {
	  if (ShowSlideNum > 0) {
	    theSlideNum = ShowSlideNum - 1;
		} else {
	    theSlideNum = document.getElementById("total_slides").value - 1;
		}
	} else {
	  theSlideNum = ShowSlideNum + 1;
	}
	
	topic_UpdateSlide(thePageId, theLang, false, theSlideNum, 4000);
}

/* VIDEOS 10 */
function videos_10_ShowVideo(theId, theLang){ // GET
	
	var ajaxRequest;  // The variable that makes Ajax possible!

	/* setup loading block */
	var new_block_h = parseInt(document.getElementById("ShowVideoBlock").scrollHeight, 10);
	var new_block_w = parseInt(document.getElementById("ShowVideoBlock").scrollWidth, 10);
	//new_block_h = new_block_h-30;
	document.getElementById("vid_loading").style.width = new_block_w+"px";
	document.getElementById("vid_loading").style.height = new_block_h+"px";
	
	document.getElementById("vid_loading").style.display = "block";
	setTimeout('document.images["vid_loading_img"].src = "layout/images/loading.gif"', 10);
	$('#vid_loading_img').css("marginTop", (new_block_h/2)-32);
	//document.getElementById("vid_loading_img").style.marginTop = ((new_block_h/2)-32);
	/* */
	
	try {
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try {
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Something is wrong with your browser!");
				return false;
			}
		}
	}
	
	var queryString = "?pageid="+theId+"&lang="+theLang;
	//updating - no cache
	//queryString = queryString+"&sid="+Math.random();
	
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4) {
			var ajaxDisplay = document.getElementById("ShowVideoBlock");
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}

	ajaxRequest.open("GET", "templates/ws_mm_videos_10/update_video.php"+queryString, true);
	ajaxRequest.send(null); 
}

function videos_10_NavButtons(BlockPageNum, MaxBlockRecs, QueryString){
	var ajaxRequest; 

	/* setup loading block */
	var new_block_h = parseInt(document.getElementById("VideosListArea").scrollHeight, 10);
	var new_block_w = parseInt(document.getElementById("VideosListArea").scrollWidth, 10);
	new_block_h = new_block_h; // paging row height
	document.getElementById("vid_list_loading").style.width = new_block_w + "px";
	document.getElementById("vid_list_loading").style.height = new_block_h + "px";
	
	document.getElementById("vid_list_loading").style.display = "block";
	// setTimeout('document.images["block_"' + BlockNum + '"_loading_img"].src = "layout/images/loading.gif"', 10); 
	//document.getElementById("vid_list_loading_img").style.marginTop = ((new_block_h / 2) - 16);
	$('#vid_list_loading_img').css("marginTop", (new_block_h/2)-16);
	/* */
	
	try {
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try {
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Something is wrong with your browser!");
				return false;
			}
		}
	}
	
	var queryString = "?blocknum=" + BlockPageNum + "&maxrecs=" + MaxBlockRecs + QueryString;
	
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4) {
			var ajaxDisplay = document.getElementById("VideosListArea");
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	ajaxRequest.open("GET", "templates/ws_mm_videos_10/update_records.php" + queryString, true);
	ajaxRequest.send(null); 
	
}

function IF_01_BlockNavButtons(BlockNum, CurBlockPage, TotalBlockPages, ParentId, QueryString){
	var ajaxRequest; 

	/* setup loading block */
	var new_block_h = parseInt(document.getElementById("block_" + BlockNum).scrollHeight, 10);
	var new_block_w = parseInt(document.getElementById("block_" + BlockNum).scrollWidth, 10);
	new_block_h = new_block_h; // paging row height
	document.getElementById("block_" + BlockNum + "_loading").style.width = new_block_w + "px";
	document.getElementById("block_" + BlockNum + "_loading").style.height = new_block_h + "px";
	
	document.getElementById("block_" + BlockNum + "_loading").style.display = "block";
	// setTimeout('document.images["block_"' + BlockNum + '"_loading_img"].src = "layout/images/loading.gif"', 10); 
	document.getElementById("block_" + BlockNum + "_loading_img").style.marginTop = ((new_block_h / 2) - 16);
	/* */
	
	try {
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try {
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Something is wrong with your browser!");
				return false;
			}
		}
	}
	
	var RecIdStr = document.getElementById("recIdStr").value;
	var queryString = "?blockNum=" + BlockNum + "&curpage=" + CurBlockPage + "&pagesnum=" + TotalBlockPages + "&parentid=" + ParentId + "&recIdStr=" + RecIdStr + QueryString;
	
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4) {
			var ajaxDisplay = document.getElementById("block_" + BlockNum);
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	ajaxRequest.open("GET", "templates/ws_bl_internalfeed_01/update_block.php" + queryString, true);
	ajaxRequest.send(null); 
}

function ValidateNltSubscriptionForm (form) {
  var fname = form.fullname.value;   
  var email = form.email.value;   
  var prof = form.profession.value;   
  var comp = form.company.value;   
  var scode = form.security_code.value;

	if (ValidateStringLength(fname) == false) {
		alert("You must enter your fullname.");
		return false;
	} else if (ValidateStringLength(email) == false) {
		alert("You must enter your email.");
		return false;
	} else if ((email.indexOf('@') == -1) || (email.indexOf('.') == -1)) {
		alert("Wrong email format.");
		return false;
	} else if (ValidateStringLength(prof) == false) {
		alert("You must enter your profession.");
		return false;
	} else if (ValidateStringLength(comp) == false) {
		alert("You must enter your company.");
		return false;
	} else if (!scode) {
		alert("Type the code shown.");
		return false;
	} else {
		return true;
	}
}

function ValidateStringLength(theString) {
	var theTrimString = trim(theString);
	if (theTrimString.length == '0') {
		return false;	
	} else {
		return true;
	}	
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function ValidateCVSubmitForm(theForm) {
  var fullname = theForm.fullname.value;
  var gender = theForm.gender.value;
  var age = theForm.age.value;
  var nationality = theForm.nationality.value;
  var phone = theForm.phone.value;
  var email = theForm.email.value;
  var security_code = theForm.security_code.value;
  
  var AlertMsg = "";
  if (!ValidateStringLength(fullname)) {
	AlertMsg += "Full Name \n";  
  }
  if (!ValidateStringLength(gender)) {
	AlertMsg += "Gender \n";  
  }
  if (!ValidateStringLength(age)) {
	AlertMsg += "Age \n";  
  }
  if (!ValidateStringLength(nationality)) {
	AlertMsg += "Nationality \n";  
  }
  if (!ValidateStringLength(phone)) {
	AlertMsg += "Phone \n";  
  }
  if (!ValidateStringLength(email)) {
	AlertMsg += "Email \n";  
  } else if ((email != '')&&((email.indexOf('@') == -1) || (email.indexOf('.') == -1))) {
	AlertMsg += "Wrong email format. \n";  
  }
  if (!ValidateStringLength(security_code)) {
	AlertMsg += "Security Code \n";  
  }
  
  if (AlertMsg != "") {
	AlertMsg = "The following fields are obligatory: \n"+AlertMsg;
	alert(AlertMsg);
	return false
  } else {
	return true;  
  }
}
