// converted to jquery

var site_index = '';
//var base_site = '192.168.1.3';
var base_site = 'anne-davis.co.uk';
//var site = 'http://'+base_site+'/anned/public_html/'+site_index; 
var site = 'http://'+base_site+'/'+site_index;
var page = window.location.href;
if(page.substr(-1,1) != '/') page = page+'/';

function logger(text)
{
	if(window.console) console.log(text);
}

function window_dims()
{
	ww = ($(window).width() == 0) ? $(window).scrollWidth-22 : $(window).width();
	wh = ($(window).height() == 0) ? $(window).scrollHeight : $(window).height();
	st = $(document.body).scrollTop()  || $(document.documentElement).scrollTop();
	topp = st + (wh / 10);
}

function event_stop(evt)
{	
	new Event(evt).stop();
}

var external_links = new Array();

function get_externals()
{
	var append_text = '(opens in new window/tab)';
	
	// traverse the links	
	$('a').each(function()
	{
		var link = $(this);
		
		// If the element doesn't have an href, skip it.
		if(link.attr("href") && !link.hasEvent('click'))
		{
			
			// if link is 'external' attach the onclick handler. 
			if ((link.attr("href").indexOf('http:\/\/') != -1 && link.attr("href").indexOf(base_site) == -1 && link.attr("href").indexOf("www." + base_site) == -1 && !link.hasClass('same_window')) || link.hasClass('new_window'))
			{
				link.attr('title',link.attr('title')+' '+append_text); 
				link.click(new_win);
			}
		}
	});	
}

/*$(document).ready(function()
{
	get_externals();
});*/
	
function new_win(evt) 
{
	logger(evt);
	
	// Open a new window with the link's href.
	var newwin = window.open($(evt.target).attr("href"));

	// return the inverse (if it didn't work will return true so that link opens)
	return !newwin;
}

// adds element.hasEvent('click') to element.Event
//(function(A){A.fn.hasEvent=function(C){var B=this.data("events");return(B&&B[C])}})(jQuery)
