
/* Against quirksmode.com */

 if (self != top) {

 /*	top.location.replace(location.href);*/
 }

/* QUIRKSMODE JAVASCRIPT */

var blogs = ['/blog/','/bugreports/','/elsewhere/'];
var archivedText = 'You\'re looking at outdated content that is no longer maintained. Use with care.';

var advancedJavaScriptSupport = createXMLHTTPObject() && document.createElement && document.getElementsByTagName;

if (advancedJavaScriptSupport)
//	document.write('<style>body {padding-top: 161px;}</style>'); 	// make room for headers

window.onunload = function () {

	// execute unload routine of page, if present

	if (self.exit)
		exit();
	
	// execute unload routine for blog pages, if present

	if (self.exitBlogs)
		exitBlogs();
}

window.onload = function () {
	
	if (navigator.userAgent.indexOf('WidgetManager') != -1) {
		alert('joehoe');
		document.body.style.fontSize = '2em';
	}

	/* See if browser supports advanced interface */

	if (!advancedJavaScriptSupport) return;
	
	/* Load advanced interface */
	
	/*sendRequest('header.txt',setHeader);
	sendRequest('nav.txt',setNavigation);
	sendRequest('footer.txt',setFooter);*/

	//zebraLists();
	
	/* Miscellaneous */
	
/*	setScreenShots();
	setCompTables();
	sizePres();
	redirectExternalLinks();*/
	window.onresize = sizePres;

	if (Preferences.siteNavPos && Preferences.siteNavPos != 'fixed') {
		document.getElementById('header_sc_a').style.position = Preferences.siteNavPos;
	}
	else {

		setMenuOffset.initialPos = getStyle('header_sc_a','top');
		window.onscroll = document.documentElement.onscroll = setMenuOffset;

		setMenuOffset();
		/* in Moz 1.7.12/FF 1.5 window.onscroll is wiped when you use the mouse wheel while 
		the pointer is NOT above a true page element (ie. when it is above the naked documentElement)
		 ... or something ...
		Of course Safari doesn't accept document.documentElement.onscroll; Op and IE 7 do */
	}

	/* Initialise blog and bilingual scripts, if they're there */



}




function setMenuOffset() { 
/*$($("#header_sc_a > div").height);*/
//alert ($("#header_sc_a > div").height());
$div_total=$("#header_sc_a > div").height();
/**showHeight("paragraph", $("p").height())*/


	var header = document.getElementById('header_sc_a');
	if (!header)
	{ 
	alert('aa');
	return;

	}
;

//	var $size_footer= $(document).height()-$(window).height();
	var $size_footer= $(document).height()-$div_total;
	/*alert($(document).height());
	alert($(window).height());
alert($size_footer);
alert($div_total);*/
	/*size_footer=size_footer-450;*/
	
if (whichBrs()=='chrome')
{
//	$size_footer=$size_footer-450;
	$size_footer=$size_footer-684;
	$scroll_final=document.body.scrollTop;
}
if (whichBrs()=='Internet Explorer')
{
		$size_footer=$size_footer-684;
//	$size_footer=$size_footer-580;
	$scroll_final=document.documentElement.scrollTop;
}

if (whichBrs()=='Firefox')
{
/*		$size_footer=$size_footer-570;*/
	//	alert($div_total);
	//		$div_total_temp=570-;
		$size_footer=$size_footer-684;
		/*$size_footer=$size_footer;*/
		$scroll_final=document.documentElement.scrollTop;
}
	if ($size_footer <=$scroll_final)
	{
		header.style.position='absolute';
		header.style.top=$size_footer+'px';

	return;	
	}
	else
	{

		
			header.style.position='fixed';
	}
	
	var currentOffset = document.documentElement.scrollTop || document.body.scrollTop; // body for Safari
	var startPos = parseInt(setMenuOffset.initialPos) || 462;


	var desiredOffset = startPos - currentOffset;

	if (desiredOffset < 10)
	{
		desiredOffset = 10;
	}

	if (desiredOffset != parseInt(header.style.top)) 
	{
		header.style.top = desiredOffset + 'px';
		//alert(header.style.top);
		
	
	}
	var currentLeftOffset = document.documentElement.scrollLeft || document.body.scrollLeft; // body for Safari
	
	if (currentLeftOffset != - parseInt(header.style.left))
	{
		//header.style.left = '-' + currentLeftOffset + 'px';
	}
	
//	alert(	header.style.left);
}
function sizePres() {

	/* Stretch pres to right edge of browser window */
	var pres = document.getElementsByTagName('pre');
	if (!pres.length) return;
	var testPre;
	for (var i=0;i<pres.length;i++) {
		if (pres[i].parentNode.nodeName == 'BODY') {
			testPre = pres[i];
			break;
		}
	}
	if (!testPre) return;
	testPre.style.marginRight = 'auto';
	var docWidth = document.documentElement.clientWidth;
	var preWidth = testPre.offsetWidth;
	var rightMargin = docWidth - preWidth;
	if (rightMargin < 0)
		rightMargin = 0;
	for (var i=0;i<pres.length;i++) {
		if (pres[i].parentNode.nodeName == 'BODY') {
			pres[i].style.marginRight = '-' + rightMargin + 'px';	
		}
	}
}
function sendRequest(url,callback,postData) {
	var req = createXMLHTTPObject();
	if (!req) return;
	var method = (postData) ? "POST" : "GET";
	req.open(method,url,true);
	req.setRequestHeader('User-Agent','XMLHTTP/1.0');
	if (postData)
		req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	req.onreadystatechange = function () {
		if (req.readyState != 4) return;
		if (req.status != 200 && req.status != 304) {
		//	alert('HTTP error ' + req.status);
			return;
		}
		callback(req);
	}
	if (req.readyState == 4) return;
	req.send(postData);
}

