

// Taken from http://blog.taragana.com/index.php/archive/how-to-add-functions-to-javascript-onload-over-third-party-scripts-playing-nice/
// var nowOnload = window.onload; // Let's save the existing assignment, if any
// 
// window.onload = function () {
//     // Here is your precious function
//     // You can call as many functions as you want here;
//     setBrowserTimeZoneOffset();
//     // Now we call old function which was assigned to onLoad, thus playing nice
//     if(nowOnload != null && typeof(nowOnload) == 'function') {
//         nowOnload();
//     }
// }

// Sets the number of hours from GMT / UTC (eg if user is in PST, it will be "-7" or "-8" depending 
// on daylight savings)
function setBrowserTimeZoneOffset() {
	thedate = new Date();
	createCookie('browser_timezone_offset', thedate.getTimezoneOffset()/60, 1);
}

// Setting of Cookies
// Taken from http://www.quirksmode.org/js/cookies.html

function createCookie(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=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

