function openListe( id )
{
		if( document.getElementById( 'ul_' + id ).style.display == 'none' )
		{
			document.getElementById( 'ul_' + id ).style.display = 'block';
			document.getElementById( 'text_' + id ).innerHTML = 'weniger';
		}
		else
		{
			document.getElementById( 'ul_' + id ).style.display = 'none';
			document.getElementById( 'text_' + id ).innerHTML = 'mehr';
		}
}

function openPopUp(url, width, height)
{
	Left = parseInt( (screen.width - width) / 2 );
	Top = 10;
	PopUp = window.open(url, 'PupUp', 'toolbar = no, location = no, scrollbars = 0, width = ' + width + ', height = ' + height + ', left = ' + Left + ', top = ' + Top + ', alwaysRaised = true');
	PopUp.focus();
}

function show(div) 
{ 
	with(document.getElementById(div).style)
	{ 
		if(display == "none")
		{ 
			display = "inline";
			document.getElementById('pm' + div).src="gfx/minus.png";
		} 
		else 
		{ 
			display = "none";
			document.getElementById('pm' + div).src="gfx/plus.png";
		} 
	} 
} 

function show_subnav(div) 
{ 
	with(document.getElementById(div).style)
	{ 
		if(display == "none")
		{ 
			display = "";
			//document.getElementById('pm' + div).src="gfx/minus.png";
		} 
		else 
		{ 
			display = "none";
			//document.getElementById('pm' + div).src="gfx/plus.png";
		} 
	} 
} 

function swap(state,object) 
{
	switch ( state )
	{
		case 1:
		object.style.backgroundColor="#cceeff";
        object.style.backgroundImage="";
		object.style.color="#000000";
		object.style.borderStyle="solid";
		object.style.borderWidth="1px";
		object.style.borderColor="#99aacc";
		object.style.cursor="pointer";
		break;
		case 2:
		object.style.backgroundColor="#cceeff";
        object.style.backgroundImage="";
		object.style.color="#000000";
		object.style.borderStyle="solid";
		object.style.borderWidth="1px";
		object.style.borderColor="#99aacc";
		object.style.cursor="pointer";
		break;
		case 3:
		object.style.backgroundColor="#cceeff";
        object.style.backgroundImage="";
		object.style.color="#000000";
		object.style.borderStyle="solid";
		object.style.borderWidth="1px";
		object.style.borderColor="#99aacc";
		object.style.cursor="pointer";
		break;
		case 4:
		object.style.backgroundColor="#cceeff";
        object.style.backgroundImage="";
		object.style.color="#000000";
		object.style.borderStyle="solid";
		object.style.borderWidth="1px";
		object.style.borderColor="#99aacc";
		object.style.cursor="pointer";
		break;
		default:
		object.style.backgroundColor="";
        object.style.backgroundImage="";
		object.style.color="";
		object.style.borderStyle="";
		object.style.borderWidth="";
		object.style.borderColor="";
		object.style.cursor="";
		break;
	}
}

function swap_input(state,Table) 
{
	if(state==1){
		document.getElementById(Table).style.backgroundColor="#ffffff";
        document.getElementById(Table).style.backgroundImage="";
		document.getElementById(Table).style.color="#000000";
		document.getElementById(Table).style.borderStyle="solid";
		document.getElementById(Table).style.borderWidth="1px";
		document.getElementById(Table).style.borderColor="#115599";
		document.getElementById(Table).style.cursor="";
	}else{
		document.getElementById(Table).style.backgroundColor="";
        document.getElementById(Table).style.backgroundImage="";
		document.getElementById(Table).style.color="";
		document.getElementById(Table).style.borderStyle="";
		document.getElementById(Table).style.borderWidth="";
		document.getElementById(Table).style.borderColor="";
		document.getElementById(Table).style.cursor="";
	}
}

function swap_bt(state,bt_id) 
{
	if(state==1){
		document.getElementById(bt_id).src="gfx/" + bt_id + "2.png";
	}else if(state==2){
		document.getElementById(bt_id).src="gfx/" + bt_id + "3.png";
        while(document.getElementById(bt_id).complete != true){
		    window.setTimeout("alert('to')",100);
        }
        window.setTimeout("window.location.href='index.php?page="+bt_id+"'",100);
	}else{
		document.getElementById(bt_id).src="gfx/" + bt_id + ".png";
	}
}

