var dwin;
function debug( msg, end ){
	if( ! dwin ){
		if( end ){
			return;
		}
		dwin = window.open( 'about:blank' , 'debug_window', 'scrollbars=yes,resizable=yes,toolbar=no,status=yes,menubar=no,dependant=yes,alwaysRaised=yes,location=yes'); 
	}
	dwin.document.writeln( msg + "<br>" );
	if( end ){
		dwin.document.close();
	}
}

/*
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
*/

function Browser() {
	var b=navigator.appName;
	if (b=="Netscape") this.b="ns";
	else if ((b=="Opera") || (navigator.userAgent.indexOf("Opera")>0)) this.b = "opera";
	else if (b=="Microsoft Internet Explorer") this.b="ie";
	if (!b) alert('Unidentified browser./nThis browser is not supported,');
	this.version=navigator.appVersion;
	this.v=parseInt(this.version);
	this.ns=(this.b=="ns" && this.v>=4);
	this.ns4=(this.b=="ns" && this.v==4);
	this.ns6=(this.b=="ns" && this.v==5);
	this.ie=(this.b=="ie" && this.v>=4);
	this.ie4=(this.version.indexOf('MSIE 4')>0);
	this.ie5=(this.version.indexOf('MSIE 5')>0);
	this.ie55=(this.version.indexOf('MSIE 5.5')>0);
	this.ie6=(this.version.indexOf('MSIE 6.0')>0);
	this.opera=(this.b=="opera");
	this.dom=(document.createElement && document.appendChild && document.getElementsByTagName)?true:false;
	this.def=(this.ie||this.dom); // most used browsers, for faster if loops
	var ua=navigator.userAgent.toLowerCase();
	if (ua.indexOf("win")>-1) this.platform="win32";
	else if (ua.indexOf("mac")>-1) this.platform="mac";
	else this.platform="other";
}
is = new Browser();

function saveCookie(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 deleteCookie(name) {
	saveCookie(name,"",-1)
}


function getLayerStyle( id ){
    if (is.ns4) {
	  return eval( 'document.' + id );
    }else
    if (is.ie4) {
	  return eval( id + '.style' );
    }else
    if (is.dom || is.opera) {
      return document.getElementById(id).style;
    }else return false;
}

function show( id ){
	l = getLayerStyle( id );
	if(l){
	    l.visibility = is.ns4 ? "show" : "visible";
		l.display = 'block';
	}
}

function hide( id ){
	l = getLayerStyle( id );
	if(l){
	    l.visibility = is.ns4 ? "hide" : "hidden";
		l.display = 'none';
	}
}


function moveTo( id, x, y ) {
	l = getLayerStyle( id );
	if (x!=null){
		if (is.ns) l.left = x
		else l.pixelLeft = x
	}
	if (y!=null){
		if (is.ns) l.top = y
		else l.pixelTop = y
	}
} 


// find element position by id
function findPos( id ){
  if(is.ns4){   //Netscape 4
    /* x = document.layers["layerMenu"+num].pageX
    y = document.layers["layerMenu"+num].pageY */
	return [0,0,0,0];
  }else{ //other browsers
    x=0; y=0; var el,temp
    el = is.ie4?document.all[ id ]:document.getElementById( id );
	if (typeof el == 'undefined') {
	    return [0,0,0,0];
	}
	w = el.offsetWidth;
	h = el.offsetHeight;

	if(el.clienLeft){
		x=el.clientLeft;
		y=el.clientTop;
	}else{
		if(el.offsetParent){
		  temp = el
		  while(temp.offsetParent){ //Looping parent elements to get the offset of them as well
			temp=temp.offsetParent; 
			x+=temp.offsetLeft
			y+=temp.offsetTop;
		  }
		}
		x+=el.offsetLeft
		y+=el.offsetTop
	}
  }
  //  window.alert( x + ':' + y );
  //Returning the x and y as an array
  return [x,y,w,h]
}


