function isPPC() {
	if (navigator.appVersion.indexOf("PPC") != -1) return true;
	else return false;
}

function sendPage(mailHeadline){
	if(!isPPC()) {
		window.location="mailto:\?subject\=" + mailHeadline + "&body=" + mailHeadline + ": " + window.location;
	} else { 
		window.location="mailto:\?body=" + mailHeadline + ": " + window.location;
	}
}

function changeFontSize(size){
	intSize = parseInt(size);
	if(intSize == 1){
		if(parseInt(this.document.fontSizeForm.fontSize.value) > 0) this.document.fontSizeForm.fontSize.value = 2;
		else this.document.fontSizeForm.fontSize.value = parseInt(this.document.fontSizeForm.fontSize.value) + 1;
	} else {
		if(parseInt(this.document.fontSizeForm.fontSize.value) < 0) this.document.fontSizeForm.fontSize.value = -2;
		else this.document.fontSizeForm.fontSize.value = parseInt(this.document.fontSizeForm.fontSize.value) - 1;
	}
	var classNm = "";
	switch(this.document.fontSizeForm.fontSize.value){
		case "-2":
			classNm = "size_verysmall";
		break;
		case "-1":
			classNm = "size_small";
		break;
		case "0":
			classNm = "size_normal";
		break;
		case "1":
			classNm = "size_large";
		break;
		case "2":
			classNm = "size_verylarge";
		break;
		default:
			classNm = "size_normal";
		break;
	}
	this.document.getElementsByTagName('body')[0].className = classNm;
}
function fixHeights(){
	lWidth = document.getElementById("leftdiv").offsetHeight;
	cWidth = document.getElementById("centerdiv").offsetHeight;
	rWidth = document.getElementById("rightdiv").offsetHeight;
	max1 = Math.max(lWidth, cWidth);
	max2 = Math.max(max1, rWidth);
	document.getElementById("leftdiv").style.height = max2+"px";
	document.getElementById("centerdiv").style.height = max2+"px";
	document.getElementById("rightdiv").style.height = max2+"px";
}

function fixHeightsTemplate3Col(){
	lWidth = document.getElementById("leftdiv").offsetHeight;
	cWidth = document.getElementById("centerdiv").offsetHeight;
	max = Math.max(lWidth, cWidth);
	document.getElementById("centerdiv").style.height = max+"px";
	document.getElementById("leftdiv").style.height = max+"px";
}

function changeFontSize(size){
		intSize = parseInt(size);
		if(intSize == 1){
			if(parseInt(this.document.fontSizeForm.fontSize.value) > 0) this.document.fontSizeForm.fontSize.value = 2;
			else this.document.fontSizeForm.fontSize.value = parseInt(this.document.fontSizeForm.fontSize.value) + 1;
		} else {
			if(parseInt(this.document.fontSizeForm.fontSize.value) < 0) this.document.fontSizeForm.fontSize.value = -2;
			else this.document.fontSizeForm.fontSize.value = parseInt(this.document.fontSizeForm.fontSize.value) - 1;
		}
		var classNm = "";
		switch(this.document.fontSizeForm.fontSize.value){
			case "-2":
				classNm = "size_verysmall";
			break;
			case "-1":
				classNm = "size_small";
			break;
			case "0":
				classNm = "size_normal";
			break;
			case "1":
				classNm = "size_large";
			break;
			case "2":
				classNm = "size_verylarge";
			break;
			default:
				classNm = "size_normal";
			break;
		}
		this.document.getElementsByTagName('body')[0].className = classNm;
	}

function opencloseDiv(divId){
    var textDivId = 't'+divId;
    var imgDivId = 's'+divId;
    if(document.getElementById(textDivId).style.display=="block"){
        document.getElementById(textDivId).style.display="none";
        if(document.getElementById(imgDivId)) document.getElementById(imgDivId).style.display="none";
    } else {
        document.getElementById(textDivId).style.display="block";
        if(document.getElementById(imgDivId)) document.getElementById(imgDivId).style.display="block";
    }
	return false;
}

var targetDiv = "";

function stateChanged() 
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
	{
		document.getElementById(targetDiv).innerHTML = xmlHttp.responseText;
	}
}

function GetXmlHttpObject()
{
	var xmlHttp = null;

	try
	{
		xmlHttp = new XMLHttpRequest();
	}
		catch (e)
	{
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}

	return xmlHttp;
}

function ajaxSetPeriodsForCurrency(resultDiv, link){

	targetDiv = resultDiv;
	xmlHttp = GetXmlHttpObject();

	if (xmlHttp == null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}

	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET",link,true);
	xmlHttp.send(null);

	return false;
}

function ajaxCheckAndAddSymbolOrCurrency(resultDiv, link){

	targetDiv = resultDiv;
	xmlHttp = GetXmlHttpObject();

	if (xmlHttp == null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}

	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET",link,true);
	xmlHttp.send(null);

	return false;
}

function getCookie(c_name) {
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) {
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
return "";
}

function number_format(a, b, c, d) {
 // number_format(number, decimals, comma, formatSeparator)
 var k = '';
 if(a.indexOf('-') == 0) {
  k = '-';
  a = a * -1;
 }
 a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
 var e = a + '';
 var f = e.split('.');
 if(!f[0]) f[0] = '0';
 if(!f[1]) f[1] = '';
 if(f[1].length < b){
  var g = f[1];
  for(var i = f[1].length + 1; i <= b; i++) {
   g += '0';
  }
  f[1] = g;
 }
 if(d != '' && f[0].length > 3) {
  var h = f[0];
  f[0] = '';
  for(var j = 3; j < h.length; j += 3) {
   i = h.slice(h.length - j, h.length - j + 3);
   f[0] = d + i +  f[0] + '';
  }
  j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
  f[0] = j + f[0];
 }
 c = (b <= 0) ? '': c;
 return k + f[0] + c + f[1];
}
