/*change picture on mouse in */
function imgHover(image,menuID)
{
    if (document.body)
    {
        element = document.getElementById(menuID);
        element.src = image;
    }
}

/*preloads Images */
var myimages=new Array()
function preloadimages(){
    for (i=0;i<preloadimages.arguments.length;i++){
        myimages[i]=new Image()
        myimages[i].src=preloadimages.arguments[i]
    }
}

/*checks if link is external, adds external class if true, do not apply if there is an image inside the link */
this.blankwin = function(){
	var hostname = window.location.hostname;
	hostname = hostname.replace("www.","").toLowerCase();
	var a = document.getElementsByTagName("a");	
	this.check = function(obj){
		var href = obj.href.toLowerCase();
		var firstchild = obj.firstChild;
		if (firstchild == null){
		return false;}else{
		
		return (firstchild.tagName != "IMG" && href.indexOf("http://")!=-1 && href.indexOf(hostname)==-1) ? true : false;
		}
					
	};
	this.set = function(obj){
		obj.target = "_blank";
		obj.className = "external";
	};	
	for (var i=0;i<a.length;i++){
		if(check(a[i])) set(a[i]);
	};		
};

this.addEvent = function(obj,type,fn){
if(obj.attachEvent){
    obj['e'+type+fn] = fn;
    obj[type+fn] = function(){obj['e'+type+fn](window.event );}
    obj.attachEvent('on'+type, obj[type+fn]);
} else {
    obj.addEventListener(type,fn,false);
    };
};

addEvent(window,"load",blankwin);


