function swapDivs(id, id2) 
{ 
document.getElementById(id).style.display = "block"; 
document.getElementById(id2).style.display = "none"; 
}

function turnonDiv(id) 
{ 
document.getElementById(id).style.display = "block"; 
}

function turnoffDiv(id) 
{ 
document.getElementById(id).style.display = "none"; 
}

function rollover(ImageName,ImageFile){
document.images[ImageName].src = ImageFile;
}

function NewWindow(mypage, myname, w, h, scroll, thetoolbar) {
	window.name="callingWindow";
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
    if (parseInt(h) + parseInt(wint) > screen.height) {
    	wint = 0;
    }
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable,toolbar='+thetoolbar+', fullscreen=0'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { 
	win.window.focus(); 
	}
}

function switchMenu(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

imgout=new Image(14,14);
imgin=new Image(14,14);

imgout.src="images/icons/14tableClosed.gif";
imgin.src="images/icons/14tableOpen.gif";

function filter(imagename,objectsrc){
	if (document.images){
		document.images[imagename].src=eval(objectsrc+".src");
	}
}

function showSection(id) 
{ 
	if (document.getElementById) { // DOM3 = IE5, NS6
	    if (document.getElementById(id) == null )
	        return;
		if (document.getElementById(id).style.display == "none"){
			document.getElementById(id).style.display = 'block';
			filter(("img"+id),'imgin');			
		} else {
			filter(("img"+id),'imgout');
			document.getElementById(id).style.display = 'none';			
		}	
	} else { 
		if (document.layers) {	
		    if (document.id == null )
		        return;
			if (document.id.display == "none"){
				document.id.display = 'block';
				filter(("img"+id),'imgin');
			} else {
				filter(("img"+id),'imgout');	
				document.id.display = 'none';
			}
		} else {
			if (document.all.id.style.visibility == "none"){
				document.all.id.style.display = 'block';
			} else {
				filter(("img"+id),'imgout');
				document.all.id.style.display = 'none';
			}
		}
	}
}

function showAlert(id, live) 
{ 
	if (document.getElementById) { // DOM3 = IE5, NS6
	    if (document.getElementById(id) == null ) {
				alert("me");
	        return;
	        }
		if (document.getElementById(id).style.display == "none"){
			if (live=='1') {
			document.getElementById(id).style.display = 'block';
            createCookie('selection', id);
			}
		} else {
			document.getElementById(id).style.display = 'none';			
		}	
	} else { 
		if (document.layers) {	
		    if (document.id == null )
		        return;
			if (document.id.display == "none" && live=="1"){
				if (live=='1') {
				document.id.display = 'block';
                createCookie('selection', id);
				}
			} else {
				document.id.display = 'none';
			}
		} else {
			if (document.all.id.style.visibility == "none" && live=="1"){
				if (live=='1') {
				document.all.id.style.display = 'block';
                createCookie('selection', id);
				}
			} else {
				document.all.id.style.display = 'none';
			}
		}
	}
}

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 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 trimString (str) {
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

String.prototype.trim = trimString;
