/* 

	Blankwin function 
	written by Alen Grakalic, provided by Css Globe (cssglobe.com)
	Modified by Matthew McDougall (http://www.matthewmcdougall.com) to include customisable javascript popup message before page load.
	
*/

var popMessage = 'You are now leaving the Sothertons Chartered Accountants website. Neither Sothertons Chartered Accountants nor IGAF Worldwide are responsible for the content of the site you are visiting.';

var secondaryMessage = 'Please Note: We are currently updating this document to include the latest Budgetary information released on May 12, 2009';

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();
		return (href.indexOf("http://")!=-1 && href.indexOf(hostname)==-1) ? true : false;				
	};
	this.check2 = function(obj){
		var id = obj.id;
		return (id=='secondMessage') ? true : false;				
	};
	this.message = function(obj){
	    alert(popMessage);
	}
	this.message2 = function(obj){
	    alert(secondaryMessage);
	}
	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]);
		    if(a[i].id!='off'){
		      a[i].onclick = message;	
	      }
	    };
	    if(check2(a[i])) { 
		    set(a[i]);
		    if(a[i].id!='off'){
		      a[i].onclick = message2;	
	      }
	    };
	};		
};



// script initiates on page load. 

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);