function checkUserTimezone(){
   var url = "/default/index/settimezone";
   var visitortime = new Date();
   var time = (getTimeZone() * -1);
   
   
   var page_request = false
   if (window.XMLHttpRequest) {
	   page_request = new XMLHttpRequest()
   } else if (window.ActiveXObject){ 
	   try {
		   page_request = new ActiveXObject("Msxml2.XMLHTTP") } 
	   catch (e){
		   try{
			   page_request = new ActiveXObject("Microsoft.XMLHTTP") }
		   catch (e){}
	   }
   } else {
	   return false;
   }

	bustcacheparameter = Math.floor(Math.random()*9999999);
	page_request.open('GET', url+'?'+bustcacheparameter+"&time="+time, true);
	page_request.send(null) 
}

function getTimeZone() {
	var now = new Date();
	var later = new Date();
	// Set cookie for the time zone offset in minutes
	// Create two new dates
	var d1 = new Date();
	var d2 = new Date();
	// Date one is set to January 1st of this year
	// Guaranteed not to be in DST for northern hemisphere,
	// and guaranteed to be in DST for southern hemisphere
	// (If DST exists on client PC)
	d1.setDate(1);
	d1.setMonth(1);
	// Date two is set to July 1st of this year
	// Guaranteed to be in DST for northern hemisphere,
	// and guaranteed not to be in DST for southern hemisphere
	// (If DST exists on client PC)
	d2.setDate(1);
	d2.setMonth(7);
	// If time zone offsets match, no DST exists for this time zone
	if(parseInt(d1.getTimezoneOffset())==parseInt(d2.getTimezoneOffset()))
	{
		return now.getTimezoneOffset()/60;
	}
	// DST exists for this time zone - check if it is currently active
	else {
	  // Find out if we are on northern or southern hemisphere
	  // Hemisphere is positive for northern, and negative for southern
	  var hemisphere = parseInt(d1.getTimezoneOffset())-parseInt(d2.getTimezoneOffset());
	  // Current date is still before or after DST, not containing DST
	  if((hemisphere>0 && parseInt(d1.getTimezoneOffset())==parseInt(now.getTimezoneOffset())) ||
	    (hemisphere<0 && parseInt(d2.getTimezoneOffset())==parseInt(now.getTimezoneOffset())))
	  {
	    return now.getTimezoneOffset()*60;
	  }
	  // DST is active right now with the current date
	  else {
	    return ((now.getTimezoneOffset()/60) + 1);
	  }
	}
}

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;
}


checkUserTimezone();