var evt_cm = true, evt_md = true, evt_mm = true, evt_ul = true, msec = 50;
var brwObj, mouseX, mouseY, docX, docY, winObj, winPop = "popWin", winPic = "popPic";

if (top != self)
{
	if (window.opera)
	{
		document.writeln('<a name="framed" href="'+self.location.href+'" target="_top"></a>');
		window.onload = unframe;
	}
	else
		top.location = self.location;
}

window.onresize = resize;

function Browser()
{
	var x, n;
	var xpl	= /MSIE ?(\d(\.[0-9]+)*)/gi;
	var nsc	= /Netscape ?(\d)?\/(\d(\.[0-9]+)*)/gi;
	var moz	= /Mozilla/gi;
	var opr	= /Opera/gi;

	this.nua	= navigator.userAgent;
	this.nav	= navigator.appVersion;
	this.ver	= (x=xpl.test(this.nua))?RegExp.$1:(n=nsc.test(this.nua))?RegExp.$2:(v=this.nav.indexOf(" "))?this.nav.substr(0,v):this.nav;
	this.dom	= document.getElementById?true:false;
	this.ie4	= !this.dom&&document.all?true:false;
	this.ie5	= x&&this.dom&&parseInt(this.ver)==5?true:false;
	this.ie6	= x&&this.dom&&parseInt(this.ver)==6?true:false;
	this.ie	= this.ie4||this.ie5||this.ie6;
	this.ns4	= !this.dom&&document.layers?true:false;
	this.ns6	= n&&this.dom&&parseInt(this.ver)==6?true:false;
	this.ns7	= n&&this.dom&&parseInt(this.ver)==7?true:false;
	this.ns	= this.ns4||this.ns6||this.ns7;
	this.op  = opr.test(this.nua)&&parseInt(this.ver)>=5?true:false;
	this.moz = !this.ie&&!this.ns&&!this.op&&moz.test(this.nua)?true:false;

	this.ok	= this.ie5||this.ie6||this.ns||this.moz;

	this.span = span;
	this.span();

	if (this.ns)	document.captureEvents(Event.MOUSEMOVE|Event.MOUSEDOWN);
	if (evt_cm)	document.oncontextmenu = contextMenu;
	if (evt_md)	document.onmousedown = mouseDown;
	if (evt_mm)	document.onmousemove = mouseMove;
	if (evt_ul)	window.onunload = unload;

	eval("brwObj = this;");

	return this;
}

function CSSObject(obj,nest,width)
{
// variables
	this.nest		= nest?eval(nest+"Obj"):null; nest = nest?"document."+nest+".":"";
	this.element	= brwObj.dom?document.getElementById(obj):brwObj.ie4?document.all[obj]:brwObj.ns4?eval("document."+obj):null;
	this.css			= brwObj.dom?document.getElementById(obj).style:brwObj.ie4?document.all[obj].style:brwObj.ns4?eval(nest+"document."+obj):null;
	this.width		= width?width:brwObj.op?this.css.pixelWidth:brwObj.ns4?this.css.document.width:this.element.offsetWidth;
	this.height		= brwObj.op?this.css.pixelHeight:brwObj.ns4?this.css.document.height:this.element.offsetHeight;
	this.initx		= parseInt(this.css.left);
	this.inity		= parseInt(this.css.top);
	this.glueing	= false;
	this.moving		= false;

	this.css.width = this.width;

// methods
	this.echo = echo;
	this.fill = fill;
	this.glue = glue;
	this.hide = hide;
	this.move = move;
	this.note = note;
	this.rect = rect;
	this.show = show;
	this.span = span;
	this.spot = spot;
	this.stop = stop;
	this.swap = swap;

// handles
	this.obj = obj+"Obj";
	eval(this.obj+" = this;");

	return this;
}

function echo(content)
{
	if (!brwObj || !brwObj.ok)	return false;

	if (brwObj.ns4)
	{
		this.css.document.open();
		this.css.document.write(content);
		this.css.document.close();
	}
	else
		this.element.innerHTML = content;

	this.span();
}

