

//the searcher refresh all tables with the current searchKey. 
function searcher(headerColor1,headerColor2,imgUrl,id)
{
	search(28,headerColor1,imgUrl,getGuiParamToArray(28),id);
	document.getElementById("nr28").value=1;
	search(29,headerColor2,imgUrl,getGuiParamToArray(29),id);
	document.getElementById("nr29").value=1;
	search(30,headerColor2,imgUrl,getGuiParamToArray(30),id);
	document.getElementById("nr30").value=1;
	search(31,headerColor2,imgUrl,getGuiParamToArray(31),id);
	document.getElementById("nr31").value=1;
	search(32,headerColor2,imgUrl,getGuiParamToArray(32),id);
	document.getElementById("nr32").value=1;
	search(33,headerColor2,imgUrl,getGuiParamToArray(33),id);
	document.getElementById("nr33").value=1;
}

//the search method refresh only the table which has the selector value as id. 
//the method use the current searchKey for result filtering. 
//headerColor= table haeder background color
//imgUrl = Url to the Sort Images
//id= Page identifier like pr,managment and s.o
function search(selector,headerColor,imgUrl,searchArray,id)	{
var sortDirection;
var xmlHttp  = false;
results="";
// XMLHttpRequest-Instanz erstellen
// ... für Internet Explorer
try {
    xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
    try {
        xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
        xmlHttp  = false;
    }
}
// ... für Mozilla, Opera und Safari
if (!xmlHttp  && typeof XMLHttpRequest != 'undefined') {
    xmlHttp = new XMLHttpRequest();
}
if(document.getElementById('Sort'+selector+'-1')!=null)
{
if((document.getElementById('Sort'+selector+'-1').src).indexOf("down")>0){
	sortDirection="desc";
	document.getElementById('Sort'+selector+'-1').src=''+imgUrl+'img/up.gif';
}else{
	sortDirection="asc";
	document.getElementById('Sort'+selector+'-1').src=''+imgUrl+'img/down.gif';
}
}else{
 sortDirection="asc";
}
if (xmlHttp) { 
     xmlHttp.open('GET', ''+imgUrl+'ajax_dba.php?'+'&id='+id+'&sortDirection='+sortDirection+'&col='+searchArray["sort"]+'&selector='+selector+'&headerColor='+headerColor+'&searchKey='+searchArray['searchKey']+'&searchKey2='+searchArray["searchKey2"]+'&standort='+searchArray["standort"]+'&filterCountry='+searchArray["filterCountry"]+'&filterUnternehmensschwerpunkt='+searchArray["filterUnternehmensschwerpunkt"]+'&filterBranch='+searchArray["filterBranch"]+'&nr='+searchArray["nr"]+'&sort='+searchArray["sort"]+'&user='+searchArray["user"]+'&group='+searchArray["group"],true);
     xmlHttp.onreadystatechange = function () {
         if ((xmlHttp.readyState == 4)&& xmlHttp.responseText!="") {
	     	document.getElementById("resTable"+selector).innerHTML=xmlHttp.responseText;
         }
     };
     xmlHttp.send(null);
 }
}
//the sortBy method refresh only the table which has the selector value as id. 
//the method use the current searchKey for result filtering and the col value to know how
//it has to sort. 
//headerColor= table haeder background color
//imgUrl = Url to the Sort Images
//id= Page identifier like pr,managment and s.o
//col= Stay for the Columne or attribute , which will be used for the sort
function sortBy(col,selector,headerColor,imgUrl,id)	{
var sortDirection;
if(document.getElementById("sort"+selector)!=null)
{
document.getElementById("sort"+selector).value=col;
}
//var xmlHttp = false;
results="";
// XMLHttpRequest-Instanz erstellen
// ... für Internet Explorer
try {
    xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
    try {
        xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
        xmlHttp  = false;
    }
}
// ... für Mozilla, Opera und Safari
if (!xmlHttp  && typeof XMLHttpRequest != 'undefined') {
    xmlHttp = new XMLHttpRequest();
}
if(document.getElementById('Sort'+selector+'-1')!=null)
{
if((document.getElementById('Sort'+selector+'-'+col).src).indexOf("down")>0){
	sortDirection="asc";
	document.getElementById('Sort'+selector+'-'+col).src=''+imgUrl+'img/up.gif';
}else{
	sortDirection="desc";
	document.getElementById('Sort'+selector+'-'+col).src=''+imgUrl+'img/down.gif';
}
}else{
 sortDirection="asc";
}
searchArray=getGuiParamToArray(selector);
if (xmlHttp) { 
     xmlHttp.open('GET', ''+imgUrl+'ajax_dba.php?sortDirection='+sortDirection+'&col='+col+'&selector='+selector+'&headerColor='+headerColor+'&searchKey='+searchArray['searchKey']+'&searchKey2='+searchArray["searchKey2"]+'&standort='+searchArray["standort"]+'&filterCountry='+searchArray["filterCountry"]+'&filterUnternehmensschwerpunkt='+searchArray["filterUnternehmensschwerpunkt"]+'&filterBranch='+searchArray["filterBranch"]+'&id='+id+'&nr='+searchArray["nr"]+'&sort='+searchArray["sort"]+'&user='+searchArray["user"]+'&group='+searchArray["group"]+'&foundedOut=1',true);
     xmlHttp.onreadystatechange = function () {
         if ((xmlHttp.readyState == 4)&& xmlHttp.responseText!="") {
	     	document.getElementById("resTable"+selector).innerHTML=xmlHttp.responseText;
         }
     };
     xmlHttp.send(null);
}
}

