// nvIR.js extension
// www.synck.com

var nvIRObj = new Object();
nvIRObj.imageRoot = "/images/";

// code example
// <a href="index.html" id="nv_01" rel="50" class="nvIR">context</a>
// rel ... button height
// id ... /images/"nv_01".gif
// code example eof

function addEventSet(elm,listener,fn){
	try{
		elm.addEventListener(listener,fn,false);
	}
	catch(e){
		elm.attachEvent("on"+listener,fn);
	}
}
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+aObjects[i].id+'.jpg)';
			aObjects[i].style.display = "block";
			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";
		}
	}
	$("a.nvIR").mouseover(function(){
		nvIR_over(this);
	});
	$("a.nvIR").mouseout(function(){
		nvIR_out(this);
	});
	$("a.nvIR").click(function(){
		nvIR_out(this);
	});
}
function nvIR_over(obj){
	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";
}
function nvIR_out(obj){
	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 0px";
}
//addEventSet(window,"load",function(){nvIR_onload();});
$(document).ready(nvIR_onload);
