function image_open2(image_loc,img,dat)
{
  HTML = "<html><style>body{margin:5px 5px 5px 5px}</style><body onBlur='top.close()'><div style='margin:5px;font-size:10px;color:#000000;text-align:center;'>"+ dat +"</div><img src='"+ image_loc +"' border=0 name=load_image onLoad='window.resizeTo(document.load_image.width+10,document.load_image.height+100)'></body></html>";
  popupImage = window.open('','_blank','toolbar=no,scrollbars=no');
  popupImage.document.open();
  popupImage.document.write(HTML);
  popupImage.document.close();
  obj_img = document.getElementById(img);
}

function NewWindow(mypage, myname, w, h, myscroll) {
	var winl = (screen.width - w) / 4;
	var wint = (screen.height - h) / 4;
	var newWindow
	winprops = 'height='+h+',width='+w+',top=0,left=0,scrollbars='+myscroll;
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
	win.focus();
}

function image_open(image_loc,img,dat)
{
  HTML = "<html><style>body{margin:0px 0px 0px 0px}</style><body onBlur='top.close()'><img src='"+ image_loc +"' border=0 name=load_image onLoad='window.resizeTo(document.load_image.width,document.load_image.height)'></body></html>";
    popupImage = window.open('','_blank','toolbar=no,scrollbars=no');
      popupImage.document.open();
        popupImage.document.write(HTML);
	  popupImage.document.close();
	    obj_img = document.getElementById(img);
}

function imagePopUpOpen(imageURL,imageTitle){
	PositionX = 100;
	PositionY = 100;
	defaultWidth  = 500;
	defaultHeight = 500;
	var AutoClose = true;
	
	var isNN=(navigator.appName=="Netscape")?1:0;
	var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
	
	var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
	var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
	
	if (isNN){imgWin=window.open('about:blank','',optNN);}
	if (isIE){imgWin=window.open('about:blank','',optIE);}
	
	with (imgWin.document){
		writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
		writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
		writeln('width=300-(document.body.clientWidth-document.images[0].width);');
		writeln('height=300-(document.body.clientHeight-document.images[0].height);');
		writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
		writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
		writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
		
		if (!AutoClose) {
			writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">');
		}else{
			 writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
			writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
			close();
		}
	}
}


function Trim(s) {
	// Remove leading spaces and carriage returns
	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r')) {
		s = s.substring(1,s.length);
	}

	// Remove trailing spaces and carriage returns
	while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r')) {
		s = s.substring(0,s.length-1);
	}

	return s;
}

function isEnglish(str) {
	if (str.search(/^([A-Za-z0-9]|\s|-|\,|\.|\&|\%|\!|\?|\(|\)|\[|\]|\+|\=|\$|\{|\}|\#|\;|\:|\@|\||\*|\/|\\|\<|\>|\~|\^|\'|\|")*$/)==-1 ) return false;
	return true;
}

function isGreek(str) {
	if (str.search(/^([��-���0-9]|\s|-|\,|\.|\&|\%|\!|\?|\(|\)|\[|\]|\+|\=|\$|\{|\}|\#|\;|\:|\@|\||\*|\/|\\|\<|\>|\~|\'|\")*$/)==-1 ) return false;
	return true;
}

function isFloat(str) {
	if (str.search(/^(-)?([0-9])*((\.)([0-9])+)?$/)==-1) return false;
	return true;
}

function isDigit(str) {
	if (str.search(/^(-)?([0-9])*$/)==-1) return false;
	return true;
}

function isTelephone(str) {
	if (str.search(/^([0-9]|\s|-|\+|\(|\)|\/)*$/)==-1) return false;
	return true;
}

function isEmail(str) {
	if (str.search(/^[A-Za-z0-9_]+((-[A-Za-z0-9_]+)|(\.[A-Za-z0-9_]+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)==-1) return false;
	return true;
}

function validRequired(formField, fieldLabel, lang) {
	if (Trim(formField.value) == "") {
		if (lang=='gr') alert('Παρακαλώ εισάγετε ' + fieldLabel +'.');
		else alert('Please Enter ' + fieldLabel +'.');
		formField.focus();
		return false;
	}
	return true;
}

function validEmail(formField, fieldLabel, required, lang) {
	if (required && !validRequired(formField, fieldLabel, lang)) return false;
	if ( !isEmail(Trim(formField.value)) ) {
		if (lang=='gr') alert("Η διεύθυνση Email δέν ειναι σωστή ");
		else alert("Please Enter a Correct E-mail Address");

		formField.focus();
		return false;
	}
	return true;
}