




/* returns the x,y coordinates of the current screen (for multi monitor setup) */
function get_top_left(width, height){
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
	  		winW = window.innerWidth;
	  		winH = window.innerHeight;
	 		winL = window.screenX;
	 		winT = window.screenY;
	 	} else {
	  		winW = document.body.offsetWidth;
	  		winH = document.body.offsetHeight;
	  		winL = window.screenLeft;
	  		winT = window.screenTop;
	 	}
	}
	
	var scroll = 0;
	var l = winL + winW/2 - width/2;
	var t = winT + winH/2 - height/2;
	
	
  	if(screen.width <= width){
  		width=screen.width;
  	}
  	if(screen.height <= height){
  		height=screen.height;
 	 	var t = 0;
  		var scroll = 1;
  	}
	return Array(t,l);
}


/* generic window opener */
function openwin(uri,title,w,h){
	if(w){wwidth = w;}else{	wwidth = 380;}
	if(h){wheight = h; }else{ wheight = 380;}
	xy = get_top_left(wwidth, wheight);
	wleft = xy[1];
	wtop = xy[0];
	wnd = window.open(uri, title, "width="+wwidth+", height="+wheight+", left="+wleft+", top="+wtop+", toolbar=no, location=no, scrollbars=yes, status=no, menubar=no, resizable=no, directories=no");
}
/* Open simple popup window */
function open_window(myuri, window_width, window_height) {
	position = get_top_left(window_width, window_height);
	opts = 'toolbar=0,location=0,top='+position[0]+',left='+position[1]+',directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+window_width+',height='+window_height;
	var wnd = window.open(myuri, 'gw', opts);
	return false;
}


/* set cookie */
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

/* get cookie */
function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else {
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) {
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}

/* delete cookie */
function deleteCookie( name, path, domain ) {
	if ( getCookie(name) ) 
		document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function check_kontakt(frm_obj) {
	var ret_val = true;
	
	var fields = getElementsByClassName(document.getElementById('kontakt'), '*', 'frm_required');
	
	for (i=0; i<fields.length; i++) {
		tag_type = fields[i].tagName;
		switch (tag_type) {
			case 'INPUT': obj_val = fields[i].value; break;
			case 'SELECT': obj_val = fields[i].options[fields[i].selectedIndex].value; break;
			case 'TEXTAREA': obj_val = fields[i].value; break;
			default: break;
		}
		
		if (trim(obj_val) == '') {
			ret_val = false;
			if (fields[i].className.indexOf('error') < 0)
				fields[i].className += ' error';
			
			fields[i].onchange = function() {
				this.className = this.className.replace(' error', '');
			}
		} else {
			fields[i].className = fields[i].className.replace(' error', '');
			fields[i].onchange = function() {};
		}
	
	}
	
	return ret_val;
}


var text_sizes		= [14, 16, 12];
var line_heights	= [1.2, 1.4, 1.6];

var def_text_size = 0;
var def_line_height = 0;


function change_line_height() {
	current_lh = getCookie('line_height');
	if (!current_lh) current_lh = 0;
	current_lh ++;
	if (current_lh == line_heights.length) current_lh = 0;
	if (current_lh != 0) {
		setCookie('line_height', current_lh);
	} else {
		deleteCookie('line_height');
		current_lh = def_line_height;
	}
	document.getElementById('inner_content').style.lineHeight = line_heights[current_lh] + "em";
}

function change_text_size() {
	current_ts = getCookie('text_size');
	if (!current_ts) current_ts = 0;
	current_ts ++;
	if (current_ts == text_sizes.length) current_ts = 0;
	if (current_ts != 0) {
		setCookie('text_size', current_ts);
	} else {
		deleteCookie('text_size');
		current_ts = def_text_size;
	}
	document.getElementById('inner_content').style.fontSize = text_sizes[current_ts] + 'px';
}

function init_text_properties() {
	current_text_size = getCookie('text_size');
	current_line_height = getCookie('line_height');
	
	if (current_text_size) {
		document.getElementById('inner_content').style.fontSize = text_sizes[current_text_size] + "px";
	}	
	if (current_line_height) {
		document.getElementById('inner_content').style.lineHeight = line_heights[current_line_height] + "em";
	}
	
}
/*
window.onload = function() {
	init_text_properties();
}
*/
