<!--

/*###############################################################
############# DON'T EDIT AFTER THIS UNLESS YOU KNOW #############
############# WHAT YOU'RE DOING!!                   #############
###############################################################*/

//BROWSER DEFINITIONS
var DOM = (document.getElementById);
var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById)?true:false;
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);
var op = (window.opera)? true : false;
var op5 = (op && DOM)? true : false;


function changePage(theform) {
	num = theform.URLSelect.selectedIndex;
	page = theform.URLSelect[num].value;
	// shift 'num' to reflect the correct URL
	// Just don't edit the next line if you don't understand it
	//numInArray = (num * 2) - 2;

	if(page != 0)
		top.location.href = page;
}

//##################################################
//############ THIS IS WHAT RUNS WHEN INCLUDED #####
//##################################################


function attach(id){
	var obj;
	if(ns4) obj = document.layers[id];
	else if(ie4) obj = document.all[id];
	else if(DOM) obj = document.getElementById(id);
	return obj;
}

function hideObj(id){
	tempObj = attach(id);
	if(ns4) tempObj.visibility = "hide";
	else tempObj.style.display = "none";
}

function showObj(id){
	tempObj = attach(id);
	if(ns4) tempObj.visibility = "show";
	else tempObj.style.visibility = "visible";
}

//#####################################################
//############### OTHER FUNCTIONS #####################
//#####################################################
//onClick="NewWindow=window.open('http://www.ggca.hu/viewer.htm','NewWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=550,height=400,top=,left=')

//FUNC USAGE:
//   - everything between [] is optional input for the func
//   - openWin(string url, string winName [, int windowWidth, int windowHeight, string windowPropertiesToEnable])
//
//   - string specsToEnable options, write a comma separated string
//     example: 'd,l,m' would enable directories,location & menubar
	/*
	d = directories
	l = location
	m = menubar
	r = resizable
	sc = scrollbars
	st = status
	t = toolbar
	*/

function openWin(url,winName,width,height,specsToEnable){ //specsToEnable: string, individual codes separated by commas (,)
	//alert(myWin);
	if(winName == "") winName = 'new';
	if(width == null || height == "") width = '400';
	if(height == null || height == "") height = '300';
	if(specsToEnable == null) specsToEnable = '';

	specsFinal = new Array("d,directories,0","f,fullscreen,0","l,location,0","m,menubar,0","r,resizable,0","sc,scrollbars,0","st,status,0","t,toolbar,0");

	for(i in specsFinal){
		specsFinal[i] = specsFinal[i].split(',');
	}
	//alert(specsFinal[0][0]);
	
	specsToEnable = specsToEnable.split(',');
	//alert(specsToEnable[1]);
	for(i in specsToEnable){
		for(j in specsFinal){
			if(specsToEnable[i] == specsFinal[j][0]){
				specsFinal[j][2] = 1;
				break;
			}
		}
	}
	specsStr = 'width=' +width+ ',height=' +height;
	for(i in specsFinal){
		specsStr += ',' +specsFinal[i][1]+ '=' +specsFinal[i][2];
	}
	
	myWin = window.open(url,winName,specsStr);
	myWin.moveTo(30,30);
	myWinOpened = 1;
	setTimeout("myWin.focus()",500);
	//delete specsStr,specsToEnable;
}
//######################################################
//############### openWinFromSource FUNC ###############
//######################################################
//USAGE:
//   - everything between [] is optional input for the func
//   - openWinFromSource(string windowTitle, string HTML-source [, int windowWidth, int windowHeight, string windowPropertiesToBeEnabled])
//DEPENDENCIES:
//   - uses the openWin func

function openWinFromSource(winHTMLtitle,winName,HTMLsource,width,height,specsToEnable){
	if(winName == "") winName = "fromSource";
	
	openWin('',winName,width,height,specsToEnable);
	d = myWin.document;
	d.close(); //clear old content
	d.writeln('<html><head><title>' +winHTMLtitle+ '</title>');
	d.writeln('<link rel=stylesheet type=text/css href=css.css>');
	d.writeln('</head>\n<body bgcolor=white onBlur="self.close();">\n');
	d.writeln(HTMLsource);
	d.writeln('<br><font size=1><center><a href="javascript:window.close()">[Close window]</a></center></font>');
	d.writeln('</center>\n</body>\n</html>');
}

