/*
 Einbinden:
 ----------
 <script src="popup.js"></script>
 <A HREF="grosses_bild.jpg" target="bild"
 onclick="return showBild(this, 'name_des_Bildes');"
 ><IMG SRC="kleines_bild.jpg"></A>
*/
///////////////////////////////////////////////////////////
// Globale Definitionen
var popup_bgColor = '#ffffff';
var rahmen        = '0px solid black';
var abstand_w      = 0;
var abstand_h      = 0;
var center_popup  = false;
var popup_close   = 'click'; // Mögliche Werte: 'blur', 'click', ''

///////////////////////////////////////////////////////////
// showBild(a, name) - die Hauptfunktion.
function showBild(a)
{
    if(!a.target) a.target = "BildFenster";
    var default_width   = 400;
    var default_height  = 200;

    if(popup_close == 'blur' || !showFenster || showFenster.closed != false
    )
    showFenster = popUp('', a.target, default_width, default_height);

    showFenster.document.open();
    showFenster.document.write( getHTML(a.href, a.title || a.alt) );
    showFenster.document.close();
    showFenster.focus();

    var img = new Image;
    img.ready = false;
    img.onload = function() { fitWin(this, showFenster);  };
    img.src = a.href;

    if(img.complete) fitWin(img, showFenster);

    return false;
}

///////////////////////////////////////////////////////////
// fitWin(Image, window) - wird aus dem Popup aufgerufen.
function fitWin(i, win)
{
    if(i.ready) return;
    i.ready = i.width > 0;
    var w_s = getWinSize(win);
    var r = 2 * parseInt(rahmen);
    var w = i.width > screen.width ? screen.width : i.width;
    var h = i.height > screen.height  ? screen.height  : i.height;
    if(i.width > screen.height || i.height > screen.width )
    {
    win.document.getElementsByTagName('body')[0].style.overflow = 'scroll';
    }

    win.resizeBy((w - w_s.width + ( 2 * abstand_w) + r), (h - w_s.height + ( 2 * abstand_h) + r) );

    if(center_popup && !window.opera)
    {
         w_s = getWinSize(win);
         win.moveTo(( screen.width - w_s.width) / 2, (screen.height - w_s.height) / 2 );
    }
    win.focus();
}



/////////////////////////////////////////////////////////////////////
// getHTML(bild, titel, farbe)
function getHTML(src, title, bgcolor)
{
    if(!title) title = 'kein Titel';
    if(!bgcolor) bgcolor = popup_bgColor;
    var NL = "\n";

    var text = '<!DOCTYPE HTML PUBLIC "-\/\/W3C\/\/DTD HTML 4.01\/\/EN" "http:\/\/www.w3.org\/TR\/html4\/strict.dtd">\n'
    + '<HTML>\n<HEAD>' + NL
    + '<TITLE>' + title + '<\/TITLE>' + NL
    + '<STYLE type="text/css">' + NL
    + 'body{margin:0;padding:0;overflow:hidden;' + NL
    + 'background-color:' + popup_bgColor  + ';}' + NL
    + 'img{padding:0;'
    + (rahmen ? 'border:' + rahmen + ';'  : '')
    + 'margin-top:' + abstand_h +'px;' + NL
    + 'margin-bottom:' + abstand_h +'px;' + NL
    + 'margin-left:' + abstand_w +'px;' + NL
    + 'margin-right:' + abstand_w +'px;' + NL
    + '}\n' + NL
    + '<\/STYLE>' + NL
    + '<\/HEAD>' + NL
    + '<body'
    + (popup_close.toLowerCase() == 'blur' ? ' onblur="self.close();"' : '')
    + '>'
    + '<img galleryimg="no" src="' + src + '" alt="" title="' + title + '"'
    + '>' + NL
    + (popup_close.toLowerCase() == 'click' ? '<script> document.images[0].onclick=function(){window.close()};</script>' : '')
    + '<\/body><\/html>'
    ;
    return text;
}
/////////////////////////////////////////////////////////////////////
// Ein popup öffnen
function popUp(url, fname, w, h)
{
    var tmp = new Array();
    tmp[tmp.length] = 'resizable=yes';
    tmp[tmp.length] = 'scrollbars=no';
    if(w) tmp[tmp.length] = 'width=' + w;
    if(h) tmp[tmp.length] = 'height=' + h;

    return window.open(url, fname, tmp.join(','));
}
////////////////////////////////////////////////////////////
// getWinSize(window)
function getWinSize(win)
{
    if(!win) win = window;
    var s = new Object();
    if(typeof win.innerWidth != 'undefined')
    {
        s.width = win.innerWidth;
        s.height = win.innerHeight;
    }
    else
    {
         var obj = getBody(win);
         s.width = parseInt(obj.clientWidth);
         s.height = parseInt(obj.clientHeight);
    }
    return s;
}
////////////////////////////////////////////////////////////
// Der IE hat 2 verschiedene Objekte für den strict und quirks Mode.
function getBody(w)
{
    return (w.document.compatMode && w.document.compatMode == "CSS1Compat") ? w.document.documentElement : w.document.body || null;
}
var showFenster = null;
/////////////////////////////////////////////////////////////////////
// ... und am schluss alle Fenster schliessen.
window.onunload = function ()
{
    if(showFenster && !showFenster.closed) showFenster.close();
}