// This funktion will be used for the tap bgcolor and color changing. 
function tapper(selectedContent,selectedTab,e)
{


	document.getElementById("aaOne").style.color='#707070';
    document.getElementById("aaTwo").style.color='#707070';
    document.getElementById("aaThree").style.color='#707070';
    document.getElementById("aaFour").style.color='#707070';
    document.getElementById("aaFive").style.color='#707070';
    document.getElementById("aaSix").style.color='#707070';
    document.getElementById("a"+selectedTab).style.color='#832406';		
	document.getElementById("aOne").style.backgroundColor='#FFF';
    document.getElementById("aTwo").style.backgroundColor='#FFF';
    document.getElementById("aThree").style.backgroundColor='#FFF';
    document.getElementById("aFour").style.backgroundColor='#FFF';
    document.getElementById("aFive").style.backgroundColor='#FFF';
    document.getElementById("aSix").style.backgroundColor='#FFF';
    document.getElementById(selectedTab).style.backgroundColor='#DDDDDD';		
    //e.className="checkBorder";
	document.getElementById("one").style.display="none";
	document.getElementById("two").style.display="none";
	document.getElementById("three").style.display="none";
	document.getElementById("four").style.display="none";
	document.getElementById("five").style.display="none";
	document.getElementById("six").style.display="none";
	document.getElementById(selectedContent).style.display="block";
}




