var http_request=false;
var full=0;
function makePOSTRequest(url,parameters,typ,extra){
	http_request=false;
	if(window.XMLHttpRequest){
		http_request=new XMLHttpRequest();
		if(http_request.overrideMimeType){
			http_request.overrideMimeType('text/html');
		}
	}else if(window.ActiveXObject){
		try{http_request=new ActiveXObject("Msxml2.XMLHTTP");}
		catch(e){
			try{http_request=new ActiveXObject("Microsoft.XMLHTTP");}
			catch(e){}
		}
	}if(!http_request){
		alert('Cannot create XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange=function() {alertContents(typ,extra);};
	http_request.open('POST',url,true);
	http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length",parameters.length);
	http_request.setRequestHeader("Connection","close");
	http_request.send(parameters);
};

function alertContents(typ,extra){
	if(http_request.readyState==4){
		if(http_request.status==200){
			result=http_request.responseText;
			switch(typ)
			{
			case'ecomp':
			document.getElementById('comp2').innerHTML=result;
			full=1;
			break;
			default: 
			break;
			}
		}else{alert('There was a problem with the request.');}
	}
};
function get(obj,typ,extra,extra2){
	var poststr;
	switch(typ)
	{
	case'ecomp':
	phpfile=typ;poststr='';
	break;
	}
	phpfile=phpfile+'.php';
	makePOSTRequest(phpfile,poststr,typ,extra);
};
function swap(obj){
	switch(obj)
	{
	case'ecomp':
	if(full==0){
		Toggle('comp');Toggle('comp2');
		swapb(obj);
		get('',obj);
	}else{
		Toggle('comp');Toggle('comp2');
		swapb(obj);
	}
	break;
	case'front':
	Toggle('comp');Toggle('comp2');
	swapb(obj);
	break;
	}
};
function swapb(obj){
	switch(obj)
	{
	case'ecomp':
	document.getElementById('com1').innerHTML='<a class="vt" style="margin-right:22px" onclick="swap(\'front\')" onmousedown="document.getElementById(\'com\').src=\'images/homep.gif\'" onmouseout="document.getElementById(\'com\').src=\'images/home.gif\'" onmouseup="document.getElementById(\'com\').src=\'images/home.gif\'"><img id="com" src="images/home.gif" /></a>';
	break;
	case'front':
	document.getElementById('com1').innerHTML='<a class="vt" style="margin-right:22px" onclick="swap(\'ecomp\')" onmousedown="document.getElementById(\'com\').src=\'images/explp.gif\'" onmouseout="document.getElementById(\'com\').src=\'images/expl.gif\'" onmouseup="document.getElementById(\'com\').src=\'images/expl.gif\'"><img id="com" src="images/expl.gif" /></a>';
	break;
	}
};
function Toggle(tdiv) {
	var obj=document.getElementById(tdiv);
	var arr=obj.className.split(' ');
	var n;
	switch(arr[0]){
		case'hide':
		n='show';
		break;
		case'show':
		n='hide';
		break;
		default:break;		
	}
	arr.splice(0,1);
	arr.splice(0,0,n);
	obj.className = arr.join(' ');
};