// JavaScript Document

/*
function click_clear(id, text)
{
	if (document.getElementById(id).value == text)
		document.getElementById(id).value = "";
}

function prefill(id, text)
{
	if (document.getElementById(id).value == "")
		document.getElementById(id).value = text;
}*/


/* ========= FORM functions ========= */

function show_error(id)
{
	document.getElementById(id).style.border="solid 2px #641511";
}

function clear_errors(which)
{
	for (i=0;i<document.forms[which].elements.length;i++)
	{
		if ( (document.forms[which].elements[i].type != "button") && (document.forms[which].elements[i].type != "reset") && (document.forms[which].elements[i].id!="fieldset") )
			document.forms[which].elements[i].style.border="solid 1px #8D7E57";
	}
}


function checkEmail(elem)
{
   var field = document.getElementById(elem);
   var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
   if (field.value.length ==0)
		return false;

   if(field.value.match(emailExp))
		   return true;
   else 
		   return false;
   
}


function check_form(formid, whichform, mandatory_fields, numericfields, emailid)
{
	clear_errors(whichform);
	
	//check mandatory fields
	var man = mandatory_fields.split(",");
	for (i=0;i<man.length;i++)
	{
		if (document.getElementById(man[i]).value == "")
		{
			show_error(man[i]);
			alert ("You must fill all the mandatory fields (*)");
			return false;
		}
	}		

	if (emailid!="")
	{
		if (!checkEmail(emailid))
		{
			show_error(emailid);
			alert ("Your email address is not valid.");
			return false;
		}
	}
	
	//check numeric fields
	if (numericfields != "")
	{
		var numeric = numericfields.split(",");
		for (i=0;i<numeric.length;i++)
		{
			document.getElementById(numeric[i]).value = document.getElementById(numeric[i]).value.replace(/,/,".");
			
			if (isNaN (document.getElementById(numeric[i]).value))
			{
				show_error(numeric[i]);
				alert (numeric[i]+": should be a number. Plase check and try again!");
				return false;
			}
		}
	}
	
	document.getElementById(formid).submit();
}


function check_form_prefilled(formid, whichform, mandatory_fields, prefilled_fields, prefilled_values, numericfields, emailid)
{
	clear_errors(whichform);		
	
	
	//check mandatory fields
	var man = mandatory_fields.split(",");
	for (i=0;i<man.length;i++)
	{	
		if ( (document.getElementById(man[i]).type) && (document.getElementById(man[i]).type == "select-one") )
		{
			if (document.getElementById(man[i]).selectedIndex == 0)
			{
				show_error(man[i]);
				alert ("You must fill all the mandatory fields (*)");
				return false;
			}
		}
		else
		{
			if (document.getElementById(man[i]).value == "")
			{
				show_error(man[i]);
				alert ("You must fill all the mandatory fields (*)");
				return false;
			}
		}
	}		

	if (emailid!="")
	{
		if (!checkEmail(emailid))
		{
			show_error(emailid);
			alert ("Your email address is not valid.");
			return false;
		}
	}
	
	//prefilled
	if (prefilled_fields!="")
		var pref_f = prefilled_fields.split(",");
		
	if (prefilled_values!="")
		var pref_v = prefilled_values.split(",");
	
	//check prefilled:
	if (prefilled_fields!="")
	{
		for (i=0;i<pref_f.length;i++)
		{
			if (document.getElementById(pref_f[i]).value == pref_v[i])
			{
				show_error(pref_f[i]);
				alert ("You must fill all the mandatory fields (*)");
				return false;
			}
		}
	}
	
	//check numeric fields
	if (numericfields != "")
	{
		var numeric = numericfields.split(",");
		for (i=0;i<numeric.length;i++)
		{
			document.getElementById(numeric[i]).value = document.getElementById(numeric[i]).value.replace(/,/,".");
			
			if (isNaN (document.getElementById(numeric[i]).value))
			{
				show_error(numeric[i]);
				alert (numeric[i]+": should be a number. Plase check and try again!");
				return false;
			}
		}
	}
	
	document.getElementById(formid).submit();
}

/* =========== */

/*
if (check_date(document.getElementById('temp_start')) == -1)
	{	
		show_error('temp_start');
		alert ("Unacceptable date format for Arrival Date (dd-mm-yyyy).");
		return false;
	}
*/

