// JavaScript Document

	// english page setting //
/*
	// {"go_to_page_uri" : "access_page_uri",  ...}

*/
	var e_pages = {
	  "/en/support/form/inquiries/index.php" : "/support/form/inquiries/index.php"
	}


	var server_name = "www15.j-server.com";
	var english_path = "/LUCLIHIT/ns/tl_ex.cgi/http%3a//www.lihit-lab.com";

	// end of settings //


function GetTranslatesUrl( url, lang ){
	if( typeof(RegExp) != "undefined" ){

		re = new RegExp("^http:\/\/www\.lihit-lab\.com");

		if( url.match( re ) ){
			var e = (window.event)? window.event : arguments.callee.caller.arguments[0] ;
			var self = e.target || e.srcElement;
			while(self && self.tagName!='A') {
				self=self.parentNode;
			}
			transUrl = "http://www15.j-server.com/LUCLIHIT/ns/tl_ex.cgi?SURL=http://www15.j-server.com/LUCLIHIT/ns/warning_mess4.cgi%3furl="+url+"%26target=_top&SLANG=ja&TLANG="+lang+"&XMODE=0";
//			transUrl = "http://www15.j-server.com/LUCLIHIT/ns/tl_ex.cgi?SURL=http://www15.j-server.com/LUCLIHIT/ns/warning_mess4.cgi%3furl=http://www.lihit-lab.com/%26target=_top&SLANG=ja&TLANG=en&XMODE=0";
			self.href = transUrl;
			return true;
		} else {
			transre = new RegExp("^http:\/\/www15\.j-server\.com");									//2011/07/06 KODENSHA
			if( url.match( transre ) ){																//2011/07/06 KODENSHA
				orgurl=url.replace("http:\/\/www15\.j-server\.com\/LUCLIHIT\/ns\/tl\.cgi/","");		//2011/07/06 KODENSHA
				orgurl=orgurl.replace("?SLANG=ja*$","");											//2011/07/06 KODENSHA
				var e = (window.event)? window.event : arguments.callee.caller.arguments[0] ;		//2011/07/06 KODENSHA
				var self = e.target || e.srcElement;												//2011/07/06 KODENSHA
				while(self && self.tagName!='A') {													//2011/07/06 KODENSHA
					self=self.parentNode;															//2011/07/06 KODENSHA
				}																					//2011/07/06 KODENSHA
				transUrl = "http://www15.j-server.com/LUCLIHIT/ns/tl_ex.cgi?SURL=http://www15.j-server.com/LUCLIHIT/ns/warning_mess4.cgi%3furl=" + orgurl + "%26target=_top&SLANG=ja&TLANG=en&XMODE=0";																			//2011/07/06 KODENSHA
				self.href = transUrl;
			}
			return true;
		}
	} else {
		return true;
	}
}


// from j_server only //
if(location.hostname == "www15.j-server.com"){
	// if english_page exists, move to english_page

	var ar_pages = new Array();
	for (key in e_pages) {
        ar_pages[english_path + key] = english_path + e_pages[key]
    } 

//	console.log(ar_pages);
//	console.log(array_search(location.pathname , ar_pages));
	if(array_search(location.pathname , ar_pages)){
	    location.href = "http://" + server_name + array_search(location.pathname , ar_pages);
	}
	

	// read english page css
	document.write('<link rel="stylesheet" href="/css/en.css" type="text/css" media="screen,tv,print" />');

	$(document).ready(function(){
		// img re-load
		$("img").each(function(){
			if($(this).attr("src").match("_jp\.")){
				$(this).attr("src" , RegExp.leftContext + "_en." + RegExp.rightContext);
			}
	  	});


		// change submit botton label
		$("input[type='submit']").attr({"value":"search"});

	});
	
	
	
	
}

function array_search (needle, haystack ) {
    var key = '';
    for (key in haystack) {
        if ((haystack[key] === needle)) {
			return key;
        }
    } 
return false;
}


