//--------------------------------------------
// formatierte Texte mit UBB-Code
//--------------------------------------------

function setVarCode(code) {
	document.forms[0].beschreibung.value += code;
	document.forms[0].beschreibung.focus();
}

function setPlaceHolder(code) {
	document.forms[0].beschreibung.value += "{"+code+"}";
	document.forms[0].beschreibung.focus();
}

function setcode(code,prompttext,question) {
	if(code == "br") {
		document.forms[0].beschreibung.value += "["+code+" /]";
	} else if(code == "p") {
		aligntxt = "left";
		align = prompt(question+"\n",aligntxt);
		document.forms[0].beschreibung.value += "["+code+" align="+align+" /]";
	} else {
	inserttext = prompt(question+"\n",prompttext);
		if ((inserttext != null) && (inserttext != "")) {
			document.forms[0].beschreibung.value += "["+code+"]"+inserttext+"[/"+code+"]";
		}
	}
	document.forms[0].beschreibung.focus();
}

function setline(code,width,questionWIDTH,questionALIGN) {
	width = "100";
	align = "center";

	width = prompt(questionWIDTH+"\n",width);
	align = prompt(questionALIGN+"\n",align);

	if ((width != null) && (width != "") && (align != null) && (align != "")) {
		document.forms[0].beschreibung.value += "["+code+" noshade=noshade align="+align+" width="+width+"%]";
	} else {
		document.forms[0].beschreibung.value += "["+code+" noshade=noshade align=center width=100%]";
	}
	document.forms[0].beschreibung.focus();
}

function seturl(type,questionDESC,questionURL,questionMAILTO,questionTARGET) {
	description = prompt(questionDESC+"\n","");
	if (type == "URL") {
		text = questionURL;
		content = "http://";
		}
	else {
		text = questionMAILTO;
		content = "";
		}
	url = prompt(text,content);
	if ((url != null) && (url != "")) {
		if ((description != null) && (description != "")) {
			if (type == "URL") {
				target_text = questionTARGET;
				target_content = "_blank";
				target = prompt(target_text,target_content);
				document.forms[0].beschreibung.value += "[a href="+url+" target="+target+"]"+description+"[/a]";
			} else {
				document.forms[0].beschreibung.value += "[a href=mailto:"+url+"]"+description+"[/a]";
			}
		} else {
			if (type == "URL") {
				target_text = questionTARGET;
				target_content = "_blank";
				target = prompt(target_text,target_content);
				document.forms[0].beschreibung.value += "[a href="+url+" target="+target+"]"+url+"[/a]";
			} else {
				document.forms[0].beschreibung.value += "[a href=mailto:"+url+"]"+url+"[/a]";
			}
		}
	}
	document.forms[0].beschreibung.focus();
}


function setimgurl(type1,type2,questionURL,questionCLICKURL,questionDESC,questionTARGET) {
	pic_text = questionURL;
	pic_content = "http://";
	picurl = prompt(pic_text,pic_content);

	link_text = questionCLICKURL;
	link_content = "http://";
	url = prompt(link_text,link_content);

	title = questionDESC;
	title_content = "";
	alt = prompt(title,title_content);

	if ((picurl != null) && (picurl != "")) {
		if ((url != null) && (url != "http://") && (url != "")) {
			target_text = questionTARGET;
			target_content = "_blank";
			target = prompt(target_text,target_content);
			document.forms[0].beschreibung.value += "[a href="+url+" target="+target+"][img src="+picurl+" border=0 alt="+alt+"][/a]";
		} else {
			document.forms[0].beschreibung.value += "[img src="+picurl+" border=0 alt="+alt+"]";
		}
		document.forms[0].beschreibung.focus();
	}
}

function setul(code,count,questionCOUNT,listEntry) {
	count = 1;

	count = prompt(questionCOUNT+"\n",count);

	liStr = "";
	ulBegin = "[ul]\n";
	for(i=0;i<count;i++) {
		number = i+1;
		newentry = prompt(listEntry+" "+number+" von "+count+"\n");
		liStr += "[li]"+newentry+"[/li]\n";
	}
	ulEnd = "[/ul]\n";

	document.forms[0].beschreibung.value += ulBegin+liStr+ulEnd;
	document.forms[0].beschreibung.focus();
}

//--------------------------------------------
// Rechnungsnummer für Gutschrift übernehmen
//--------------------------------------------

function getInvoicePaidmails(num) {
	document.paidmails.rechn1.value = num;
	document.paidmails.rechn1.focus();
}

function getInvoicePoints(num) {
	document.points.rechn.value = num;
	document.points.rechn.focus();
}

function getInvoiceViews(num) {
	document.viewpoints.views.value = num;
	document.viewpoints.views.focus();
}

function getInvoiceClicks(num) {
	document.clickpoints.clicks.value = num;
	document.clickpoints.clicks.focus();
}

function getInvoiceTextAdd(num) {
	document.textpoints.textaddv.value = num;
	document.textpoints.textaddv.focus();
}



//--------------------------------------------
// Derzeit deaktiv
//--------------------------------------------

