/* fix flicker issue */
document.write('<style type="text/css">#pagewrapper{display:none}#footer{display:none}</style>');
jQuery(function($) {
	$('#pagewrapper').css('display','block');
	$('#footer').css('display','block');
});


/* detect browser and display message */
jQuery(function($) {
	if(($.browser.safari && $.browser.version.substr(0,3) < 523) || ($.browser.msie && $.browser.version < 7)) {
		if($.cookie('oldbrowser') != 'hidden') {
			$('body').prepend('<div id="oldbrowser" style="margin:0px auto;padding:20px;background-color:none;width:670px;"><div style="padding:20px;background-color:#fff;border:2px solid #990000;"><p style="font-size:1.7em;">Sorry, you may get unpredictable results using your web browser.</p><p>This website uses technology that requires a more recent web browser such as Safari 3+, Internet Explorer 7 or 8, or Firefox 3+<br />Please download an up to date web browser and visit us again!</p><p><a href="http://www.spreadfirefox.com/node&id=0&t=306" id="#oldbrowserff"><img border="0" alt="Firefox 3" title="Firefox 3" src="http://sfx-images.mozilla.org/affiliates/Buttons/firefox3/110x32_get_ffx.png"/></a></p><p><a style="text-decoration:underline;" href="javascript:void(0)" onclick="$(\'#oldbrowser\').fadeOut();$.cookie(\'oldbrowser\', \'hidden\');">Hide this message</a></p></div></div>');
		}
		
	}
});

function var_dump(obj) {
   if(typeof obj == "object") {
	    var out = '';
	    for (var i in obj) {
	        out += i + ": " + obj[i] + "\n";
	    }
      return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + out;
   } else {
      return "Type: "+typeof(obj)+"\nValue: "+obj;
   }
}//end function var_dump

function windowWidth() {
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
	} else if( document.documentElement && document.documentElement.clientWidth) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	} else if( document.body && document.body.clientWidth) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}
	return myWidth;
}


function windowHeight() {
	if( typeof( window.innerHeight ) == 'number' ) {
		//Non-IE
		myHeight = window.innerHeight;
	} else if( document.documentElement && document.documentElement.clientHeight) {
		//IE 6+ in 'standards compliant mode'
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && document.body.clientHeight) {
		//IE 4 compatible
		myHeight = document.body.clientHeight;
	}
	return myHeight;
}

$(document).ready(function() {
	$("a[href$=pdf]").not('.noPdfIcon').addClass("pdflink").attr({target: "_blank"});
	$('.noPdfIcon').attr({target: "_blank"})
	/*$('.button').mouseover(function() {
		$('.button').css('opacity','0.5');
	}
	$('.button').mouseout(function() {
		$('.button').css('opacity','1');
	}*/

	var scriptLocation = '/images/render/magicText.php?text=';
	window.scriptLocation = scriptLocation;

	// if not on the homepage - they have officially entered the website
	/*if($('#nowhere .questHome').length == 0) {
		$.cookie('enteredNowhere','true',{path:'/'});
	}*/
	
	// replace text for image (bespoke)
	if($('.iReplaceFile').length > 0) {
		$('.iReplaceFile').each(function() {
			text = $(this).html();
			fileTextLower = $(this).html().toLowerCase();
			fileText = fileTextLower.replace(/ /g,'-');
			file = fileText+'.png';
			$(this).html('<img src="/images/headings/'+file+'" alt="'+text+'" />');
			$(this).addClass('iReplaced');
		});
	}
	
	
	// replace text for image (automatic)
	$('#contentjoin h2, #contentlogin h2, #loginb3uttons h2').imageReplace('&font_color=000&img_type=png&font_size=20&transparency=false',scriptLocation);

	$('h1.iReplace').imageReplace('&font_color=000&img_type=png&font_size=22',scriptLocation);
	$('h1.iReplaceWhite').imageReplace('&font_color=ffffff&img_type=png&bg_color=000000&font_size=22',scriptLocation);
	$('h1.iReplaceNofoRed').imageReplace('&font_color=c41230&img_type=png&bg_color=000000&font_size=22',scriptLocation);


	$('#eqs #quest h2').imageReplace('&font_color=a5b934&img_type=png&bg_color=000000&font_size=16',scriptLocation);
	$('#on #quest h2').imageReplace('&font_color=e2bb0c&img_type=png&bg_color=000000&font_size=16',scriptLocation);


	$('#nowhere .darkBg h1').imageReplace('&font_color=ffffff&img_type=png&bg_color=000000&font_size=25',scriptLocation);
	$('h1.academy').imageReplace('&font_color=c41230&img_type=png&bg_color=000000&font_size=25',scriptLocation);

	$('#nowhere h1').imageReplace('&font_color=000000&img_type=png&bg_color=000000&font_size=25',scriptLocation);
	$('#conceptstore h1').imageReplace('&font_color=ea2127&img_type=png&bg_color=000000&font_size=20',scriptLocation);
	$('#eqs h1').imageReplace('&font_color=a5b934&img_type=png&bg_color=000000&font_size=25',scriptLocation);
	$('#ecl h1').imageReplace('&font_color=e89016&img_type=png&bg_color=000000&font_size=25',scriptLocation);
	$('#ccm h1').imageReplace('&font_color=00B0D8&img_type=png&bg_color=000000&font_size=25',scriptLocation);

	$('#nowhere h2').imageReplace('&font_color=000000&img_type=png&bg_color=000000&font_size=18',scriptLocation);
	$('#conceptstore h2').imageReplace('&font_color=ea2127&img_type=png&bg_color=000000&font_size=18',scriptLocation);
	$('#eqs h2').imageReplace('&font_color=a5b934&img_type=png&bg_color=000000&font_size=18',scriptLocation);
	$('#ecl h2').imageReplace('&font_color=e89016&img_type=png&bg_color=000000&font_size=18',scriptLocation);
	$('#ccm h2').imageReplace('&font_color=00B0D8&img_type=png&bg_color=000000&font_size=18',scriptLocation);

});