function selectCSS(){
	if (document.styleSheets){
		if (document.styleSheets[0]&&document.styleSheets[1]){
			if (parent.jpsub){
				document.styleSheets[0].disabled = true;
				document.styleSheets[1].disabled = false;
			}else{
				document.styleSheets[0].disabled = false;
				document.styleSheets[1].disabled = true;
			}
		}
	}
}

function turnImgOn(imgName) {
	if (document.images){		
		document[imgName].src = eval(imgName + '_on.src');
	}
}
		
function turnImgOff(imgName) {
	if (document.images){		
		document[imgName].src = eval(imgName + '_off.src');
	}
}

function writeSubtitle(jpsubtitle){
	if (parent.jpsub){
		parent.jpsub.document.JPFORM.jpform.value=jpsubtitle;
	}
}

function dir_depth(){
	
	var thePathname = location.pathname.replace(/\/www/, "");
	thePathname = thePathname.replace(/\/cgi-bin.*/, "");

/*	var thePathname = location.pathname;*/
	
	if (thePathname.lastIndexOf("/") + 1 == thePathname.length){
		var result = thePathname.split("/").length;
	}else{
		var result = thePathname.split("/").length - 1;
	}
	return result;
}

function check_for_frame(){
	if (navigator.userAgent.indexOf("Opera")>=0){
		return 0;
	}else if (navigator.userAgent.indexOf("Gecko")>=0){
		return 1;
	}else if (navigator.userAgent.indexOf("MSIE 5.")>=0 && navigator.userAgent.indexOf("Mac")>=0){
		return 2;
	}else{
		return 0;
	}
}

function openFAuthorW(){
	var d = dir_depth() -1;
	var dstring = "";
	for (i=0; i < d; i++){
		dstring = "../" + dstring;
	}
	var FAuthorUrl = dstring + "misc/fromAuthor.shtml";
	var FAuthorW;
	FAuthorW= window.open(FAuthorUrl,"window2","toolbar=no,location=no,status=yes,scrollbars=no,width=300,height=430");
	if(!((navigator.appName.indexOf("Net")>=0) && ((navigator.appVersion.indexOf("Win")>=0) || (navigator.appVersion.indexOf("5.0")>=0)))){
		FAuthorW.focus();
	}
}

function addMouseMove(){
	if (check_for_frame() > 0){ 
		if (check_for_frame() == 1){
			window.addEventListener("mousemove", writeCurPos, true);
		}else if(check_for_frame() == 2){
			document.onmousemove = writeCurPos;
		}
		if (document.FIGURE.figure){
			document.FIGURE.figure.value = "0 0";
		}
	}
}

var stop_sDown = 0;
var stop_sUp = 0;
var onScrolling = 0;
var i = 0;
var sc_unit = 10;

function startScroll(direction){
	if (!onScrolling){
		i = 0;
		if (direction == "down"){
			stop_sUp = 1;
			stop_sDown = 0;
			if (document.images){
				document.scrdown.src = down_on.src;
				document.scrup.src = up_off.src;
			}
		}else{
			stop_sDown = 1;
			stop_sUp = 0;
			if (document.images){
				document.scrup.src = up_on.src;
				document.scrdown.src = down_off.src;
			}	
		}
	}
}

function startScrollOn(direction){
	i = 0;
	onScrolling = 1;
	if (direction == "down"){
		stop_sUp = 1;
		stop_sDown = 0;
		if (document.images){
			document.scrdown.src = down_on.src;
			document.scrup.src = up_off.src;
		}
	}else{
		stop_sDown = 1;
		stop_sUp = 0;
		if (document.images){
			document.scrup.src = up_on.src;
			document.scrdown.src = down_off.src;
		}	
	}
}

function stopScroll(direction){
	if (!onScrolling){
			stop_sUp = 1;
			stop_sDown = 1;
		if (document.images){
			document.scrdown.src = down_off.src;
			document.scrup.src = up_off.src;
		}
	}
}

