    
    //add mega is the function that displays the big new menu div
    function addMega()
    {
    	$(this).children("div").each(function(idx,el)
    	{
		    el.style.display='block';
		});
        
        $(this).addClass("hovering");
    }
        
        
    //remove mega is the function that fades the big new menu div after mouseout
      function removeMega()
      {
		var par = $(this).children("div").get(0);
		var $div = $(par);
        $div.fadeOut("normal");
        
		setTimeout(function() {$(this).removeClass("hovering"); },1000);
        //need this to remove the hovering class otherwise it doesn't load next mouseover.
        //the timeout is to give the fade effect enough time to complete.
        
        }

	//the function that deals with the updateportal button in each row
	
	function updatePortal(aid){
	
		var toupd= confirm("Do you really want to update "+aid+" overnight and remove ALL data and give it a fresh install?");
	
		if (toupd== true)
		{
			$("#"+aid).parent("td").parent("tr").removeClass();
			$("#"+aid).parent("td").parent("tr").addClass("yellowbg");
			//$("#"+aid).text("update pending...");
			
			var server = aid;//.substring(0,3);
			
			$("#updatep").load("ajaxsave.php?action=updateserver",{server:server} );
			
			filterALLTable();
		
			$("#updatep").slideDown("normal");
			
			setTimeout(function () { $("#updatep").slideUp("normal");}, 10000);
			
			//send alert saying marked for udpdate	
		}
		else
		{
			//do nothing if they don't really want to update it
		}
	
		
	}

	

	
	//the function that changes the classes and updates the database to lock the server when the lock icon is clicked
	
	function lockServer(aid){
	
		var curclass = $("#"+aid).parent("td").parent("tr").attr("class");
		
		//if class = green || red then make it the locked version
		
		if(curclass == "greenbg")
		{
			$("#"+aid).parent("td").parent("tr").removeClass();
			$("#"+aid).parent("td").parent("tr").addClass("lockgreenbg");
			$("#"+aid).html("<img width=\"18px\" height=\"18px\" src=\"images/lockedlock.gif\" alt=\"click to unlock\" title=\"click to unlock\" />");
			
			var serv = aid.substr(3);
			$("#updatep").load("ajaxsave.php?action=lockserver",{server:serv} );
			$("#updatep").slideDown("normal");
			setTimeout(function () { $("#updatep").slideUp("normal");}, 10000);
			
		}
		else if(curclass == "redbg")
		{
			$("#"+aid).parent("td").parent("tr").removeClass();
			$("#"+aid).parent("td").parent("tr").addClass("lockredbg");
			$("#"+aid).html("<img width=\"18px\" height=\"18px\" src=\"images/lockedlock.gif\" alt=\"click to unlock\" title=\"click to unlock\" />");
			
			var serv = aid.substr(3);
			$("#updatep").load("ajaxsave.php?action=lockserver",{server:serv} );
			$("#updatep").slideDown("normal");
			setTimeout(function () { $("#updatep").slideUp("normal");}, 10000);
		}
		else if(curclass == "lockredbg")
		{
			$("#"+aid).parent("td").parent("tr").removeClass();
			$("#"+aid).parent("td").parent("tr").addClass("redbg");
			$("#"+aid).html("<img width=\"18px\" height=\"18px\" src=\"images/unlockedlock.gif\" alt=\"click to lock\" title=\"click to lock\" />");
			
			var serv = aid.substr(3);
			$("#updatep").load("ajaxsave.php?action=unlockserver",{server:serv} );
			$("#updatep").slideDown("normal");
			setTimeout(function () { $("#updatep").slideUp("normal");}, 10000);
						
		}
		else if(curclass == "lockgreenbg")
		{
			$("#"+aid).parent("td").parent("tr").removeClass();
			$("#"+aid).parent("td").parent("tr").addClass("greenbg");
			$("#"+aid).html("<img width=\"18px\" height=\"18px\" src=\"images/unlockedlock.gif\" alt=\"click to lock\" title=\"click to lock\" />");
			
			var serv = aid.substr(3);
			$("#updatep").load("ajaxsave.php?action=unlockserver",{server:serv} );
			$("#updatep").slideDown("normal");
			setTimeout(function () { $("#updatep").slideUp("normal");}, 10000);
						
		}
		else if(curclass == "yellowbg")
		{
			alert("Sorrry, you can't lock/unlock a server that is flagged to be updated.");
		}
		
	
	}
	
	//the function that gets the data to use in the filtering at the top of the dashboard
	function filterALLTable(){
	
		var loadingdiv = document.getElementById('loadingall');
		
		loadingdiv.innerHTML= '<img src="images/loader.gif" />';	

		var spe = document.getElementById('filterallPlatform');
		var svtplatform = spe.options[spe.selectedIndex].value;
		
		var sde = document.getElementById('filterallDB');
		var svtdb = sde.options[sde.selectedIndex].text;
		
		var swe = document.getElementById('filterallWcmb');
		var svtwcmb = swe.options[swe.selectedIndex].text;
		
		var stat = document.getElementById('filterStatus');
		var filtStat = stat.options[stat.selectedIndex].value;
		
		var team = document.getElementById('filterTeam');
		var filtTeam = team.options[team.selectedIndex].value;		
				
		
		var svttab = document.getElementById('alltable');
		
		var filurl = "filter.php";		
		
		
		//awesome jQuery function that automatically fills the element specified with the response from the AJAX call.
		
		$("#alltable").load(filurl, {filterteam: filtTeam, filterstat: filtStat, platform: svtplatform, db: svtdb, wcmbuild: svtwcmb});
		
		loadingdiv.innerHTML= '';
	}	
	
	
	//the function that dynamically loads the testers that are on each server, on a per server/request basis.
	function testers()
	{
	
		var serverid = document.getElementById('cancel_server'); //make this get it using jquery
		var servername = serverid.options[serverid.selectedIndex].value;
		
		$("select#cancel_tester").load("ajaxcancel.php?server="+servername);	
			
	}	
	
	
	//the function that actually does the 'remove server'
	
	function remserver()
	{
		var remserver = $("select#rem_server option:selected").val();
		
		tb_remove();
				
		$("#updatep").load("ajaxsave.php?action=removeserver",{server:remserver} );
		
		filterALLTable();
		
		$("#updatep").slideDown("normal");
		
		setTimeout(function () { $("#updatep").slideUp("normal");}, 10000);
		
		
		
	}
	
	function addtester()
	{
		var addtester = $("#new_tester").val();
		
		tb_remove();
				
		$("#updatep").load("ajaxsave.php?action=addtester",{tester:addtester} );
		
		$("#updatep").slideDown("normal");
		
		setTimeout(function () { $("#updatep").slideUp("normal");}, 10000);
		
	}	
	
	function remtester()
	{
		var remtester = $("select#rem_tester option:selected").val();
		
		tb_remove();
				
		$("#updatep").load("ajaxsave.php?action=removetester",{tester:remtester} );
		
		filterALLTable();
		
		$("#updatep").slideDown("normal");
		
		setTimeout(function () { $("#updatep").slideUp("normal");}, 10000);
		
	}	
	
	
	function bookserver()
	{
		var selserver = $("select#reserve_server option:selected").val();
		var seltester = $("select#reserve_tester option:selected").val();
		
		var selres = $("#reserve_exclusive").is(":checked"); 
		var notes = $("#reserve_notes").val();
		
		tb_remove();
				
		$("#updatep").load("ajaxsave.php?action=bookserver",{server:selserver ,tester:seltester ,reserve: selres ,notes:notes} );
		
		if(selres == "true")
		{
			var aid = "lck"+selserver.toUpperCase();
			
			lockServer(aid);
		}
		
		filterALLTable();
		
		$("#updatep").slideDown("normal");
		
		setTimeout(function () { $("#updatep").slideUp("normal");}, 10000);
		
	}	
	
	function cancelbooking()
	{
		var selserver = $("select#cancel_server option:selected").val();
		var seltester = $("select#cancel_tester option:selected").val();
		
		var selres = $("#cancel_exclusive").is(":checked"); 
		
		tb_remove(); //get rid of the thickbox so that we can see what happens.
				
		$("#updatep").load("ajaxsave.php?action=cancelbooking",{server:selserver ,tester:seltester ,reserve: selres } );
		
		if(selres == "true")
		{
			var aid = "lck"+selserver.toUpperCase();
			
			lockServer(aid);
		}
		
		filterALLTable();
		
		$("#updatep").slideDown("normal");
		
		setTimeout(function () { $("#updatep").slideUp("normal");}, 10000);
		
	}	
	
	function cancelupdate()
	{
		var selserver = $("select#cancelu_server option:selected").val();
		
		tb_remove(); //get rid of the thickbox so that we can see what happens.
				
		$("#updatep").load("ajaxsave.php?action=cancelupdate",{server:selserver } );
				
		filterALLTable();
		
		$("#updatep").slideDown("normal");
		
		setTimeout(function () { $("#updatep").slideUp("normal");}, 10000);
		
	}	
	
	
	//the function that gets the list of teams... for something?
	function showteam()
	{
	
			var serverid = document.getElementById('team_server');	
			var d = document.getElementById('server_team');
			var servername = serverid.options[serverid.selectedIndex].value;
			var team = '';
	
			var a = new Ajax.Request('teameditor.jsp?servername='+servername, { 
			onSuccess: function(transport){
					team = transport.responseText;		
					
					if(team == 'SVT')
					{
						d.options[0].selected=true;
					}
					else if(team == 'FVT')
					{
						d.options[1].selected=true;
					}
					else if(team == 'Dev')
					{
						d.options[2].selected=true;
					}
					else if(team == 'Sup')
					{
						d.options[3].selected=true;
					}
    			}
  		});	
  		
	}
	
function createBookmark() {

 title = "WCM Dashboard with Filter"; 
 url = document.location.href;
 
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }