 var prompttext = new Array();
 prompttext["normal"] = "Gib einen Text ein.";
 prompttext["EMAIL"] = "Gib eine Email-Adresse ein.";
 prompttext["FLOAT"] = "Wo soll das zu umfließende Objekt sein? (left / right)";
 prompttext["URL"] = "Gib eine Internetadresse ein.";
 prompttext["IMG"] = "Gib eine Bildadresse ein.";
 prompttext_linkdesc = "Gib einen Linknamen ein (optional!)";

 
// BB-Codes
function bbTags(tag, valuetext)
{
	var value = '';
	var linkdescription = '';
	var myPrompttext = '';
	var eingabe = '';
	
	if(tag == 'URL' || tag == 'EMAIL')
	{
		linkdescription = window.prompt(prompttext_linkdesc, '');
		if(tag == 'URL')
		{
			value = 'http://';
			myPrompttext = prompttext[tag];
			eingabe = window.prompt(myPrompttext, value);
		}
		else if(tag == 'EMAIL')
		{
			
			myPrompttext = prompttext[tag];
			eingabe = window.prompt(myPrompttext, value);
		}				
	}
	else
	{
		if(tag == 'IMG')
			eingabe = window.prompt(prompttext[tag], value);
		else if(tag == 'FLOAT')
		{
			value = 'right';
			eingabe = window.prompt(prompttext[tag], value);
			if (eingabe != 'left' ||  eingabe != 'right') eingabe = 'right';
			
		}
		else
			eingabe = window.prompt(prompttext["normal"], value);
	}
	
	if(eingabe != '' && eingabe != null)
	{
		if((tag == 'URL' || tag  == 'EMAIL') && (linkdescription != ""))
		{
			document.form.message.value += "["+tag+"="+eingabe+"]"+ linkdescription +"[\/"+tag+"]";
		}
		else if (tag == 'FLOAT')
		{
			document.form.message.value += "["+tag+"="+eingabe+"]Zu umfließendes Objekt hier[\/"+tag+"]Umfließender Text hier \[CLEAR\]";
		}
		else if (tag == 'FONT' || tag == 'COLOR' || tag == 'SIZE')
		{
			document.form.message.value += "["+tag+"="+valuetext+"]"+ eingabe + "[\/"+tag+"]";
		}
		else	
			document.form.message.value += "["+tag+"]"+ eingabe +"[\/"+tag+"]";
	}
	document.form.message.focus();
}

/** smiliefunctions **/

function smilie(smiliecode)
{ // write into textarea on a click
	document.form.message.value += smiliecode+" ";
	document.form.message.focus();
}

function smilieshoutbox(smiliecode)
{ // write into textarea on a click
	document.shoutbox_form.shoutbox_form_message.value = document.shoutbox_form.shoutbox_form_message.value + smiliecode + " ";
	document.shoutbox_form.shoutbox_form_message.focus();
}

function openSmilieWindow()
{ // open a new window with smilies
  window.open("index.php?module=misc&action=misc&section=smilies", "Smilies", "menubar=no,scrollbars=yes,resizeable=yes,statusbar=yes,width=310, height=400,left=0,top=0");
}

function openSmilieWindowShoutbox()
{ // open a new window with smilies
  window.open("index.php?module=misc&action=misc&section=smilies_shoutbox", "Smilies", "menubar=no,scrollbars=yes,resizeable=yes,statusbar=yes,width=310, height=400,left=0,top=0");
}


/** URL-Input Function **/
function url(inputname){
	 if(inputname.value == '')
	    inputname.value = 'http://';
	 else if(inputname.value == 'http://')
	    inputname.value = '';
}

// useful e.g. for login inputs
function empty(inputname){
         if(inputname.value==inputname.defaultValue)
            inputname.value="";
}
function refill(inputname){
         if(inputname.value=="")
            inputname.value=inputname.defaultValue;
}

/** show / hide divs **/
function swap(str_id)
{
	var icon = document.getElementById(str_id+"_icon");
	

	//alert(icon.src);
    if (document.getElementById(str_id).style.display == 'none')
    {
    	icon.src = 'images/icons/minus.jpg';
		document.getElementById(str_id).style.display = '';
    }
    else
    {
    	icon.src = 'images/icons/plus.jpg';
		document.getElementById(str_id).style.display = 'none';
    }
}

