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_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_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 launchWindow(cat, id){

	if (cat == "catering") {
		window.open ('popuptext.php?cat='+cat+'&id='+id, 'newwindow', config='height=410, width=540, toolbar=no, menubar=no, scrollbars=yes, location=no, directories=no')
    }
}

function popBio() {
	window.open ('events/annapiatou.html', 'newwindow', config='height=568, width=540, toolbar=no, menubar=no, scrollbars=no, location=no, directories=no')
}

function popEkdilwseis(id,directory) {
	window.open ('ekdilwseis.php?id='+id+'&dir='+directory, 'newwindow', config='height=620, width=560, toolbar=no, menubar=no, scrollbars=no, location=no, directories=no')
}

function popEkdilwseis1(id,directory) {
	window.open ('ekdilwseis.php?id='+id+'&dir='+directory, 'newwindow', config='height=620, width=560, toolbar=no, menubar=no, scrollbars=no, location=no, directories=no')
}
// Extension developed by David G. Miles
// Original Scrollable Area code developed by Thomas Brattli
function verifyCompatibleBrowser(){
    this.ver=navigator.appVersion
    this.dom=document.getElementById?1:0
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
    this.ie4=(document.all && !this.dom)?1:0;
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;

    this.ns4=(document.layers && !this.dom)?1:0;
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
    return this
}
bw=new verifyCompatibleBrowser()


var speed=40

var loop, timer

function ConstructObject(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
    this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
    this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
    this.up=MoveAreaUp;this.down=MoveAreaDown;
    this.MoveArea=MoveArea; this.x; this.y;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this
}
function MoveArea(x,y){
    this.x=x;this.y=y
    this.css.left=this.x
    this.css.top=this.y
}

function MoveAreaDown(move){
	if(this.y>-this.scrollHeight+objContainer.clipHeight){
    this.MoveArea(0,this.y-move)
    if(loop) setTimeout(this.obj+".down("+move+")",speed)
	}
}
function MoveAreaUp(move){
	if(this.y<0){
    this.MoveArea(0,this.y-move)
    if(loop) setTimeout(this.obj+".up("+move+")",speed)
	}
}

function PerformScroll(speed){
	if(initialised){
		loop=true;
		if(speed>0) objScroller.down(speed)
		else objScroller.up(speed)
	}
}

function CeaseScroll(){
    loop=false
    if(timer) clearTimeout(timer)
}
var initialised;
function InitialiseScrollableArea(){
    objContainer=new ConstructObject('divContainer')
    objScroller=new ConstructObject('divContent','divContainer')
    objScroller.MoveArea(0,0)
    objContainer.css.visibility='visible'
    initialised=true;
}
// end absolutely positioned scrollable area object scripts

function showFullSize(image_src)
{
			document.images['big'].src=image_src;
}


// *** COMMON CROSS-BROWSER COMPATIBILITY CODE ***

var isDOM=document.getElementById?1:0;
var isIE=document.all?1:0;
var isNS4=navigator.appName=='Netscape'&&!isDOM?1:0;
var isOp=window.opera?1:0;
var isDyn=isDOM||isIE||isNS4;


function getRef(id, par)
{
 par=!par?document:(par.navigator?par.document:par);
 return isIE ? par.all[id] :
  (isDOM ? (par.getElementById?par:par.ownerDocument).getElementById(id) :
  (isNS4 ? par.layers[id] : null));
}

function getSty(id, par)
{
 var r=getRef(id, par);
 return r?(isNS4?r:r.style):null;
}

if (!window.LayerObj) var LayerObj = new Function('id', 'par',
 'this.ref=getRef(id, par); this.sty=getSty(id, par); return this');
function getLyr(id, par) { return new LayerObj(id, par) }