function fill(text,msec,intro,extro)
{
	var content = eval(text);
	if (!brwObj || !brwObj.ok || !content[0])	return false;

	if (!this.row)
		this.row = 0;

	if (brwObj.ns4)
	{
		if (this.row == 0)
		{
			this.css.document.open();
			this.css.document.writeln(intro);
		}
		if (content[this.row])
			this.css.document.writeln(content[this.row]);
		else
		{
			this.css.document.writeln(extro);
			this.css.document.close();
		}
	}
	else
	{
		if (this.row == 0)
			this.element.innerHTML = "";
		if (content[this.row])
			this.element.innerHTML = intro+this.element.innerHTML+content[this.row]+extro+"\n";
	}

	this.span();

	if (content[this.row++])
		window.setTimeout(this.obj+".fill('"+text+"',"+msec+",'"+intro+"','"+extro+"')",msec);
	else
		this.row = 0;
}

function glue(glueX,glueY,offX,offY,gapX,gapY)
{
	if (!brwObj || !brwObj.ok)	return false;

	if (this.glueing)	{ window.clearTimeout(this.glueing); this.glueing = false; }

	var argc = glue.arguments.length;
	if (argc>0)
	{
		var varX	= eval(glueX)?parseInt(eval(glueX)):0;
		var tmpX	= parseInt(offX);
		if (argc>4)
		{
			var pgX	= brwObj.ns||brwObj.moz?window.pageXOffset:document.body.scrollLeft;
			if (varX+tmpX < pgX+gapX)
				tmpX = pgX+gapX-varX;
			else
			if (varX+tmpX+this.width > pgX+brwObj.width-gapX)
				tmpX = (pgX+brwObj.width-gapX)-(varX+this.width);
		}
		this.css.left	= varX+tmpX;
	}
	if (argc>1)
	{
		var varY	= eval(glueY)?parseInt(eval(glueY)):0;
		var tmpY	= parseInt(offY);
		if (argc>5)
		{
			var pgY	= brwObj.ns||brwObj.moz?window.pageYOffset:document.body.scrollTop;
			if (varY+tmpY < pgY+gapY)
				tmpY = pgY+gapY-varY;
			else
			if (varY+tmpY+this.height > pgY+brwObj.height-gapY)
				tmpY = (pgY+brwObj.height-gapY)-(varY+this.height);
		}
		this.css.top	= varY+tmpY;
	}

	this.glueing = window.setTimeout(this.obj+".glue('"+glueX+"','"+glueY+"',"+offX+","+offY+(gapX?","+gapX+(gapY?","+gapY:""):"")+");",msec);
}

function hide(keep)
{
	if (!brwObj || !brwObj.ok)	return false;

	if (brwObj.ns4)
		this.css.visibility	= "hide";
	else
		this.css.visibility	= "hidden";

	if (keep)	return;

	if (brwObj.ns4)
	{
		this.css.document.open();
		this.css.document.write('');
		this.css.document.close();
	}
	else
		this.element.innerHTML = "";

	this.width	= 0;
	this.height	= 0;
}

