String.prototype.replaceAll = function (pattern,toreplace) {
	var datas = this.split(pattern);
	var ret="";
	for( var c = 0; c < datas.length; c++ ) {
		ret += datas[c];
		if(c < datas.length-1) ret += toreplace;
	}
	return ret;
}
String.prototype.Trim = function () {
    return (this.replace(/\s+$/,"").replace(/^\s+/,""));
}

var myEventOjects = new Array();
var mycontainer = "";


function AdpAjaxEvent_loadCallBack() {
	for(i=0;i<myEventOjects.length;i++) {
       		if(myEventOjects[i]==null) break;
      		myEventOjects[i].checkAndSetContainer();
    	}
}
function AdpAjaxEvent(mycontainer) {
	this.container = mycontainer;
	this.readyLoaded=false;
	this.http_request=new Object();
	this.aborted=false;
	this.url="";
	
	this.ajaxInit = function() {
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
            this.http_request = new XMLHttpRequest();
            if (this.http_request.overrideMimeType) {
                this.http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
            try {
                this.http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    this.http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }
	}

	this.getHttpRequest = function() {
		return this.http_request;
	}

	this.getContainer = function() {
		return this.container;
	}
	
	this.loadContainer = function(url) {
		if(eval("document.getElementById('"+this.container+"')") == null ) return;
		this.ajaxInit();
		this.url=url;
		if( this.http_request != null ) {      
    	    	this.http_request.open( "GET", url, true );
        	this.http_request.onreadystatechange = AdpAjaxEvent_loadCallBack;
	        this.http_request.send( null );
	        //this.http_request.open( "POST", url, true );
	        //this.http_request.onreadystatechange = AdpAjaxEvent_loadCallBack;
	        //this.http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	        //this.http_request.send(url);
		} else {
			alert("http-request is null");
		}
	}
	
	this.checkAndSetContainer = function() {
	  if( this.aborted==true) return;
      	  if( 4 == this.http_request.readyState ) {
      			  if( 200 != this.http_request.status ) {
      			    eval("document.getElementById('"+this.container+"')").innerHTML =  this.http_request.statusText;
      			  } else {
      			    if(this.readyLoaded==true) return;
      			    eval("document.getElementById('"+this.container+"')").innerHTML = this.http_request.responseText;
      			  }
      			  this.readyLoaded=true;
      	  }
	}
}
	



function adp_goUrl(url) {
	window.location = adp_getUrl(url);
}

function resetNavDivs() {
	document.getElementById('homenav').className='navtd';
	document.getElementById('companynav').className='navtd';
	document.getElementById('segmentsnav').className='navtd';
	document.getElementById('customersnav').className='navtd';
	document.getElementById('contactnav').className='navtd';
	document.getElementById('impressumnav').className='navtd';
	
}

function adp_loadContainer(url,container,divid,divclass) {
	myEventOjects=new Array();
	obj1 = new AdpAjaxEvent(container);
	myEventOjects[0]=obj1;
	obj1.loadContainer(url);
	resetNavDivs();
	document.getElementById(divid).className=divclass;
}

function adp_loadSegmentav( segdiv )  {
	document.getElementById('segmentnav2').innerHTML="<table cellpadding='0' cellspacing='0'><tr height='20px'><td>&nbsp;</td></tr><tr><td class='navtd'><div id='segment1' class='navtd'><a class='navlink' href='#' onclick="+"\"adp_loadContainer('geschaeft.html','ttarget','segmentsnav','navtdselected4');adp_loadSegmentav(1);\""+">datenbanken</a></div></td></tr><tr><td class='navtd'><div id='segment2' class='navtd'><a class='navlink' href='#' onclick="+"\"adp_loadContainer('geschaeft2.html','ttarget','segmentsnav','navtdselected4');adp_loadSegmentav(2);\""+">software</a></div></td></tr><tr><td class='navtd'><div id='segment3' class='navtd'><a class='navlink' href='#' onclick="+"\"adp_loadContainer('geschaeft3.html','ttarget','segmentsnav','navtdselected4');adp_loadSegmentav(3);\""+">webapplikationen</a></div></td></tr></table>";
	document.getElementById('impressumspacer').style.margin='6px 0px 0px 0px';
	if(segdiv == 1) {
		document.getElementById('segment1').className='navtdselected4';
	} else {
		document.getElementById('segment1').className='navtd';
		if( segdiv == 2 ) {
			document.getElementById('segment2').className='navtdselected4';	
		} else {
			document.getElementById('segment2').className='navtd';
			if( segdiv == 3 ) {
				document.getElementById('segment3').className='navtdselected4';	
			}
		}
		
	}
}

function adp_hideSegmentnav() {
	document.getElementById('segmentnav2').innerHTML='';
	document.getElementById('impressumspacer').style.margin='90px 0px 0px 0px';
}

function nextPicture() {
	var src = document.getElementById('imgid').src;
	if( src.indexOf("haus2") > -1 ) {
		document.getElementById('imgid').src = 'buero.jpg';
		document.getElementById('morepicures').innerHTML='&nbsp;';
	}
}
