// show indicator
var indicatorID			= "indicator"	// div id
var indicatorImgPath 	= "images/indicator.gif"; 
var indicatorImgHtml 	= "<img src=\""+indicatorImgPath+"\" alt=\"Loading...\" width=\"16px\" height=\"16px\"/>";

var browserType 		= navigator.userAgent; 	// type of browser. i.e. MSIE or opera.

function showIndicator(){
	var indicator			= document.getElementById(indicatorID);
	indicator.innerHTML 	= indicatorImgHtml;
	indicator.onclick 		= function(){hideIndicator();}
}

function hideIndicator(){
	var indicator			= document.getElementById(indicatorID);
	indicator.innerHTML		="&nbsp;";
}

function posToCenter(elem) {
	var scrollPos = new getScrollPos();
	var pageSize = new getPageSize();
	var emSize = new getElementSize(elem);
	var x = Math.round(pageSize.width/2) - (emSize.width /2) + scrollPos.scrollX;
	var y = Math.round(pageSize.height/2) - (emSize.height /2) + scrollPos.scrollY;	
	elem.style.left = x+'px';
	elem.style.top = y+'px';	
}

function getScrollPos() {
	var docElem = document.documentElement;
	this.scrollX = self.pageXOffset || (docElem&&docElem.scrollLeft) || document.body.scrollLeft;
	this.scrollY = self.pageYOffset || (docElem&&docElem.scrollTop) || document.body.scrollTop;
}

function getPageSize() {
	var docElem = document.documentElement
	this.width = self.innerWidth || (docElem&&docElem.clientWidth) || document.body.clientWidth;
	this.height = self.innerHeight || (docElem&&docElem.clientHeight) || document.body.clientHeight;
}

function getElementSize(elem) {
	this.width = elem.offsetWidth ||  elem.style.pixelWidth;
	this.height = elem.offsetHeight || elem.style.pixelHeight;
}

function toggle(image, divId) {	
	var ob = document.getElementById(divId);
	if(image.title == 'maximise'){
		image.title = 'minimise';
		image.alt = 'minimise';
		image.src = 'images/minimise.gif';		
		ob.style.display = 'block'; 
	}else
	if(image.title == 'minimise'){
		image.title = 'maximise';
		image.alt = 'maximise';
		image.src = 'images/maximise.gif';
		ob.style.display = 'none'; 
	}
}

function setCookie(c_name,value,expiredays){
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	  {
		  c_start=document.cookie.indexOf(c_name + "=")
		  if (c_start!=-1)
		  { 
			c_start=c_start + c_name.length+1 
			c_end=document.cookie.indexOf(";",c_start)
			if (c_end==-1) c_end=document.cookie.length
			return unescape(document.cookie.substring(c_start,c_end))
		  } 
	  }
	return "";
}