/*****************************************************************************************************
		Kirsir Internet Solutions Project Template v1.2
		http://www.kirsir.ca
		
		Date Created: October 20, 2004
		Description: Each file in the project template contributes to a Kirsir web site project and
		             provides a base website for each client.
					 The structure and logic has been developed for use by Kirsir to assist in project development
					 and cannot be distributed or sold.
******************************************************************************************************/


function showHideLayers() { 

  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  { 
		if ((obj=findObj(args[i]))!=null) 
		{ 
			v=args[i+2];
			if (obj.style) 
			{ 
				obj=obj.style; 
				v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
			}
			obj.visibility=v; 
		} 
	}
}


//this function shows the layer(s) passed into the function while hiding all other dd's
//each level is new argument ('1', '2'... = 1st dropdown & 2nd sub dropdown for the 1st box)
//if nothing is passed, all layers will close
function hideAllOtherLayers()
{
	var dd_depth_max = 7; //depth of dropdowns
	var dds = hideAllOtherLayers.arguments, dd_id;
  
	for(var x=1; x<=dd_depth_max; x++)
	{	
		dd_id = 'dd_' + x;
		
		if(dds[0] == x)
			showHideLayers(dd_id, '', 'show');
		else
			showHideLayers(dd_id, '', 'hide');
			
		for(var s=1; s<=dd_depth_max; s++)
		{
			if( (dds[0] == x) && (dds[1] == s) ) //only show the dd where both numbers are the id (e.g. '2_1' not '2_1', '3_1', '4_1')
				showHideLayers(dd_id + '_' + s, '', 'show');
			else
				showHideLayers(dd_id + '_' + s, '', 'hide');
		}
	}
	
	if(dds[0] != '') //if not empty, we want to show a drop down layer so show the closer!
		showHideLayers('closer', '', 'show');
	else
		showHideLayers('closer', '', 'hide'); //if '' was passed in, we want to close everything
}


function preloadImages() 
{
  	var d=document; 
	if(d.images)
	{ 
		if(!d.img_p) d.img_p=new Array();
    	var i, j=d.img_p.length, a=preloadImages.arguments; 
		
		for(i=0; i<a.length; i++)
		{
    		if (a[i].indexOf("#")!=0)
			{ 
				d.img_p[j]=new Image; 
				d.img_p[j++].src=a[i];
			}
		}
	}
}

function switchImage(imgID, imgSrc) 
{
	document.getElementById(imgID).setAttribute('src', imgSrc);
}

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&id.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function setStatus(text) 
{ 
  window.status = text;
  return true;
}

function openPopup(thePage, theWidth, theHeight, theWindowName, intScroll)
{
	//This function accepts the page to be loaded, the width and height of the popup, and the name of the window so that
	//new popups open in their own window and not in other ones
	//Also accepts intScroll indicating if scrollbars should be included (0=no, 1=yes)
	
	//POPUP PROPERTIES CODE
	var popWin, theProperties, popWidth, popHeight, leftPos, topPos;
	
	popWidth = theWidth;
	popHeight = theHeight;
	
	//open in center
	leftPos = (screen.width-popWidth)/2;
	topPos = (screen.height-popHeight)/2;
	
	//popup only has scrollbars
	theProperties = "menubar=0,toolbar=0,resizable=1,scrollbars=" + intScroll + ",width=" + popWidth + ",height=" + popHeight + ",left=" + leftPos + ",top=" + topPos;
	
	//Open a popup window
	popWin = window.open(thePage, theWindowName, theProperties);
	popWin.focus();
	
	return false;
}