/* AJAX FUNCTIONS */
function reqContent(url, target) {
	var container = document.getElementById(target);
	if (target == "centerCol") {
		loaderImg();
		AjaxRequest.get(
			{
					'url':url,
					'onSuccess':function(req) { container.innerHTML = req.responseText; },
					'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);},
					'groupName':'Loading',
     				'onGroupBegin':AjaxRequestGroupBegin,
    				'onGroupEnd':AjaxRequestGroupEnd
			}
		);
	} else {
		AjaxRequest.get(
			{
					'url':url,
					'onSuccess':function(req) { container.innerHTML = req.responseText; },
					'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
			}
		);
	}
}
function AjaxRequestGroupBegin(groupName) { activeLoading(document.getElementById(groupName), 'centerCol'); }
function AjaxRequestGroupEnd(groupName) { inactiveLoading(document.getElementById(groupName), 'centerCol'); }
function launchJavascript(responseText) {
  // RegExp from prototype.sonio.net
  var js = '';
  var ScriptFragment = '(?:<script.*?>)((\n|.)*?)(?:</script.*?>)';
           
  var match    = new RegExp(ScriptFragment, 'img');
  var scripts  = responseText.match(match);

    if(scripts) {
        var js = '';
        for(var s = 0; s < scripts.length; s++) {
            var match = new RegExp(ScriptFragment, 'im');
            js += scripts[s].match(match)[1];
        }
        js = js.replace(/<!--/g,'').replace(/\/\/-->/g,'');
        eval(js);
    }
}
function activeLoading(loader, target) {
	if (loader) {
		var center = Position.getCenter(target);
		if (isObject(center)) {
			CSS.replaceClass(loader,"inactiveLoading", "activeLoading");
			var posX = center.left - loader.offsetWidth/2;
			var myPos = centerWindow();
			var posY = myPos[1] - loader.offsetHeight/2;
			Position.set(loader,posX,posY);
		}
	}
}
function inactiveLoading(loader) {
	CSS.replaceClass(loader,"activeLoading", "inactiveLoading");
}
/* END AJAX FUNCTIONS */
/* BANNER FUNCTIONS */
function playBanner() {
	// <![CDATA[		
	var so = new SWFObject("/images/Banner.swf", "banner", "500", "116", "8", "#0f143a");
	so.addParam("wmode","transparent");
	so.write("headerCenterCnt");		
	// ]]>
}
function stopBanner() {
	// <![CDATA[		
	var so = new SWFObject("/images/Banner_noplay.swf", "banner", "500", "116", "8", "#0f143a");
	so.addParam("wmode","transparent");
	so.write("headerCenterCnt");		
	// ]]>
}
/* END BANNER FUNCTIONS */
/* CMS CUSTOM CAMMANDS */
function pdfLink(pdf, scrollX, scrollY) {
	var parent = document.getElementById('contentWrapper');
	var posParent = Position.get(parent);
	if (!document.getElementById('pdfFrame')) {
		var pdfFrame = document.createElement('iframe');
		parent.appendChild(pdfFrame);
		pdfFrame.setAttribute('id','pdfFrame');
		pdfFrame.setAttribute('name','pdfFrame');
		pdfFrame.setAttribute('src','/inc/pdfShow.php?file='+rawurlencode(pdf));
		pdfFrame.setAttribute('scrolling','no');
		var pdfFrame = document.getElementById('pdfFrame');
	} else {
		var pdfFrame = document.getElementById('pdfFrame');
		pdfFrame.src = '/inc/pdfShow.php?file='+rawurlencode(pdf);
		pdfFrame.style.left = (posParent.left+7)+"px";
		pdfFrame.style.top = posParent.top+"px";
		return false;
	}
	if (document.getElementById('pdfFrame')) {
		pdfFrame.style.width = (parent.offsetWidth-14)+"px";
		pdfFrame.style.height = "596px";
		pdfFrame.style.backgroundColor = '#FFFFFF';
		pdfFrame.style.overflow = "hidden";
		pdfFrame.style.position = "absolute";
		pdfFrame.style.left = (posParent.left+7)+"px";
		pdfFrame.style.top = posParent.top+"px";
		pdfFrame.style.zIndex = 1001;
		document.getElementById('centerCol').style.minHeight = "570px";
		window.scroll(scrollX,scrollY);
		// Don't open new window link if successful
		return false;
	} else {
		// Allow new window to open is failure to create DOM object
		return true;
	}
}
function pdfClose() {
	var conf = confirm("Close the document?");
	if (conf) {
		window.parent.scroll(0,0);
		var pdfFrame = parent.document.getElementById('pdfFrame');
		parent.document.getElementById('centerCol').style.minHeight = "300px";
		parent.document.getElementById('centerCol').style.height = "auto";
		pdfFrame.parentNode.removeChild(pdfFrame);
	}
}
/* UTILITY FUNCTIONS */
///////////////////////////////////////
// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth() {
	return (window.innerWidth != null)? window.innerWidth : (document.documentElement && document.documentElement.clientWidth)? document.documentElement.clientWidth : (document.body != null)? document.body.clientWidth : null;
}
function pageHeight() {
	return (window.innerHeight != null)? window.innerHeight : (document.documentElement && document.documentElement.clientHeight)? document.documentElement.clientHeight : (document.body != null)? document.body.clientHeight : null;
} 
function posLeft() {
	return (typeof(window.pageXOffset) != 'undefined')? window.pageXOffset : (document.documentElement && document.documentElement.scrollLeft)? document.documentElement.scrollLeft : (document.body.scrollLeft)? document.body.scrollLeft : 0;
} 
function posTop() {
	return typeof(window.pageYOffset != 'undefined')? window.pageYOffset : (document.documentElement && document.documentElement.scrollTop)? document.documentElement.scrollTop : (document.body.scrollTop)? document.body.scrollTop : 0;
} 
function posRight() {
	return posLeft()+pageWidth();
} 
function posBottom() {
	return posTop()+pageHeight();
}
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}
function centerWindow() {
	var myScroll = getScrollXY();
	var myPosW = myScroll[0]+(pageWidth()/2);
	var myPosH = myScroll[1]+(pageHeight()/2);
	return [ myPosW, myPosH ];
}