function redirect(page, time){
	setTimeout('goPage("'+page+'")', time*1000);
}

function popOut(page){
	document.getElementById('popOut').style.display='block';
	var url=page+'.php?iframe';
	document.getElementById('popOutFrame').src=url;
}

function goPage(page){
	location.href=redirStart+page;
}

function loadSection(URL, Id){
	var req=null;
	try {
		req = new XMLHttpRequest(); // xmlHttp is now a XMLHttpRequest.
	} catch (e) {
		try {
			req=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			req=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}

//	document.getElementById('loading').innerHTML='Loading...';
//	var req = new XMLHttpRequest();
	req.open('GET', URL, true);
//	alert(URL);
	window.scroll(0,0);
//	new Effect.BlindUp(Id, {duration: 3});
	req.onreadystatechange = function (aEvt) {
//		alert(req.readyState);
		if (req.readyState == 4) {
//			alert(req.status);
			if(req.status == 200) {
//				Effect.Shrink(Id);
				document.getElementById(Id).innerHTML=req.responseText;
//				window.scroll(0,0);
//				new Effect.BlindDown(Id, {duration: 3, queue: 'end' });
//				document.getElementById('loading').innerHTML='&nbsp;';
//				alert(dump(Effect));
			}
		}
	}
	req.send(null);
}

function spawnIFrame(loc, newName){
	var newFrame=document.createElement('iframe');
	newFrame.setAttribute('id', newName);
	newFrame.setAttribute('src', loc);
	newFrame.style.background='white';
	newFrame.style.position='absolute';
	newFrame.style.left='50px';
	newFrame.style.right='50px';
	newFrame.style.top='50px';
	newFrame.style.bottom='50px';
	newFrame.style.width='90%';
	newFrame.style.height='90%';

	document.getElementById('content').appendChild(newFrame);
}

function spawnDiv(loc, newName){
	var newDiv=document.createElement('div');
	newDiv.setAttribute('id', newName);
	newDiv.setAttribute('src', loc);
	
	newDiv.style.position='absolute';
//	newDiv.style.overflow='scroll';
	newDiv.style.background='url(\'images/stars2.jpg\')';
	newDiv.style.border='2px solid blue';

	newDiv.style.left='50px';
	newDiv.style.right='50px';
	newDiv.style.top='50px';
//	newDiv.style.bottom='50px';
	newDiv.style.width='auto';
	newDiv.style.height='auto';
	
	document.getElementById('content').appendChild(newDiv);
	
	loadSection(loc,newName);
}

function submitJoinForm(id){
	return(true);
	error=false;
	if (!document.getElementById('errorbox')){
		document.getElementById('content').innerHTML='<p id="errorbox" style="display:none;" class="error"></p>' + document.getElementById('content').innerHTML;
	} else {
		document.getElementById('errorbox').innerHTML='';
		document.getElementById('errorbox').style.display="none"
		}
	if (document.getElementById('joinform').elements[0].value == ''){
		document.getElementById('errorbox').innerHTML='You must provide your e-mail address.'
		error=true;
	}
	if (!error){
		poststr =
			"?email=" + document.getElementById('joinform').elements[0].value +
			"&sub=" + document.getElementById('joinform').elements[1].value + 
			"&AJAX" ;
		loadSection("join.php" + poststr, "content");
	} else {
		document.getElementById('errorbox').style.display="block";
	}
	return(false);
}

function submitLoginForm(id){
	return(true);
	error=false;
	if (!document.getElementById('errorbox')){
		document.getElementById('content').innerHTML='<p id="errorbox" style="display:none;" class="error"></p>' + document.getElementById('content').innerHTML;
	} else {
		document.getElementById('errorbox').innerHTML='';
		document.getElementById('errorbox').style.display="none"
	}
	if (document.getElementById('loginform').elements[0].value == ''){
		document.getElementById('errorbox').innerHTML='You must provide your username.'
		error=true;
	}
	if (document.getElementById('loginform').elements[1].value == ''){
		if (error){
			document.getElementById('errorbox').innerHTML+='<br />';
		}
		document.getElementById('errorbox').innerHTML+='You must provide your password.'
		error=true;
	}
//	alert(typeof document.getElementById('loginform').elements[2].value);
	if (document.getElementById('loginform').elements[2].value != 'none'){
		var gal=eval(document.getElementById('loginform').elements[2].value);
		if ((gal<1)||(gal>1)){
			if (error){
				document.getElementById('errorbox').innerHTML+='<br />';
			}
			document.getElementById('errorbox').innerHTML+='Invalid galaxy.'
			error=true;
		}
	}

	poststr =
		"?username=" + document.getElementById('loginform').elements[0].value +
		"&password=" + document.getElementById('loginform').elements[1].value + 
		"&galaxy=" + document.getElementById('loginform').elements[2].value + 
		"&remember=" + document.getElementById('loginform').elements[3].value + 
		"&sub=" + document.getElementById('loginform').elements[4].value;// + 
//		"&AJAX" ;
//	alert(poststr);
	if (!error){
//		loadSection("login.php" + poststr, "content");
		window.location=("login.php" + poststr);
	} else {
		document.getElementById('errorbox').style.display="block";
	}
	return(false);
}


/**
* Function : dump()
* Arguments: The data - array,hash(associative array),object
*    The level - OPTIONAL
* Returns  : The textual representation of the array.
* This function was inspired by the print_r function of PHP.
* This will accept some data as the argument and return a
* text that will be a more readable version of the
* array/hash/object that is given.
*/
function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;

//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { //Array/Hashes/Objects
 for(var item in arr) {
  var value = arr[item];
 
  if(typeof(value) == 'object') { //If it is an array,
   dumped_text += level_padding + "'" + item + "' ...\n";
   dumped_text += dump(value,level+1);
  } else {
   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
  }
 }
} else { //Stings/Chars/Numbers etc.
 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
} 

function bookmark_us(url, title){

if (window.sidebar) // firefox
    window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
    var elem = document.createElement('a');
    elem.setAttribute('href',url);
    elem.setAttribute('title',title);
    elem.setAttribute('rel','sidebar');
    elem.click();
}
else if(document.all)// ie
    window.external.AddFavorite(url, title);
}