var xmlHttp;

function ajaxFunction(page,type,id,ex,leavehtml)
{

if (id.length==0)
  { 
  document.getElementById("ajaxReturn").innerHTML="";
  return;
  }
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  } 
var url=page+".php";
url=url+"?id="+id;
url=url+"&ex="+ex;
url=url+"&type="+type;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 	
			document.getElementById("ajaxReturn").innerHTML= xmlHttp.responseText;
	 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

function verify(id){
		if(confirm('Are you sure you want to delete this page?')==true)
		{
        ajaxFunction('../ajaxdisplay','deletePage',id);
        }
  }
  
function verifyRCE(id, table, year){
		if(confirm('Are you sure you want to delete this item?')==true)
		{
        ajaxFunction('../ajaxdisplay','deleteRCE',id, table, year);
        }
  }
  
function publishPage(id){
        ajaxFunction('../ajaxdisplay','publish',id);
		window.location = "/pdisp.php?pid="+id;
  }

function withdrawPage(id){
        ajaxFunction('../ajaxdisplay','withdraw',id);
		window.location = "/pdisp.php?pid="+id;
  } 
  
function sfHover() {
	var sfEls = document.getElementById("navlinks").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" iehover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

 
 
 function resultauto(year, event_id)
 {	
	$.post("index.php", { type:"refreshresults", id:event_id, elid:"ajaxReturn", ex:year }, function(data){
				if(data.length>1){
						$('#ajaxReturn tbody:first').prepend(data);
						$("#ajaxReturn tbody:first tr:first").hide();
						$("#ajaxReturn tbody:first tr:first").css({backgroundColor: '#000080', color: '#fff'});
						$("#ajaxReturn tbody:first tr:first").fadeIn(2000);
						//$("#ajaxReturn tbody:first tr:first").switchClass('oldresult', 'newresult', 3000);
						//$("#ajaxReturn tbody:first tr:first").animate({ backgroundColor: "#000080", color: "#fff" }, 3000);
						setTimeout("$('#ajaxReturn tbody:first tr:first').animate({ backgroundColor: '#fff', color:'#000' }, 1000)",5000);
						//$("#ajaxReturn tbody:first tr:first").css({backgroundColor: '#fff', color: '#000'});

						//setTimeout("$('#ajaxReturn tbody:first tr:first').switchClass('newresult', 'oldresult', 3000)",5000);
				}
	});
														
														
 }