function openPopupWindow(theURL, width, height) {
	if (height == undefined && width == undefined){ 
		var newWind = eval("window.open('"+theURL+"','popupwin','width=350,height=300,scrollbars=no,resizable=yes')")}
	else {
		var newWind = eval("window.open('"+theURL+"','popupwin','width="+width+",height="+height+",scrollbars=yes,resizable=yes')")}
	if (!newWind) {
		alert('Sorry, unable to open window at this time.')
		return;}
	if (!newWind.opener || newWind.opener == null) newWind.opener = window;    
	if (newWind) newWind.focus();
}

function submitform()
{
  document.ccoptin.submit();
}

function showleaf(leafID) {
	//alert (leafID);
	leafhandle = document.getElementById(leafID);
	maphandle = document.getElementById("navtree");
	leafhandle.style.zIndex = 100;
	maphandle.style.zIndex = 50;
	removeClass(leafhandle,"hidden");
}

function hideleaf(leafID) {
	//alert (leafID);
	leafhandle = document.getElementById(leafID);
	addClass(leafhandle,"hidden");
}

function rolloverInit() {
	//alert('rolloverInit');
	//alert('document.images.length: ' + document.images.length);
	for (var i=0; i<document.images.length; i++) {
		if (document.images[i].parentNode.tagName == "A") {
			setupRollover(document.images[i]);
		}		
	}
	//alert('done');
}

function setupRollover(thisImage) {	
	//alert('setupRollover');
	thisImage.outImage = new Image();
	thisImage.outImage.src = thisImage.src;
	thisImage.onmouseout = rollOut;
	
	thisImage.overImage = new Image();
	thisImage.overImage.src = "css/skin/" + thisImage.id + "_over.jpg";
	thisImage.onmouseover = rollOver;
}

function rollOver() {
	//alert('rollOver: ' + this.overImage.src);
	this.src = this.overImage.src;
}

function rollOut() {
	this.src = this.outImage.src;
}

function hasClass(ele,cls) {
	return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}

function addClass(ele,cls) {
	if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}

function removeClass(ele,cls) {
	if (hasClass(ele,cls)) {
    	var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
		ele.className=ele.className.replace(reg,' ');
	}
}
