function onPageLoad(){
	recomendElement = getElementsByClassName("recommend");
	if(recomendElement.length == 1){
		recomendElement[0].setAttribute("href", "/index.php?id=111&tipUrl=" +  location.href);	
	}
	setLocalosation();
	setContactAndRecommend();
	setSearch();
	setMenuHeaderItem();
	//setLinkLabel();
	/*javascript:document.write(document.getElementsByTagName("html")[0].innerHTML + '<style>@import url(/fileadmin/templates/css/print.css);"</style>');*/
}	

function onIndexLoad(){	
	if(navigator.userAgent.indexOf("Firefox/3") != -1 || navigator.userAgent.indexOf("Chrome") != -1 || navigator.userAgent.indexOf("Safari") != -1){	
		addCSSRule("div.referencePopUp p", "top:58px;");
		if(navigator.userAgent.indexOf("Firefox/3") != -1){
			popups = getElementsByClassName("referencePopUp");
			for(i = 0; i < popups.length; i++){
				popups[i].style.top = (parseInt(popups[i].style.top) + 12) + "px";
			}
		}
		
	}
	
	setLocalosation();
	setSearch();
	//setLinkLabel();
	return 0;
}

function setLocalosation(){
			var en = document.getElementsByAttribute("href", "http://www.wellen-noethen.com/");
			var de = document.getElementsByAttribute("href", "http://www.wellen-noethen.de/");
			
			if(location.host.indexOf("wellen-noethen.") != -1){	
				if (en[0].tagName == "BASE"){
					en[1].href= en[0].href.substr(0, en[0].href.length -1) + location.pathname + location.search;
					de[0].href = de[0].href.substr(0, de[0].href.length -1) + location.pathname + location.search;			
				}
				else{
					en[0].href= en[0].href.substr(0, en[0].href.length -1) + location.pathname + location.search;
					de[1].href = de[0].href.substr(0, de[0].href.length -1) + location.pathname + location.search;			
				}
			}				
			else{
				en[0].parentNode.parentNode.style.display = "none";
			}
}

function setLinkLabel(){
			if( (location.host.indexOf("wellen-noethen.com") != -1) || (location.host.indexOf("qvestmedia.") != -1)){
				var more = getElementsByClassName('more');
				for(i = 0; i < more.length; i++){
					more[i].firstChild.innerHTML = "more";
				}
				
				var backToList = getElementsByClassName('backToList');
				for(i = 0; i < backToList.length; i++){
					backToList[i].firstChild.innerHTML = backToList[i].firstChild.innerHTML.replace(/zurück zu/, "back to");
				}				
			}
}

function setContactAndRecommend(){
	if(getElementsByClassName('recommend')[0]){
		if(location.host.indexOf("wellen-noethen.") == -1){
			pageId = 111;
		}
		else{
			pageId = 418;
		}	
		getElementsByClassName('recommend')[0].href = getElementsByClassName('recommend')[0].href.replace(/index.php\?id=111/, "index.php?id=" + pageId )	
	}
	
	if(getElementsByClassName('contact')[0]){
		if(location.host.indexOf("wellen-noethen.") == -1){
			pageId = 239;
		}
		else{
			pageId = 54;
		}	
		getElementsByClassName('contact')[0].href = getElementsByClassName('contact')[0].href.replace(/12/, pageId )	
	}	
}

function setSearch(){
	searchID = document.getElementById("searchform");
	
	if(location.host.indexOf("wellen-noethen.") == -1){
		searchID.action = "index.php?id=231";
	}
	else{
		searchID.action = "index.php?id=81";
	}			
}

