var newWin = null;
function popUp(strURL, strType, strHeight, strWidth) {
	if (newWin != null && !newWin.closed)
		newWin.close();
		var strOptions="";
	if (strType=="popup")
		strOptions="location=0,menubar=1,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,height="+strHeight+",width="+strWidth;
	newWin = window.open(strURL, 'newWin', strOptions);
	newWin.focus();
}

//Function for expanding or collapsing a chosen tag in the XSL template
 function expand(thistag) {
      if(document.getElementById(thistag)){
      styleObj = document.getElementById(thistag).style;
      if (styleObj.display=='none') {styleObj.display = '';}
      else {styleObj.display = 'none';}
      }
}
function goTarget(url) {
  window.open(url);
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}function isInt(str) {
    return /^ *[1-9]+ *$/.test(str);
}

function externalLinks(){
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for(var i=0;i<anchors.length; i++){
		var anchor = anchors[i];
		if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
			anchor.target = "_blank";
		}
	}
}

function clearField(field,defText){

    if((field.value==defText)){
        field.value="";
    }
    else
        field.value = field.value;
}


/*
	Class: ImageRotator
	A class that handles rotating images.
	
	Parameters:
	
		emelId - A HTML element id.
		interval - Interval in seconds.
*/

function ImageRotator(elemId, interval) 
{
  
	this.elem = document.getElementById(elemId);// HTML element
	this.image = []; // Array
	this.url = [];	// Array
	this.current = 0; // Integer
	this.interval = interval; // Integer
	
	var me = this; // Self
/*
		Function: addItem
		Adds an item to the display list.
	*/
	this.addItem = function(item) 
	{
		this.image.push(item[0]);
		this.url.push(item[1]);
		
		//	This is as but ugly as it can get. Needs more work!
		var tmpImg = new Image();
		tmpImg.src = item[0];
		return true;
	}
/*
		Function: showItem
		Show the current image.
	*/
	this.showItem = function()
	{
		if (this.url[this.current] != null) {
			this.elem.innerHTML = '<a href="' + this.url[this.current] + '"><img src="' + this.image[this.current] + '" alt=""></a>';
		} else {
			this.elem.innerHTML = '<img src="' + this.image[this.current] + '" alt="">';
		}
		this.current ++;
		if (this.current == this.image.length) {
			this.current = 0;
		}
		window.setTimeout(function() {me.showItem()}, this.interval * 1000);
		return true;
	}
/*
		function: start
		Start the rotation.
	*/
	this.start = function() 
	{
		if (this.image.length > 1) {
			this.showItem();
		}
		return true;
	}

	return true;
	
}