function getPageOffset(axis){
	if (axis == "x"){
		if (check_for_frame() == 1){
			return self.pageXOffset;
		}else if (check_for_frame() == 2){
			return document.body.scrollLeft;
		}
	}else{
		if (check_for_frame() == 1){
			return self.pageYOffset;
		}else if (check_for_frame() == 2){
			return document.body.scrollTop;
		}
	}
}

function scrollDownOn(amount,speed){
	var cpXO = getPageOffset('x');
	var cpYO = getPageOffset('y');
	var curPosY = eval(document.FIGURE.figure.value.split(" ")[1]) - cpYO;
	
	currentAmount = amount;
	currentSpeed = speed;
	
	if (!stop_sDown){
		if (i < amount/sc_unit){
			window.scroll(cpXO,cpYO + sc_unit);
			if (document.FIGURE.figure.value.split(" ")[1] != eval(curPosY + getPageOffset('y'))){
				document.FIGURE.figure.value = document.FIGURE.figure.value.split(" ")[0] + " " + eval(curPosY + getPageOffset('y'));
				setTimeout('scrollDownOn(currentAmount, currentSpeed)', speed /1.5);
				i++;
			}else{onScrolling = 0; stopScroll('down');}
		}else{onScrolling = 0; stopScroll('down');}
	}
}

function scrollDown(speed){
	if (!onScrolling){
		var cpXO = getPageOffset('x');
		var cpYO = getPageOffset('y');
		var curPosY = eval(document.FIGURE.figure.value.split(" ")[1]) - cpYO;
		
		currentSpeed = speed;
		
		if (!stop_sDown && i < 10000){
			window.scroll(cpXO,cpYO + sc_unit);
			if (document.FIGURE.figure.value.split(" ")[1] != eval(curPosY + getPageOffset('y'))){
				document.FIGURE.figure.value = document.FIGURE.figure.value.split(" ")[0] + " " + eval(curPosY + getPageOffset('y'));
				setTimeout('scrollDown(currentSpeed)', speed);
				i++;
			}else{stopScroll('down');}
		}else{stopScroll('down');}
	}
}

function scrollUpOn(amount,speed){
	var cpXO = getPageOffset('x');
	var cpYO = getPageOffset('y');
	var curPosY = eval(document.FIGURE.figure.value.split(" ")[1]) - cpYO;
	
	currentAmount = amount;
	currentSpeed = speed;
	
	if (!stop_sUp){
		if (i < amount/sc_unit){
			window.scroll(cpXO,cpYO - sc_unit);
			if (document.FIGURE.figure.value.split(" ")[1] != eval(curPosY + getPageOffset('y'))){
				document.FIGURE.figure.value = document.FIGURE.figure.value.split(" ")[0] + " " + eval(curPosY + getPageOffset('y'));
				setTimeout('scrollUpOn(currentAmount, currentSpeed)', speed /1.5);
				i++;
			}else{onScrolling = 0; stopScroll('up');}
		}else{onScrolling = 0; stopScroll('up');}
	}
}

function scrollUp(speed){
	if (!onScrolling){
		var cpXO = getPageOffset('x');
		var cpYO = getPageOffset('y');
		var curPosY = eval(document.FIGURE.figure.value.split(" ")[1]) - cpYO;
	
		currentSpeed = speed;
	
		if (!stop_sUp && i < 10000){
			window.scroll(cpXO,cpYO - sc_unit);
			if (document.FIGURE.figure.value.split(" ")[1] != eval(curPosY + getPageOffset('y'))){
				document.FIGURE.figure.value = document.FIGURE.figure.value.split(" ")[0] + " " + eval(curPosY + getPageOffset('y'));
				setTimeout('scrollUp(currentSpeed)', speed);
				i++;
			}else{stopScroll('up');}
		}else{stopScroll('up');}
	}
}

