//this function handles dhtml action (registrant/gift giver list pages and view/edit gift notes) as well as image swapping within dhtml sections.
//four arguments are passed:

//'id' is the name of the layer thats being turned on and off
//'imgid' is the name of the title image that contains the plus or minus icons
//'onpath' is the filename of the image when the layer is on, or open.  this image has the minus icon.
//'offpath' is the filename of the image when the layer is off, or closed.  this image has the plus icon.

//passing these four arguments is all that ever needs to happen to both turn layers on and off and swap their respective title imagary.
//the function below should not change unless you need to change the image directory structure in the two variables below.
function toggle(id, imgid, onpath, offpath){
	imgpath1 = 'images/buttons/' + onpath;
	imgpath2 = 'images/buttons/' + offpath;
	prefix = document.getElementById(id);
	iprefix = document.getElementById(imgid);
		if(prefix.className == 'on'){
			prefix.className = 'off';
			iprefix.src = imgpath1;
		}
		else if(prefix.className == 'off'){
			prefix.className = 'on';
			iprefix.src = imgpath2;
		}
}

//this function is used to open all dhtml layers before a form on either the registrant/gift giver list pages or the view/edit gift notes page is submitted.  all layers MUST be open for netscape6 upon form submission or data will be lost.  therefore this function needs to be called first, before any form submission functions.
//this function should never change
function ns6(){
	if(document.getElementById && !document.all){
		for(i=0; i<arguments.length; i++){
		document.getElementById(arguments[i]).className = 'on';
		}
	}
}

//this function launches the colin cowie popup window.  it does not need to change.  pass in the file name of the popup page as the only argument.
function openWin(i){
window.open(i,"","width=402,height=525,toolbar=no,scrollbars=no,resizable=no,status=no");
}


//functions below are for general image swapping and preloading for use with tab navigation or anywhere else.
//they should never change
function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) {
  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&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
