//
// Allgemeines PopUp
//
function popup(page,x,y,s,titel) {
  if (!x) { x = "510" }
  if (!y) { y = "510" }
  if (!s) { s = "1" }
  if (!titel) { titel = x +""+ y; }
  PopWindow=window.open(page,titel,"scrollbars="+s+",resizable=yes,width="+x+",height="+y);
  PopWindow.focus();
}


//
// Spezielle PopUps
//

// Foto öffnen
function foto(modus,memberid,fotoid) {
    var zusatz = "";
    if (fotoid) {
        zusatz += "&foto="+fotoid;
    }

    if (modus == 1) {
        popup("/showfoto.php?id="+memberid+zusatz+"&art=1",620,540,1,"FotoWindow1");
    } else if (modus == 2) {
        popup("/showfoto.php?id="+memberid+zusatz+"&art=A",620,540,1,"FotoWindow2");
    } else if (modus == 3) {
        popup("/showfoto.php?id="+memberid+zusatz+"&art=E",620,540,1,"FotoWindow2");
    }
}

// Interview
function Interview(id) {
  popup("/popup_index.php?mode=interview&id="+id,670,450,1,"InterviewWindow");
}

// Postkarte
function postcard(id) {
    url = "http://www.digital-postcard.ch/dp_singles.php?memberid=" + id + "";
    neu=window.open(url,"Postcard","toolbar=no,scrollbars=yes,directories=no,menubar=no,resizable=yes,width=480,height=490");
    neu.focus();
}

// Profil-Fenster
function ProfilWin(id,name) {
  if (id == "0") { id = "0"; }
  if (!id) { id = ""; }
  if (!name) { name = ""; }
  popup("/popup_index.php?mode=profil&id="+id+"&name="+name,670,450,1,"ProfilWindow"+id);
}

// Konto-Fenster
function Konto() {
  popup("/popup_index.php?mode=konto",730,520,1,"KontoWindow");
}

// Punkte-Fenster
function Punkte() {
  popup("/popup_index.php?mode=punkte",670,450,1,"PunkteWindow");
}


// Nachricht schreiben
function nachricht(id,aid,msgid) {
  //if (aid == undefined) { aid = "0"; }
  //if (msgid == undefined) { msgid = "0"; }
  popup("/popup_index.php?mode=msgwrite&id="+id+"&aid="+aid+"&msgid="+msgid,670,500,1,"MsgWindow"+id+"x"+aid+"x"+msgid);
}

// Nachrichten-Fenster
function MsgWin() {
  popup("/popup_index.php?mode=msg",670,500,1,"MsgWindow");
}

// Favorit hinzufügen
function FavAdd(id) {
  popup("/popup_index.php?mode=fav&id="+id,670,450,1,"FavWindow");
}

// Richtlinien (Gelbe Karte)
function Richtlinien(id) {
  popup("/popup_index.php?mode=gelbekarte&id="+id,670,450,1,"GKWindow");
}

// Richtlinien Erotik (Gelbe Karte)
function Richtlinien2(id) {
  popup("/popup_index.php?mode=gelbekarte_erotik&id="+id,670,450,1,"GKEWindow");
}


// Hilfe-Fenster
function Help(id,topic) {
  popup("/popup_index.php?mode=help&id="+id+"&topic="+topic,500,600,1,"HelpWindow");
}


// Fotos wählen
function FotoWahl(ids) {
  ids = document.form1.Fotos.value;
  popup("popup_index.php?mode=fotowahl&IDs="+ids,690,400,0,"FotoWindow");
}




//
// Favoriten
//
function addfav() {
    window.external.AddFavorite('http://www.singles.ch', 'singles.ch - Der original Kontaktanzeiger der Schweiz');
}


// Member-Liste anzeigen / schliessen
function MemberList(status) {
  mainpage = escape(top.siindex2.simain.location.href);
  top.siindex2.location.href = "index2.php?showlist="+status+"&page="+mainpage;
  top.sionline.location.href = "online.php?showlist="+status;
}


//
// Seite des Hauptfensters ändern (von Popup aus)
//
function MainURL(page,modus) {
  if (top.opener.top.window) {
    //alert('test');
    top.opener.top.window.location.href = page;
    if (modus == 1) {
        top.opener.focus();
    }
  }
}


//
// Smily in Nachricht hinzufügen
//
function AddSmily(code) {
  var d = document.form1.text;

  if (d.createTextRange && d.caretPos) {
    var caretPos = d.caretPos;
    caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? code + ' ' : code;
  } else {
    d.value += code;
  }

  d.focus();
}

// Zusatzfunktion für AddSmily
function getActiveText(selectedtext) {
  text = (document.all) ? document.selection.createRange().text : document.getSelection();
  if (selectedtext.createTextRange) {
    selectedtext.caretPos = document.selection.createRange().duplicate();
  }
  return true;
}


//
// Formular senden
//
function SendForm(d) {
  d.submit2.disabled = true;
  d.submit2.value = "Wird gesendet...";
  d.submit();
}


//
// Kreditkarten-Zahlung
//
function ccpop() {
  id = document.form.id.value;
  betrag = document.form.betrag.value;
  abo = document.form.abo.value;
  PopWindow=window.open("https://secure.singles.ch/ccpay.php?id="+id+"&betrag="+betrag+"&abo="+abo,"ccpay","scrollbars=yes,menubar=no,status=yes,location=yes,toolbar=yes,resizable=yes,width=500,height=450");
  PopWindow.focus();
  return false;
}