function move(moveX,moveY,cmd)
{
	if (!brwObj || !brwObj.ok || !this.nest)	return false;

	var tol	= parseInt(this.css.left);
	var tot	= parseInt(this.css.top);
	var tow	= parseInt(brwObj.ns4?this.css.document.width:this.element.offsetWidth);
	var toh	= parseInt(brwObj.ns4?this.css.document.height:this.element.offsetHeight);
	var tcw	= parseInt(brwObj.ns4?this.nest.css.clip.left+this.nest.css.clip.right:this.nest.element.offsetWidth);
	var tch	= parseInt(brwObj.ns4?this.nest.css.clip.top+this.nest.css.clip.bottom:this.nest.element.offsetHeight);
	var once	= false;

	if (cmd == 'once')
	{
		once	= true;
		cmd	= false;
	}
	if ((tol+moveX <= this.initx) && (tol+tow+moveX >= tcw))
		this.css.left = tol+moveX;
	else
	{
		moveX	= Math.floor(Math.abs(moveX)/2)*(moveX>0?1:-1);
		once	= false;
	}
	if ((tot+moveY <= this.inity) && (tot+toh+moveY >= tch))
		this.css.top = tot+moveY;
	else
	{
		moveY = Math.floor(Math.abs(moveY)/2)*(moveY>0?1:-1);
		once = false;
	}

	if (once)	return true;

	if (moveX || moveY)
		this.moving = window.setTimeout(this.obj+".move("+moveX+","+moveY+(cmd?",'"+cmd.replace(/'/g,"\\'")+"'":"")+")",msec);
	else
	{
		this.stop();
		if (cmd)	eval(cmd);
	}
}

function note(head,body,width,frame,frcol,bgcol,headc,bodyc,bgimg)
{
	var argc = note.arguments.length;
	if ((this.css && (!brwObj || !brwObj.ok)) || argc < 3)	return false;

	frame	= (argc>3?parseInt(frame):2);
	frcol	= (argc>4?frcol:"#000000");
	bgcol	= (argc>5?bgcol:"#FFFFFF");
	headc	= (argc>6?headc:false);
	bodyc	= (argc>7?bodyc:false);
	bgimg	= (argc>8?bgimg:false);

	var pad = 3;
	var txt = '<table width="'+width+'" bgcolor="'+frcol+'" cellspacing="0" cellpadding="'+frame+'" border="0"><tr>';
	if (head) { txt = txt+'<td><table cellspacing="0" cellpadding="0" border="0"><tr><td width="'+pad+'"><br></td><td'+(headc?' class="'+headc+'"':'')+'>'+(headc?'':'<font color="#FFFFFF">')+'<b>'+head+'</b>'+(headc?'':'</font>')+'</td><td width="'+pad+'"><br></td></tr></table></td></tr><tr>'; }
	txt = txt+'<td><table width="100%" bgcolor="'+bgcol+'"'+(bgimg?' background="'+bgimg+'"':'')+' cellspacing="0" cellpadding="'+pad+'" border="0"><tr><td'+(bodyc?' class="'+bodyc+'"':'')+'>'+body+'</td></tr></table></td></tr></table>';

	if (this.css)
	{
		if (brwObj.ns4)
		{
			this.css.document.open();
			this.css.document.write(txt);
			this.css.document.close();
		}
		else
			this.element.innerHTML = txt;

		if (!isNaN(width))	{ this.width = width; this.css.width = width; }
		this.span();
	}
	else
		document.write(txt);
}

function rect(x1,y1,x2,y2)
{
	if (!brwObj || !brwObj.ok)	return false;

	if (brwObj.ns4)
	{
		this.css.clip.left	= x1;
		this.css.clip.top		= y1;
		this.css.clip.right	= x1+x2;
		this.css.clip.bottom	= y1+y2;
	}
	else
		this.css.clip = "rect("+y1+"px "+(x1+x2)+"px "+(y1+y2)+"px "+x1+"px)";
}

function show(posX,posY,canX,canY,init)
{
	if (!brwObj || !brwObj.ok)	return false;

	if (show.arguments.length)	this.spot(posX,posY,canX,canY,init);

	if (brwObj.ns4)
		this.css.visibility	= "show";
	else
		this.css.visibility	= "visible";
}

function span()
{
	if (this.nua)
	{
		if (this.ns || document.body != null)
		{
			this.width	= this.ns?window.innerWidth:document.body.clientWidth;
			this.height	= this.ns?window.innerHeight:document.body.clientHeight;
		}
	}
	else if (this.css)
	{
		var moz14 = false;
		if ((brwObj.ns7 && brwObj.ver > 7) || brwObj.moz)
		{
			moz14 = true;
			cs = document.defaultView.getComputedStyle(this.element,'');
			tw = parseInt(cs.getPropertyValue('width'));
			th = parseInt(cs.getPropertyValue('height'));
		}
		if (!this.width)	this.width	= brwObj.ns4?this.css.document.width:moz14?tw:this.element.offsetWidth;
		this.height	= brwObj.ns4?this.css.document.height:moz14?th:this.element.offsetHeight;
	}
}

function spot(posX,posY,canX,canY,init)
{
	if (!brwObj || !brwObj.ok)	return false;

	var argc = spot.arguments.length;
	posX = (argc>0?parseInt(eval(posX)):0);
	posY = (argc>1?parseInt(eval(posY)):0);
	canX = (canX?parseInt(canX)+(brwObj.ns4?16:brwObj.ns6?14:0):0);
	canY = (canY?parseInt(canY)+(brwObj.ns4?16:0):0);

	this.css.left	= ((canX&&canX<brwObj.width)?Math.floor((brwObj.width-canX)/2):0)+posX;
	this.css.top	= ((canY&&canY<brwObj.height)?Math.floor((brwObj.height-canY)/2):0)+posY;

	if (init)
	{
		this.initx = init>0?posX:parseInt(this.css.left);
		this.inity = init>0?posY:parseInt(this.css.top);
	}
}

function stop()
{
	if (!brwObj || !brwObj.ok)	return false;

	if (this.moving)	{ window.clearTimeout(this.moving); this.moving = false; }
}

function swap(name,img)
{
	var obj = brwObj?brwObj.ns4?this.css?this.css:this:window:window;
	if (obj.document.images)
		obj.document.images[name].src = img.src;
}

function contextMenu(evt)
{
	return false;
}

function mouseDown(evt)
{
	if (evt && evt.which != 1)	return false;
	return true;
}

function mouseMove(evt)
{
	if (brwObj && (brwObj.ns || brwObj.moz))
		{ docX = window.pageXOffset; docY = window.pageYOffset; mouseX = evt.pageX; mouseY = evt.pageY; }
	else
		{ docX = document.body.scrollLeft; docY = document.body.scrollTop; mouseX = event.x+docX; mouseY = event.y+docY; }
}

function resize()
{
	location.reload();
}

function unframe()
{
  document.links['framed'].click();
}

function unload()
{
	if (winObj && !winObj.closed)	winObj.close();
}

function openWindow(url,posX,posY,width,height,config)
{
	if (winObj && !winObj.closed)	winObj.close();

	var data = "left="+posX;
	data+= ",top="+posY;
	data+= ",width="+width;
	data+= ",height="+height;
	data+= ","+(config?config:"scrollbars=no,resizable=no");

	winObj = window.open(url,winPop,data);
	if (parseInt(navigator.appVersion) >= 4)	winObj.focus();

	return winObj;
}

function openPicWin(url,winWidth,winHeight,picWidth,picHeight,config,title)
{
	if (winObj && !winObj.closed)	winObj.close();
	if (!title)	title = "click inside to close window";

	var data = "left="+Math.floor((screen.availWidth-winWidth)/8);
	data+= ",top="+Math.floor((screen.availHeight-winHeight)/2);
	data+= ",width="+(winWidth > screen.availWidth-10 ? screen.availWidth-10 : winWidth);
	data+= ",height="+(winHeight > screen.availHeight-10 ? screen.availHeight-10 : winHeight);
	data+= ","+(config?config:"scrollbars=no,resizable=no");
	var size = (picWidth && picHeight);

	winObj = window.open("",winPic,data);
	winObj.document.open();
	winObj.document.writeln('<html>');
	winObj.document.writeln('<head>');
	winObj.document.writeln('<title>'+title+'</title>');
	winObj.document.writeln('<scr'+'ipt>\n<!--');
	winObj.document.writeln('if (document.layers) document.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP); document.onmousedown=md; document.onmouseup=mu; document.oncontextmenu=cm;');
	winObj.document.writeln('function md(evt) { if (evt&&evt.which==3) return false; return true; } function mu(evt) { '+(size?"if (evt&&evt.which==3) self.close(); return false;":"self.close();")+' } function cm(evt) { return false; }');
	winObj.document.writeln('//-->\n</scr'+'ipt>');
	winObj.document.writeln('</head>');
	winObj.document.writeln('<body background="'+url+'" marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">');
	if (size) winObj.document.writeln('<div onclick="self.close();" oncontextmenu="self.close();" style="width:'+picWidth+'px; height:'+picHeight+'px;"></div>');
	winObj.document.writeln('</body>');
	winObj.document.writeln('</html>');
	winObj.document.close();
	if (parseInt(navigator.appVersion) >= 4)	winObj.focus();

	return winObj;
}

