var addthis_share = {
	url: "http://www.jamesboagspure.com.au/"
}
var componentHasInitialised = false;

$(document).ready(function() {
	// ie6 png fix
	$.ifixpng('/assets/images/pixel.gif');
	$('.mask-left, .mask-right').ifixpng();
	
	$('a[rel=popup]').click(function(event) {		
		var url 	= event.target.href;
		var width 	= getURLParameter('w', url);
		var height 	= getURLParameter('h', url);
		var scroll 	= getURLParameter('s', url);
		
		openPopup(url, url, width, height, scroll);
		
		return false;
	});
	
	// plain new window
	$('a[rel=new]').click(function(event) {		
		window.open($(this).attr('href'));
        
        return false;
	});
});

function openPopup(mypage,myname,w,h,scroll){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable';
	
	var realname = myname.substring(1,4);
	
	window.open(mypage, realname, settings);
	return false;
}

function getURLParameter(name, url){
	url = (url != null)?url:window.location.href;
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( url );
	if( results == null )
		return "";
	else
		return results[1];
}

function isUnderIE8()
{
	if ($.browser.msie && $.browser.version.substr(0, 1) < "8") {
		return true;
	}
	
	return false;
}

// interacting with flash player		
function shareHandler()
{
	addthis_sendto();
	return false;
}

function initHandler()
{
	componentHasInitialised = true;
}

function play()
{
	if(componentHasInitialised)
	{
		getObject("videoPlayer").fl_play();
	}	
}

function loadVideo(url)
{
	if(componentHasInitialised)
	{
		getObject("videoPlayer").fl_play(url);
	}
}

function stop()
{
	if(componentHasInitialised)
	{
		getObject("videoPlayer").fl_stop();
	}		
}

//Returns a reference to a flash movie object based on its ID
function getObject(id)
{
	var object = null;
	if( document.layers )
	{   
		object = document.layers[id];
	}
	else if( document.all )
	{
		object = document.all[id];
	}
	else if( document.getElementById )
	{
		object = document.getElementById(id);
	}
	
	return object;
}