function surfto(form) {
	var myindex=form.select1.selectedIndex;
	if (form.select1.options[myindex].value != "0") {
		parent.location=form.select1.options[myindex].value;
	}
	var myindex=form.select2.selectedIndex;
	if (form.select2.options[myindex].value != "0") {
		parent.location=form.select2.options[myindex].value;
	}
	var myindex=form.select3.selectedIndex;
	if (form.select3.options[myindex].value != "0") {
		parent.location=form.select3.options[myindex].value;
	}
}

//--------------------------------------------
// ToolTip Anzeige
//--------------------------------------------

wmtt = null;

document.onmousemove = updateWMTT;

function updateWMTT(e) {
	x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
	y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
	if (wmtt != null) {
		wmtt.style.left = (x + 5) + "px";
		wmtt.style.top 	= (y + 5) + "px";
	}
}

function showWMTT(id) {
	wmtt = document.getElementById(id);
	wmtt.style.display = "block"
}

function hideWMTT() {
	wmtt.style.display = "none";
}

//--------------------------------------------
// User Menu
//--------------------------------------------

mmtt = null;


// document.getElementById('link01').onmousedown = updateMMTT;
// function updateMMTT(e) {
// 	x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
// 	y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
// 	if (mmtt != null) {
// 		mmtt.style.left = (x + 5) + "px";
// 		mmtt.style.top 	= (y + 5) + "px";
// 	}
// }

function showMMTT(id) {
	mmtt = document.getElementById(id);
	mmtt.style.left = "250px";
	mmtt.style.top 	= "200px";
	mmtt.style.display = "block"
}

function hideMMTT() {
	mmtt.style.display = "none";
}

//--------------------------------------------
// On Klick -> goto link
//--------------------------------------------

function gotoURL(URL){
	window.location.href = URL;
}


//--------------------------------------------
// mail bestätigen aus dem account heraus
//--------------------------------------------

function openMailWin(clickMail) {
	clickM = window.open(clickMail,"BestWin","resizable=yes,scrollbars=yes,toolbar=yes,location=yes,status=yes,menubar=yes");
	clickM.focus();
}

//--------------------------------------------
// Admin Main Menu
//--------------------------------------------

var mpos=new Array();
var mdir=new Array();
var maxmenus=6;
var delay=1;

function do_menu(menu)
{
        for(i=0; i<maxmenus; i++)
        {
                if(menu!=i && mpos[i]>-290)
                {
                        mdir[i]=-4;
                        if(mpos[i]>=23)
                                move_menu(i);
                }
        }
        mdir[menu]=-mdir[menu];
        if(mpos[menu]<=-290 || mpos[menu]>=23)
                move_menu(menu);
}

function move_menu(menu)
{
        mpos[menu]+=mdir[menu];

if
(document.all)
document.all["menu"+menu].style.top=mpos[menu];

else if(document.layers)
                document.layers["menu"+menu].top=mpos[menu];

else if(document.getElementById)
                document.getElementById(["menu"+menu]).style.top=mpos[menu];



        if(mpos[menu]>-290 && mpos[menu]<23)
                setTimeout("move_menu("+menu+")", delay);
}

function init()
{
        for(i=0; i<maxmenus; i++)
        {
                mpos[i]=-290;
                mdir[i]=-4;
        }
}


//--------------------------------------------
// Zeige gebuchte Banner in Extrafenster
//--------------------------------------------

function showBanner(tbl,width,height,bannerID,sessionid) {
	// alert("Breite: "+width+"\nHöhe: "+height+"\nBannerID: "+bannerID+"\nTabelle: "+tbl);

	sBanner = window.open("bview.php?sessionid="+sessionid+"&id="+bannerID+"&tbl="+tbl,"sBanner","width="+width+",height="+height+",left=10,top=10,resizable=no,scrollbars=no,toolbar=no,status=no");
	sBanner.focus();


}


function showMemberBanner(tbl,width,height,bannerID,sessionid) {
	// alert("Breite: "+width+"\nHöhe: "+height+"\nBannerID: "+bannerID+"\nTabelle: "+tbl);

	sBanner = window.open("spbview.php?sessionid="+sessionid+"&id="+bannerID+"&tbl="+tbl,"sBanner","width="+width+",height="+height+",left=10,top=10,resizable=no,scrollbars=no,toolbar=no,status=no");
	sBanner.focus();


}

//--------------------------------------------
// Einblenden Textfeld für gebuchten Werbetext
//--------------------------------------------

function showAddsArea(maxcount) {
	document.writeln("<textarea class='textfeld' name='addtext' cols='38' rows='7' id='message' onkeydown='textCounter(this.form.addtext, this.form.remLen, "+maxcount+");' onkeyup='textCounter(this.form.addtext, this.form.remLen, "+maxcount+");'></textarea><br /><br />");

	document.writeln("<input class='textfeld' name='remLen' type='text' id='remLen' value='"+maxcount+"' size='5' maxlength='4' readonly /> verbleibende Zeichen.");
}

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) {				// wenn die eingegebene Länge größer als erlaubt ist
		field.value =field.value.substring(0, maxlimit); 	// es wird keine weitere Eingabe mehr zugelassen
	} else {
		countfield.value = maxlimit - field.value.length;	// die verbleibende Anzahl von Zeichen wird angezeigt
	}
}

function setMaxCount(id, url) {
	window.location.href = url+"&id="+id;
}
