document.pageLoaded = false;
function setLoaded()
{
	document.pageLoaded = true;
}
function isLoaded()
{
	return document.pageLoaded;
}

function findObj(theObj, theDoc)
{
	var p, i, foundObj;

	if(!theDoc) theDoc = document;
	if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
	{
		theDoc = parent.frames[theObj.substring(p+1)].document;
		theObj = theObj.substring(0,p);
	}
	if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
	for (i=0; !foundObj && i < theDoc.forms.length; i++) 
		foundObj = theDoc.forms[i][theObj];
	for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
		foundObj = findObj(theObj,theDoc.layers[i].document);
	if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);

	return foundObj;
}

function preloadImages()
{
	var d=document;if(d.images){ if(!d.pl_imgs) d.pl_imgs=new Array();
	var i,j=d.pl_imgs.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.pl_imgs[j]=new Image; d.pl_imgs[j++].src=a[i];}}
}

function swapImgRestore()
{
	var i,x,a=document.swp_imgs; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function swapImage()
{
	var i,j=0,x,a=swapImage.arguments; document.swp_imgs=new Array; for(i=0;i<(a.length-1);i+=2)
	if ((x=findObj(a[i]))!=null){document.swp_imgs[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+1];}
}

function expandCollapse(sectName)
{
	var cnt = eval('cnt_' + sectName);
	if (cnt == null || cnt == '' || cnt == 0)
		return false;
	
	var obj = findObj('lst_' + sectName);
	if (obj == null)
		return false;
	
	if (obj.style.height == 'auto')
		obj.style.height = '6px';
	else
		obj.style.height = 'auto';
	return false;
}

function getCurrentDate()
{
	var d = new Date();
	var m = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
	var s = "";
	
	s += d.getDate();
	switch (d.getDate())
	{
	case 1:
	case 21:
	case 31:
		s += 'st';
		break;
	case 2:
	case 22:
		s += 'nd';
		break;
	case 3:
	case 23:
		s += 'rd';
		break;
	default:
		s += 'th';
		break;
	}
	s += ' ';
	s += m[d.getMonth()];
	s += ' ';
	s += d.getFullYear();
	
	return s;
}

function showHide(sectName)
{
	var obj = findObj(sectName);
	if (sectName == null)
		return true;
		
	if (obj.style.display == 'none')
	{
		obj.style.display = '';
		obj.style.visibility = 'visible';
	}
	else
	{
		obj.style.display = 'none';
		obj.style.visibility = 'hidden';
	}
	
	return false;
}

function preloadImageArray(arrName)
{
	var arr=eval(arrName);
	for (var i=0;i<arr.length;++i)preloadImages(arr[i]);
}

function rotateImage(imgName, arrName, index)
{
	var img=findObj(imgName);var arr=eval(arrName);
	if (img){img.src=arr[index];++index;if(index>=arr.length)index=0;
	setTimeout("rotateImage('"+imgName+"','"+arrName+"',"+index+");",10000);}
}

function imgPreload()
{
	preloadImages('site_images/lh_menu_d_topx.gif','site_images/lh_menu_d_botx.gif','site_images/lh_menu_d_botx2.gif'
		,'site_images/lh_menu_1x.gif','site_images/lh_menu_2x.gif','site_images/lh_menu_3x.gif'
		,'site_images/lh_menu_4x.gif','site_images/lh_menu_5x.gif','site_images/lh_menu_6x.gif'
		,'site_images/rh_menu_6x.gif','site_images/rh_menu_d_topx.gif','site_images/rh_menu_d_botx.gif');
}

function lhSwap(pos,isLast)
{
	var swapCmd = "swapImage('lh_menu_d_" + (pos - 1) + "','site_images/lh_menu_d_topx.gif','lh_menu_"
		+ pos + "','site_images/lh_menu_" + pos + "x.gif','lh_menu_d_" + pos + "','site_images/lh_menu_d_bot"
		+ (isLast ? "x" : "x2") + ".gif')";
	eval(swapCmd);
}

function anySwap(side,col,name)
{
	var swapCmd = "swapImage('" + name + "_top','site_images/" + side + "_menu_d_topx.gif','" + name
		+ "_img','site_images/" + side + "_menu_" + col + "x.gif','" + name + "_bot','site_images/"
		+ side + "_menu_d_botx.gif')";
	eval(swapCmd);
}
