function emailpopup(mailid, typ, schemaid, wellenid)
{
  link = "/kontakt/index.php?modus=popup&mailid="+mailid+"&type="+typ+"&schema_id="+schemaid+"&wellen_id="+wellenid;
  popup(link,540,540);
}

function emailpopup2(mailid, typ, wellenid, bundeslandid)
{
  link = "/kontakt/index.php?modus=popup&mailid="+mailid+"&type="+typ+"&bundesland_id="+bundeslandid+"&wellen_id="+wellenid;
  popup(link,540,540);
}

function emailpopup3(progid)
{
  link = "/kontakt/index.php?modus=popup&prog_id="+progid;
  popup(link,540,540);
}

function emailpopup4(progid,mailid,typ)
{
  link = "/kontakt/index.php?modus=popup&prog_id="+progid+"&mailid="+mailid+"&type="+typ;
  popup(link,540,540);
}

function popup(url, w, h)
{
  var now = new Date();
  var name = "Popup" + now.getTime();
  window.open(url,name,"width="+w+",height="+h+",resizable=yes,scrollbars=yes");
}

function popupFenster(url, w, h)
{
  var now = new Date();
  var name = "Popup" + now.getTime();
  window.open(url,name,"width="+w+",height="+h+",resizable=yes,scrollbars=yes");
}

function popup2(url, w, h, name)
{
  window.open(url,name,"width="+w+",height="+h+",resizable=yes,scrollbars=yes");
}

function popup3(url, w, h, name)
{
  window.open(url,name,"width="+w+",height="+h+",resizable=no,scrollbars=no");
}

function stdpopup(url, groesse)
{
  if(groesse==1)  // kleines Popup + 20px fuer Scrollbalken
    popup(url, 440, 250);
  if(groesse==2)  // mittleres Popup + 20px fuer Scrollbalken
    popup(url, 440, 350);
  if(groesse==3)  // grosses Popup + 20px fuer Scrollbalken
    popup(url, 440, 450);
}

function emailtofriend()
{
  popup("/cgi-bin/emailtofriend.pl?which=show&url="+location.pathname+"&search="+escape(location.search), 470, 440);
}

function bookmark()
{
  var ver = navigator.appName;
  var num = parseInt(navigator.appVersion);

  if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) {
    window.external.AddFavorite(location.href, document.title);
  }
  else {
    alert("Leider kann Ihr Browser nicht automatisch einen Bookmark setzen. Bitte benutzen Sie statt dessen die Tastenkombination 'Strg-D'.");
  }
}

function zoompic(url, w, h)
{
  popup("/imperia/showpic.php?url="+url, w+40, h+65);
}

function zoompic2(url, w, h, bu)
{
  if ((bu) && (bu != "")) {
    var reg = /\s+/g;
    var neu = bu.replace(reg, "_");
    popup("/imperia/showpic.php?url="+url+"&bu="+neu, w+40, h+85);
  }
  else  {
    popup("/imperia/showpic.php?url="+url, w+40, h+85);
  }
}

function gallery(groupid, galleryid, w, h, img)
{
  if (groupid=="")
    groupid=0;
  if (w < 380)  { w = 380; }
  if (h < 470)  { h = 470; }
  if (img != "")  {
    popup("/imagegallery/index.php?group="+groupid+"&gallery="+galleryid+"&image="+img, w, h);
  }
  else  {
    popup("/imagegallery/index.php?group="+groupid+"&gallery="+galleryid, w, h);
  }
}

function surfto(form) {
  var myindex=form.dest.selectedIndex;

  if(form.dest.options[myindex].value!="")
    location = form.dest.options[myindex].value;
}

function surfto2(form, pull) {
  var myindex=document.forms[form].elements[pull].selectedIndex;

  if(document.forms[form].elements[pull].options[myindex].value!="")  {
    var test = document.forms[form].elements[pull].options[myindex].value;
    var ergebnis = test.match(/http:/gi);
    if (ergebnis != null) {
      window.open(test);
    }
    else  {
      parent.location = test;
    }
  }
}

