// JavaScript Document
function validate_field(field, msg) {
	with (field) {
		if (value == null || value == "") {
			alert(msg);
			return false;
		} else {
			return true;
		};
	};
}

function validate_email(field, msg) {
	with (field) {
		var apos = value.indexOf("@");
		var dotpos = value.lastIndexOf(".");
		if (apos < 1 || dotpos-apos < 2) {
			alert(msg);
			return false;
		} else {
			return true;
		};
	};
}

function fieldfocus(obj) {
	obj.style.backgroundColor="#B2BB1E";
}

function fieldblur(obj) {
	obj.style.backgroundColor="";
}

function buttonover(obj) {
	obj.style.backgroundColor="#B2BB1E";
}

function buttonout(obj) {
	obj.style.backgroundColor="";
}

function getNews(obj) {
	if (obj.value != "") {
		window.location='?id=' + obj.value;
	}
}

function validate_contact_gr(xform) {
	with (xform) {
		if (validate_field(firstname,"Απαιτείται να συμπληρώσετε το πεδίο \'Όνομα\'!") == false) {
			firstname.focus();
			return false;
		}
		if (validate_field(lastname,"Απαιτείται να συμπληρώσετε το πεδίο \'Επώνυμο\'!") == false) {
			lastname.focus();
			return false;
		}
	}
}

function validate_contact_en(xform) {
	with (xform) {
		if (validate_field(firstname,"Please enter your first name!") == false) {
			firstname.focus();
			return false;
		}
		if (validate_field(lastname,"Please enter your last name!") == false) {
			lastname.focus();
			return false;
		}
	}
}

function expandMenu(id) {
	var attributes = { 
		height: { to: document.getElementById(id).scrollHeight } 
	}; 
	var anim = new YAHOO.util.Anim(id, attributes, 0.5, YAHOO.util.Easing.easeOut);
	anim.animate();
}

function collapseMenu(id) {
	var attributes = { 
		height: { to: 0 } 
	};
	var anim = new YAHOO.util.Anim(id, attributes, 0.3, YAHOO.util.Easing.easeOut); 
	anim.animate();
}

function doMenu(id) {
	if (document.getElementById(id).style.height == "" || document.getElementById(id).style.height == "0px") {
		expandMenu(id);
	} else {
		collapseMenu(id);
	}
}

function iePrompt(str){
   var settings = "dialogWidth: 290px; dialogHeight: 160px; center: yes; edge: raised; scroll: no; status: no;";
   return window.showModalDialog("iePrompt.html", str, settings);
}

function inv() {
	if (navigator.userAgent.indexOf('MSIE 7')>0) {
		window.location="/inv/";
	} else {
		var id = prompt("Παρακαλώ εισάγετε τον αριθμό που θα βρείτε τυπωμένο\nστο άνω δεξί μέρος της κάρτας εισόδου σας:", "");
		if (id!=null && id!="" && id.length==12) {
			if (Number(id.substr(1,5)) != 0) {
				window.location="/vip/";
			} else {
				window.location="/inv/";
			}
		} else {
			alert("Άκυρος αριθμός κάρτας εισόδου!\nΠαρακαλώ προσπαθήστε ξανά.");
		}		
	}
}