function setMenuHeaderItem(){
	if(location.host.indexOf("wellen-noethen.") == -1){
		imageLink = getElementsByClassName('menu')[0].parentNode;
		switch(imageLink.href.substr(imageLink.href.indexOf("=") + 1,imageLink.href.length )){
			case "6":
				imageLink.href = "/index.php?id=352";
				break;
			case "5":
				imageLink.href = "/index.php?id=332";
				break;
			case "4":
				imageLink.href = "/index.php?id=380";
				break;
			case "3":
				imageLink.href = "/index.php?id=276";
				break;
			case "87":
				imageLink.href = "/index.php?id=248";
				break;
			case "7":
				imageLink.href = "/index.php?id=238";
				break;
			default:
				break;
		}
	}
}

function showPopUp(index){
	document.getElementById("referencePopUp" + index).style.display = "block";
}

function hidePopUp(index){
	document.getElementById("referencePopUp" + index).style.display = "none";
}

function showTab(index){
	
	if(index == 1){
		indexClose = 2;
	}
	else{
		indexClose = 1;
	}
	
	
	document.getElementById("tabBoxTitle" + indexClose).className = "";
	document.getElementById("tabBoxContent" + indexClose).className = "";

	document.getElementById("tabBoxTitle" + index).className = "selected";		
	document.getElementById("tabBoxContent" + index).className = "selected";		
}

	function bildOptionMenu(classCol){
		

                var services = getElementsByClassName(classCol);
		var options = new Array();

		for (i = 0; i < services.length; i++){
			if ( !contains(options, services[i].innerHTML) ) {
				options.push(services[i].innerHTML);
			}
		}
		options.sort();
		selector = document.getElementById("serviceSelector");
		
		for (i = 0; i < options.length; i++){
			option = document.createElement("option");
			selector.appendChild(option);
			option.setAttribute("value", options[i]);
			option.innerHTML = options[i];
		}		
	}
	
	function filter(value, classCol){
		var services = getElementsByClassName(classCol);		
		
		for (j = 0; j < services.length; j++){
			if ( (services[j].innerHTML == value) || (value == "@all")  ){
				services[j].parentNode.style.display = "block";
                        }
			else{
				services[j].parentNode.style.display = "none";
			}

		}		
		
	}	
	
	function contains(array, value){
		for (k = 0; k < array.length; k++){
			if(array[k] == value){
				return true;
			}
		}
		return false;
	}

	/* Utillitis */

	function getElementsByClassName(class_name)
	{
	  var all_obj,ret_obj=new Array(),j=0;
	  if(document.all)all_obj=document.all;
	  else if(document.getElementsByTagName && !document.all)all_obj=document.getElementsByTagName("*");
	  for(i=0;i<all_obj.length;i++)
	  {
	    if(all_obj[i].className==class_name)
	    {
	      ret_obj[j]=all_obj[i];
	      j++
	    }
	  }
	  return ret_obj;
}   


function addCSSRule(selector, attributes){
var ss = document.styleSheets[document.styleSheets.length-2];
if(ss.insertRule) 
{
ss.insertRule(selector + '{' + attributes + '}', ss.cssRules.length);
}
else if(ss.addRule)
{
ss.addRule(selector, attributes);
}
}

			document.getElementsByAttribute=function(attrN,attrV,multi){
			    attrV=attrV.replace(/\|/g,'\\|').replace(/\[/g,'\\[').replace(/\(/g,'\\(').replace(/\+/g,'\\+').replace(/\./g,'\\.').replace(/\*/g,'\\*').replace(/\?/g,'\\?').replace(/\//g,'\\/');
			    var
			        multi=typeof multi!='undefined'?
			            multi:
			            false,
			        cIterate=typeof document.all!='undefined'?
			            document.all:
			            document.getElementsByTagName('*'),
			        aResponse=[],
			        re=new RegExp(multi?
			            '\\b'+attrV+'\\b':
			            '^'+attrV+'$'),
			        i=0,
			        elm;
			    while((elm=cIterate.item(i++))){
			        if(re.test(elm.getAttribute(attrN)||''))
			            aResponse[aResponse.length]=elm;
			    }
			    return aResponse;
			}	