function Is() {
    var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
    this.ns2 = (this.ns && (this.major == 2));
    this.ns3 = (this.ns && (this.major == 3));
    this.ns4b = (this.ns && (this.major == 4) && (this.minor <= 4.03));
    this.ns4 = (this.ns && (this.major >= 4));
	this.ns7 = (this.ns && (this.major >= 7));
    this.ie   = (agent.indexOf("msie") != -1);
    this.ie3  = (this.ie && (this.major == 2));
    this.ie4  = (this.ie && (this.major >= 4));
    this.ffox = (agent.indexOf("firefox") != -1);
    //this.win   = (agent.indexOf("win")!=-1);
	//this.mac   = (agent.indexOf("mac")!=-1);
    //this.unix  = (agent.indexOf("x11")!=-1);	
}

function OpenWindow(sUrl,name)
{
	var fenster;
   	var options = "toolbar=no,location=0,directories=no,status=no,scrollbars=auto,menubar=yes,hotkeys=no,resizable=yes";
 	fenster = window.open(sUrl, name, options);
   	fenster.focus();
}


var fadeObj = null;

function fade(object,endOp,time,step) {
	clearTimeout(fadeObj);
	var is = new Is()
	
	if(is.ie) opac = document.getElementById(object).filters.alpha.opacity;
	if(is.ffox || is.ns) opac = 100 * document.getElementById(object).style.MozOpacity;
	
	direction = 1;
	if (opac > endOp){
		direction = -1;
	}

	if(opac != endOp){
		opac+=direction*step;
		if(is.ie) document.getElementById(object).filters.alpha.opacity = opac;
		if(is.ffox || is.ns) document.getElementById(object).style.MozOpacity = opac/100;
		
		fadeObj = setTimeout('fade("' + object + '",' + endOp + ',' + time + ',' + step + ')', time);
	}
	else
		clearTimeout(fadeObj);
}

function set_content_height(home)
{
	var is = new Is()
	var height_image = 0;
	var temp = 0;
	var temp2 = 0;
	var temp3 = 0;
	var height_col_1 = 0;
	var height_col_2 = 0;
	var height_col_3 = 0;
	var height_col_4 = 0;
	
	var height_col_0 = document.body.clientHeight;
		
	if (is.ie)
	{
		if(document.getElementById("box_content")) 	var height_col_1 = document.getElementById("box_content").offsetHeight;
	}
	if (is.ffox || is.ns)
	{
		if(document.getElementById("box_copy")) 	var height_col_1 = document.getElementById("box_copy").offsetHeight;
		if(document.getElementById("box_content")) 	var height_col_2 = document.getElementById("box_content").offsetHeight;
		if(document.getElementById("box_promo")) 	var height_col_3 = document.getElementById("box_promo").offsetHeight;
		if(document.getElementById("box_right")) 	var height_col_4 = document.getElementById("box_right").offsetHeight;
		
		if(home == 1) height_col_1 = height_col_2;
		if(height_col_3 > height_col_1) height_col_1 = height_col_3 + 60;
		if(height_col_4 > height_col_1) height_col_1 = height_col_4 + 60;
	}
	
	if(document.getElementById("box_header_image"))
		var height_image = document.getElementById("box_header_image").offsetHeight - 3;
	
	if (is.ie)				size = height_col_0 - 125
	if (is.ffox || is.ns)	size = height_col_0 - 250
	
	if(size > height_col_1)
	{
		var height_layer = height_col_0;
		if(home == 1)
		{
			var height_layer = height_col_1 + 132;
			var temp = -24;
			
		}
		
		if(document.getElementById("box_main")) 		document.getElementById("box_main").style.height = height_layer + temp + "px";
		if(document.getElementById("box_content")) 		document.getElementById("box_content").style.height = height_layer  - 110 + "px";
		if(document.getElementById("box_navigation")) 	document.getElementById("box_navigation").style.height = height_layer  - 144 - height_image + "px";
		
	}
	else
	{
		var height_layer = height_col_1;
		if(home == 1) 
			var temp = -37;
		
		if (is.ffox || is.ns)
		{
			if(home == 1)
			{
				var temp2 = -115;
				var temp3 = -20;
			}
			
			if(document.getElementById("box")) 				document.getElementById("box").style.height = height_layer + temp2 + temp3 + 257 + "px";
			if(document.getElementById("box_main")) 		document.getElementById("box_main").style.height = height_layer + temp2 + 258 + temp  + "px";
			if(document.getElementById("box_content")) 		document.getElementById("box_content").style.height = height_layer + temp2 + 140 + "px";
			if(document.getElementById("box_navigation")) 	document.getElementById("box_navigation").style.height = height_layer - height_image + 106 + "px";
		}
		else
		{
			if(document.getElementById("box")) 				document.getElementById("box").style.height = height_layer + 114 + "px";
			if(document.getElementById("box_main")) 		document.getElementById("box_main").style.height = height_layer + 135 + temp  + "px";
			if(document.getElementById("box_content")) 		document.getElementById("box_content").style.height = height_layer + 25 + "px";
			if(document.getElementById("box_navigation")) 	document.getElementById("box_navigation").style.height = height_layer - height_image - 4 + "px";
		}
	}	
}

