function go(lnk)
{
	window.location.href=lnk;
}

function mapInfo(town, player, population, alliance)
{
	document.getElementById("mapInfo").innerHTML="<table class='dT' style='border-collapse: collapse' width='200' border='1'><tr><td colspan='2' align='left'>"+town+"</tr><tr><td width='70' align='left'>Player<td>"+player+"</td></tr><tr><td width='70' align='left'>Population<td>"+population+"</td></tr><tr><td width='70' align='left'>Alliance<td>"+alliance+"</td></tr></table>";
}

function counter(data, lnk)
{
	dat=document.getElementById(data);
	var time=(dat.innerHTML).split(":"); var done=0;
	if (time[2]>0) time[2]--;
	else
	{
		time[2]=59;
		if (time[1]>0) time[1]--;
		else
		{
			time[1]=59;
			if (time[0]>0) time[0]--;
			else { clearTimeout(id[data]); window.location.href=lnk; done=1;}
		}
	}
	if (!done)
	{
		dat.innerHTML=time[0]+":"+time[1]+":"+time[2];
		id[data]=setTimeout("counter('"+data+"', '"+lnk+"')", 1000);
	}
}

function retrive()
{
	usr=document.getElementById("name");
	go("sc/retrive.php?name="+usr.value);
}

function trOpt( type, subtype, data )
{
	t=document.getElementById(type);
	st=document.getElementById(subtype);
	if (t.value==0) 
		st.innerHTML="<select name='"+subtype.substr(0, subtype.length-1)+"'><option value='0'>Hydroponic Food</option><option value='1'>Tricity</option><option value='2'>Nocxdrine</option><option value='3'>Mexarite</option><option value='4'>ISC</option></select>";
}


// here we define global variable
var ajaxdestination="";

function getdata(what,where) 
{ // get data from source (what)
	if (window.ActiveXObject)
	{
		try 
		{
			xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
			new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e) 
		{ /* do nothing */  }
	}
	else 
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		xmlhttp = new XMLHttpRequest()
	else
	return false
 //document.getElementById(where).innerHTML ="<center><img src='loading.gif'></center>";
// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
	 ajaxdestination=where;
	 xmlhttp.onreadystatechange = triggered; // when request finished, call the function to put result to destination DIV
	 xmlhttp.open("GET", what);
	 xmlhttp.send(null);
  return false;
}

function triggered() { // put data returned by requested URL to selected DIV
  if (xmlhttp.readyState == 4) if (xmlhttp.status == 200) 
    document.getElementById(ajaxdestination).innerHTML =xmlhttp.responseText;
}


loadImage1 = new Image();
loadImage1.src = "img/marker_previous_on.gif";
staticImage1 = new Image();
staticImage1.src = "img/marker_previous_off.gif";

loadImage2 = new Image();
loadImage2.src = "img/marker_next_on.gif";
staticImage2 = new Image();
staticImage2.src = "img/marker_next_off.gif";

loadImage3 = new Image();
loadImage3.src = "img/marker_middle_on.gif";
staticImage3 = new Image();
staticImage3.src = "img/marker_middle_off.gif";


function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false;}
else {return true;}
}
}

function validate_form(thisform)
{
with (thisform)
{
if (validate_email(email,"Not a valid e-mail address. Please try again.")==false)
  {email.focus();return false;}
}
}



function myTime() {
var dst = 0;       	// set to 1 for daylight savings time
var loc = ''; 			// set to your location
var mtz = 3;      		// set to your local timezone (hours ahead of UTC, negative if behind)
var stdz = ''; 			// standard time indicator
var dayz = 'ADST'; 	// daylight saving time indicator (blank if you dont have daylight saving)

document.writeln('' + loc + '<span id="time">' + setDsp(mtz,dst,stdz,dayz) + '<\/span>');
if (DOMsupported) setTimeout('updDsp('+mtz+',' +dst+',"' +stdz+'","' +dayz+'")', 5000);
}

var DOMsupported = 0;var standardDOMsupported = 0;var ieDOMsupported = 0;
if (document.getElementById) { standardDOMsupported = 1; DOMsupported = 1;}
else { if (document.all) {ieDOMsupported = 1; DOMsupported = 1;}
}
function findDOM(objectId) {
if (standardDOMsupported) {return (document.getElementById(objectId));}
if (ieDOMsupported) {return (document.all[objectId]);}
}

function updDsp(mtz,dst,stdz,dayz) {
var obj = findDOM('time');
obj.innerHTML = setDsp(mtz,dst,stdz,dayz);
setTimeout('updDsp('+mtz+ ','+dst+ ',"'+stdz+ '","'+dayz+ '")', 5000);
}
function setDsp(mtz,dst,stdz,dayz) {
var dayname = new Array ('', '', '', '', '','', '', '');
var now = new Date;
now.setUTCMinutes(now.getUTCMinutes() + (mtz + dst)*60);
var dow = now.getUTCDay();
var minute = now.getUTCMinutes();
var hour = now.getUTCHours();
if (hour > 11) {ampm = 'PM'; hour -= 12;} else {ampm = 'AM'}
if (hour == 0) {hour = 12;} if (minute < 10) {pad = ':0';} else {pad = ':';}
var txt = hour + pad + minute + ' ' + ampm + ' ';
if (dst) txt += dayz; else txt += stdz;
txt += ' ' + dayname[dow];
return (txt);
}