function XMLHttpFactories() {
	return [
		function () {return new XMLHttpRequest()},
		function () {return new ActiveXObject("Msxml2.XMLHTTP")},
		function () {return new ActiveXObject("Msxml3.XMLHTTP")},
		function () {return new ActiveXObject("Microsoft.XMLHTTP")}
	];
}

function createXMLHTTPObject() {
	var xmlhttp = false;
	var factories = XMLHttpFactories();
	for (var i=0;i<factories.length;i++) {
		try {
			xmlhttp = factories[i]();
		}
		catch (e) {
			continue;
		}
		break;
	}
	return xmlhttp;
}
function getStyle(el,styleProp) {
	var x = document.getElementById(el);
	if (!x) return;
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}

var Cookies = {
	init: function () {
		var allCookies = document.cookie.split('; ');
		for (var i=0;i<allCookies.length;i++) {
			var cookiePair = allCookies[i].split('=');
			this[cookiePair[0]] = cookiePair[1];
		}
	},
	create: function (name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
		this[name] = value;
	},
	erase: function (name) {
		this.create(name,'',-1);
		this[name] = undefined;
	}
};
Cookies.init();

var Preferences = {
	init: function () {
		if (!Cookies.sitePrefs) return;
		sitePrefs = Cookies.sitePrefs.split(',,');
		for (var i=0;i<sitePrefs.length;i++) {
			var oneSitePref = sitePrefs[i].split(':');
			this[oneSitePref[0]] = oneSitePref[1];
		}	
	}
};
Preferences.init();


// Browser Detection Javascript
// copyright 1 February 2003, by Stephen Chapman, Felgall Pty Ltd

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.
function showHeight(ele, h) {
      $("div").text("The height for the " + ele + 
                    " is " + h + "px.");
    }


function whichBrs() {
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("staroffice") != -1) return 'Star Office';
if (agt.indexOf("webtv") != -1) return 'WebTV';
if (agt.indexOf("beonex") != -1) return 'Beonex';
if (agt.indexOf("chimera") != -1) return 'Chimera';
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
if (agt.indexOf("phoenix") != -1) return 'Phoenix';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("chrome") != -1) return 'chrome';
if (agt.indexOf("safari") != -1) return 'Safari';
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
}

