/*
	Standards Compliant Popup Script
	Author : Kevin Cannon
	http://www.multiblah.com
	Last Edited: 12.12.2004
	Version 1.0
	
	Searches through a document for links with the class popup.
	When clicked, this link will open in a popup window.
	This means you don't have to add javascript to your code, 
	and means the links continue to work, for search engines, 
	and browsers without javascript
	
*/


function initPopups() {

	if (!document.getElementById) return
	
	var aLinks = document.getElementsByTagName('a');

	for (var i = 0; i < aLinks.length; i++) {		
		if (aLinks[i].className == 'popup' || aLinks[i].className == 'external') {
			
			if (aLinks[i].className == 'popup') {
				aLinks[i].onclick = function() {
					var url = this.href;
					openPopup(url,1);
					return false;
					}
				}
			else {
				aLinks[i].onclick = function() {
					var url = this.href;
					openPopup(url,0);
					return false;
					}
				}	
		}
	}
}

// popupWindow function
// This is where you set your specific height & width etc... for your popups.
function openPopup(url,popType) {
	if (popType==1)
		window.open(url, 'popupwindow', 'width=500,height=500,scrollbars,resizable'); 
	else
		window.open(url);
	return false;
}


// Piggy-back fucntion onto onLoad event ............................................
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(initPopups);

// Gallery popup stuff.
var newWindow = null;

function toggleElementText(el, strValue1, strValue2)
{

	(el.innerHTML.indexOf(strValue1) != -1 ? el.innerHTML = strValue2 : el.innerHTML = strValue1);
	
}
	
function closeWin() {
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
		}
	}

function popUpWin(url, type, strWidth, strHeight) {
	closeWin();
	
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
		}
	else {
		strWidth = strWidth + 60;
		strHeight = strHeight + 123;
		}
	
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+"";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
	}
// Gallery popup stuff end.
