
function showhide(id)
{
	if(document.getElementById(id).style.display != 'none')
	{
		if($('#switch_'+id)) $('#switch_'+id).attr('src', '/img/plus.gif');
		if($('#anchor_'+id)) $('#anchor_'+id).attr('className', 'white');
		$('#'+id).slideUp("fast")
	}
	else
	{
		if($('#switch_'+id)) $('#switch_'+id).attr('src', '/img/minus.gif');
		if($('#anchor_'+id)) $('#anchor_'+id).attr('className', 'red');
		$('#'+id).slideDown("fast")
	}
}

function show(eid)
{
	if(document.getElementById(eid).style.display == 'none')
	{
		if($('#switch_'+eid)) $('#switch_'+eid).src = '/templates/images/symbols/minus.gif';
		if($('#anchor_'+eid)) $('#anchor_'+eid).className = 'red';
		document.getElementById(eid).style.display = '';
	}
}

function hide(eid)
{
	if(document.getElementById(eid).style.display != 'none'){
		if($('#switch_'+eid)) $('#switch_'+eid).src = '/templates/images/symbols/plus.gif';
		if($('#anchor_'+eid)) $('#anchor_'+eid).className = 'white';
		document.getElementById(eid).style.display = 'none';
	}
}

function bookmark(URL,title,pcat)
{
	purl = (URL) ? URL : window.location.pathname;
	ptitle = (title) ? title : document.title;
	$.get(ajax_url, { mode: 'addbookmark', ptitle: ptitle, purl: purl, pcat: pcat } );
	$('#favadd').attr('src', "/templates/images/symbols/favadd2.png");
}

function menuswitch()
{
	$('#menuimg').attr('src') = ($('#menuimg').attr('src') == '/templates/images/symbols/header_menu_button.png') ? '/templates/images/symbols/header_menu_button2.png' : '/templates/images/symbols/header_menu_button.png';
}

function favswitch()
{
	$('#favadd').src = ($('#favadd').src == '/templates/images/symbols/favadd.png') ? '/templates/images/symbols/favadd_over.png' : '/templates/images/symbols/favadd.png';
}

function switchflag(country, id)
{
	$('#flag').attr('src', '/img/countries/'+country+'.gif');
	if(id)
	{
		$.getJSON("/ajax?mode=getRegions&country="+country,
	        function(data){
				var options = '<option value="0">-</option>';
				for (var i = 0; i < data.length; i++) {
					options += '<option value="' + data[i].id + '">' + data[i].region + '</option>';
				}
				$("#"+id).html(options);
	        });
	}
}

function countchars(id,max)
{
	document.getElementById(id+'_chars').innerHTML = max-document.getElementById(id).value.length;
}

function popup2(tpl, path, info)
{
	var headtitle = tpl.replace('_',' - ');
	tpl = (tpl) ? tpl : 'about';
	tpl = (path) ? path+tpl : 'help/'+tpl;
	popup(headtitle, '');
	$('#popcont').load(ajax_url+'?mode=showTpl&tpl='+tpl+'&info='+info);
}

function popup(title, content, icon)
{
	if(document.getElementById('popup'))
	{
		document.body.removeChild(document.getElementById('popup'));
		document.body.removeChild(document.getElementById('overlay'));
	}
	else
	{
		var myWidth = 0, myHeight = 0;
		if(typeof(window.innerWidth)=='number')
		{
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		}
		else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
		{
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		}
		else if(document.body && (document.body.clientWidth || document.body.clientHeight))
		{
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		icon = (icon) ? icon : '/img/ico/help.png';

		var objBody = document.getElementsByTagName("body").item(0);
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.style.height = myHeight+'px';
		objOverlay.style.width = myWidth+'px';
		objBody.insertBefore(objOverlay, objBody.firstChild);
		var box = document.createElement("div");
		box.setAttribute('id','popup');
		box.innerHTML = '<div class="cathead2"><div class="float75"><h1><img src="'+icon+'" alt="" /> '+title+'</h1></div><div class="float25 right"><a href="javascript:popup()"><img src="/img/ico/close.png" alt="" /></a></div><div class="clearer"></div></div><div class="contentbox" id="popcont"><div class="center bold"><img src="/img/ajax-loader.gif" alt="loading" /><br/>Loading</div></div>';
		box.style.left = (myWidth/2)-(myWidth/8)+'px';
		box.style.top = (myHeight/2)-(myHeight/8)+'px';
		objBody.insertBefore(box, objBody.firstChild);
		$('#popcont').html(content);
	}
}

function rate_over(id, rating)
{
	var txt=new Array();
	txt[1]='Mag ich &uuml;berhaupt nicht';
	txt[2]='Gef&auml;llt mir nicht';
	txt[3]='Nicht schlecht';
	txt[4]='Gef&auml;llt mir';
	txt[5]='Gef&auml;llt mir sehr';
	
	for(var i=1;i<=rating;i++)
	{
		$('#'+'rate'+i).attr('src', '/img/ico/rating.over.png');
	}
	for(i;i<=5;i++)
	{
		$('#'+'rate'+i).attr('src', '/img/ico/rating.off.png');
	}
//Text anzeigen
	$('#'+'rating_text').attr('innerHTML', txt[rating]);
}

function show_rating(id, rating)
{
	for(var i=1;i<=rating;i++)
	{
		
		$('#'+'rate'+i).attr('src', '/img/ico/rating.on.png');
	}
	for(i;i<=5;i++)
	{
		if(rating%1==0.5 && Math.floor(rating)+1==i)
		{
			$('#'+'rate'+i).attr('src', '/img/ico/rating.half.png');
		}
		else
		{
			$('#'+'rate'+i).attr('src', '/img/ico/rating.off.png');
		}
	}
	$('#'+'rating_text').attr('innerHTML', '&nbsp;');
}

function rating_submit(type, id, rating)
{
	$('#'+type+'_ratebox').html('<div class="center" style="height:100px;line-height:100px"><img src="/img/ajax-loader.gif"></div>');
	$('#'+type+'_ratebox').load('/ajax?mode=rating&type='+type+'&id='+id+'&rating='+rating);
}

function switchTab(num)
{
	for(var i=1;i<=4;i++)
	{
		$('#tab'+i).removeClass('ctab');
		$('#tab'+i).addClass('tab');
		if($('#tabcontent'+i).css('display')=='block')
		{
			$('#tabcontent'+i).fadeOut('fast', function()
			{
				$('#tabcontent'+num).fadeIn('fast');
			});
		}
	}
	$('#tab'+num).addClass('ctab');
}