function HideMyMenu() {
		  for (i = 1; i < 9; ++ i) {
				 		  		 		 x = new getObj('menuitem'+i);
											 x.style.display='none'
									 }
}

function getObj(name) {
  if (document.getElementById) { //Dom3 browsers (Ο Opera 6 δεν υποστηρίζει πλήρως το Dom3)
  			this.obj = document.getElementById(name);
				this.style = document.getElementById(name).style
  			}
  else if (document.all) { //ie
			 this.obj = document.all[name];
			 this.style = document.all[name].style;
  		 }
  else if (document.layers) { //netscape
			 this.obj = getObjNN4(document,name);
			 this.style = this.obj;
 			  }
}

function ShowObject(objname) {
				 x = new getObj(objname);
				 x.style.display='block'
}
function HideObject(objname) {
				 x = new getObj(objname);
				 x.style.display='none'
}

function ToggleMenu(menuitem) {
	 				 x = new getObj(menuitem);
					 if (x.style.display=='block') { 
					 		(x.style.display='none') 
							}
							else {
				 					 for (i = 1; i < 9; ++ i) {
				 		  		 		 x = new getObj('menuitem'+i);
											 x.style.display='none'
									 }
	 				 				x = new getObj(menuitem);
								  x.style.display='block' 
							}
}

function Highlight(menuhead) {
	 				 x = new getObj(menuhead);
					 x.style.background='#c0d0e0'
					 x.style.color='#333'
}

function DeHighlight(menuhead) {
	 				 x = new getObj(menuhead);
					 x.style.background='#fafaff'
					 x.style.color='#06c'
}

//////////////////////////////////////////////////////////
// Open up new window
//////////////////////////////////////////////////////////

function OpenWin(file,W,H) {
var X =(window.screen.availWidth-W-30)
var Y =(window.screen.availHeight-H)/2
var features = "WIDTH="
             + W
	     + ",HEIGHT="
	     + H
	     + ",screenX=" + X  // Netscape
             + ",screenY=" + Y  // Netscape
	     + ",left=" + X     // IE
	     + ",top=" + Y     // IE
	     + "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes";

TradeForm = open(file,"tradewindow",features);
}

//////////////////////////////////////////////////////////
// Zoom Window for displaying images and returning
//////////////////////////////////////////////////////////

function ShowImage(S){
var features = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no";

ZoomWindow=window.open("","_self",features);
ZoomWindow.document.open();
ZoomWindow.document.writeln('<HTML><TITLE>Enlarged Picture</TITLE>'); 
ZoomWindow.document.writeln('<link rel="stylesheet" href="/menu/format.css" type="text/css" />');
ZoomWindow.document.writeln('</HEAD><BODY bgcolor="#FFFFFF" LEFTMARGIN="0" TOPMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0" />');
ZoomWindow.document.write('<br /><p class="kentro"><IMG SRC='+S+' /></p>'); 
ZoomWindow.document.write('<p class="paragr"><a href="javascript:history.back()"><img alt="Return to Previous Page" src="/images/arrow_l.gif" height="20" width="20"></a></p>');
ZoomWindow.document.write('</BODY></HTML>');
ZoomWindow.document.close();
ZoomWindow.focus();
}

//////////////////////////////////////////////////////////
// Zoom Window for enlarging images
//////////////////////////////////////////////////////////

function Zoom(S,W,H){
var locX =(window.screen.availWidth-W-30)
var locY =(window.screen.availHeight-H)/2
var features = "WIDTH="
             + W
	     + ",HEIGHT="
	     + H
	     + ",screenX=" + locX  // Netscape
             + ",screenY=" + locY  // Netscape
	     + ",left=" + locX     // IE
	     + ",top=" + locY     // IE
	     + "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no";

ZoomWindow=window.open("","ZOOM",features);
ZoomWindow.document.open();
ZoomWindow.document.writeln('<HTML><TITLE>Enlarged Picture</TITLE><BODY bgcolor="#FFFFFF" LEFTMARGIN="0" TOPMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0" onBlur="self.close()">'); 
ZoomWindow.document.write('<IMG SRC='+S+' WIDTH='+W+' HEIGHT='+H+'>'); 
ZoomWindow.document.write('</BODY></HTML>');
ZoomWindow.document.close();
ZoomWindow.focus();
}


var whitespace=" "

