function char_count (source, num_chars, out_source){
	var total_c
	total_c = document.getElementById(""+source+"").value.length
	document.getElementById(""+out_source+"").innerHTML = num_chars - total_c + ' Zeichen übrig'

}

function writeform(url, adid){

	var myForm = '';

	myForm = '<form method="post" action="{SITEURL}/contact.php">' +
					'<input type="text" name="email"><input type="submit" value="Kontakt">' +
					'<textarea name="note"></textarea>' +
					'</form>';
	document.write(myForm);
}
function hidestatus(){
var statusmsg=""
window.status=statusmsg
return true
}
function mark_errors (str_forms){
	var arrFields = str_forms.split(',');
	if (document.getElementById('errormsg')) document.getElementById('cms').style.display = 'none';
	if ( arrFields.length > 0 && arrFields[0]!='0') {
		for(i=0;i<arrFields.length;i++)
		{
			if(arrFields[i] == 'CATEGORY_ID')  { 
					document.getElementById('catTitle').style.border = '1px solid #FF6600';
					document.getElementById('catTitle').style.background = '#DAE9F5';
		 	}	else if (arrFields[i] == 'AGB'){
					document.getElementById('agbs').style.border = '1px solid #FF6600';
					document.getElementById('agbs').style.background = '#DAE9F5';
			} else 	{ 
				document.ad_form[arrFields[i]].style.background='#DAE9F5';
				document.ad_form[arrFields[i]].style.border = '1px solid #FF6600';
			}
		}	
		
	}
}

function switchcms(){
if (document.getElementById('cms').style.display == 'none'){
		document.getElementById('cms').style.display = '';
	} else document.getElementById('cms').style.display = 'none';

}
function switcherror(){
		var text;
		if(document.getElementById('errormsg').style.display == 'none') document.getElementById('errormsg').style.display = '';
		else {
			document.getElementById('errormsg').style.display = 'none';
			document.getElementById('cms').style.display = '';
		}


}
function openCMS (str){
		/*alert( decodeBase64(str));*/
		var arrFields =  decodeBase64(str).split(';');
		if(arrFields.length > 0) {
			cmsWin = window.open(arrFields[0], arrFields[1], arrFields[2]);
			cmsWin.focus();
		}


}

function ccc (){
if (document.cookie)
 {
  if (document.cookie.indexOf("KLSESSION")) alert("jojo");
	else alert ("nono");
	} else alert("no cookies");
}

function showtrade(act){
	
	if(act == true)  {
		document.getElementById('trade').style.display = 'block';
		document.getElementById('trade').style.height = '140px';
	}
	else document.getElementById('trade').style.display= 'none';

}

function setVar (myStr, myElement){
	
	if(document.getElementById(myElement)) {
		document.getElementById(myElement).value = myStr;
		document.getElementById(myElement).focus();
	}

}
function check_upload(value, id) {
	regex = /(jpg|jpeg)$/i;
	result = regex.test(value);
	if(result == 0){
	document.getElementById(id).value='';
	alert("Die Datei ist kein unterstütztes Bild-Format.");
	// alert("Die ausgewählte Datei muss im\n - bmp\n - gif\n - jpg/jpeg\n - png\nFormat vorliegen.");
	return 0;
	}
	return 1;
}
function pop_image(id , w){

	document.getElementById('img_preview').innerHTML = '<img onclick="prvclose(\'img_preview\')" align="top" title="Click to Close" alt="Click to Close" src="userpics/' + w + '/' + id + '.jpg"><br><a href="javascript:prvclose(\'img_preview\')">schließen</a>';
	document.getElementById('img_preview').style.visibility = 'visible';
}
function prvclose(ob){
	document.getElementById(ob).style.visibility = 'hidden';	
}
function make_coins(){
	var x=document.getElementById("fcoins").value;
	if ((x%1000)==0 && x>=3000 && x<=100000) {
		document.getElementById("ppreis").innerHTML = number_format(Math.round((0.00998*x)*100)/100, 2, ',', '.') + '*';
		document.getElementById("cerror").innerHTML = '';
			document.getElementById("bonus").innerHTML = 'Bonuscoins: ' + get_bonus(x);
	} else {
			document.getElementById("bonus").innerHTML = 'Bonuscoins: 300';
			document.getElementById("ppreis").innerHTML = number_format(Math.round((0.00998*3000)*100)/100, 2, ',', '.') + '*';
			if((x%1000)!=0) document.getElementById("cerror").innerHTML = 'ändern in 1000er-Schritten';
			else 	document.getElementById("cerror").innerHTML = 'min. 3000, max. 100.000 Coins';
	}
}
function get_bonus(x){
	var coins = new Array();
	var y = 300;
	coins[3000] = 10;
	coins[4000] = 11;
	coins[5000] = 12;
	coins[6000] = 13;
	coins[7000] = 14;
	coins[8000] = 15;
	coins[9000] = 16;
	coins[10000] = 17;
	coins[11000] = 18;
	coins[12000] = 19;
	if (3000<=x && x<4000) y = x*coins[x]/100;
	if (4000<=x && x<5000) y = x*coins[x]/100;
	if (5000<=x && x<6000) y = x*coins[x]/100;
	if (6000<=x && x<7000) y = x*coins[x]/100;
	if (7000<=x && x<8000) y = x*coins[x]/100;
	if (8000<=x && x<9000) y = x*coins[x]/100;
	if (9000<=x && x<10000) y = x*coins[x]/100;
	if (10000<=x && x<11000) y = x*coins[x]/100;
	if (11000<=x && x<12000) y = x*coins[x]/100;
	if (x>=12000) y = x*19/100;

	return y;
}
function number_format (number, decimals, dec_point, thousands_sep)
{
  var exponent = "";
  var numberstr = number.toString ();
  var eindex = numberstr.indexOf ("e");
  if (eindex > -1)
  {
    exponent = numberstr.substring (eindex);
    number = parseFloat (numberstr.substring (0, eindex));
  }
  
  if (decimals != null)
  {
    var temp = Math.pow (10, decimals);
    number = Math.round (number * temp) / temp;
  }
  var sign = number < 0 ? "-" : "";
  var integer = (number > 0 ? 
      Math.floor (number) : Math.abs (Math.ceil (number))).toString ();
  
  var fractional = number.toString ().substring (integer.length + sign.length);
  dec_point = dec_point != null ? dec_point : ".";
  fractional = decimals != null && decimals > 0 || fractional.length > 1 ? 
               (dec_point + fractional.substring (1)) : "";
  if (decimals != null && decimals > 0)
  {
    for (i = fractional.length - 1, z = decimals; i < z; ++i)
      fractional += "0";
  }
  
  thousands_sep = (thousands_sep != dec_point || fractional.length == 0) ? 
                  thousands_sep : null;
  if (thousands_sep != null && thousands_sep != "")
  {
	for (i = integer.length - 3; i > 0; i -= 3)
      integer = integer.substring (0 , i) + thousands_sep + integer.substring (i);
  }
  
  return sign + integer + fractional + exponent;
}
function clickurl(site){
	clk = window.open(site);
}