

// Add functions to the onload event
//-----------------------------------------------------------------
 function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

// Cookie scripts
//-----------------------------------------------------------------
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = '; expires='+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+'='+value+expires+'; path=/';
}

function readCookie(name)
{
	var nameEQ = name + '=';
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,'',-1);
}


function initPopups() {

//alert("hello");

	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=550,height=550,scrollbars,resizable'); 
	else
		window.open(url);
	return false;
}


// Cue up the onloads
//-----------------------------------
//addLoadEvent(searchTabs);
addLoadEvent(initPopups);