function SelectItem(SelectBox, Item, Type)
{
  var lv=0;
  for (lv=0;(lv < SelectBox.options.length);lv++) {
    if (Type == "TEXT") {
      if (SelectBox.options[lv].text == Item) {
        SelectBox.options[lv].selected = true;
        return true;
      }
    }
    else {
      if (Type == "VALUE") {
        if (SelectBox.options[lv].value == Item) {
          SelectBox.options[lv].selected = true;
          return true;
        }
      }
      else {
        return false;
      }
    }
  }
  return false;
}

function selSucheDatum()
{
   heute = new Date();

   year = heute.getFullYear();
   month = heute.getMonth()+1;
   day =  heute.getDate();


   if(month < 10) {month ="0".month;}
   if(day< 10) {day ="0".day;}

   if ( SelectItem(document.forms["imperia"].elements["endyear"], String(year), "VALUE") != true) {}
   if ( SelectItem(document.forms["imperia"].elements["endmon"], String(month), "VALUE") != true) {}
   if ( SelectItem(document.forms["imperia"].elements["endday"], String(day), "VALUE") != true) {}

   startyear = document.forms["imperia"].elements["defaultyear"].value;
   startmonth = document.forms["imperia"].elements["defaultmon"].value;
   startday =  document.forms["imperia"].elements["defaultday"].value;

   if ( SelectItem(document.forms["imperia"].elements["startyear"], String(startyear), "VALUE") != true) {}
   if ( SelectItem(document.forms["imperia"].elements["startmon"], String(startmonth), "VALUE") != true) {}
   if ( SelectItem(document.forms["imperia"].elements["startday"], String(startday), "VALUE") != true)   {}

}

function checknl(Emailshift)
{
  var Email = /^[a-zA-Z0-9-\.\_]+@[a-zA-Z0-9-\_]+\.[a-zA-Z-\.\_]+$/
  var alerttxt = "Bitte überprüfen Sie:\n";
  var iserror = false;
  if(Emailshift=="") {
    iserror = true;
    alerttxt += "\nBitte geben Sie eine E-Mailadresse an.";
  } else {
    if(!Email.test(Emailshift)) {
      iserror = true;
      alerttxt += "\nDas E-Mailformat stimmt nicht z.B. name@domain.de";
    }
  }
  if(iserror) {
    alert(alerttxt);
    return false;
  } else {
    return true;
  }
}

function webplayer(url, type, id, media,descr,descr_long) {
                //alert(descr +" - "+descr_long);
                //alert(descr.indexOf("\""));
                //alert(escape(descr_long));

    var isNav4, isIE4,height;
    var which = null;
    if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
        isNav4 = (navigator.appName == "Netscape") ? 1 : 0;
        isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
      }

    if (media=="audio")
    {height=300; }
    else
    {height=447; }

    if(isNav4){
        wwin = window.open("http://www1.swr.de/mediaplayer/player/webplayerframes.php?nurl=" + escape(url) + '&prog_id=' + id + '&type=' + type + '&media=' + media+ '&descr='+escape(descr)+ '&descr_long='+escape(descr_long),"Webradio","width=440,height=' + height+ ',resizable=no,scrollbars=no");
        wwin.focus();
    } else{
        wwin = window.open("http://www1.swr.de/mediaplayer/player/webplayerframes.php?nurl=" + escape(url) + '&prog_id=' + id + '&type=' + type + '&media=' + media+ '&descr='+escape(descr)+ '&descr_long='+escape(descr_long),"Webradio","width=440,height=' + height+ ',resizable=no,scrollbars=no");
        wwin.focus();
    }
  }

function setStartseite() {
  if (document.getElementById) {
    document.getElementById("setstart").style.behavior= "url(#default#homepage)";
    document.getElementById("setstart").sethomepage("http://www.swr.de/");
  }
  else if (document.all) {
    document.all.setstart.style.behavior= "url(#default#homepage)";
    document.all.setstart.sethomepage("http://www.swr.de/");
  }
}

function startWebradio() {
 var wwin = window.open('/mediaplayer/webradio.php?type=all&sch_id=47','Webradio','width=520,height=505,resizable=yes,scrollbars=yes');
 wwin.focus();
}

function startMediaplayerPopup(url, w, h, name) {
 var wwin = window.open(url,name,"width="+w+",height="+h+",resizable=yes,scrollbars=yes");
 wwin.focus();
}