function newhtml(code) {
	document.editform.description.value += code;
	document.editform.description.focus();
}
function format(format) {
	if (format == 'B') ptext="<? echo $format_bold_str;?>";
	if (format == 'I') ptext="<? echo $format_italic_str;?>";
	if (format == 'U') ptext="<? echo $format_underline_str;?>";
	if (format == 'CENTER') ptext="<? echo $format_center_str;?>";
	if (format == 'BIG') ptext="<? echo $format_big_str;?>";
	if (format == 'SMALL') ptext="<? echo $format_small_str;?>";
	text = prompt("<? echo $format_str;?>"+ptext,"");
	if (text != "" && text != null) {
		code = "<"+format+">"+text+"</"+format+">";
		newhtml(code);
	}
}
function list(format) {
	text = prompt("<? echo $list_first_str;?>","");
	if (text != "" && text != null) {
		code = "\n<"+format+">\n";
		while (text != "" && text != null) {
			code += " <LI>"+text+"\n";
			text = prompt("<? echo $list_next_str;?>","");
		}
		code += "</"+format+">";
		newhtml(code);
	}
}
function link() {
	text = prompt("<? echo $link_url_str;?>","http://");
	if (text != "" && text != null) {
		code = "<A HREF=\""+text+"\">";
		text2 = prompt("<? echo $link_name_str;?>","");
		if (text2 == "" || text2 == null) text2 = text;
		code += text2+"</A>";
		newhtml(code);
	}
}

///////////////////////////////////////////////////////////////////////////////
//Bildupload Vorschau

function showPic(Quelle)
{
	if(document.getElementById("preview"))
	{
		var source = document.getElementById("preview");
		if(Quelle)
		{
			Dateiendung=Quelle.substring(Quelle.lastIndexOf(".")+1);
			if(Dateiendung.toLowerCase() != "jpg" && Dateiendung.toLowerCase() != "jpeg" && Dateiendung.toLowerCase() != "gif" && Dateiendung.toLowerCase() != "png")
			{
				var Fehlermeldung = "Bitte wählen Sie eine Bilddatei aus.";
				alert(Fehlermeldung);
				document.getElementById("preview").value = "";
				document.getElementById("preview").src = "images/pixel.gif";
				return false;
			}
			else
			{
				document.getElementById("preview").src = Quelle;
				return true;
			}
		}
		else
		{
			return;
		}
	}
	else
	{
		return;
	}
}
///////////////////////////////////////////////////////////////////
////////// Textcounter /////////////////////////////////////////

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
countfield.value = maxlimit - field.value.length;
}
////////////////////////////////////////////////////////////////////
//////////// Favoriten hinzufügen ////////////////////////////////

function addFavorite() {
bookmarkurl=self.location.href;
bookmarktitle=document.title;
if (document.all) {
window.external.AddFavorite(bookmarkurl,bookmarktitle)
} else alert("Bitte bei Netscape STRG + D drücken");

}

////////////////////////////////////////////////////////////////////
//////////// Region wechseln ////////////////////////////////
  function changeRegion0() {
    var Pos = document.regional.region.options.selectedIndex;
    var newReg =  document.regional.region.options[Pos].value;
    if (newReg.length > 0 && newReg != "") {
      location.href = "http://"+newReg+".procy.de/";
    }
  }

  function changeRegion1() {
    var Pos = document.regional.region.options.selectedIndex;
    var fos = document.getElementById("makeit").value;
    var newReg =  document.regional.region.options[Pos].value;
    if (newReg.length > 0 && newReg != "") {
      location.href = "http://"+newReg+".procy.de/"+fos;
    }
  }

  function changeCategory() {
    var Pos = document.dirCategory.caty.options.selectedIndex;
    var newCat =  document.dirCategory.caty.options[Pos].value;
    if (newCat.length > 0 && newCat != "" && newCat != "0") {
    	if (newCat == "2000") {
	      location.href = "auto_transport_logistik.html"; }
    	if (newCat == "2500") {
	      location.href = "bauen_renovieren.html"; }
    	if (newCat == "5002") {
	      location.href = "beauty_wellness.html"; }
    	if (newCat == "3500") {
	      location.href = "beratung_hilfe.html"; }
    	if (newCat == "1600") {
	      location.href = "beruf_karriere.html"; }
    	if (newCat == "7000") {
	      location.href = "betreuung_pflege.html"; }
    	if (newCat == "3000") {
	      location.href = "buero_finanzen.html"; }
    	if (newCat == "5000") {
	      location.href = "fitness_erholung.html"; }
    	if (newCat == "1300") {
	      location.href = "freizeit_unterhaltung.html"; }
    	if (newCat == "1400") {
	      location.href = "gesundheit_medizin.html"; }
    	if (newCat == "1000") {
	      location.href = "haus_garten.html"; }
    	if (newCat == "8000") {
	      location.href = "minijobs.html"; }
    	if (newCat == "7500") {
	      location.href = "haustiere_zoo.html"; }
    	if (newCat == "1200") {
	      location.href = "internet_computer.html"; }
    	if (newCat == "1500") {
	      location.href = "kinder.html"; }
    	if (newCat == "6500") {
	      location.href = "kunst_kreativ.html"; }
    	if (newCat == "3700") {
	      location.href = "marketing_werbung.html"; }
    	if (newCat == "4500") {
	      location.href = "multimedia.html"; }
    	if (newCat == "8600") {
	      location.href = "nahrung_genuss.html"; }
    	if (newCat == "5500") {
	      location.href = "party_catering_event.html"; }
    	if (newCat == "6000") {
	      location.href = "unterricht_workshops_nachhilfe.html"; }
    	if (newCat == "8500") {
	      location.href = "urlaub_reisen.html"; }
    	if (newCat == "6101") {
	      location.href = "geschenkideen_geschenkideen_6100_6101_1.html"; }
    	if (newCat == "8564") {
	      location.href = "sonstiges_sonstiges_8565_8564_1.html"; }
    }
  }