var uAgent = navigator.userAgent;
var uName = navigator.appName;
var uPlugins = navigator.plugins;
var d = document;

function sniffer(){
	/* os ----------------------------------------------- */
	this.Win = uAgent.indexOf("Win",0) != -1 ? 1 :0;
	this.Mac = uAgent.indexOf("Mac",0) != -1 ? 1 :0;
	this.MacOSX = ((uAgent.indexOf("Mozilla") != -1) && (uAgent.indexOf("Mac OS X") != -1)) ? 1 :0;
	if(uPlugins){for(i=0;i<uPlugins.length;i++){if(this.Mac && (uPlugins[i].filename.indexOf("QuickTime Plugin.plugin")!=-1)){this.MacOSX=true;}}}

	/* browser ----------------------------------------------- */
	this.IE = ((uAgent.indexOf("MSIE") != -1) && (uAgent.indexOf("Opera") == -1)) ? 1 :0;
	this.NS = ((uName == "Netscape") && (uAgent.indexOf("Opera") == -1)) ? 1 :0;
	this.NC = ((uName == "Netscape") && (uAgent.indexOf("Gecko") == -1) && (uAgent.indexOf("Opera") == -1)) ? 1 :0;
	this.Gecko = (uAgent.indexOf("Gecko") != -1) ? 1 :0;
	this.Moz = ((uAgent.indexOf("Gecko") != -1) && (uAgent.indexOf("Safari",0) == -1)) ? 1 :0;
	this.OPERA = uAgent.indexOf("Opera",0) != -1 ? 1 :0;
	this.SAFARI = uAgent.indexOf("Safari",0) != -1 ? 1 :0;
	this.ICAB = uAgent.indexOf("iCab",0) != -1 ? 1 :0;

	this.IE3 = (uAgent.indexOf('MSIE 3.',0) != -1);
	this.MacIE4 = (this.Mac && (uAgent.indexOf('MSIE 4.',0) != -1));
	this.MacIE45 = (this.Mac && (uAgent.indexOf('MSIE 4.5',0) != -1));
	this.MacIE5 = (this.Mac && (uAgent.indexOf('MSIE 5.',0) != -1));
	this.NS60 = (uAgent.indexOf("Netscape6/6.0") != -1);
	this.NS6 = (uAgent.indexOf("Netscape6/") != -1);
	this.NS7 = (uAgent.indexOf("Netscape/7") != -1);

	/* object ----------------------------------------------- */
	/* NS4 = 1, IE4 = 2, IE5+,OPERA5,7 = 3, NS6+,SAFARI,OPERA6 = 4, others = 0 */
	this.checkObj = d.all?(d.getElementById?3:2):(d.getElementById?4:(d.layers?1:0));
	this.allObj = ((this.checkObj == 1) || (this.checkObj == 2) || (this.checkObj == 3) || (this.checkObj == 4));
	this.checkObj4 = (d.getElementById && !d.all) ? 1 :0;
	this.checkObj3 = (d.getElementById && d.all) ? 1 :0;
	this.checkObj2 = (d.all && !d.getElementById) ? 1 :0;
	this.checkObj1 = d.layers ? 1 :0;

	this.modeStandard = d.compatMode == "CSS1Compat" ? 1 : 0;
	this.modeQuirks = d.compatMode == "BackCompat" ? 1 : 0;

	this.WinIE6s = (this.Win && this.IE && this.modeStandard && (uAgent.indexOf('MSIE 6.',0) != -1));
	this.WinIE6q = (this.Win && this.IE &&this. modeQuirks && (uAgent.indexOf('MSIE 6.',0) != -1));
	
	return this;
}

var usrs = new sniffer;
var fileUrl = location.href;
var checkAnchor = fileUrl.indexOf("#",0);
var checkPageScroller = fileUrl.match("pSc");
function resetPage(){
	if(!!checkPageScroller){
		anchorId = fileUrl.substring(fileUrl.lastIndexOf("?pSc")+4,fileUrl.length);
		timerID=setTimeout("toAnchor(anchorId)",400);
	}
	if(usrs.NS && !checkAnchor){
		window.scroll(0,0);
	}else return true;
}


/* anchor ----------------------------------------------- */
function GetScreenRealSize(type){
	if(type == "width"){
		return(screen.availWidth);
	}else if(type == "height"){
		return(screen.availHeight);
	}
}

function GetWindowRealSize(type){
	if(type == "width"){
		if(usrs.ICAB || usrs.OPERA){
			return(window.innerWidth);
		}else if(d.all){
			return(document.body.clientWidth);
		}else if(d.layers || d.getElementById){
			return(window.innerWidth);
		}
	}else if(type == "height"){
		if(usrs.ICAB || usrs.OPERA){
			return(window.innerHeight);
		}else if(d.all){
			return(document.body.clientHeight);
		}else if(d.layers || d.getElementById){
			return(window.innerHeight);
		}
	}
}

