// nvIR.js Version 1.2.3
// 2011-02-25
// www.synck.com

var nvIRObj = new Object();

nvIRObj.imageRoot = '/images/';
nvIRObj.pulldown = null;
nvIRObj.pulldownHN = null;
nvIRObj.pulldownTimer = 2000;
nvIRObj.opacityTime = 70;

// SoundEffect disabled = false;
nvIRObj.SoundEffect = true;

nvIRObj.currentId = "";

if(navigator.userAgent.indexOf("MSIE") > -1)
	nvIRObj.lang = navigator.browserLanguage.toLowerCase();
else
	nvIRObj.lang = navigator.language.toLowerCase()

//nvIRObj.lang = "en";

if(nvIRObj.lang.indexOf('ja') > -1 || nvIRObj.lang.indexOf('jp') > -1)
	nvIRObj.lang = "";
else
	nvIRObj.lang = "e_";

function nvIR_onload(){
	var d = window.document;
	var aObjects = d.getElementsByTagName("a");
	for (i=0;i<aObjects.length;i++) {
		if(aObjects[i].className == "nvIR"){
			aObjects[i].style.backgroundImage = 'url('+nvIRObj.imageRoot+nvIRObj.lang+aObjects[i].id+'.gif)';
			aObjects[i].style.display = "block";
			if(nvIRObj.lang == "")
				aObjects[i].style.textIndent = "-5000px";
			aObjects[i].style.height = aObjects[i].rel + "px";
			if(location.href.replace("index.html","").split(document.domain)[1] == aObjects[i].href.replace("index.html","").split(document.domain)[1])
				aObjects[i].style.backgroundPosition = "0px "+((aObjects[i].rel*2)*-1)+"px";
			else if(location.href.replace("index.html","").split(document.domain)[1] != "/" && location.href.replace("index.html","").split(document.domain)[1].indexOf(aObjects[i].href.replace("index.html","").split(document.domain)[1]) > -1)
				aObjects[i].style.backgroundPosition = "0px "+((aObjects[i].rel*2)*-1)+"px";
			//
			aObjects[i].onmouseover = function(){
				nvIR_over(this);
			}
			aObjects[i].onmouseout = function(){
				nvIR_out(this);
			}
			aObjects[i].onmousedown = function(){
				nvIR_down(this);
			}
			aObjects[i].onmouseup = function(){
				nvIR_up(this);
			}
		}
		else if(aObjects[i].className == "nvIRPDn"){
			aObjects[i].onmouseover = function(){
				nvIR_puldown_over();
			}
			aObjects[i].onmouseout = function(){
				nvIR_puldown_out();
			}
		}
		if(aObjects[i].rel == "external")
			aObjects[i].target = '_blank';
		//if(aObjects[i].href.indexOf('https://') > -1)
			//aObjects[i].href = aObjects[i].href.replace('https','http');
	}
	try {
		var bodyObj = d.getElementsByTagName("body").item(0);
		var audioObj = d.createElement('audio');
		if(navigator.userAgent.indexOf("Safari") > -1 && navigator.userAgent.indexOf("Chrome") == -1)
			audioObj.src = nvIRObj.imageRoot + "click.wav";
		else
			audioObj.src = nvIRObj.imageRoot + "click.ogg";
		audioObj.id = 'clickSE';
		audioObj.autobuffer = true;
		bodyObj.appendChild(audioObj);
		d.getElementById('clickSE').load();
	}
	catch (e) {
		nvIRObj.SoundEffect = false;
	}
}
function nvIR_up(obj){
	if(location.href.replace("index.html","").split(document.domain)[1] == obj.href.replace("index.html","").split(document.domain)[1])
		obj.style.backgroundPosition = "0px "+((obj.rel*2)*-1)+"px";
	else if(location.href.replace("index.html","").split(document.domain)[1] != "/" && location.href.replace("index.html","").split(document.domain)[1].indexOf(obj.href.replace("index.html","").split(document.domain)[1]) > -1)
		obj.style.backgroundPosition = "0px "+((obj.rel*2)*-1)+"px";
}
function nvIR_down(obj){
	var d = window.document;
	if(nvIRObj.SoundEffect)
		d.getElementById('clickSE').play();
	obj.style.backgroundPosition = "0px "+((obj.rel*3)*-1)+"px";
	return false;
}
function nvIR_over(obj){
	var d = window.document;
	if(nvIRObj.pulldownHN != null)
		clearTimeout(nvIRObj.pulldownHN);
	if(obj.href != location.href && location.href.replace("index.html","").split(document.domain)[1].indexOf(obj.href.replace("index.html","").split(document.domain)[1]) == -1)
		obj.style.backgroundPosition = "0px "+((obj.rel)*-1)+"px";
	if(nvIRObj.pulldown != null && nvIRObj.pulldown != obj.id && obj.id.indexOf(nvIRObj.pulldown) == -1)
		nvIR_hide_pulldown(nvIRObj.pulldown);
	if(d.getElementById("pd_"+obj.id+"_navigator") && nvIRObj.currentId != obj.id){
		nvIRObj.pulldown = obj.id;
		d.getElementById("pd_"+obj.id+"_navigator").style.display = "block";
		nvIR_setOpacity("pd_"+obj.id+"_navigator",50);
		setTimeout('nvIR_setOpacity("pd_'+obj.id+'_navigator",100)',nvIRObj.opacityTime);
		if(d.getElementById("pd_"+obj.id+"_background")){
			d.getElementById("pd_"+obj.id+"_background").style.display = "block";
			nvIR_setOpacity("pd_"+obj.id+"_background",50);
			setTimeout('nvIR_setOpacity("pd_'+obj.id+'_background",100)',nvIRObj.opacityTime);
		}
		nvIRObj.currentId = obj.id;
	}
}
function nvIR_out(obj){
	if(typeof obj != "undefined" && obj != null){
		if(obj.href != location.href && location.href.replace("index.html","").split(document.domain)[1].indexOf(obj.href.replace("index.html","").split(document.domain)[1]) == -1 && obj.id != nvIRObj.pulldown)
			obj.style.backgroundPosition = "0px 0px";
		if(nvIRObj.pulldown != null)
			nvIRObj.pulldownHN = setTimeout("nvIR_hide_pulldown('"+nvIRObj.pulldown+"')",nvIRObj.pulldownTimer);
	}
}
function nvIR_puldown_over(){
	if(nvIRObj.pulldownHN != null){
		clearTimeout(nvIRObj.pulldownHN);
	}
}
function nvIR_puldown_out(){
	if(nvIRObj.pulldownHN != null)
		clearTimeout(nvIRObj.pulldownHN);
	nvIRObj.pulldownHN = setTimeout("nvIR_hide_pulldown('"+nvIRObj.pulldown+"')",nvIRObj.pulldownTimer);
}
function nvIR_hide_pulldown(id){
	var d = window.document;
	if(nvIRObj.pulldownHN != null)
		clearTimeout(nvIRObj.pulldownHN);
	nvIRObj.pulldown = null;
	nvIR_out(d.getElementById(id));
	if(d.getElementById("pd_"+id+"_background")){
		nvIR_setOpacity("pd_"+id+"_navigator",50);
		setTimeout('document.getElementById("pd_'+id+'_background").style.display="none"',nvIRObj.opacityTime);
		setTimeout('nvIR_setOpacity("pd_'+id+'_background",0)',nvIRObj.opacityTime);
	}
	if(d.getElementById("pd_"+id+"_navigator")){
		nvIR_setOpacity("pd_"+id+"_navigator",50);
		setTimeout('document.getElementById("pd_'+id+'_navigator").style.display="none"',nvIRObj.opacityTime);
		setTimeout('nvIR_setOpacity("pd_'+id+'_navigator",0)',nvIRObj.opacityTime);
	}
	nvIRObj.currentId = "";
}
function nvIR_setOpacity(id,opt){
	var d = window.document;
	if(navigator.appVersion.indexOf("Safari") > -1 || navigator.userAgent.indexOf("Opera") > -1)
		d.getElementById(id).style.opacity = (opt/100);
	else if(navigator.userAgent.indexOf('Gecko') != -1)
		d.getElementById(id).style.MozOpacity = (opt/100);
}
try{
	window.addEventListener("load",function(){nvIR_onload();},false);
}
catch(e){
	window.attachEvent("onload",function(){nvIR_onload();});
}

//addEventSet(window,"load",function(){nvIR_onload();});
//$(document).ready(nvIR_onload);
