//alert('include begin');

function loadFile(filename)
{
	document.write("<"+"script language='JavaScript' type='text/javascript' src='"+filename+"'"+"><"+"/script"+">");
}

function showGlobalMenu()
{
	loadFile('/newhead/menuContent/menuContent.js');
}

function showLocalMenu(extra)
{
	loadFile("/newhead/menuContent/menucontent.php"+extra);
}

function sleep(howLong)
{ // howLong is the time in milliseconds
	var start= new Date();
	var startTime=start.getTime();
	var elapsed=0;
	while (elapsed<howLong)
	{
		var now= new Date();
		elapsed=now.getTime()-startTime;
	}
}

function showLoginBox()
{
	showBox('login');
	document.getElementById('username').focus();
}

function done()
{
	document.write( "<"+"/body"+">"+"<"+"/html"+">");

}

function hideDiv(thingID) { 
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById(thingID).style.display = 'none'; 
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.thingID.display = 'none'; 
		} 
		else { // IE 4 
			document.all.thingID.style.display = 'none'; 
		} 
	} 
} 

function showDiv(thingID) { 
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById(thingID).style.display = 'block'; 
	} 
	else { 
	if (document.layers) { // Netscape 4 
		document.thingID.display = 'block'; 
	} 
	else { // IE 4 
		document.all.thingID.style.display = 'block'; 
	} 
	} 
}

function showConfirm(cTitle, url)
{
	showBox('foregroundThing');
	var destination=document.getElementById('boxContent');
	destination.innerHTML='<B>Confirm '+cTitle+'?</B><BR><A HREF="javascript:void(0);" onmouseup="javascript:document.location=\''+url+'\';">Confirm</A> or <A HREF="javascript:void(0);" onmouseup="javascript:hideConfirm();">Cancel</A>';
	
}

function hideConfirm()
{
	hideBox('foregroundThing');
}

function showBox(boxName)
{
	showDiv('blackness');
	showDiv(boxName);
}

function hideBox(boxName)
{
	hideDiv(boxName);
	hideDiv('blackness');
}

function changeClass(elementID, newClass)
{
	changeClassObj(document.getElementById(elementID), newClass);
}

function changeClassObj(obj, newClass)
{
	obj.setAttribute('class', newClass);
	obj.setAttribute('className', newClass);
}






var wizardRegistry;
wizardRegistry=Array();
var wizardBank;
wizardBank=Array();
var wizardPosition;
wizardPosition=Array();

function registerWizard(phpID)
{
	var newID;
	newID=wizardRegistry.length;
	wizardRegistry[newID]=phpID;
	wizardBank[newID]=Array();
	wizardPosition[newID]=0;
}

function registerWizardTab(phpID, tab)
{
	var bankID; bankID=getBankID(phpID);
	var currentWizard; currentWizard=wizardBank[bankID];
	currentWizard[currentWizard.length]=tab;
}

function getBankID(phpID)
{
	for (i in wizardRegistry)
	{
		if (wizardRegistry[i] == phpID) return i;
	}
	
	return false;
}



function donext(phpID)
{
	var bankID;
	bankID=getBankID(phpID);

	wizardPosition[bankID]++;
	setActiveTab(phpID);

	if (wizardPosition[bankID]==wizardBank[bankID].length-1)
	{
		setEnd(phpID);
	}
	else
	{
		setMiddle(phpID);
	}
}

function doprevious(phpID)
{
	var bankID;
	bankID=getBankID(phpID);

	wizardPosition[bankID]--;
	setActiveTab(phpID);
	
	if (wizardPosition[bankID]==0)
	{
		setBeginning(phpID);
	}
	else
	{
		setMiddle(phpID);
	}
}


function dofinish(phpID)
{
	document.getElementById('form'+phpID).submit();
}


function explicitlySetActiveTab(phpID, pos)
{
	var bankID;
	bankID=getBankID(phpID);

	wizardPosition[bankID]=pos;
	setActiveTab(phpID);

	if (wizardPosition[bankID]==0)
	{
		setBeginning(phpID);
	}
	else
	{
		if (wizardPosition[bankID]==wizardBank[bankID].length-1)
		{
			setEnd(phpID);
		}
		else
		{
			setMiddle(phpID);
		}
	}
}


