/*
	CMSZWO Public JS Scripts
*/

function litTD(td, color)
{
	if(color != '')
	{
		td.style.backgroundColor  = color;
	}
}

function go(url)
{
	if(url != '')
	{
		window.location.href = url;
		if(document.all)
		{
			event.cancelBubble = true;
		}
	}
}

function getTextValue(id)
{
	var result = "";
	c = document.getElementById(id);	
	if(c != null)
	{
		result = c.value;
	}
	return result;
}

function setTextValue(id, value)
{
	document.getElementById(id).value = value;
}

function getComboValue(id)
{
	ret = -1;
	ret = document.getElementById(id).options[document.getElementById(id).options.selectedIndex].value;
	return ret;
}

function setComboValue(id, value)
{
	var i=0;
	for(i=0; i<document.getElementById(id).length; i++)
	{
		if(document.getElementById(id).options[i].value == value)
		{
			document.getElementById(id).selectedIndex = i;
			break;
		}
	}
}


function toggleElement(id)
{
	ctrl = document.getElementById(id);
	visible = (ctrl.style.visibility == 'visible');
	if(ctrl != null)
	{
		if(!visible)
		{
			ctrl.style.visibility='visible';
			if(document.all)
			{
				ctrl.style.display='block';
			}
			else
			{
				ctrl.style.display='table';
			}
		}
		else
		{
			ctrl.style.visibility='hidden';
			ctrl.style.display='none';
		}
	}
}

function showElement(id, visible)
{
	ctrl = document.getElementById(id);
	if(ctrl != null)
	{
		if(visible)
		{
			ctrl.style.visibility='visible';
			if(document.all)
			{
				ctrl.style.display='block';
			}
			else
			{
				ctrl.style.display='table';
			}
		}
		else
		{
			ctrl.style.visibility='hidden';
			ctrl.style.display='none';
		}
	}
}

/* BÖHLER ANPASSUNGEN */
function posDlg(id)
{
	var d = document.getElementById(id);
	var px = 0;
	var py = 0;
	var dw = 0;

	dw = d.style.width.substr(0, d.style.width.length-2);
	if(document.all)
	{
		py = document.body.scrollTop + 0;
		px = (document.body.clientWidth - dw) / 2;
	}
	else
	{
		py = window.pageYOffset + 0;
		px = (window.innerWidth - dw) / 2;
	}
	d.style.top = py + "px";	
	d.style.left = px + "px";	
}

function litSel(td)
{
		litTD(td, "#FFE91A");
		td.style.color='#000000';
}

function delitSel(td)
{
		litTD(td, "#FFFFFF");
		td.style.color='#000000';
}

function litTDWeb(td)
{
		litTD(td, "#F14F11");
		td.style.color = "#FFFFFF";
}

function delitTDWeb(td)
{
		litTD(td, "#FFFFFF");
		td.style.color = "#333333";
}

function goBr(url)
{
	window.open(url,'','status=yes,scrollbars=yes,resizable=yes');
}

function setDivHTML(id, html)
{
	target = document.getElementById(id);
	if(target != null)
	{
		target.innerHTML = html;
	}
}

<!--
function number_format(number)
{
	return number_format_ex(number, 2, ',', '.');
}

function /*out: String*/ number_format_ex( /* in: float   */ number, 
                                        /* in: integer */ laenge, 
                                        /* in: String  */ sep, 
                                        /* in: String  */ th_sep ) {

  number = Math.round( number * Math.pow(10, laenge) ) / Math.pow(10, laenge);
  str_number = number+"";
  arr_int = str_number.split(".");
  if(!arr_int[0]) arr_int[0] = "0";
  if(!arr_int[1]) arr_int[1] = "";
  if(arr_int[1].length < laenge){
    nachkomma = arr_int[1];
    for(i=arr_int[1].length+1; i <= laenge; i++){  nachkomma += "0";  }
    arr_int[1] = nachkomma;
  }
  if(th_sep != "" && arr_int[0].length > 3){
    Begriff = arr_int[0];
    arr_int[0] = "";
    for(j = 3; j < Begriff.length ; j+=3){
      Extrakt = Begriff.slice(Begriff.length - j, Begriff.length - j + 3);
      arr_int[0] = th_sep + Extrakt +  arr_int[0] + "";
    }
    str_first = Begriff.substr(0, (Begriff.length % 3 == 0)?3:(Begriff.length % 3));
    arr_int[0] = str_first + arr_int[0];
  }
  return arr_int[0]+sep+arr_int[1];
}

function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

function writeCookie(name, value, days)
{
  var expire = "";
  if(days != null)
  {
    expire = new Date((new Date()).getTime() + days * 3600000 * 24);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  return window.open(theURL,winName,features);
}
//-->


