// Javascript
function createRequestObject()
{
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer")
    {
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sndReq(element, postdata, action)
{
	http.open('POST', action);
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    	http.onreadystatechange = new Function("handleResponse('" + element + "');");
    	http.send(postdata);
}

function handleResponse(element)
{
    	if(http.readyState == 4)
    	{
		document.getElementById(element).innerHTML=http.responseText;
	}

}

function update_firma_eintragen(dpage)
{
  	var postdata;

	if (dpage=='send')
	{
		postdata = postdata + '&reg_company='+document.getElementById('reg_company').value;
     	postdata = postdata + '&reg_kontakt='+document.getElementById('reg_kontakt').value;
		postdata = postdata + '&reg_branche='+document.getElementById('reg_branche').value;
		postdata = postdata + '&reg_strasse='+document.getElementById('reg_strasse').value;
		postdata = postdata + '&reg_plz='+document.getElementById('reg_plz').value;
		postdata = postdata + '&reg_ort='+document.getElementById('reg_ort').value;
		postdata = postdata + '&reg_telvw='+document.getElementById('reg_telvw').value;
		postdata = postdata + '&reg_tel='+document.getElementById('reg_tel').value;
		postdata = postdata + '&reg_faxvw='+document.getElementById('reg_faxvw').value;
		postdata = postdata + '&reg_fax='+document.getElementById('reg_fax').value;
		postdata = postdata + '&reg_email='+document.getElementById('reg_email').value;
		postdata = postdata + '&reg_email='+document.getElementById('reg_email').value;
		postdata = postdata + '&reg_leistungen='+document.getElementById('reg_leistungen').value;
		if (document.getElementById('reg_agb').checked) postdata = postdata + '&reg_agb=1'; else postdata = postdata + '&reg_agb=0';
 	}
	else postdata='';

     sndReq('form_firma_eintragen', postdata, 'firma_eintragen.php?page='+dpage);
}

function update_firma_aendern(dpage,sid)
{
  	var postdata;

	if (dpage=='send')
	{
		postdata = postdata + '&reg_sid='+sid;
     	postdata = postdata + '&reg_kontakt='+document.getElementById('reg_kontakt').value;
		postdata = postdata + '&reg_email='+document.getElementById('reg_email').value;
		postdata = postdata + '&reg_content='+document.getElementById('reg_content').value;
	}
	else postdata = postdata + '&reg_sid='+sid;

     sndReq('form_firma_aendern', postdata, 'firma_aendern.php?page='+dpage);
}

function update_firma_logo(dpage,sid)
{
  	var postdata;

	if (dpage=='send')
	{
		postdata = postdata + '&reg_sid='+sid;
     	postdata = postdata + '&reg_kontakt='+document.getElementById('reg_kontakt').value;
		postdata = postdata + '&reg_email='+document.getElementById('reg_email').value;
		postdata = postdata + '&reg_logo='+document.getElementById('reg_logo').value;
	}
	else postdata = postdata + '&reg_sid='+sid;

     sndReq('form_firma_logo', postdata, 'firma_logo.php?page='+dpage);
}




// Funktion lädt dynamischen js - Code
function sendRequest(searchTerm)
{
	var head = document.getElementsByTagName('head')[0];
	var script = document.createElement('script');
	script.type = 'text/javascript';
	script.src = 'http://www.companix.de/companix/autofill/' + searchTerm;
	head.appendChild(script);
}

function sendPHPJS(searchTerm)
{
	var head = document.getElementsByTagName('head')[0];
	var script = document.createElement('script');
	script.type = 'text/javascript';
	script.src = 'http://www.companix.de/'+ searchTerm;
	head.appendChild(script);
}

function show_more_sucheerg(idnr,idnr_box,hoehe)
{
	document.getElementById(idnr_box).style.height=hoehe;
	document.getElementById('suche_erg_' + idnr).style.display='inline';
	document.getElementById('suche_erg_mlink_' + idnr).style.display='none';
}
function hide_sucheerg(idnr,idnr_box,hoehe)
{
	document.getElementById(idnr_box).style.height=hoehe;
	document.getElementById('suche_erg_' + idnr).style.display='none';
	document.getElementById('suche_erg_mlink_' + idnr).style.display='inline';
}


function show_more_searcherg(idnr)
{
	document.getElementById('suchergebnis_liste_eintrag_erw_' + idnr).style.display='inline';
	document.getElementById('suchergebnis_liste_eintrag_mehrlink_' + idnr).style.display='none';
}
function show_more_ergdata(idnr,ztypnr)
{
	document.getElementById('st_ergdata_' + idnr + '_' + ztypnr).style.display='inline';
	document.getElementById('st_ergdata_link_' + idnr+ '_' + ztypnr).style.display='none';
}

function show_more_websitedata(idnr)
{
	document.getElementById('st_websitedata_' + idnr).style.display='inline';
	document.getElementById('st_websitedata_link_' + idnr).style.display='none';
}

function wicompanix_einblenden()
{
 	document.getElementById('mitte_content_oben1').style.height='100px';
 	document.getElementById('wicompanix_box').style.display='inline';
}

function einf_form_einblenden()
{
 	document.getElementById('reiter_suche_einfach').style.background='url(images/suchen_reiter_normal.jpg) left top no-repeat';
 	document.getElementById('reiter_suche_erweitert').style.background='url(images/suchen_reiter_highlight.jpg) left top no-repeat';
 	document.getElementById('form_erw_suche').style.display='none';
}
function erw_form_einblenden()
{
 	document.getElementById('reiter_suche_einfach').style.background='url(images/suchen_reiter_highlight.jpg) left top no-repeat';
 	document.getElementById('reiter_suche_erweitert').style.background='url(images/suchen_reiter_normal.jpg) left top no-repeat';
 	document.getElementById('form_erw_suche').style.display='inline';
}

function einf_form_einblenden2()
{
 	document.getElementById('reiter_suche_einfach2').style.background='url(images/suchen_reiter_normal2.jpg) left top no-repeat';
 	document.getElementById('reiter_suche_erweitert2').style.background='url(images/suchen_reiter_highlight2.jpg) left top no-repeat';
 	document.getElementById('form_erw_suche').style.display='none';
}
function erw_form_einblenden2()
{
 	document.getElementById('reiter_suche_einfach2').style.background='url(images/suchen_reiter_highlight2.jpg) left top no-repeat';
 	document.getElementById('reiter_suche_erweitert2').style.background='url(images/suchen_reiter_normal2.jpg) left top no-repeat';
 	document.getElementById('form_erw_suche').style.display='inline';
}

function show_please_wait()
{
 	document.getElementById('box_please_wait').style.display='inline';
}



function hide_firma_aendern()
{
	document.getElementById('form_firma_aendern').style.display='none';
}

function show_firma_aendern(sid)
{
	var lm_screenheight = document.body.clientHeight;
	if (lm_screenheight==null) lm_screenheight = window.innerHeight;
 	var lm_screenwitdth = document.body.clientWidth;
	if (lm_screenwitdth==null) lm_screenwitdth = window.innerWidth;

	lm_screenwitdt = (lm_screenwitdth/2-200);

     document.getElementById('form_firma_aendern').style.top= '130px';
     document.getElementById('form_firma_aendern').style.left= lm_screenwitdt + 'px';

	document.getElementById('form_firma_aendern').style.display='inline';
     update_firma_aendern('start',sid);
}

function show_firma_eintragen()
{
	var lm_screenheight = document.body.clientHeight;
	if (lm_screenheight==null) lm_screenheight = window.innerHeight;
 	var lm_screenwitdth = document.body.clientWidth;
	if (lm_screenwitdth==null) lm_screenwitdth = window.innerWidth;

	lm_screenwitdt = (lm_screenwitdth/2-200);

     document.getElementById('form_firma_eintragen').style.top= '130px';
     document.getElementById('form_firma_eintragen').style.left= lm_screenwitdt + 'px';
	document.getElementById('form_firma_eintragen').style.display='inline';
     update_firma_eintragen('start');
}
function hide_firma_eintragen()
{
	document.getElementById('form_firma_eintragen').style.display='none';
}

function show_firma_logo()
{
	var lm_screenheight = document.body.clientHeight;
	if (lm_screenheight==null) lm_screenheight = window.innerHeight;
 	var lm_screenwitdth = document.body.clientWidth;
	if (lm_screenwitdth==null) lm_screenwitdth = window.innerWidth;

	lm_screenwitdt = (lm_screenwitdth/2-200);

     document.getElementById('form_firma_logo').style.top= '130px';
     document.getElementById('form_firma_logo').style.left= lm_screenwitdt + 'px';
	document.getElementById('form_firma_logo').style.display='inline';
     update_firma_logo('start');
}
function hide_firma_logo()
{
	document.getElementById('form_firma_logo').style.display='none';
}



function alleerg_einblenden(alle_ids,buttonid)
{ 

	var i;
	var einzelne = alle_ids.split(";");

	for (i=0;i<(einzelne.length-1);i++)
	{
		document.getElementById(einzelne[i]).style.display='block';
          document.getElementById(einzelne[i]).style.background='#FFEEEE';
	}
	document.getElementById(buttonid +'_einblenden').style.display='none';
	document.getElementById(buttonid +'_ausblenden').style.display='block';
}

function alleerg_ausblenden(alle_ids,buttonid)
{

	var i;
	var einzelne = alle_ids.split(";");

	for (i=0;i<(einzelne.length-1);i++)
	{
		document.getElementById(einzelne[i]).style.display='none';
          document.getElementById(einzelne[i]).style.background='#FFFFFF';
	}
	document.getElementById(buttonid +'_ausblenden').style.display='none';
	document.getElementById(buttonid +'_einblenden').style.display='block';
}

 	function zu_fav()
  	{
  		window.external.addFavorite('http://www.companix.de','Companix.de - Die Firmensuchmaschine');
	}

     function s_onfocus(formname,starttext)
     {
		if (document.getElementById(formname).value == starttext) document.getElementById(formname).value = '';
	}
     function s_onblur(formname,starttext)
     {
		if (document.getElementById(formname).value == '') document.getElementById(formname).value = starttext;
	}

	function keypress_form(evt,formname)
	{
		evt = (evt) ? evt : (window.event) ? event : null;
  		if (evt)
  		{
    			var charCode = (evt.charCode) ? evt.charCode :
                   ((evt.keyCode) ? evt.keyCode :
                   ((evt.which) ? evt.which : 0));

    			if (charCode == 13)
		     {
       			frm = document.getElementById(formname);
     	          frm.submit();
			}
		}
	}

 	function keypress_form_q(evt,formname)
	{
		evt = (evt) ? evt : (window.event) ? event : null;
  		if (evt)
  		{
    			var charCode = (evt.charCode) ? evt.charCode :
                   ((evt.keyCode) ? evt.keyCode :
                   ((evt.which) ? evt.which : 0));

              	var begriff = document.getElementById('s_suche_begriff').value+String.fromCharCode(charCode);

             	if (begriff.length>2)
			{
                   	sendPHPJS('autoc_suchname.php?freitext_value='+begriff);
			}
			else
			{
                    document.getElementById('ac_s_suche_begriff').style.display ='none';
			}

    			if (charCode == 13)
		     {
       			frm = document.getElementById(formname);
     	          frm.submit();
			}
		}
	}
	function keypress_form_o(evt,formname)
	{
		evt = (evt) ? evt : (window.event) ? event : null;
  		if (evt)
  		{
    			var charCode = (evt.charCode) ? evt.charCode :
                   ((evt.keyCode) ? evt.keyCode :
                   ((evt.which) ? evt.which : 0));
			var begriff = document.getElementById('s_suche_plzort').value+String.fromCharCode(charCode);

             	if (begriff.length>2)
			{
                   	sendPHPJS('autoc_suche_plz.php?freitext_value='+begriff);
			}
			else
			{
                    document.getElementById('ac_s_suche_plz').style.display ='none';
			}

    			if (charCode == 13)
		     {
       			frm = document.getElementById(formname);
     	          frm.submit();
			}
		}
	}