//#####################################################
//############### openWinForSports FUNC ###############
//#####################################################
//USAGE:
//   - everything between [] is optional input for the func
//   - openWinForSports(string windowTitle, string imagesPath [, string gameStory])
//DEPENDENCIES:
//   - uses the openWin & openWinFromSource functions

function openWin4Sports(winHTMLtitle,winName,imagesPath,gameStory){ //images are given as extra parametres
	if(gameStory == null) gameStory = '';
	a = openWin4Sports.arguments;
	s = '<center>';
	
	s += "<h5 style=\"background: #cccce5; border: 1px solid black\">" +winHTMLtitle+ "</h5>";
	
	//if var gameStory includes a photo instead of the text format story about the game
	if((gameStory.indexOf('.jpg') > 0) || (gameStory.indexOf('.gif') > 0))
		tmp = 3; else tmp = 4;
		
	if(tmp==4){//gameStory is text and not a photo
		s += '<table border=0 width=500 cellspacing=3 cellpadding=3>';
		s += '<tr><td valign=top width=100 class=news><b>About the game:</b></td>';
		s += "</td><td valign=top class=news>" +gameStory +'</td></tr></table><br><br>';
	}
	
	for(i = tmp; i < a.length; i++){
		s += '<img src="' +imagesPath+a[i]+ '" border=0 class=photo><br><br>';
	}
	s += '</center>';

	openWinFromSource(winHTMLtitle,winName,s,680,500,'sc');
	myWin.focus();
}

function emailUsAtGGIS(){
	if(emailUsAtGGIS.arguments.length > 0){
		arg = emailUsAtGGIS.arguments;
		domain = 'ggis';
		ending = 'hu';
		s = 'mailto:';
		
		// building the mailto: link from defined variables
		for(i=0; i < arg.length; i++){
			s += arg[i]+ '%40' +domain+ '.' +ending;
			if(i < arg.length-1)
				s += ', ';
		}
		
		// popping up the new email window for the user
		// (in other words directing the user to the mailto: link that was built on the previous lines)
		location.href = s;
	} else {
		alert('emailUsAtGGIS() function used wrong!\nNeeded variables were not specified!');
	}
}
//#####################################################
//############### MACROMEDIA IMG-SWAPS ################
//#####################################################
/*
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.0
  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 && document.getElementById) x=document.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];}
}

*/


//#####################################################
//############### PRELOAD IMAGES FUNC #################
//#####################################################
function preloadImages(){
	d=document;
	if(d.images){
		Ar_preloadedImages = new Array();
		
		p = Ar_preloadedImages;
		
		i,j = Ar_preloadedImages.length;
		a = preloadImages.arguments;
	
		for(i=0; i<a.length; i++){
			if (a[i].indexOf("#")!=0){
				p[j] = new Image();
				p[j++].src = a[i];
			}
		}
	}
}

///###########################################################
//################### COOKIE FUNCTIONS #######################
//############################################################

// An adaptation of Dorcht's function for setting a cookie.
// usage: setCookie(str name, str value, date expires, str path, str domain, str secure)
function setCookie(name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape(value) +
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
}

// Heinle's function for retrieving a cookie.
// returns a STRING even if the content is numeric!!!
function getCookie(name){
  var cname = name + "=";
  var dc = document.cookie;
  if (dc.length > 0) {
    begin = dc.indexOf(cname);
    if (begin != -1) {
      begin += cname.length;
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        return unescape(dc.substring(begin, end));
    }
  }
  return null;
}


// An adaptation of Dorcht's function for deleting a cookie.
function delCookie (name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    ((domain == null) ? "" : "; domain=" + domain) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
//-->