// JavaScript Document
function MM_reloadPage(init) {  //Updated by PVII. Reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_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&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function P7_swapClass(){ //v1.4 by PVII
 var i,x,tB,j=0,tA=new Array(),arg=P7_swapClass.arguments;
 if(document.getElementsByTagName){for(i=4;i<arg.length;i++){tB=document.getElementsByTagName(arg[i]);
  for(x=0;x<tB.length;x++){tA[j]=tB[x];j++;}}for(i=0;i<tA.length;i++){
  if(tA[i].className){if(tA[i].id==arg[1]){if(arg[0]==1){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}else{tA[i].className=arg[2];}
  }else if(arg[0]==1 && arg[1]=='none'){if(tA[i].className==arg[2] || tA[i].className==arg[3]){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}
  }else if(tA[i].className==arg[2]){tA[i].className=arg[3];}}}}
}

/*
addEvent function found at http://www.scottandrew.com/weblog/articles/cbs-events
*/
function addEvent(obj, evType, fn) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, true);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on"+evType, fn); 
		return r;
	} else {
		return false;
	}
}

/*
createElement function found at http://simon.incutio.com/archive/2003/06/15/javascriptWithXML
*/
function createElement(element) {
	if (typeof document.createElementNS != 'undefined') {
		return document.createElementNS('http://www.w3.org/1999/xhtml', element);
	}
	if (typeof document.createElement != 'undefined') {
		return document.createElement(element);
	}
	return false;
}

function insertTop(obj) {
	// Create the div element needed for the top of the box
	d=createElement("div");
	d.className="trcorner"; // The div needs a class name
	obj.insertBefore(d,obj.firstChild);
}

function insertBottom(obj) {
	// Create the div element needed for the bottom of the box
	d=createElement("div");
	d.className="blcorner"; // The div needs a class name
	obj.appendChild(d);
}

function initFB()
{
	// Find all div elements
	var divs = document.getElementsByTagName('div');
	var fancyboxDivs = [];
	for (var i = 0; i < divs.length; i++) {
	// Find all div elements with fancybox in their class attribute while allowing for multiple class names
		if (/\bcbb\b/.test(divs[i].className)) {
			fancyboxDivs[cbDivs.length] = divs[i];
		}
	}
	// Loop through the found div elements
	var thediv, outer, i1, i2;
	for (var i = 0; i < fancyboxDivs.length; i++) {
		insertTop(fancyboxDivs[i]);
		insertBottom(fancyboxDivs[i]);
	}
}
if(document.getElementById && document.createTextNode)
{
	addEvent(window, 'load', initFB);
}

function confirmDelete( text, url ) {
	if( confirm(text) ) {
		window.location.href = url;
	}
}