function LyrFn(fn, fc)
{
 LayerObj.prototype[fn] = new Function('var a=arguments,p=a[0],px=isNS4||isOp?0:"px"; ' +
  'with (this) { '+fc+' }');
}
LyrFn('x','if (!isNaN(p)) sty.left=p+px; else return parseInt(sty.left)');
LyrFn('y','if (!isNaN(p)) sty.top=p+px; else return parseInt(sty.top)');
LyrFn('w','if (p) (isNS4?sty.clip:sty).width=p+px; ' +
 'else return (isNS4?ref.document.width:ref.offsetWidth)');
LyrFn('h','if (p) (isNS4?sty.clip:sty).height=p+px; ' +
 'else return (isNS4?ref.document.height:ref.offsetHeight)');
LyrFn('vis','sty.visibility=p');




// *** MAIN SCROLLER FUNCTIONS ***

function ilsLoad(pageToLoad) { with (this)
{
 if (!isDyn) return;

 // Pre-existing page? Hide it, and reset the div object to null.
 if (div)
 {
  (isNS4?div:divCont).vis('hidden');
  div = null;
 }

 // Record this as the active page, scroll back to 0 position.
 pageName = pageToLoad;
 scrollTo(0, 0);
}}

function ilsScrollTo(xPos, yPos) { with (this)
{
 if (!pageName || !isDyn) return;

 // Get references and set up divs....
 if (!div)
 {
  // Get a reference to either the very outer ILAYER (NS4), or this page's container (others).
  divCont = getLyr(myName + '_Container' + (isNS4?'':'_'+pageName));
  if (!divCont.ref) return;

  // In NS4, record ILAYER's dimensions as the scroller dimensions now.
  if (isNS4) { scrW = divCont.sty.clip.width; scrH = divCont.sty.clip.height }

  // The inside page div in question that is actually moved within its container(s).
  div = getLyr(myName + '_' + pageName, isNS4?divCont.ref:null);
  if (!div.ref) return;

  // We show the inner page divs themselves in NS4, or their containers in others.
  (isNS4?div:divCont).vis('visible');

  // Add mousewheel support in IE6+, you may wish to alter the scrolling amount or direction.
  if (isIE) div.ref.onmousewheel = new Function(myName +
   '.scrollBy(0,event.wheelDelta/-3); return false');
 }

 // Find the dimensions of the scrolling content. Opera 5 doesn't want to return width of
 // in-scroller page content, so we let it scroll right forever (Opera 6 is fine).
 // If you have many vocal Opera 5 users, perhaps hardcode page widths in somewhere.

 var divW = div.w(), divH = isOp?div.sty.pixelHeight:div.h();

 // Check the scroll position for content edges & scroll!

 if (xPos + scrW > divW) xPos = divW - scrW;
 if (xPos < 0) xPos = 0;
 scrLeft = xPos;
 div.x(0 - parseInt(xPos));

 if (yPos + scrH > divH) yPos = divH - scrH;
 if (yPos < 0) yPos = 0;
 scrTop = yPos;
 div.y(0 - parseInt(yPos));
}}


function ilsScrollBy(xDiff, yDiff) { with (this)
{
 // Scrolls the div by a certain amount of pixels.
 if (!pageName) return;
 scrollTo(scrLeft + xDiff, scrTop + yDiff);
}}


function ilsSetScroll(newX, newY, steps) { with (this)
{
 if (!pageName || !isDyn) return;

 // Alter scroller velocity in steps to the new speed, set timer interval.
 stepsLeft = steps;

 if (timer) { clearInterval(timer); timer = null }
 timer = setInterval('with (' + myName + ') { if (stepsLeft > 0) { xSpeed += ' +
  ((newX-xSpeed)/steps) + '; ySpeed += ' + ((newY-ySpeed)/steps) + '; stepsLeft-- } ' +
  'scrollBy(xSpeed, ySpeed) }', 50);
}}



// *** IE/NS6/OPERA DIV CONSTRUCTION FUNCTIONS ***

/*
function ilsStartArea(w, h) { with (this)
{
 // Record dimensions of scrolling area, and write out container div.
 scrW = w;
 scrH = h;
 document.write('<div style="position:relative; top:0x; left:-365px; clip rect(0,0,700,90); width: 700px; height: 90px; overflow: hidden">');
}}
*/

