 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 != ""))
		{
			form.message.value += "["+tag+"="+eingabe+"]"+ linkdescription +"[\/"+tag+"]";
		}
		else if (tag == 'FLOAT')
		{
			form.message.value += "["+tag+"="+eingabe+"]Zu umfließendes Objekt hier[\/"+tag+"]Umfließender Text hier \[CLEAR\]";
		}
		else if (tag == 'FONT' || tag == 'COLOR' || tag == 'SIZE')
		{
			form.message.value += "["+tag+"="+valuetext+"]"+ eingabe + "[\/"+tag+"]";
		}
		else	
			form.message.value += "["+tag+"]"+ eingabe +"[\/"+tag+"]";
	}
	form.message.focus();
}

/** smiliefunctions **/

function smilie(smiliecode)
{ // write into textarea on a click
	document.form.message.value += smiliecode+" ";
	document.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");
}


/** 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;
}

