// JavaScript Document

function $(v) { return(document.getElementById(v)); }
function $S(v) { return(document.getElementById(v).style); }

/*
function window_teil( url )
{
	window_teil_ = openwindow_center( url, 'teilwindow', 800, 600, 'yes', 'yes' );
	window_teil_.focus();
}
*/

function openwindow_center( url, name, width, height, scrollbars, resizable, menubar )
{
	var left = parseInt( (screen.width - width) / 2 );
	var top = parseInt( (screen.height - height) / 2 );
	
	if( left == NaN || left < 0 ) left = 0;
	if( top == NaN || top < 0 ) top = 0;
	if( scrollbars == undefined ) scrollbars = 'no';
	if( resizable == undefined ) resizable = 'no';
	if( menubar == undefined ) menubar = 'no';
	
	winopen = window.open( url, name, "width="+width+",height="+height+",left="+left+",top="+top+",scrollbars="+scrollbars+",status=no,menubar="+menubar+",toolbar=no,resizable="+resizable);
	
	return winopen;
}

/**
 * Checks/unchecks all tables
 *
 * @param   string   the form name
 * @param   boolean  whether to check or to uncheck the element
 *
 * @return  boolean  always true
 */
function setCheckboxes(the_form, the_field, do_check)
{
    var elts      = document.forms[the_form].elements[the_field];
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = do_check;
        } // end for
    } else {
        elts.checked        = do_check;
    } // end if... else

} // end of the 'setCheckboxes()' function

function set_location_href( new_url )
{
	window.location.href = new_url;
	//alert( linktarget );
}

function Go(U,T) {
	var Check;
	Check=confirm(T);
	if(Check==true)
		this.location=U;
} 


function change_display( option, value )
{
	if( value == 1 )
	{
		document.getElementById(option + '_button').style.display = 'none';
		document.getElementById(option).style.display = '';
	}
	else
	{
		document.getElementById(option + '_button').style.display = '';
		document.getElementById(option).style.display = 'none';
	}
	set_cookie(option, value);
}

function set_cookie (Bezeichner, Wert) 
{
  var Verfallszeit = 1000 * 60 * 60 * 24 * 365;
  var jetzt = new Date();
  var Auszeit = new Date(jetzt.getTime() + Verfallszeit);
  document.cookie = Bezeichner + "=" + Wert + "; expires=" + Auszeit.toGMTString() + ";";
}

function add_option( select_id, value, name )
{
	var select_element = document.getElementById( select_id );
	
	var opt = document.createElement("option");
	
	opt.text = name;
	opt.value = value;
	var index = null;
  	if (document.all)
    	index = attr.length;
  	select_element.add(opt, index);
}

function toggle_display(obj)
{
	objs = obj.split('-');
         for(i=0;i < objs.length; i++){
	         if (document.getElementById(objs[i]).style.display == 'none')
	         {
	                 document.getElementById(objs[i]).style.display = '';
	         }
	         else
	         {
	                 document.getElementById(objs[i]).style.display = 'none';
	         }
         }

}