//the pagerCenter method refresh only the table which has the selector value as id. 
//the method use the current searchKey for result filtering and the col value to know how
//it has to sort. The result is the current selected result Page. E.g. page 2 if  page 2 is selected
//or page 3 if page 3 is on the pagescroller selected.  
//headerColor= table haeder background color
//imgUrl = Url to the Sort Images
//id= Page identifier like pr,managment and s.o
//col= Stay for the Columne or attribute , which will be used for the sort
function pagerCenter(col,selector,headerColor,imgUrl,id)	{
var sortDirection;
if(document.getElementById("sort"+selector)!=null)
{
document.getElementById("sort"+selector).value=col;
}
//var xmlHttp = false;
results="";
// XMLHttpRequest-Instanz erstellen
// ... für Internet Explorer
try {
    xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
    try {
        xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
        xmlHttp  = false;
    }
}
// ... für Mozilla, Opera und Safari
if (!xmlHttp  && typeof XMLHttpRequest != 'undefined') {
    xmlHttp = new XMLHttpRequest();
}
if(document.getElementById('Sort'+selector+'-1')!=null)
{
if((document.getElementById('Sort'+selector+'-'+col).src).indexOf("down")>0){
	sortDirection="desc";
	document.getElementById('Sort'+selector+'-'+col).src=''+imgUrl+'img/up.gif';
}else{
	sortDirection="asc";
	document.getElementById('Sort'+selector+'-'+col).src=''+imgUrl+'img/down.gif';
}
}else{
 sortDirection="asc";
}
searchArray=getGuiParamToArray(selector);
if (xmlHttp) { 
     xmlHttp.open('GET', ''+imgUrl+'ajax_dba.php?sortDirection='+sortDirection+'&col='+col+'&selector='+selector+'&headerColor='+headerColor+'&searchKey='+searchArray['searchKey']+'&searchKey2='+searchArray["searchKey2"]+'&standort='+searchArray["standort"]+'&filterCountry='+searchArray["filterCountry"]+'&filterUnternehmensschwerpunkt='+searchArray["filterUnternehmensschwerpunkt"]+'&filterBranch='+searchArray["filterBranch"]+'&id='+id+'&nr='+searchArray["nr"]+'&sort='+searchArray["sort"]+'&user='+searchArray["user"]+'&group='+searchArray["group"],true);
     xmlHttp.onreadystatechange = function () {
         if ((xmlHttp.readyState == 4)&& xmlHttp.responseText!="") {
	     	document.getElementById("resTable"+selector).innerHTML=xmlHttp.responseText;
         }
     };
     xmlHttp.send(null);
}
}

// Will be used to scroll a page back in a result list.
function pagerBack(selector,headerColor,imgUrl,id)
{
var posb;
posb=parseInt(document.getElementById("nr"+selector).value);
posb--;
document.getElementById("nr"+selector).value=posb;
searchArray=getGuiParamToArray(selector);
pagerCenter(searchArray["sort"],selector,headerColor,imgUrl,id);
//search(selector,headerColor,imgUrl,getGuiParamToArray(selector),id);
}
// Will be used to scroll a page forward in a result list.
function pagerForward(selector,headerColor,imgUrl,id,end)
{   
var posf;
posf=parseInt(document.getElementById("nr"+selector).value);
posf++;
if(posf>end)
{
posf=parseInt(end);
}
document.getElementById("nr"+selector).value=posf;
searchArray=getGuiParamToArray(selector);
pagerCenter(searchArray["sort"],selector,headerColor,imgUrl,id);
//search(selector,headerColor,imgUrl,getGuiParamToArray(selector),id);
}

// Will be used to scroll to a page , with were selected on the scroll pager.
function pager(nr,selector,headerColor,imgUrl,id)
{   
document.getElementById("nr"+selector).value=nr;
searchArray=getGuiParamToArray(selector);
pagerCenter(searchArray["sort"],selector,headerColor,imgUrl,id);
//search(selector,headerColor,imgUrl,getGuiParamToArray(selector),id);
}

// will be used to give all ajax function the Form parameter
function getGuiParamToArray(id)
{
searchArray = new Array();
searchArray["searchKey"]  = document.getElementById('searchKey').value;
searchArray["searchKey2"] = document.getElementById('searchKey2').value;
searchArray["standort"]   = document.getElementById('standort').value;
searchArray["filterCountry"] = document.getElementById('filterCountry').value;
searchArray["filterUnternehmensschwerpunkt"] = document.getElementById('filterUnternehmensschwerpunkt').value;
searchArray["filterBranch"]= document.getElementById('filterBranch').value;
searchArray["user"]=document.getElementById('user').value;
searchArray["group"]=document.getElementById('group').value;
if(document.getElementById("nr"+id)!=null)
{
searchArray["nr"]=document.getElementById("nr"+id).value;
searchArray["sort"]=document.getElementById("sort"+id).value;
}
return searchArray;
}

if(document.getElementById('searchModExtra')!=null)
{
window.addEvent('domready', function(){
			//-vertical
			var mySlide = new Fx.Slide('searchModExtra',{duration: 800});
			    mySlide.hide();
			    document.getElementById('searchModExtra').style.display="block";
			    mySlide.slideOut();
			$('aShowMore').addEvent('click', function(e){
				e = new Event(e);
				mySlide.toggle();
				e.stop();
			});
		}); 
}
			
