// JavaScript Document

//Set the possible paths
var splash = new Array();
splash['blue'] = 'blue.png';
splash['clarke'] = 'clarke.png';
splash['machine'] = 'machine.png';
splash['postLogic'] = 'postLogic.png';
splash['primeFocus'] = 'primeFocus.png';
splash['primeFocusLondon'] = 'primeFocusLondon.png';

//JS Version of PHP's array_key_exists
function array_key_exists ( key, search ) {
    if (!search || (search.constructor !== Array && search.constructor !== Object)){
        return false;
    }
    return key in search;
}

//Check if hash referrer is present
$(document).ready(function () {
	if (location.hash.substr(0, 6)=='#from-') {
		var referrer = location.hash.replace('#from-','');
		$("body").append('<div id="overlay"></div><div id="overlay-panel" style="background-image: url(/sites/default/themes/pf/images/splash/'+splash[referrer]+');"></div>');
		$("#overlay").fadeTo(0,0.8);
		$("#overlay-panel").click(function() {$("#overlay,#overlay-panel").fadeOut(500,function(){$("#overlay,#overlay-panel").remove()});});
	}
});