/*
	main.js
	
	PixelCounter Ltd.
	http://pixelcounter.co.uk			mail@pixelcounter.co.uk
	
	Developed by John M. Kavanagh
	http://johnkavanagh.co.uk			mail@johnkavanagh.co.uk
	
	This file is built and cached dynamically server-side, contents
	vary depending on the current website configuration - hence
	some verbosity and repetition.

	(C) Copyright John M. Kavanagh & PixelCounter
	All rights reserved, not for redistribution

*/

function initLinks(){
	$("a[href*='http://']:not([href*='"+location.hostname+"'])").attr("target","_blank");
}

function initPIE(){
	if (window.PIE) {
		$('.pie').each(function() {
			PIE.attach(this);
		});
	}	
}

function checkWidths(){
	var windowWidth = $(window).width();
	var windowHeight = $(window).width();
	var bear = $('.bear');
	var island = $('.island');

	if((windowHeight > 700)  && (windowWidth > 1450)){
		island.show();
		bear.show();
	}
	else if ((windowHeight > 700)  && (windowWidth > 1150)){
		bear.show();
		island.hide();
	}
	else{
		bear.hide();
		island.hide();	
	}

};

function initIslandandBear(){
	$('#container').append('<section class="island">&nbsp;</section><section class="bear">&nbsp;</section>');
};

$(function() {
	initLinks();
	initPIE();
	initIslandandBear();
	checkWidths();
});

$(window).resize(function(){
	checkWidths();
});
