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_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_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 doSearch(stdValue) {
	if ($("searchStr").value && $("searchStr").value != stdValue) {
		document.searchForm.submit();
	}
}
function formFocus(field,active,word) {
	if (active && field.value == word) field.value='';
	else {
		if (field.value == "") field.value=word;
	}
	
}

// Fontsize ----------------------------------------------------------------------------------------------------

function setcookie(name, value, days, path, domain, secure) { 
	var expires = -1; 
	if(typeof days == "number" && days >= 0) {
		var d = new Date(); d.setTime(d.getTime()+(days*24*60*60*1000)); expires = d.toGMTString(); 
	} 
	value = escape(value); 
	document.cookie = name + "=" + value + ";" + (expires != -1 ? " expires=" + expires + ";" : "") + (path ? "path=" + path : "") + (			domain ? "; domain=" + domain : "") + (secure ? "; secure" : ""); 
}

function delcookie(name) { setcookie(name, "-", 0); }
function getcookie(name) { 
	var idx = document.cookie.indexOf(name+'='); 
	if(idx == -1) { 
		return null; 
	} 
	value = document.cookie.substring(idx+name.length+1); 
	var end = value.indexOf(';'); 
	if(end == -1) { 
		end = value.length; 
	} 
	
	value = value.substring(0, end); 
	value = unescape(value); return value; 
}

function setFontSize(fs) {
	document.body.style.fontSize=fs+"px";
	document.body.style.lineHeight=((fs*1)+5)+"px";
	$('outercontainer').style.fontSize=fs+"px";
	$('outercontainer').style.lineHeight=((fs*1)+5)+"px";
	
	//changeClassProperties(fs);
	
	var obj = document.getElementsByTagName("td");
						
	for (var i=0; i<obj.length; i++) {
		with ( obj[i] ) {
			style.fontSize= fs+"px";
			style.lineHeight=  fs+"px";							}
	}
	
	setcookie('cr_font_size', fs, 365, '/');
	try {
		resizeContent('font');
	}catch(e){
	}
}

function setFontSizeLoad(fs) {
	document.body.style.fontSize=fs+"px";
	document.body.style.lineHeight=((fs*1)+5)+"px";
	changeClassProperties(fs);
	setcookie('cr_font_size', fs, 365, '/');
	try {
		//resizeContent();
	}catch(e){
	}
}
function loadFontSize() {
	//alert('cookie: '+getcookie('oeci_font_size'));
	if(getcookie('cr_font_size')){ setFontSize(getcookie('cr_font_size')); }	
}

// ---------------------------------------------------------------------------------------------------
var flap = 0;

function cr_flapout(flap_url){
	if(flap==0){
		flap=1;
		$('flapout').morph('width:620px;'); 
		setTimeout("ajax_init('"+flap_url+"');",1000);
	}else{
		flap=0;
		$('flapout').morph('width:41px;'); 		
		$('ajaxcontent').style.display = 'none';
	}
}

var act_faq = 0;

function cr_faq(uid){
	
	if(act_faq>0){
		cr_faq_close(10000+act_faq)
	}
	
	act_faq = uid;
	$('faq_txt_'+uid).style.height = '';
	$('faq_no_'+uid).style.display = 'none';
	$('faq_act_'+uid).style.display = '';
	Effect.BlindDown('faq_txt_'+uid, { duration: 0.5 });
}
function cr_faq_close(uid){
	
	if(uid>10000){
		uid = uid-10000;
	}else{
		act_faq = 0;
	}
	
	$('faq_act_'+uid).style.display = 'none';
	$('faq_no_'+uid).style.display = '';
	Effect.BlindUp('faq_txt_'+uid, { duration: 0.5 });	
}

var initajax = 0;
function ajax_init(flap_url) {
	//$('ajaxcontent').style.display = '';
	Effect.Appear('ajaxcontent', { duration: 0.5 });	

	if(initajax==0){
		var url = "fileadmin/inc/ajax.php";
		var pars = "flapurl="+flap_url; //&clear="+clear;
		var myAjax = new Ajax.Request(url, {method: "get", parameters: pars, onComplete: updateDiv});
		initajax = 1;
	}
}

function updateDiv(orgRequest) {
	var xmldoc = orgRequest.responseXML;
	
	xmldoc.getElementsByTagName("data")[0].normalize();
	var result_big = xmldoc.getElementsByTagName("data")[0].firstChild.data;
	result_big.evalScripts();
	document.getElementById("ajaxcontent").innerHTML = result_big;

}

// ---------------------------------------------------------------------------------------------------


var dropDownMenu = Class.create();
dropDownMenu.prototype = {
	initialize: function(parent, menu) {
		var item = this;
		this.element = $(parent);
		
		this.menu = $(menu);
		//this.menu.style.position = 'absolute';
		this.menu.style.zIndex = 9999;		
		
		this.timeout = 0.5;
		this.fadeTime = 0.2;

		this.element.onmouseover = function() {
			item.open();
		}
		this.menu.onmouseover = function() {
			item.open();
		}
		this.element.onmouseout = function() {
			item.close();
		}
		this.menu.onmouseout = function() {
			item.close();
		}
	},
	open: function() {
		this.lock = 1;
		this.menu.appear({duration:this.fadeTime});
	},
	close: function() {
		this.lock = 0;
		this.close2.delay(this.timeout, this);
	},
	close2: function(item) {
		if (item.lock==0){
			item.menu.fade({duration:item.fadeTime});
		}
	}
}