function setActiveTab(phpID)
{
	var bankID;
	bankID=getBankID(phpID);
	
	var bankPos;
	
	for (i in wizardBank[bankID])
	{
		bankPos=wizardBank[bankID][i];
		
		if (i==wizardPosition[bankID])
		{
			
			showDiv('content'+bankPos);
			changeClass('tab'+bankPos, 'wizardTabSelected');
		}
		else
		{
			hideDiv('content'+bankPos);
			changeClass('tab'+bankPos, 'wizardTab');
		}
	}
}

function enableButton(elementID)
{
	showDiv(elementID);
	document.getElementById(elementID).disabled=false;
}

function disableButton(elementID)
{
	hideDiv(elementID);
	//showDiv(elementID);
	document.getElementById(elementID).disabled=true;
}

function initialJSState(phpID)
{
	showDiv('previous'+phpID);
	showDiv('finish'+phpID);
	showDiv('next'+phpID);
}

function setBeginning(phpID)
{
	disableButton('previous'+phpID);
	disableButton('finish'+phpID);
	enableButton('next'+phpID);
}

function setMiddle(phpID)
{
	enableButton('previous'+phpID);
	disableButton('finish'+phpID);
	enableButton('next'+phpID);
}

function setEnd(phpID)
{ // Make next hidden, and previous and finish showing
	enableButton('previous'+phpID);
	enableButton('finish'+phpID);
	disableButton('next'+phpID);
}


function noEnterKey(e)
{
	e.returnValue=false;
}

function setFail(obj)
{
	changeClassObj(obj, 'fail');
}

function setPass(obj)
{
	changeClassObj(obj, 'pass');
}

function requireAtLeast(obj, characters)
{
	if (typeof(obj)=='')
	{
		if (obj.value.length<characters)
		{
			setFail(obj);
		}
		else
		{
			setPass(obj);
		}
	}
}

function requireSame(obj, objSame)
{
	if ((typeof(obj)=='') && (typeof(objSame)==''))
	{
		if (obj.value==objSame.value)
		{
			setPass(obj);
		}
		else
		{
			setFail(obj);
		}
	}
}

function requireValue(obj, testValue)
{
	if (typeof(obj)=='')
	{
		if (obj.value==testValue)
		{
			setPass(obj);
		}
		else
		{
			setFail(obj);
		}
	}
}

function requireChecked(obj, testValue)
{
	if (obj.value)
	{
		if (obj.checked==testValue)
		{
			setPass(obj);
		}
		else
		{
			setFail(obj);
		}
	}
}



/* Begin Wizard stuff */
	var t=setTimeout(function (){}, 10);

	function iframeCheckAvailablity(textBox, what, where)
	{
		requireAtLeast(textBox, 3);
		if (t)
		{
			window.clearTimeout(t);
		}
		t=window.setTimeout(function(){updateState(textBox.value, what, where)}, 600);
	}
	
	function updateState(newValue, what, where)
	{
		if (where)
		{
			document.getElementById(where).src="uncheck.php?what="+what+"&value="+newValue;
		}
	}
/* End Wizard stuff */

/* Begin littleImage */
function setWhitenessContent(content)
{
	document.getElementById('whitenessContent').innerHTML=content;
}

function openLittleImage(url, class)
{
	showDiv('blackness');
	setWhitenessContent("<CENTER><TABLE HEIGHT=99% WIDTH=99%><TR><TD VALIGN='CENTER' ALIGN='CENTER'><A HREF='javascript:void(0);' onClick='closeWhiteness();'><IMG SRC='"+url+"' CLASS='"+class+"' /></A></TD></TR></TABLE></CENTER>");
	showDiv('whiteness');
}

function closeWhiteness()
{
	hideDiv('whiteness');
	setWhitenessContent("No content here yet.");
	hideDiv('blackness');
}

/* End littleImage */


/* Begin editor stuff*/
function sizeEditor(size)
{
	document.getElementById('wysiwygptext').style.height=size;
}
/* End editor stuff */


function addTag(tagName, fieldName)
{
	alert(tagName);
	addTagDirect(tagName, document.getElementById(fieldName));
}

function addTagDirect(tagName, field)
{
	if (field.value=='')
	{
		field.value=tagName
	}
	else
	{
		field.value=tagName+', '+field.value
	}
}

var test1 = function ()
{
	alert('test1');
}

function test2 ()
{
	alert('test2');
}

test3 = function ()
{
	alert('test3');
}

//alert('include end');

