function winOpen(theURL,winName,features) 
{ 
  winName = window.open(theURL,winName,features); 
  
  if(winName == null || winName.closed)
    window.open(theURL,winName,features);
  else
    winName.location.href = theURL;

  if (!winName.closed) 
    winName.focus(); 
}

function switch2Url(targeturl)
{
  if (targeturl != null)
  {
    var values = targeturl.split(";"); 
    var target = values[0];
    var href = values[1];
    
    switch (target)
    {
      case "_self":
        self.document.location.href = href;
        break;
      case "_top":
        top.document.location.href = href;
        break;
      case "_parent":
        parent.document.location.href = href;
        break;
      case "_blank":
        window.open(href, target, "", "toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600");
        break;
      case "_winopen":
        window.open(href, target, "", "toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600");
        break;
      default:
        if (document.location.frames == null || document.location.frames[target])
          document.location.href = href;
        else
          document.location.frames[target].href = href;       
    }
  }
}

function sendSearch()
{
  var suchstring = escape(document.getElementById("suchanfrage").value);
  document.location.href = "/Suche.aspx?searchvalue=" + suchstring;
}

function stopSubmit(e)
{
  return false;
}

function stopEvent(e)
{
  if (!e)
    e = window.event;

  var keyCode = 0;

  if (e.which) {
    keyCode = e.which;
  } else if (e.keyCode) {
    keyCode = e.keyCode;
  }


  if(keyCode == 13 || keyCode == 96)
  {
    if (document.getElementById("onControls"))
    {   
      document.getElementById("onControls").onsubmit = stopSubmit; 
    }
    sendSearch();
  }
}

function setAction()
{
  document.getElementById("suchanfrage").onkeydown = stopEvent;
}

function printtxt()
  {
    var Url = encodeURI(document.location.href);
    window.open("/module/print/print.aspx?url=" +encodeURIComponent(Url)+"&outputtype=text", "Drucken","width=775,height=800,scrollbars=yes");
  }

function printpdf()
  {
    var Url = encodeURI(document.location.href);
    window.open("/module/print/print.aspx?url=" +encodeURIComponent(Url)+"&outputtype=pdf", "Drucken","width=775,height=800,scrollbars=yes");
  }

function printnormal()
  {
    var Url = encodeURI(document.location.href);
    window.open("/module/print/print.aspx?url=" +encodeURIComponent(Url)+"&outputtype=html", "Drucken","width=775,height=800,scrollbars=yes");
  }

function setCursor()
{
  var login = document.getElementById("UserLogin");
  if (login != null) {
    login.focus();
  }
}

function updateFBSuche()
{
  ajaxCallCBLAjax(document.getElementById("landesverbandfachbetriebe").value);
}


function myCallbackOCRcontent()
{
  if (document.location.href.indexOf('ContentReader.aspx?remotePage=/Software.aspx') > -1)
  {
    var e = document.getElementById('teaser');
    e.style.display = 'none';
  }
}
var isTeaser = false;

function setValueOnElement(id, value) {
  document.getElementById(id).value = value;
}

function myCallbackfooter_plzOrtUpd(value) {
  if ($(value).find('li').length > 0) {
    if(!isTeaser) {
      $('#plzchoose').css({"left": "705px", "top": "289px"});
    }
    $('#plzchoose').show();
  } else {
    setStadtMitte();
  }
}

function checkPLZ(teaser) {
  if (teaser) {
    isTeaser = teaser;
  }
  if ($('#plzbox')[0].value.length != 5 && $('#umkreisfachbetriebe')[0].value != -1 && $('#ortsname')[0].value != '') {
    ajaxCallfooter_plzOrtUpd($('#ortsname')[0].value);
  } else {
    plzortSubmit();
  }
  return false;
}

function setStadtMitte() {
  if ($('#ortsname')[0].value.indexOf('(Stadtmitte)') == -1) {
    $('#ortsname')[0].value += ' (Stadtmitte)';
    $('#plzbox')[0].value = '';
  }
  plzortSubmit();
}

function setPLZ(plz) {
  if ($('#ortsname')[0].value.indexOf('(Stadtmitte)') != -1) {
    $('#ortsname')[0].value = $('#ortsname')[0].value.replace(' (Stadtmitte)', '');
  }
  $('#plzbox')[0].value = plz;
  plzortSubmit();
}

function plzortSubmit() {
  $('#plzchoose').hide();
  if (isTeaser) {
    mySubmitfachbetriebe();
    document.forms[0].submit();
  } else {
    mySubmitfachbetriebe();
    document.forms[0].submit();
  }
}

  var xmlhttpfooter_plzOrtUpd;
   function loadXMLDocfooter_plzOrtUpd(url, callback, sc, params)
   {
     scriptCallback = 'if (callback){ callback(filterhtml(window["xmlhttp" + ClientID].responseText, "", ""));}';
     if (!callback || callback == '')
     {
       scriptCallback = '';
     }
     loadXMLDocV2(url, callback, sc, params, 'footer_plzOrtUpd', true, false, true, '', 25000, '0', scriptCallback, false, '', '', false, 'footer_plzOrtUpd', false, '__VIEWSTATE');
   }

 function callbackfooter_plzOrtUpd(result) 
{
  callbackAjaxV2(result, 'footer_plzOrtUpd', 'document.getElementById("footer_plzOrtUpd").innerHTML', false, '');
}

function ajaxCallfooter_plzOrtUpd(params)
{
  callback = 'callbackfooter_plzOrtUpd';
  scriptCallback = 'if (callback){ callback(filterhtml(window["xmlhttp" + ClientID].responseText, "", ""));}';
  scriptCallback = scriptCallback.replace(/callback/g, callback);
  if (!callback || callback == '')
  {
    scriptCallback = '';
  }

  ajaxCallAjaxV2(params, 0, '', 'document.getElementById("footer_plzOrtUpd").innerHTML', '\x2fmodule\x2fajax\x2fAjaxPlzOrt.aspx\x3fajax\x3dfooter_plzOrtUpd', 'callbackfooter_plzOrtUpd' , false, 'footer_plzOrtUpd', true, false, true, '' , 25000, '0', scriptCallback, false, '', '', false, 'footer_plzOrtUpd' , false, '__VIEWSTATE')
}

function myCallbackCBLAjax(html)
{
  var id = getParameterByName('stringRegionId');
  if (id != '' && document.getElementById('landesverbandRegionenfachbetriebe_Data_' + id))
  {
    document.getElementById('landesverbandRegionenfachbetriebe_Data_' + id).checked = true;
    checkPLZ(false);
  }
}

function getParameterByName( name ) 
{ 
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 
  var regexS = "[\\?&]"+name+"=([^&#]*)"; 
  var regex = new RegExp( regexS ); 
  var results = regex.exec( window.location.href ); 
  if( results == null ) 
    return ""; 
  else 
    return decodeURIComponent(results[1].replace(/\+/g, " ")); 
} 
