function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=250,height=400,left = 770,top = 320');");
}

function createBookmarkLink(title,url) {
	if (window.sidebar) { 
		// Mozilla Firefox Bookmark
		window.sidebar.addPanel(title,url,"");
	} else if( window.external ) { 
		// IE Favorite
		window.external.AddFavorite(url,title); 
	} else if(window.opera && window.print) { 
		// Opera Hotlist
		return true; 
	}
}

function matchHeight(){
	var divs,contDivs,maxHeight,divHeight,d;
	// get all <div> elements in the document
	divs=document.getElementsByTagName('div');
	contDivs=[];
	// initialize maximum height value
	maxHeight=0;
	// iterate over all <div> elements in the document
	for(var i=0;i<divs.length;i++){
		// make collection with <div> elements with class attribute 'matchedheight'
		if(/\bmatchedheight\b/.test(divs[i].className)){
			d=divs[i];
			contDivs[contDivs.length]=d;
			// determine height for <div> element
			if(d.offsetHeight){
				divHeight=d.offsetHeight;
			}else if(d.style.pixelHeight){
				divHeight=d.style.pixelHeight;
			}
			// calculate maximum height
			maxHeight=Math.max(maxHeight,divHeight);
		}
	}
	if(!maxHeight || maxHeight < 20) maxHeight = 20;
	//alert(contDivs.length+' : '+maxHeight);
	// assign maximum height value to all of container <div> elements
	for(var i=0;i<contDivs.length;i++){
		contDivs[i].style.height=maxHeight+'px';
	}
}

function matchHeightByClass(classid){
	var divs,contDivs,maxHeight,divHeight,d;
	contDivs=[];
	// initialize maximum height value
	maxHeight=0;
	// iterate over all <div> elements in the document
	var divs = document.getElementsByClassName(classid);
	for (var i=0; i < divs.length; i++) {
		var d=divs[i];
		contDivs[contDivs.length]=d; // copy object to contDivs
		// determine height for <div> element
		d.style.height = 'auto';  //reset the content elements height
		if(d.offsetHeight){
			divHeight=d.offsetHeight;
		}else if(d.style.pixelHeight){
			divHeight=d.style.pixelHeight;
		}
		// calculate maximum height
		maxHeight=Math.max(maxHeight,divHeight);
	}//end for
	if(!maxHeight || maxHeight < 20) maxHeight = 20;
	//alert(contDivs.length+' : '+maxHeight);
	// assign maximum height value to all of container <div> elements
	for(var i=0;i<contDivs.length;i++){
		contDivs[i].style.height=maxHeight+'px';
	}//end for
}//end func


function setTableRowColors(){
	if (!document.getElementsByTagName) return false;
	var tables = document.getElementsByTagName("table");
	for (var i=0; i < tables.length; i++) {
		var rows = tables[i].getElementsByTagName("tr");  
		for(r = 0; r < rows.length; r++){ 
			if(r % 2 == 0){
       		rows[r].className = "r0";
			}else{
				rows[r].className = "r1";
			}//end if
		}//end for
	}//end for
}//end func



/*
function od_displayImage(strId, strPath, intWidth, intHeight, strClass, strAlt) {	
 if (pngAlpha) {
  document.write('<div style="height:'+intHeight+'px;width:'+intWidth+'px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader»
  (src=\''+strPath+'.png\', sizingMethod=\'scale\')" id="'+strId+'" class="'+strClass+'"></div>');
	} else if (pngNormal) {
  document.write('<img src="'+strPath+'.png" »
	width="'+intWidth+'"»
  height="'+intHeight+'" name="'+strId+'" »
	border="0" class="'+strClass+'" alt="'+strAlt+'" />');
	} else {
  document.write('<img src="'+strPath+'.gif" »
	width="'+intWidth+'"»
  height="'+intHeight+'" name="'+strId+'" »
	border="0" class="'+strClass+'" alt="'+strAlt+'" />');
	}
}
*/

function doPopupImage() {
	if (!document.getElementsByTagName) return false;
	var links = document.getElementsByTagName("a");
	for (var i=0; i < links.length; i++) {
		if (links[i].className.match("popupimage")) {
			//alert('got one');
			//add mag icon
			oMag = document.createElement("div");
			oMag.className = "mag";
			if(BrowserDetect.browser == 'Explorer' && BrowserDetect.version > 5){
				//set class to use IE filter crap
				oMag.className = "magie";
			}//if
			
			links[i].appendChild(oMag);
			//add onclick code
			links[i].onclick = function() {
				var w = this.getAttribute('w') ? parseInt(this.getAttribute('w')) : 300;
				var h = this.getAttribute('h') ? parseInt(this.getAttribute('h')) : 300;
				w += 40;
				h += 40;
				//alert('w='+w+' h='+h);
				var popWindow = window.open(this.href,'','toolbar=0,resizable=1,menubar=0,scrollbars=1,width='+w+',height='+h);
				return false;
			}//end func
		}//end if
	}//end if
}//end func

function doPopupGeneral() {
	if (!document.getElementsByTagName) return false;
	var links = document.getElementsByTagName("a");
	for (var i=0; i < links.length; i++) {
		if (links[i].className.match("popupgen")) {
			//alert(i + ' : ' + links[i].href);
			//add onclick code
			links[i].onclick = function() {
				//alert('clicked');
				var sWidth = '';
				var sHeight = '';
				var sModal = '';
				if(this.getAttribute('w')) sWidth = ',width='+ this.getAttribute('w');
				if(this.getAttribute('h')) sHeight = ',height='+ this.getAttribute('h');
				if(this.getAttribute('modal')) sModal = ',modal=1,dependant=1,chrome=0,alwaysRaised=1';
				//alert('w='+w+' h='+h);
				window.open(this.href,'','toolbar=0,resizable=1,menubar=0,scrollbars=1'+sWidth+sHeight+sModal);
				return false;
			}//end func
		}//end if
	}//end if
}//end func

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{	// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 	// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

var currentWindowOnload =(window.onload)?window.onload:function(){};
window.onload = function(){
	currentWindowOnload();
	//setPagetitle();
/*
	if(document.getElementsByTagName){
		//matchHeightByClass('mhcolumns');
	}
*/
	Nifty("div.rounded","transparent");
	Nifty("div.impactblock","transparent");
	Nifty("div.block","transparent");
	/*
	Nifty("div.block","transparent");
	Nifty("p.fullimg","transparent");
	*/
	//setTableRowColors();
	doPopupImage();
	doPopupGeneral();
	if(	window.adminmode && window.bLoggedIn){
		//we are logged in and editing
		qp = document.location.search.toQueryParams();  //convert to struct of sorts
		elm = $('c_' + qp.uuid);  //get the object ID
		if(elm){
			Element.scrollTo(elm);  //scroll to it
		}
	}
}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}