// RealRead Viewer JavaScript
// 2006.6.21

//
// initial
//
var init = false;
var macos = false;
var lang = "";

function initial() {
	trap_mouse_key_events();
	if(navigator.userAgent.indexOf("Mac") != -1) {
		macos = true;
	}
//	if(navigator.javaEnabled() == false) {
	if(document.applets.length < 1) {
		if(lang == "ja") {
			alert("Javaアプレットを実行できません");
		} else {
			alert("Java applet does not work.");
		}
		return false;
	}
	init = true;
	return true;
}

function initial_ja() {
	setLang("ja");
	initial();
}

//
// setLang
//
function setLang(set) {
	lang = set;
}

//
// trap_mouse_key_events
//
var alertmsg = ""
var ie = false
var nn = false
function trap_mouse_key_events(){
	ie = (navigator.appName.indexOf("Microsoft") != -1)
	nn = (navigator.appName.indexOf("Netscape") != -1)
	if(nn){
		document.captureEvents(Event.MOUSEDOWN)
		document.onmousedown = mousedown
	}
	if(ie) {
		document.onkeydown = keydown
		document.onmousedown = mousedown
	}
	if(lang == "ja") {
		alertmsg ="右クリックを許可していません";
	} else {
		alertmsg ="Right Mouse Button Is Disabled";
	}
}

function mousedown(e){
	if(ie){
		e = window.event
		if(e.button >= 2){
			alert(alertmsg)
			return false
		}
	}
	if(nn) {
		if(e.which == 3) {
			alert(alertmsg)
			return false
		}
	}
	return true
}

function keydown(){
	if(ie){
		if(event.keyCode == 93) {
			alert(alertmsg)
		}
		if(event.shiftKey && event.keyCode == 121) {
			alert(alertmsg)
		}
	}
}

//
// Applet tag
//
function appletTag(codeBase, width, height, session, folder, userAgent, openPage, param1, param2, param3, appLang) {
	document.write( '<applet name="RRViewer" codebase="' + codeBase + '"' 
					+ 'archive="RRViewer.jar" code="PageViewer.class" ' 
					+ 'width="' + width + '" height="' + height + '">' + '\n');
	document.write( '<param name="SESSION" value="' + session + '">' + '\n');
	document.write( '<param name="FOLDER" value="' + folder + '">' + '\n');
	document.write( '<param name="USER_AGENT" value="' + userAgent + '">' + '\n');
	if (openPage != "null" &&  openPage != "") {
		document.write( '<param name="OPENPAGE" value="' + openPage + '">' + '\n');
	}
	if (param1 != "null" &&  param1 != "") {
		document.write( '<param name="PARAM1" value="' + param1 + '">' + '\n');
	}
	if (param2 != "null" &&  param2 != "") {
		document.write( '<param name="PARAM2" value="' + param2 + '">' + '\n');
	}
	if (param3 != "null" &&  param3 != "") {
		document.write( '<param name="PARAM3" value="' + param3 + '">' + '\n');
	}
	if(appLang == "ja") {
		document.write( '<b>Javaアプレットを実行できません</b><br>' + '\n');
		document.write( '<a href="http://www.java.com/" target="_blank"><b>' );
		document.write( 'Javaアプレットが起動しない場合はこちらをクリックして下さい' );
	} else {
		document.write( '<b>Java applet does not work.</b><br>' + '\n');
		document.write( '<a href="http://www.java.com/" target="_blank"><b>' );
		document.write( 'CLICK HERE IF GETTING JAVA ERROR MESSAGE OR JAVA IS NOT STARTING PROPERLY' );
	}
	document.write( '</b></a><br>' + '\n');
	document.write( '</applet>' + '\n');
}