function getHeight(idName) {
	if(usrs.checkObj == 2){
		return d.all(idName).style.pixelHeight;
	}else if(usrs.checkObj == 3 || usrs.checkObj == 4){
		return parseInt(d.getElementById(idName).offsetHeight);
	}else if(usrs.checkObj == 1){
		return d.layers[idName].clip.height;
	}
}

function getWidth(idName) {
	if(usrs.checkObj == 2){
		return d.all(idName).style.pixelWidth;
	}else if(usrs.checkObj ==3 || usrs.checkObj ==4){
		return parseInt(d.getElementById(idName).offsetWidth);
	}else if(usrs.checkObj == 1){
		return d.layers[idName].clip.width;
	}
}

function getTop(idName){
	if(usrs.checkObj == 3 || usrs.checkObj == 4){
		return parseInt(d.getElementById(idName).style.top);
	}else if(usrs.checkObj == 2){
		return d.all(idName).style.pixelTop;
	}else if(usrs.checkObj == 1){
		return d.layers[idName].top;
		/*return d.layers[idName].pageX;*/
	}
}

function getLeft(idName){
	if(usrs.checkObj == 3 || usrs.checkObj == 4){
		return parseInt(d.getElementById(idName).style.left);
	}else if(usrs.checkObj == 2){
		return d.all(idName).style.pixelLeft;
	}else if(usrs.checkObj == 1){
		return d.layers[idName].left;
		/*return d.layers[idName].pageY;*/
	}
}

function getWindowWidth(){
	if(usrs.WinIE6s){
		return d.documentElement.clientWidth;
	}else if(usrs.OPERA || (usrs.Mac && (usrs.checkObj == 1 || usrs.OPERA))){
		return window.innerWidth;
	}else if(usrs.Win && usrs.checkObj == 1){
		return window.innerWidth - 16;
	}else if(usrs.checkObj == 4){
		return window.innerWidth - 15;
	}else if(usrs.checkObj == 2 || usrs.checkObj == 3){
		return d.body.clientWidth;
	}
}

function getWindowHeight(){
	if(usrs.WinIE6s){
		return d.documentElement.clientHeight;
	}else if(usrs.OPERA || (usrs.Mac && (usrs.checkObj == 1 || usrs.OPERA))){
		return window.innerHeight;
	}else if(usrs.Win && usrs.checkObj == 1){
		return window.innerHeight - 16;
	}else if(usrs.checkObj == 4){
		return window.innerHeight - 15;
	}else if(usrs.checkObj == 2 || usrs.checkObj == 3){
		return d.body.clientHeight;
	}
}

function getWindowXOffset(){
	if(usrs.WinIE6s && usrs.modeStandard){
		return d.body.parentNode.scrollLeft;
	}else if(usrs.checkObj == 2 || usrs.checkObj == 3){
		return d.body.scrollLeft;
	}else if(usrs.checkObj == 1 || usrs.checkObj == 4){
		return window.pageXOffset;
	}
}

function getWindowYOffset(){
	if(usrs.WinIE6s && usrs.modeStandard){
		return d.body.parentNode.scrollTop;
	}else if(usrs.checkObj == 2 || usrs.checkObj == 3){
		return d.body.scrollTop;
	}else if(usrs.checkObj == 1 || usrs.checkObj == 4){
		return window.pageYOffset;
	}
}

function getDocWidth(){
	if(usrs.allObj){
		return getTagLeft('end') + 1;
	}
}
function getDocHeight(){
	if(usrs.allObj){
		return getTagTop('end') + 1;
	}
}

function getDistanceMaxX(){
	if(usrs.allObj){
		return (getDocWidth() - getWindowWidth());
	}
}
function getDistanceMaxY(){
	if(usrs.allObj){
		return (getDocHeight() - getWindowHeight());
	}
}

function getVisibility(idName){
	if(usrs.checkObj == 2 || usrs.checkObj == 3){
		if(d.all(idName).style.visibility=='')return 'inherit'
		return d.all(idName).style.visibility
	}else if(usrs.checkObj == 4){
		if(d.getElementById(idName).style.visibility=='')return 'inherit'
		return d.getElementById(idName).style.visibility
	}else if(usrs.checkObj == 1){
		if(d.layers[idName].visibility=='show')return 'visible'
		if(d.layers[idName].visibility=='hide')return 'hidden'
		if(d.layers[idName].visibility=='inherit')return 'inherit'
	}
}

function setObj(idName){
	return d.all ? d.all(idName) : d.getElementById ? d.getElementById(idName) : d.layers[idName];
}