function ilsStartArea(w, h) { with (this)
{
 // Record dimensions of scrolling area, and write out container div.
 scrW = w;
 scrH = h;
 document.write('<div style="position: relative; width: '+w+'px; height: '+h+'px; overflow: hidden">');
}}

function ilsStartPage(pN) { with (this)
{
 document.write('<div id="' + myName + '_Container_' + pN + '" style="position: absolute; ' +
  'width: '+scrW+'px; height: '+scrH+'px; clip:rect(0px '+scrW+'px '+scrH+'px 0px); ' +
  'overflow: hidden; visibility: hidden"><div id="' + myName + '_' + pN + '" style="position: ' +
  (isIE?'absolute':'relative') + '">');
}}



// *** SCROLLER OBJECT SETUP ***

function InlineScrollbox(myName)
{
 // These are the properties and function bindings used.

 this.myName = myName;
 this.divCont = null;
 this.div = null;
 this.pageName = '';

 this.scrW = this.scrH = this.scrTop = this.scrLeft = 0;
 this.xSpeed = this.ySpeed = this.stepsLeft = 0;

 this.timer = 0;

 this.load = ilsLoad;
 this.scrollTo = ilsScrollTo;
 this.scrollBy = ilsScrollBy;
 this.setScroll = ilsSetScroll;
 this.startArea = ilsStartArea;
 this.startPage = ilsStartPage;
}

// **** START EDITING HERE ****


// First, we create one or more scroller objects. These correspond to a set of layers/divs
// beneath in the page and bundle together all the properties we need to scroll them.

// Syntax: var scrollerName = new InlineScrollbox('scrollerName');

var scr = new InlineScrollbox('scr');
//var anotherScroller = new InlineScrollbox('anotherScroller');


// Then set them to activate on page load like this (backing up old onload event...).
// Pass the name of a scroller page you want to show first (see below for the pages).

var ilsOldOL = window.onload;
window.onload = function()
{
 if (ilsOldOL) ilsOldOL();

 scr.load('Page1');
 //anotherScroller.load('PageNameHere');
}


// A small function that refreshes NS4 on horizontal resize, just leave this here.
var nsWinW = window.innerWidth, nsWinH = window.innerHeight;
function ns4BugCheck()
{
 if (isNS4 && (nsWinW!=innerWidth || nsWinH!=innerHeight)) history.go(0);
}

var ilsOldOR = window.onresize;
window.onresize = function()
{
 if (ilsOldOR) ilsOldOR();
 ns4BugCheck();
}


// form validation

function formValidation(form){
	if(notEmpty(form.field_name)) {
		if(notEmpty(form.field_address)) {
			if(notEmpty(form.field_email)) {
				if(validEmail(form.field_email)) {
					if(notEmpty(form.field_phone)) {
						if(notEmpty(form.field_body)) {												
							return true;
						} else {
							alert('Παρακαλώ εισάγετε το μήνυμα σας.');
							return false;
						}									
					} else {
						alert('Παρακαλώ εισάγετε το τηλέφωνο σας.');
						return false;
					}							
				} else {
					alert('To email που εισάγατε δεν είναι αποδεκτό.');
					return false;
				}							
			} else {
				alert('Παρακαλώ εισάγετε το email σας.');
				return false;
			}					
		} else {
			alert('Παρακαλώ εισάγετε τη διεύθυνση σας.');
			return false;
		}	
	} else {
		alert('Παρακαλώ εισάγετε το ονοματεπώνυμο σας.');
		return false;
	}
}

function notEmpty(elem){
	var str = elem.value;
	if(str.length == 0) {
		return false;
	} else {
		return true;
	}
}

function validEmail(elem) {
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(elem.value)) {
		return true;
	} else {
		return false;
	}
}
// form validation

function popContact(id) {
	window.open ('pop_contact.php?id='+id, 'newwindow', config='height=562, width=530, toolbar=no, menubar=no, scrollbars=yes, location=no, directories=no')
}