function JumpToLink(url) 
{
	//alert("http://" + window.location.host + "/georgeson/trunk/" + url)
	window.location.href = url;
}

function cookiesEnabled() {
 var result=3;  // undefined, if the browser does not know the property
 if (navigator.cookieEnabled!=null) {
  if (navigator.cookieEnabled) result=1;
  else result=2;
 }
 return result;
}

function setCookie(a_name, a_value, a_lifetime) {  // a_lifetime in Tagen
 var now = new Date();
 var expiry = new Date(now.getTime() + a_lifetime*24*60*60*1000);
 if ((a_value != null) && (a_value != ""))
  document.cookie=a_name + "=" + escape(a_value) + "; expires=" + expiry.toGMTString();
 return getCookie(a_name) != null; // Test, ob es geklappt hat
}

function getCookie(a_name) {
 var a_start, an_end;
 if (document.cookie) {
  a_start = document.cookie.indexOf(a_name+"=");
  if (a_start < 0) return null;
  a_start = document.cookie.indexOf("=", a_start) + 1;
  an_end = document.cookie.indexOf(";", a_start);
  if (an_end < 0) an_end = document.cookie.length;
  return unescape(document.cookie.substring(a_start, an_end));
 }
 else return null;
}

function deleteCookie(a_name) {
 var now = new Date();
 var expired = new Date(now.getTime() - 2*24*60*60*1000);  // 2 Tage zurueck
 document.cookie=a_name + "=null; expires=" + expired.toGMTString();
}


function SubmitCountrySelect(value,checkbox) 
{
	
	if(value != 'index.html')
	{
		if(checkbox) 
			setCookie('georgeson_lang_select', value, 100); 
		
		else if(getCookie('georgeson_lang_select') != null)
			 deleteCookie('georgeson_lang_select');
	}
	else alert('Please choose a Country here.')
	
	JumpToLink(value);
}

function checkCookie()
{
	var newLanguage = 0;
	
	if(window.location.hash == '#newLanguage')
		var newLanguage = 1;
	
	var url = getCookie('georgeson_lang_select');
	//var url = 'en_uk/index.html';
	
	if(url != null)
	{
		if(newLanguage)
		{	
			document.getElementById("RememberCountry").checked = 1;
			
			for(i=1;i<document.getElementById("SelectCountry").options.length;i++)
			{
				if(document.getElementById("SelectCountry").options[i].value == url)
				{
					document.getElementById("SelectCountry").selectedIndex = i;
				}
			}
		}
		else
		{
			JumpToLink(url);
		}
		
	}
	
}

function delCookie(name) {
document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/georgeson/";
}

function newCountry(path) {

	delCookie('georgeson_lang_select');
	window.location.href = path;

}