function check_date(str)
{
		months=new Array();
		months[1]=31;months[2]=28;months[3]=31;months[4]=30;
		months[5]=31;months[6]=30;months[7]=31;months[8]=31;
		months[9]=30;months[10]=31;months[11]=30;months[12]=31;
		
		//message="Unacceptable date format (dd-mm-yyyy)";
		
		//field = str.value.replace(///g,"-");
		var field = str.value;
		//str.value =field;
		
		if (str.value=="")
		{
			//alert(message);
			return(-1);
		}
		else
		{
			comp=field.split('-');

			if ( (field.indexOf('-')<0) || (comp.length!=3) || (isNaN(comp[2])) || (isNaN(comp[1])) || (isNaN(comp[0])) || (comp[1]<1)||(comp[1]>12) )
			{
				//alert(message);
				return(-1);
			}
			
			if (comp[2].length==2)
				comp[2] = "20" + comp[2];
				
			if (months[comp[1]]<comp[0])
			{
				 
				if ((comp[1]==2)&&(comp[0]==29))
				{  
					if ( (comp[2]%400==0) || ( (comp[2]%4==0) && (comp[2]%100!=0) ) ) //->disekto
					{
						return(comp[0] + "-" + comp[1] + "-" + comp[2]);
					}
				}
				//alert(message);
				return(-1);
			}
			if (comp[2].length!=4){
				//alert(message);
				return(-1);
			}
			if ((comp[2]<2008)||(comp[2]>2029)){
				alert("Year is out of range: should be between 2008 and 2029");
				return(-1);
			}
			
			return(comp[0] + "-" + comp[1] + "-" + comp[2] );
			
		}
}








// JavaScript Document

// Open External Links as Blank Targets via Unobtrusive JavaScript
// http://perishablepress.com/press/2007/11/20/open-external-links-as-blank-targets-via-unobtrusive-javascript/

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (
			anchor.getAttribute("href") && ( 
			anchor.getAttribute("rel") == "external" || 
			anchor.getAttribute("rel") == "external nofollow" || 
			anchor.getAttribute("rel") == "nofollow external" )
			)
		anchor.target = "_blank";
	}
}
window.onload = function() {
	externalLinks();
}



function TextScroll(scrollname, div_name, up_name, down_name)
{
    this.div_name = div_name;
    this.name = scrollname;
    this.scrollCursor = 0;
    this.speed = 2;
    this.timeoutID = 0;
    this.div_obj = null;
    this.up_name = up_name;
    this.dn_name = down_name;

{



        if (document.getElementById) {
            div_obj = document.getElementById(this.div_name);
            if (div_obj) {
                this.div_obj = div_obj;
                this.div_obj.style.overflow = 'hidden';
            }
            div_up_obj = document.getElementById(this.up_name);
            div_dn_obj = document.getElementById(this.dn_name);
            if (div_up_obj && div_dn_obj) {

			div_up_obj.onmouseover = function() { eval(scrollname + ".scrollUp();") };
			div_up_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") };
			div_dn_obj.onmouseover = function() { eval(scrollname + ".scrollDown();") };
			div_dn_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") };

            }
        }
    }

this.stopScroll = function() {
        clearTimeout(this.timeoutID);
    }

this.scrollUp = function() {
        if (this.div_obj) {
            this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
            this.div_obj.scrollTop = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
        }
    }

this.scrollDown = function() {
if (this.div_obj) {
this.scrollCursor += this.speed;
this.div_obj.scrollTop = this.scrollCursor;
if (this.div_obj.scrollTop == this.scrollCursor) {
this.timeoutID = setTimeout(this.name + ".scrollDown()", 60);
} else {
this.scrollCursor = this.div_obj.scrollTop;
}
}
}

this.resetScroll = function() {
        if (this.div_obj) {
            this.div_obj.scrollTop = 0;
            this.scrollCursor = 0;
        }
    }
/*
this.hideScroll = function() {
	if (this.div_obj.clientHeight > (this.div_obj.scrollHeight-this.div_obj.clientHeight)) {
		document.getElementById('scroll_up').style.display="none";
		document.getElementById('scroll_down').style.display="none";
	}
}

this.hideScroll();	
	*/	
}





// Menu Rollover function

<!--
var menu1='About Us'
var num1='01'
var menu2='Hotel Operations Management'
var num2='02'
var menu3='Consulting Services'
var num3='03'
var menu4='Real Estate Development'
var num4='04'
var menu5='Human Resources'
var num5='05'
var menu6='Contact'
var num6='06'




function writetext(what,num){
document.getElementById('menu_text').innerHTML=''+what+'';
document.getElementById('menu_num').innerHTML=''+num+'';
document.getElementById('test').style.display = "none";
}

function notext(){
document.getElementById('menu_text').innerHTML='';
document.getElementById('menu_num').innerHTML='';
document.getElementById('test').style.display = "block";
}
//-->

// Menu Rollover function Greek

<!--
var menugr1='Η εταιρία'
var numgr1='01'
var menugr2='Λειτουργική Διαχείριση Ξενοδοχείων'
var numgr2='02'
var menugr3='Παροχή Συμβουλευτικών Υπηρεσιών'
var numgr3='03'
var menugr4='Ανάπτυξη Ακινήτων'
var numgr4='04'
var menugr5='Ανθρώπινο Δυναμικό'
var numgr5='05'
var menugr6='Επικοινωνία'
var numgr6='06'




function writetextgr(whatgr,numgr){
document.getElementById('menu_text').innerHTML=''+whatgr+'';
document.getElementById('menu_num').innerHTML=''+numgr+'';
document.getElementById('test').style.display = "none";
}

function notextgr(){
document.getElementById('menu_text').innerHTML='';
document.getElementById('menu_num').innerHTML='';
document.getElementById('test').style.display = "block";
}
//-->



