/* COOKIES OBJECT */
var Cookies = {
  // Initialize by splitting the array of 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: Pass name of cookie, value, and days to expire
  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;
	if(value!=""){
		window.frames['ide'].location = "http://www.huesker.de/typo3conf/ext/cookies.php?lang="+value;
		window.frames['icom'].location = "http://www.huesker.com/typo3conf/ext/cookies.php?lang="+value;
		
	}	
  },
  // Erase cookie by name
  erase: function (name) {
    this.create(name,'',-1);
    this[name] = undefined;
  }
};
jQuery.ready(function(){
   Cookies.init(); 

});

function showMenu(obj) {
	var submenu = jQuery(obj.parentNode.getElementsByTagName("ul")[0]);

	if (submenu.css("display") == "block"){
		submenu.hide();
	} else {
		jQuery(".sub-navigation:visible").hide();
		submenu.show();
	}

	obj.blur();

	if(obj.search.match("id=7")){
		return true;
	} else {
		return false; 
	}	
}

function showDownload(obj) {
	
	var list = jQuery(obj.parentNode.getElementsByTagName("ul")[0]);

	if (list.css("display") == "block") {
		list.hide();
		jQuery(obj).css("background","url('fileadmin/huesker/_img/service/blt_arrow_download.gif') 26px 10px no-repeat #DFDFDF");
	} else {
		list.show();
		jQuery(obj).css("background","url('fileadmin/huesker/_img/service/blt_arrow_download_o.gif') 26px 10px no-repeat #DFDFDF");
	}
}


function showSecondDownload(obj) {
	jQuery(obj.parentNode.getElementsByTagName("table")[0]).show();
	jQuery(obj).css("background","url('fileadmin/huesker/_img/service/blt_smallarrow_download_o.gif') 12px 5px no-repeat #F1F1F1");
	jQuery(obj).attr("onclick","hideSecondDownload(this)");
}

function hideSecondDownload(obj) {
	jQuery(obj.parentNode.getElementsByTagName("table")[0]).hide();
	jQuery(obj).css("background","url('fileadmin/huesker/_img/service/blt_smallarrow_download.gif') 12px 5px no-repeat #F1F1F1");
	jQuery(obj).attr("onclick","showSecondDownload(this)");
}


function selectLanguage() {
	jQuery("#box-languages").show();
}

var URLGLOBAL = "";
var isHref = 0;

function goURLLocation(){
	if(isHref==1)
		window.location = "http://www.huesker.com/" + URLGLOBAL;
	else
		window.location = URLGLOBAL;
}

function setLanguage(obj) {
	jQuery("#box-languages").hide();
	
	var as 		 = document.getElementById("link-languages").getElementsByTagName("a");
	var options  = obj.getElementsByTagName("option");
	var language = "";

	for (var i = 0; i < options.length; i++) {
		if (options[i].selected) {
			language = options[i].innerHTML;
			Cookies.erase("selected_language");
			Cookies.create("selected_language", language, 10000);			
			break;
		}
	}


	for (var x = 0; x < as.length; x++) {
		if (as[x].innerHTML == language) {
			Cookies.erase("selected_language");
			Cookies.create("selected_language", language, 10000);
		
			if (language != "ASD") {
				var newUrl = as[x].href.split("/")[3];
				var newUrlRight = as[x].hre;

				/*if (newUrl == "espana") {
					URLGLOBAL = "http://www.huesker.com/espana";
					var t=setTimeout("goURLLocation()",1000);
					//window.location = "http://www.huesker.es/";					
					break;
				}-*/
								
				if (newUrl == "osterreich"){			
					URLGLOBAL = "http://www.huesker.de/";	
					var t=setTimeout("goURLLocation()",1000);		
					//window.location = "http://www.huesker.de/";
					break;
				}

				if (language == "ESPAŅA"){						
					URLGLOBAL = "http://www.huesker.com/espana";
					var t=setTimeout("goURLLocation()",1000);			
					//window.location = "http://www.huesker.com/russia";
					break;
				}
				
				if (language == "RUSSIA"){						
					URLGLOBAL = "http://www.huesker.com/poccnr";
					var t=setTimeout("goURLLocation()",1000);			
					//window.location = "http://www.huesker.com/russia";
					break;
				}				

                
                if (language == "BRASIL"){
                    URLGLOBAL = "http://www.huesker.com/br/geokunststoffe";
                    //URLGLOBAL = "http://www.huesker.com/brasil";
					var t=setTimeout("goURLLocation()",1000);			
					break;
                }
                
                
				if (newUrl == "poccnr")
					newUrl = "poccnr";

				if (language == "DEUTSCHLAND"){	
					URLGLOBAL = "http://www.huesker.de";
					var t=setTimeout("goURLLocation()",1000);				
					//window.location = "http://www.huesker.de/";
					break;
				}
				URLGLOBAL = newUrl;
				isHref = 1;
				
				var t=setTimeout("goURLLocation()",1000);	
				
				//window.location = "http://www.huesker.com/" + newUrl;
				break;
			} else {
				URLGLOBAL = as[x].href;
				var t=setTimeout("goURLLocation()",1000);
				//window.location = as[x].href;
				break;
			}
			
			break;
		}
	}
}




var currenctlyTabId;

function changeTab(id,obj) {

	jQuery("#" + currenctlyTabId + "-content").hide();
	jQuery("#" + currenctlyTabId + "-tab").removeClass("selected");
	
	jQuery("#" + id + "-content").show();
	jQuery("#" + id + "-tab").addClass("selected");
	
	currenctlyTabId = id;

	obj.blur();
}

function htmlDecode(input){
  var e = document.createElement('div');
  e.innerHTML = input;
  return e.childNodes[0].nodeValue;
}