function hasWhitespace (s)
{   var i;
    // Search through string's characters one by one
    // until we find a whitespace character.
    // When we do, return true; if we don't, return false.

    for (i = 0; i < s.length; i++)
    {   
	// Check that current character isn't whitespace.
	var c = s.charAt(i);
	if (whitespace.indexOf(c) != -1) return true;
    }
    return false;
}

function isWhitespace (s)
{   var i;
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
	// Check that current character isn't whitespace.
	var c = s.charAt(i);

	if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

/****************************************************************/

// isEmail (STRING s [, BOOLEAN emptyOK])
// 
// Email address must be of form a@b.c ... in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isEmail (s)
{  
    // is s whitespace?
    if (isWhitespace(s)) return false;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

function isNumber(s)
{
	if (isWhitespace(s)) return true;
	if (s=="Number of coins you own") return true;
	if (s=="From how many countries?") return true;
	if (s=="Year you began collecting") return true;
	var i = 0;
	for (i = 0; i < s.length; i++)
		if (s.charAt(i) < '0' || s.charAt(i) > '9') {
			return false;
		}

	return true;
}

//////////////////////////////////////////////////////////
// exists() function:
// Determines whether or not a value passed in is non-null
//////////////////////////////////////////////////////////
function exists(userEntry) {
  var aCharExists = 0;
  var entry = userEntry;

  if (entry) {
    for (var i=0; i<entry.length; i++) {
      //spaces don't count as "existence"
      if (entry.charAt(i) != " ") {
        aCharExists = 1;
      }
    }
  }
  if (!aCharExists) {
    return 0;
  }
  return 1;
}

// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function validateContactForm(){
  var fixThis = "";

  if (!(exists(document.forms['ContactFRM'].youremail.value))) {
    fixThis += "Please enter your e-mail address.\n";
		document.forms['ContactFRM'].youremail.focus();
    alert(fixThis); return false;
  } 

  if (!(isEmail(document.forms['ContactFRM'].youremail.value))) {
    fixThis += "Please enter a correct e-mail address.\n";
    document.forms['ContactFRM'].youremail.focus();
    alert(fixThis); return false;
  }

  if (document.forms['ContactFRM'].message.value==("" || "Don't forget to include your name in the message!")){
    fixThis += "Please enter a message.\n";
    document.forms['ContactFRM'].message.focus();
    alert(fixThis); return false;
  } 

	if (fixThis=="") { return true }
	else { return false }
}


/////////////////////////////////////////////////////////
///////////     	  suggest-ajax                  /////////////
/////////////////////////////////////////////////////////
var request = false;
try {
  request = new XMLHttpRequest();
} catch (trymicrosoft) {
  try {
    request = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (othermicrosoft) {
    try {
      request = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (failed) {
      request = false;
    }
  }
}

if (!request) { // Error initializing XMLHttpRequest!
alert("Ο browser που χρησιμοποιείτε δεν υποστηρίζει την τεχνολογία suggest-ajax!");
}


function findExplanation(term,type) {
	var url = "/glossary/getterm.asp?term=" + term;

	if (term.length==0) { 
	  document.getElementById("suggest-ajax").innerHTML="";
	  document.getElementById("suggest-ajax").style.display="none";
	  return;
	  }

	if (type==1) url = url + "&type=currencies";
	if (type==2) url = url + "&type=glossary";

	request.abort();
	request.open("GET",url,true);
	request.onreadystatechange = updateLexiko;
	request.send(null);
	return;
}

function updateLexiko() {
	var temp = document.getElementById("suggest-ajax").innerHTML;
	document.getElementById("suggest-ajax").style.display="inline";
	if (temp.indexOf("not found")<0) temp = "<a href='#' onclick='javascript:void(0);'><em>Searching - please wait ... </em></a>";
	if (temp.indexOf("Searching")<0) temp = temp + "<a href='#' onclick='javascript:void(0);'><em>Searching - please wait ... </em></a>";
	document.getElementById("suggest-ajax").innerHTML = temp;
	
	if (request.readyState == 4) {
         Response = request.responseText;
           switch (request.status) {
				 case 200:
						 // Everything is ok
						 var response = request.responseText;
							 if (exists(response)) {
								document.getElementById("suggest-ajax").style.display="inline";
								document.getElementById("suggest-ajax").innerHTML = response;
							 }
						break;
						}
		   }
	document.getElementById("suggest-ajax").innerHTML = document.getElementById("suggest-ajax").innerHTML.replace("<a href='#' onclick='javascript:void(0);'><em>Searching - please wait ... </em></a>","");
   }