function swap_sub_nav(state,Table) 
{
	if(state==1){
		document.getElementById(Table).style.borderStyle="solid";
		document.getElementById(Table).style.borderWidth="0px 1px 0px 0px";
		document.getElementById(Table).style.borderColor="#CCFF00";
		document.getElementById(Table).style.cursor="pointer";
	}else{
		document.getElementById(Table).style.borderStyle="";
		document.getElementById(Table).style.borderWidth="";
		document.getElementById(Table).style.borderColor="";
		document.getElementById(Table).style.cursor="";
	}
}

function smilie(gif)
{
	document.frmPost.text.value = document.frmPost.text.value + '_:' + gif + ':_';
}

function add_link(target, text)
{
	document.frmPost.text.value = document.frmPost.text.value + '[LINK=' + target + ']' + text + '[/LINK]';
}

function add_image(source)
{
	document.frmPost.text.value = document.frmPost.text.value + '[IMG=' + source + ']';
}

function text_bold(text)
{
    edit_text('[B]', '[/B]', text);
}

function text_italic(text)
{
	edit_text('[I]', '[/I]', text);
}

function text_strike(text)
{
	edit_text('[S]', '[/S]', text);
}

function text_underline(text)
{
	edit_text('[U]', '[/U]', text);
}

function text_size(text, size)
{
    edit_text('[SIZE=' + size + ']', '[/SIZE]', text);
}

function text_left(text)
{
    edit_text('[LEFT]', '[/LEFT]', text);
} 

function text_right(text)
{
    edit_text('[RIGHT]', '[/RIGHT]', text);
}

function text_center(text)
{
    edit_text('[CENTER]', '[/CENTER]', text);
}

function text_color(color)
{
	buf = document.frmPost.text.value;
	document.frmPost.text.value = '[COLOR=' + color + ']' + buf + '[/COLOR]';
}

function text_bgcolor(color)
{
	buf = document.frmPost.text.value;
	document.frmPost.text.value = '[BGCOLOR=' + color + ']' + buf + '[/BGCOLOR]';
}

function head_nav_over(button)
{
  document.getElementById('head_nav').src='gfx/head_v2_'+button+'_over.png';
}

function head_nav_out()
{
  document.getElementById('head_nav').src='gfx/head_v2.png';
}

function is_haus()
{
        if(document.getElementById('kat1').value == "2")
        {
            o1 = new Option('Einfamilienhaus', '1', false, false);
            o2 = new Option('Doppelhaushälfte', '2', false, false);
            o3 = new Option('Reihenhaus', '3', false, false);
            o4 = new Option('Mehrfamilienhaus', '4', false, false);
            document.getElementById('kat2').options[1] = o1;
            document.getElementById('kat2').options[2] = o2;
            document.getElementById('kat2').options[3] = o3;
            document.getElementById('kat2').options[4] = o4;
            document.getElementById('ishaus').style.display = "inline";
        }
        else if(document.getElementById('kat1').value == "1")
        {
            o1 = new Option('bis 60 m²', '1', false, false);
            o2 = new Option('bis 100 m²', '2', false, false);
            o3 = new Option('ab 100 m²', '3', false, false);
            o4 = new Option('Vermietet', '4', false, false);
            document.getElementById('kat2').options[1] = o1;
            document.getElementById('kat2').options[2] = o2;
            document.getElementById('kat2').options[3] = o3;
            document.getElementById('kat2').options[4] = o4;
            document.getElementById('ishaus').style.display = "inline";
        }
        else
        {
            document.getElementById('ishaus').style.display = "none"; 
        }
}

function edit_text(aTag, eTag, text) 
{
    var input = document.getElementById(text);
    input.focus();
    if(typeof document.selection != 'undefined') 
    {
        var range = document.selection.createRange();
        var insText = range.text;
        range.text = aTag + insText + eTag;
        range = document.selection.createRange();
        if (insText.length == 0) 
        {
            range.move('character', -eTag.length);
        } 
        else 
        {
            range.moveStart('character', aTag.length + insText.length + eTag.length);      
        }
        range.select();
    }
    else if(typeof input.selectionStart != 'undefined')
    {
        var start = input.selectionStart;
        var end = input.selectionEnd;
        var insText = input.value.substring(start, end);
        input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
        var pos;
        if (insText.length == 0) 
        {
            pos = start + aTag.length;
        } 
        else 
        {
            pos = start + aTag.length + insText.length + eTag.length;
        }
        input.selectionStart = pos;
        input.selectionEnd = pos;
    }
}

function add_tag(tag, target)
{
	edit_text(document.getElementById(tag).value, '', target);
}