function getTagLeft(idName) {
	var obj = setObj(idName);
	var tagCoords = new Object();
	if((usrs.checkObj == 2) || (usrs.checkObj == 3) || (usrs.checkObj == 4)) {
		tagCoords.x = obj.offsetLeft;
		while ((obj = obj.offsetParent) != null) {
			tagCoords.x += obj.offsetLeft;
		}
	} else if(usrs.checkObj == 1) {
		tagCoords.x = d.anchors[idName].x;
	}if((tagCoords.x*0)==0){
		return tagCoords.x;
	}else{
		return idName;
	}
}

function getTagTop(idName) {
	var obj = setObj(idName);
	var tagCoords = new Object();
	if((usrs.checkObj == 2) || (usrs.checkObj == 3) || (usrs.checkObj == 4)) {
		tagCoords.y = obj.offsetTop;
		while ((obj = obj.offsetParent) != null) {
			tagCoords.y += obj.offsetTop;
		}
	} else if(usrs.checkObj == 1) {
		tagCoords.y = d.anchors[idName].y;
	}if((tagCoords.y*0) == 0){
		if(usrs.Mac && usrs.Moz){
			return (tagCoords.y - 12);
		}else if((usrs.Win && usrs.Moz) || (usrs.Mac && usrs.SAFARI)){
			return (tagCoords.y - 9);
		}else{
			return (tagCoords.y);
		}
	}else{
		return idName;
	}
}

var pageScrollTimer;
function pageScroll(toX,toY,frms,frX,frY) {
	if(pageScrollTimer) clearTimeout(pageScrollTimer);
	var spd = usrs.Moz?2:usrs.Mac ? 14 :16;
	var actX = getWindowXOffset();
	var actY = getWindowYOffset();
	if(!toX || toX < 0) toX = 0;
	if(!toY || toY < 0) toY = 0;
	if(!frms) frms = (usrs.Mac&&(usrs.OPERA||usrs.NS6))?3:usrs.NS6?4:usrs.NS?10:5;
	if(!frX) frX = 0 + actX;
	if(!frY) frY = 0 + actY;

	frX += (toX - actX) / frms;
	if (frX < 0) frX = 0;
	frY += (toY - actY) / frms;
	if (frY < 0) frY = 0;
	var posX = Math.ceil(frX);
	var posY = Math.ceil(frY);
	window.scrollTo(posX, posY);
	if((Math.floor(Math.abs(actX - toX)) < 1) && (Math.floor(Math.abs(actY - toY)) < 1)){
		clearTimeout(pageScrollTimer);
		window.scroll(toX,toY);
	}else if(posX != toX || posY != toY){
		pageScrollTimer = setTimeout("pageScroll("+toX+","+toY+","+frms+","+frX+","+frY+")",spd);
	}else{
		clearTimeout(pageScrollTimer);
	}
}

function toAnchor(idName,longitudinalAdj,traverser) {
	if(usrs.allObj){
		if(!!idName){
			var anchorX = traverser ? getTagLeft(idName) : 0;
			var anchorY = longitudinalAdj? getTagTop(idName)-longitudinalAdj : getTagTop(idName)-20;
			var dMaxX = getDistanceMaxX();
			var dMaxY = getDistanceMaxY();
			if(((anchorX*0) == 0)||((anchorY*0) == 0)){
				var setX = (anchorX<1)?0:(anchorX>dMaxX)?dMaxX:anchorX;
				var setY = (anchorY<1)?0:(anchorY>dMaxY)?dMaxY:anchorY;
				pageScroll(setX,setY);
			}else{
				location.hash = idName;
			}
		}else{
			pageScroll(0,0);
		}
	}else{
		!!idName ? location.hash = idName : location.hash = "top";
	}
}


/* swapImgChannel ----------------------------------------------- */
function openwin(url) {
	location.href=url;
}
function swapimg(url,src) {
	document.getElementById("urls").setAttribute("href",""+url+"");
	//document.getElementById("urls").setAttribute("href","javascript:openwin('"+url+"');");
	document.getElementById("image").src = src;
}


/* incuSwapImage ----------------------------------------------- */
function findObj(n, d) {
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function incuswapImage() {
	var i,j=0,x,a=incuswapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


/* openWin ----------------------------------------------- */
function openWindow(url,title,width,height,options) {
	var newWin;
	if (!!window && url) {
	if (!title) title = "blank";
	if (!options) options = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,favorites=no";
	var whop = "width="+width+",height="+height+","+options;
	newWin = window.open(url,title,whop);
	newWin.focus();
	newWin.moveTo(10, 10)
	}
}


/* formpulldown ----------------------------------------------- */
function navi(obj) {
 url = obj.options[obj.selectedIndex].value;
 if(url != "") {
   location.href = url;
  }
}