/** poll functions **/
function checkPoll(int_pollid, int_maxAnswers)
{
	var answers = document.getElementsByName("poll_answer["+int_pollid+"][]");
	var length = answers.length;
	var count = 0;
	
	for(var i = 0; i < length; i++)
	{
		if(answers[i].checked == true)
			count++;
	}

	if (count > int_maxAnswers)
	{
		alert("Bitte maximal "+ int_maxAnswers +" Antworten auswählen!");
		return false;
	}
	else
		return true;	
}

/** change classes function - rollover effect, also for IE (IE can't hover anything but links with CSS) **/
function changeClass(obj_object, str_standardClass, str_additionalClass)
{
	if (obj_object.className == str_standardClass+' '+str_additionalClass || obj_object.className == str_standardClass)
		obj_object.className = str_additionalClass+' rowhover';
	else
		obj_object.className = str_standardClass+' '+str_additionalClass;
}

/** shoutbox functions **/
/** count letters left during writing in textarea **/
/** notice: limit: number of maximal allowed letters; outputid: id of html element for output; inputvalue: value of form element;**/
/** example (on shoutbox.html) : onkeyup="countletter($int_post_length,this.value,'output_shoutbox');" **/

function countletter(limit,inputvalue,outputid)
	{
	if ((limit-inputvalue.length) > -1)
	{
	document.getElementById(outputid).innerHTML = (limit-inputvalue.length) + ' Zeichen noch übrig';
	}
	else
	{
	document.getElementById(outputid).innerHTML = 'Nachricht überschreitet das Limit.';
	}
	}

function countletter_confirm(limit,inputvalue)
	{
	if ((limit-inputvalue.length) < 0)
	{
	agree = confirm("Ihre Nachricht ist zu lang und wird auf " + limit +" Zeichen gekürzt. Trotzdem die Nachricht abschicken?");	
	if (agree)
	return true ;
	else
	return false ;
	}
	else
	{
	return true ;
	}
	}


function hide_box() {
      document.getElementById('info').style.visibility = "hidden";
}

function show_div(divid) {
	document.getElementById(divid).style.visibility = 'visible';
}
function hide_div(divid) {
	document.getElementById(divid).style.visibility = 'hidden';
}
function show_box(e,txt,offsetX,offsetY)
{
        if (offsetX) {offsetx=offsetX;} else {offsetx=20;}
        if (offsetY) {offsety=offsetY;} else {offsety=0;}
        var PositionX =0;
        var PositionY = 0;
        if (!e) var e = window.event;
        if (e.pageX || e.pageY)
        {
                PositionX = e.pageX;
                PositionY = e.pageY;
        }
        else if (e.clientX || e.clientY)
        {
                PositionX = e.clientX + document.body.scrollLeft;
                PositionY = e.clientY + document.body.scrollTop + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
        }
        
        txt = txt.replace(/&qout;/g, '"');
        document.getElementById("text").innerHTML=txt;
        document.getElementById("info").style.left = (PositionX + offsetx) +'px';
        document.getElementById("info").style.top =  (PositionY + offsety) + 'px';
        document.getElementById("info").style.visibility = "visible";
}

function show_smilies()
{
        
    if (document.getElementById('shb_smilies').style.display == "none")
	{ 
	document.getElementById('shb_smilies').style.display = "block";
	}
        else 
	{
	document.getElementById('shb_smilies').style.display = "none";
	}
        

}

function markall(begin,end)
{
	for (var i = begin; i <= end; i++)
	{
		id = 'checkbox_del[' + i + ']'
 		document.getElementById(id).checked = 'true';
	}
}

function submit_confirm(text,formname)
{
agree = confirm(text);	
	if (agree)
	document.forms[formname].submit();
	else
	return false ;
}
function show_smilies()
{
        
    if (document.getElementById('shb_smilies').style.display == "block")
	{ 
	document.getElementById('shb_smilies').style.display = "none";
	}
        else 
	{
	document.getElementById('shb_smilies').style.display = "block";
	}
        

}
