var firefox = navigator.userAgent.indexOf("Firefox") != -1
var explorer = navigator.userAgent.indexOf("MSIE") != -1
var explorer7 = navigator.userAgent.indexOf("MSIE 7.0") != -1
var netscape = navigator.userAgent.indexOf("Netscape") != -1
var safari = navigator.userAgent.indexOf("Safari") != -1
var opera = navigator.userAgent.indexOf("Opera") != -1
var camino = navigator.userAgent.indexOf("Camino") != -1
var macintosh = navigator.platform.indexOf("Mac") != -1

function correctPNG() {
	for(var i=0; i<document.images.length; i++) {
		var img = document.images[i]
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
			//alert(img.src)
			var imgID = (img.id) ? "id='" + img.id + "' " : ""
			var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "display:block;" + img.style.cssText 
			if (img.align == "left") imgStyle = "float:left;" + imgStyle
			if (img.align == "right") imgStyle = "float:right;" + imgStyle
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			var strNewHTML = "<span class=\"pngFix\" " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			img.outerHTML = strNewHTML
			i = i-1
		}
	}
}

if (explorer && !explorer7) {
	window.attachEvent("onload", correctPNG);
}

function changeImage(which) { 
	try {
		myImgSrc = document.getElementById(which);
		buttonStatus = myImgSrc.src.substring(myImgSrc.src.length -6, myImgSrc.src.length -4);
		if (buttonStatus == 'of') myImgSrc.src = myImgSrc.src.substring(myImgSrc.src.length -6,0) + 'on.gif';
		else if (buttonStatus == 'in') myImgSrc.src = myImgSrc.src.substring(myImgSrc.src.length -6,0) + 'in.gif';
		else myImgSrc.src = myImgSrc.src.substring(myImgSrc.src.length -6,0) + 'of.gif';
	}
	catch(err) { }
}

function siteWidth() {
	var frameWidth = 932;
	var winWidth = document.body.offsetWidth;
	var sites = (winWidth - frameWidth) / 2;
	document.getElementById('footerLeft').style.width = sites + 'px';
	document.getElementById('footerRight').style.width = sites + 'px';
	document.getElementById('footer').style.display = 'block';
}

function setBox(id) {
	var w = $('box_'+id).getWidth();
	var h = $('box_'+id).getHeight();
	if (h < 110) {
		$('box_'+id).setStyle({background:'#f0f0f0 url(/sites/all/themes/pwc/images/boxes/middle_bg_small.gif) repeat-x left bottom'})
	}
	$('top_'+id).setStyle({width:w+'px'})
	$('bottom_'+id).setStyle({width:w+'px'})
	$('left_'+id).setStyle({height:h+'px'})
	$('right_'+id).setStyle({height:h+'px'})
}

function controlFind() {
	Effect.toggle('form_find','slide',{duration:0.2});
}

function setActiveTo(el) {
	el = $(el);
	for (var i=0; i < activeItems.length; i++) {
		if (activeItems[i] == el) { 
			Element.addClassName(activeItems[i], "active"); 
		}
		else { 
			Element.removeClassName(activeItems[i], "active"); 
		}
	}
}

function insertFlash(path, id, width, height, flashvars) {
	document.write('<object width="' + width + '" height="' + height + '" id="' + id + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0">\n');
	document.write('<param name="allowScriptAccess" value="always" />\n');
	document.write('<param name="movie" value="' + path + '" />\n');
	document.write('<param name="menu" value="false" />\n');
	document.write('<param name="flashvars" value="' + flashvars + '">\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="scale" value="noscale" />\n');
	document.write('<param name="bgcolor" value="#FF0000" />\n');
	document.write('<param name="wmode" value="transparent" />\n');
	document.write('<embed wmode="transparent" width="' + width + '" height="' + height + '" name="' + id + '" src="' + path + '" flashvars="' + flashvars + '" menu="false" quality="high" scale="noscale" bgcolor="#FF0000" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>\n');
}