function draw_frame(amount,speed){
	var d = dir_depth() -1;
	var dstring = "";
	for (i=0; i < d; i++){
		dstring = "../" + dstring;
	}
	 
	if (check_for_frame() > 0){
		document.write('<DIV ID=\"top-left\" STYLE=\"top:20px; left:30px; position:fixed; z-index:2; visibility:visible;\">\n');
		document.write('<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR>\n');
		document.write('<TD WIDTH=\"82\" HEIGHT=\"10\" STYLE=\"border-style:ridge; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; border-right-width:0px;\" ALIGN=\"left\" VALIGN=\"bottom\">\n');
		document.write('<A HREF=\"');
		document.write(dstring);
		document.write('index1.shtml\" CLASS=\"frame\" TARGET=\"_self\"><SPAN CLASS=\"frame\" LANG=\"en\">INDEX</SPAN></A>\n');
		document.write('</TD></TR><TR><TD HEIGHT=\"82\" STYLE=\"border-style:ridge; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; border-right-width:0px;\" ALIGN=\"left\" VALIGN=\"top\">\n');
		document.write('<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"2\"><TR>\n');
		document.write('<TD WIDTH=\"80\" HEIGHT=\"80\" STYLE=\"border-style:ridge; border-top-width:1px; border-bottom-width:0px; border-left-width:1px; border-right-width:0px;\" ALIGN=\"right\" VALIGN=\"top\">\n');

		document.write('<A HREF=\"');
		document.write(dstring);
		document.write('index1.shtml#bio\" CLASS=\"frame\" TARGET=\"_self\"><SPAN CLASS=\"frame\" LANG=\"en\">about the author</SPAN></A>\n');

		document.write('</TD></TR></TABLE>\n</TD></TR></TABLE></DIV>\n');
		
		document.write('<DIV ID=\"top-right\" STYLE=\"top:20px; right:30px; position:fixed; z-index:2; visibility:visible;\">\n');
		document.write('<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR>\n');
		document.write('<TD WIDTH=\"82\" HEIGHT=\"10\" STYLE=\"border-style:ridge; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; border-right-width:0px;\" ALIGN=\"right\" VALIGN=\"bottom\">\n');
		document.write('<A HREF=\"http://www.kay-n.com/guestbook.shtml\" CLASS=\"frame\" TARGET=\"_blank\"><SPAN CLASS=\"frame\" LANG=\"en\">GREENROOM</SPAN></A>\n');
		document.write('</TD></TR><TR><TD HEIGHT=\"82\" STYLE=\"border-style:ridge; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; border-right-width:0px;\" ALIGN=\"right\" VALIGN=\"top\">\n');

		document.write('<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"2\"><TR>\n');
		document.write('<TD WIDTH=\"80\" HEIGHT=\"80\" STYLE=\"border-style:ridge; border-top-width:1px; border-bottom-width:0px; border-left-width:0px; border-right-width:1px;\" ALIGN=\"left\" VALIGN=\"top\">\n');

		document.write('<A HREF=\"');
		document.write('javascript://\" onClick=\"openFAuthorW();\" CLASS=\"frame\" TARGET=\"_self\"><SPAN CLASS=\"frame\" LANG=\"en\">about this site</SPAN></A>\n');

		document.write('</TD></TR></TABLE>\n</TD></TR></TABLE></DIV>\n');

		document.write('<DIV ID=\"bottom-left\" STYLE=\"bottom:10px; left:30px; position:fixed; z-index:2; visibility:visible;\">\n');
		document.write('<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR>\n');
		document.write('<TD WIDTH=\"82\" HEIGHT=\"82\" STYLE=\"border-style:ridge; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; border-right-width:0px;\" ALIGN=\"left\" VALIGN=\"top\">\n');

		document.write('<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"2\"><TR>\n');
		document.write('<TD WIDTH=\"80\" HEIGHT=\"80\" STYLE=\"border-style:ridge; border-top-width:0px; border-bottom-width:1px; border-left-width:1px; border-right-width:0px;\"><BR></TD>\n');
		document.write('</TR></TABLE></TD></TR><TR>\n');
		document.write('<TD HEIGHT=\"20\" STYLE=\"border-style:ridge; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; border-right-width:0px;\" ALIGN=\"left\" VALIGN=\"top\">');
		document.write('<FORM NAME=\"FIGURE\"><INPUT TYPE=\"text\" CLASS=\"nocolumn\" NAME=\"figure\" VALUE=\"\" SIZE=\"10\" onFocus=\"blur\(\)\" READONLY></FORM>\n');

/*		document.write(d + '\n');*/

		document.write('</TD>\n');
		document.write('</TR></TABLE></DIV>\n');
		
		document.write('<DIV ID=\"bottom-right\" CLASS=\"frame\" STYLE=\"bottom:10px; right:30px; position:fixed; z-index:2; visibility:visible;\">\n');
		document.write('<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR>\n');
		document.write('<TD WIDTH=\"82\" HEIGHT=\"82\" STYLE=\"border-style:ridge; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; border-right-width:0px;\" ALIGN=\"right\" VALIGN=\"top\">\n');

		document.write('<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"2\"><TR>\n');
		document.write('<TD WIDTH=\"80\" HEIGHT=\"80\" STYLE=\"border-style:ridge; border-top-width:0px; border-bottom-width:1px; border-left-width:0px; border-right-width:1px;\"><BR></TD>\n');
		document.write('</TR></TABLE></TD></TR><TR>\n');
		document.write('<TD HEIGHT=\"20\" STYLE=\"border-style:ridge; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; border-right-width:0px;\" ALIGN=\"right\" VALIGN=\"top\">');
		document.write('<A HREF=\"javascript://\" onClick=\"startScrollOn\(\'down\'\); scrollDownOn\(');
		document.write(amount);
		document.write(',');
		document.write(speed);
		document.write('\);\" onMouseOver=\"startScroll\(\'down\'\); scrollDown\(');
		document.write(speed);
		document.write('\); window.status=\'\';  return true\" onMouseOut=\"stopScroll\(\'down\'\)\">');
		document.write('<IMG SRC=\"');
		document.write(dstring);
		document.write('images/frame/down_off.gif\" NAME=\"scrdown\" WIDTH=\"11\" HEIGHT=\"10\" BORDER=\"0\"></A>\n');
		document.write('<A HREF=\"javascript://\" onClick=\"startScrollOn\(\'up\'\); scrollUpOn\(');
		document.write(amount);
		document.write(',');
		document.write(speed);
		document.write('\);\" onMouseOver=\"startScroll\(\'up\'\); scrollUp\(');
		document.write(speed);
		document.write('\); window.status=\'\';  return true\" onMouseOut=\"stopScroll\(\'up\'\)\">');
		document.write('<IMG SRC=\"');
		document.write(dstring);
		document.write('images/frame/up_off.gif\" NAME=\"scrup\" WIDTH=\"11\" HEIGHT=\"10\" BORDER=\"0\"></A>\n');
		document.write('</TD></TR></TABLE></DIV>\n');
		
		document.write('<SCRIPT TYPE=\"text/javascript\" LANGUAGE=\"Javascript1.2\"><!--\n');
		document.write('function writeCurPos\(event\){\n');
		document.write('	if \(check_for_frame\(\) == 1\){\n');
		document.write('		Xpos = event.clientX + self.pageXOffset;\n');
		document.write('		Ypos = event.clientY + self.pageYOffset;\n');
		document.write('	}else if\(check_for_frame\(\) == 2\){\n');
		document.write('		Xpos = window.event.clientX+ document.body.scrollLeft;\n');
		document.write('		Ypos = window.event.clientY + document.body.scrollTop;\n');
		document.write('	}\n');
		document.write('	if \(document.FIGURE.figure\){\n');
		document.write('		document.FIGURE.figure.value=Xpos + \" \" + Ypos;\n');
		document.write('	}}//--></SCRIPT>\n');
	}
}
