//###############################
// The assignment display panel #
//###############################
function Assignment(Tab){
	var i=1;
	while(i<=11){
		document.getElementById('JOBLIST'+i).style.display='none';
		document.getElementById('ASSIGNMENT_TAB'+i).className='ASSIGNMENT_TAB';
	i++;}
	document.getElementById('JOBLIST'+Tab).style.display='block';
	document.getElementById('ASSIGNMENT_TAB'+Tab).className='ACTIVE_ASSIGNMENT_TAB';
}


function ShowMenu(Panel){
	document.getElementById(Panel).style.display='block';
}

function HideMenu(Panel){
	document.getElementById(Panel).style.display='none';
}








//##################################
// Create the active page settings #
//##################################
function Layout(Address,Telephone,Fax,Target,Domain){
	Assignment('1');
	OfficeAddress(Address);
	if(Telephone!='0')document.getElementById('ADDRESS'+Address+'TEL').innerHTML='t:&nbsp;'+Telephone;
	if(Fax!='0')document.getElementById('ADDRESS'+Address+'FAX').innerHTML='f:&nbsp;'+Fax;
	if(Target!='0')document.getElementById('ADDRESS'+Address+'EML').innerHTML='e:&nbsp;<a href="mailto:'+Target+'@'+Domain+'">'+Target+'@'+Domain+'</a>';
}

//----------------------------------------------------------------------------------------------------

//#################################
// Retrieve session cookie values #
//#################################
function getSessionCookieValue(cookieName){
	var exp=new RegExp(escape(cookieName)+"=([^;]+)");
	if(exp.test(document.cookie+";")){exp.exec(document.cookie+";");return unescape(RegExp.$1);}
	else return false;
}

//----------------------------------------------------------------------------------------------------

//#########################################
// Write email contact points to the page #
//#########################################
function ContactAddress(Target,Domain){
	document.write('<a href="mailto:'+Target+'@'+Domain+'">'+Target+'@'+Domain+'</a>');
}

//----------------------------------------------------------------------------------------------------

//#######################################
// Write a basic email link to the page #
//#######################################
function ContactHref(Target,Domain){
	document.write('<a href="mailto:'+Target+'@'+Domain+'">');
}

//----------------------------------------------------------------------------------------------------

//##################################
// Write an email link to the page #
//##################################
function ContactLink(Target,Domain,Subject){
	document.write('<a href="mailto:'+Target+'@'+Domain+'?subject='+Subject+'">');
}

//----------------------------------------------------------------------------------------------------

//#############################################
// Drive the flag-tabbed office address panel #
//#############################################
function OfficeAddress(Tab){
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// On site entry, before the session cookie has been created, set the default address panel +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	if(!getSessionCookieValue('flagpanel'))Tab=1;
//++++++++++++++++++++++++++++++++++++++++
// Set all elements to the passive state +
//++++++++++++++++++++++++++++++++++++++++
	var Display=Tab;
	var Loop=8;
	for(x=1;x<=Loop;x++){
	document.getElementById('FLAGTAB'+x).className='FLAGTAB';
	document.getElementById('FLAG'+x).className='FLAG FLAG'+x;
	document.getElementById('ADDRESS'+x).className='FLAGADDRESS';}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// If the page requires a specific panel then display it +
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	if(Tab!=0){
	document.getElementById('FLAGTAB'+Tab).className='ACTIVEFLAGTAB';
	document.getElementById('FLAG'+Tab).className='ACTIVEFLAG ACTIVEFLAG'+Tab;
	document.getElementById('ADDRESS'+Tab).className='ACTIVEFLAGADDRESS';
	document.cookie=escape('flagpanel')+"="+escape(Tab)+";path=/";}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// If the page has no panel specified then load the one carried over from the previous page +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	else if(Tab==0){
	if(getSessionCookieValue('flagpanel'))Tab=getSessionCookieValue('flagpanel');
	document.getElementById('FLAGTAB'+Tab).className='ACTIVEFLAGTAB';
	document.getElementById('FLAG'+Tab).className='ACTIVEFLAG ACTIVEFLAG'+Tab;
	document.getElementById('ADDRESS'+Tab).className='ACTIVEFLAGADDRESS';}
}

//----------------------------------------------------------------------------------------------------

//##################################################
// Drive the link onmouseover office address panel #
//##################################################
function FlipOfficeAddress(Tab){
	var Display=Tab;
	var Loop=8;
	for(x=1;x<=Loop;x++){
	document.getElementById('FLAGTAB'+x).className='FLAGTAB';
	document.getElementById('FLAG'+x).className='FLAG FLAG'+x;
	document.getElementById('ADDRESS'+x).className='FLAGADDRESS';}
	document.getElementById('FLAGTAB'+Tab).className='ACTIVEFLAGTAB';
	document.getElementById('FLAG'+Tab).className='ACTIVEFLAG ACTIVEFLAG'+Tab;
	document.getElementById('ADDRESS'+Tab).className='ACTIVEFLAGADDRESS';
}

//----------------------------------------------------------------------------------------------------

//#############################################
// Randomize the job list panel content order #
//#############################################
function randomizeContent(classname){
	var contents=randomizeContent.collectElementbyClass(classname)
	contents.text.sort(function(){return 0.5-Math.random();})
	var tbodyref=contents.ref[0].tagName=="TR"? contents.ref[0].parentNode:new Object();
	for(var i=0;i<contents.ref.length;i++){
	if(tbodyref.moveRow)tbodyref.moveRow(0,Math.round(Math.random()*(tbodyref.rows.length-1)));
	else contents.ref[i].innerHTML=contents.text[i]
	contents.ref[i].style.visibility='visible';}}
	randomizeContent.collectElementbyClass=function(classname){
	var classnameRE=new RegExp("(^|\\s+)"+classname+"($|\\s+)","i");
	var contentobj=new Object();
	contentobj.ref=new Array();
	contentobj.text=new Array();
	var alltags=document.all?document.all:document.getElementsByTagName('*');
	for(var i=0;i<alltags.length;i++){
	if(typeof alltags[i].className=="string"&&alltags[i].className.search(classnameRE)!=-1){
	contentobj.ref[contentobj.ref.length]=alltags[i]
	contentobj.text[contentobj.text.length]=alltags[i].innerHTML;}}
	return contentobj;
}

//----------------------------------------------------------------------------------------------------

//##############################
// Write in the copyright date #
//##############################
function Copyright(){
	today=new Date();
	document.write(today.getFullYear());
}

