// MM functions start
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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
// MM functions end

function alarm(string)
{
  alert (string);
}

/* xAjax calls Start */
/* <input name="texto" type="text" onKeyUp="updateResults(this.value);"> */
var suggestTimer = null;
function updateResults(searchinput)
{
  if (searchinput.length > 3)
  {
    if (suggestTimer != null)
    {
      clearTimeout(suggestTimer);
    }
    suggestTimer = setTimeout("xajax_updateresult('"+searchinput+"')", 1000);
  }
  /*
  else
  {
    document.getElementById('resultbox').innerHTML = '';
  }
  */
}

function submitForm(frm, rt_editors)
{
  if (arguments.length > 1)
  {
    for (var i = 0; i < rt_editors.length; i++)
    {
      var val = getText(rt_editors[i]);
      frm.elements[rt_editors[i]].value = val;
    }
  }
  xajax_processForm(xajax.getFormValues(frm));
  return false;
}

function getText(editor_name)
{
	if(FCKeditorAPI){
		var oEditor = FCKeditorAPI.GetInstance(editor_name);
	}
	else{
		var oEditor = fckeditorAPI.GetInstance(editor_name);
	}
  if (oEditor.EditorDocument.body.innerHTML)
  {
    return oEditor.EditorDocument.body.innerHTML;
  }
  else
  {
    return '';
  }
}

function confirmDelete(id, message, table, rowIndex)
{
	if (confirm (message+'?'))
	{
		xajax_deleteSingle(id, table, rowIndex);
	}
	return false;
}

function addOption(selectId, txt, val)
{
  var objOption = new Option(txt, val);
  document.getElementById(selectId).options.add(objOption);
}
/* all other */
//set a style attribute value
function setStyleAttribute(objId, styleAttr, attrValue){
	
	document.getElementById(objId).style[styleAttr]=attrValue;
}


//user JS

var soundstatus=1;
function play(){
	if(document.test_sound){
	document.test_sound.TCallLabel("/mc_controls", "start_sound");
	start_equalizer();
	}
	if(document.getElementById("id_controls_buttons")){
		document.getElementById("id_controls_buttons").innerHTML='<a href="javascript:stop()"><img id="id_play_button"  src="system/icons/stopbutton.jpg" border=0 title="Stop"></a>';
	}
	
	soundstatus=1;
	
}
function stop(){
	if(document.test_sound){
		document.test_sound.TCallLabel("/mc_controls", "stop_sound");
		stop_equalizer();
	}
	if(document.getElementById("id_controls_buttons")){
		document.getElementById("id_controls_buttons").innerHTML='<a href="javascript:play()"><img id="id_play_button"  src="system/icons/playbutton.jpg" border=0 title="Play"></a>';
	}
	
	soundstatus=0;
	
}
//stop flash butto - equalizer
function stop_equalizer(){
	if(document.eq_thumb){
		document.eq_thumb.TCallLabel("/mc_controls", "stop_sound");
	}
}
//start flash butto - equalizer
function start_equalizer(){
	if(document.eq_thumb){
		document.eq_thumb.TCallLabel("/mc_controls", "start_sound");
	}
}
function init_sound_button(){
	if(soundstatus==1){
		//playing
		if(document.getElementById("id_controls_buttons")){
		document.getElementById("id_controls_buttons").innerHTML='<a href="javascript:stop()"><img id="id_play_button"  src="system/icons/stopbutton.jpg" border=0 title="Stop"></a>';
		}
	}
	else{
		if(document.getElementById("id_controls_buttons")){
			document.getElementById("id_controls_buttons").innerHTML='<a href="javascript:play()"><img id="id_play_button"  src="system/icons/playbutton.jpg" border=0 title="Play"></a>';
		}
	}
		
}

function dim_in(){
		var div=xajax.$('id_dimmer');
		div.className="dimin";
}
function dim_out(){
	var div=xajax.$('id_dimmer');
	div.className="dimout";
}
function show_mixer(){	
	var ref=document.getElementById("id_mixer");
	if(!ref) return;
	ref.style.width="526px";
	ref.style.height="400px";
	var b=document.getElementsByTagName("BODY");
	var h=b[0].offsetHeight;
	
	ref.style.left=""+ (parseInt(screen.availWidth/2) - 260) + "px";
	ref.style.top=""+ (parseInt(h/2) - 200) + "px";
	if(document.test_sound){
		document.test_sound.style.width="526px";
		document.test_sound.style.height="385px";
	}
	dim_in();
}
function hide_mixer(){
	
	var ref=document.getElementById("id_mixer");
	ref.style.width="1px";
	ref.style.height="0px";
	ref.style.left="0px";
	ref.style.top="0px";
	if(document.test_sound){
		document.test_sound.style.width="0px";
		document.test_sound.style.height="0px";
	}
	dim_out();
}
function show_gallery(){
	var ref=document.getElementById('id_id_media');
	if(!ref) return;
	ref.style.width="800px";
	ref.style.height="450px";
	ref.style.overflow='auto';
	ref.style.display="block";
	var b=document.getElementsByTagName("BODY");
	var h=b[0].offsetHeight;
	ref.style.left=""+ (parseInt(screen.availWidth/2) -400) + "px";
	ref.style.top=""+ (parseInt(h/2) - 220) + "px";
	dim_in();
}
function hide_gallery(){
	var ref=document.getElementById('id_id_media');
	if(!ref) return;
	
	ref.style.display='none';
	dim_out();
}
//upload - dim
function show_upload(url){
	//iframe
	var up_frame=document.getElementById('id_iframe_upload');
	if(!up_frame) return;
	up_frame.src=url;
	var ref=document.getElementById('id_id_upload');
	if(!ref) return;
	ref.style.width="800px";
	ref.style.height="450px";
	ref.style.overflow='auto';
	ref.style.display="block";
	var b=document.getElementsByTagName("BODY");
	var h=b[0].offsetHeight;
	ref.style.left=""+ (parseInt(screen.availWidth/2) -400) + "px";
	ref.style.top=""+ (parseInt(h/2) - 220) + "px";
	dim_in();
}
function hide_upload(){
	var ref=document.getElementById('id_id_upload');
	if(!ref) return;
	
	ref.style.display='none';
	dim_out();
}
function getScreenSize(){
	var sWidth=screen.width;
	var sHeight=screen.height;
}
var user_upload_dir="/user/upload/jpg/";
function handleScreenSize(){
	return;
	var sWidth=screen.width;
	var sHeight=screen.height;
	var back="back_"+sWidth+".jpg";
	if(sWidth > 1280){
		back="back_max.jpg";	
	}
	//xajax.$('id_body').style.backgroungImage="url('http://www.cms.um/user/upload/jpg/back_1440x900.jpg')";
	//xajax.$('id_body').style.backgroungColor="#ff0000";
	document.body.background=user_upload_dir+back;
	if(sWidth <= 1280){
		document.body.style.backgroundRepeat='repeat-y';
	}
	else{
		document.body.style.backgroundRepeat='repeat';	
	}
	
	
}
//bildergallerie - pagenav
var selected_pagenav;
function set_selected_pagenav(obj){
	if(obj){alert(obj);
		obj.className="selected_pagenav";
		selected_pagenav=obj;
	}

}
//Video anzeigen
function show_tv_video(){
	var ref=xajax.$('id_tv_video');
	if(!ref) return;
	
	ref.style.backgroundColor="#eaeaea";
	ref.style.display='block';
}
function hide_tv_video(){
	var ref_video=xajax.$('id_play_video');
	if(!ref_video) return;
	var ref_div=xajax.$('id_tv_video');
	if(!ref_div) return;
	ref_video.innerHTML="";
	ref_div.style.display='none';
}
function show_search(){	
	var ref=document.getElementById("id_search");
	if(!ref) return;
	ref.style.display='block';
	ref.style.width="800px";
	ref.style.height="600px";
	var b=document.getElementsByTagName("BODY");
	var h=b[0].offsetHeight;
	ref.style.left=""+ (parseInt(screen.availWidth/2) - 400) + "px";
	ref.style.top=""+ (parseInt(h/2) - 300) + "px";
	
	dim_in();
}
function hide_search(){
	
	var ref=document.getElementById("id_search");
	/*ref.style.width="1px";
	ref.style.height="0px";
	ref.style.left="0px";
	ref.style.top="0px";
	*/
	ref.style.display='none';
	
	dim_out();
}
function load_page(page){
	xajax_loadPage(page);
}
//kontakt aus content
function load_kontakt(b){
	xajax_loadKontakt(b);
}
//Untermenü
var is_browser_ok=true;
var b=getBrowser();
if(b!="msie6" && b!="msie7" && b!="fx2" && b!="fx3"){
	is_browser_ok=false;
}

function show_umenu(id){
	var ref=document.getElementById(id);
	if(!is_browser_ok){	
		if(ref.style.backgroundImage)	
			ref.style.backgroundImage=ref.style.backgroundImage.replace(/.png/, ".jpg");		
	}
	
	if(ref)	ref.style.display='block';
}
function hide_umenu(id){	
	var ref=document.getElementById(id);
	if(ref) ref.style.display='none';
}
function getBrowser(){
	var browser="";

	if(navigator.userAgent.indexOf("MSIE 6") != -1)browser="msie6";
	if(navigator.userAgent.indexOf("MSIE 7") != -1)browser="msie7";
	if(navigator.userAgent.indexOf("Firefox/3") != -1)browser="fx3";
	if(navigator.userAgent.indexOf("Firefox/2") != -1)browser="fx2";

	return browser;
}
//iframe im div: id_div_mobile / id_iframe_mobile
function loadMobile(url){
	xajax_loadMobile(url);
}
function showMobile(){
	var div=document.getElementById('id_div_mobile');
	if(!div) return false;
	div.style.width="720px";
	div.style.height="620px";
	div.style.overflow='auto';
	div.style.display="block";
	
	var b=document.getElementsByTagName("BODY");
	var h=b[0].offsetHeight;
	div.style.left=""+ (parseInt(screen.availWidth/2) -350) + "px";
	div.style.top=""+ (parseInt(h/2) - 300) + "px";
	dim_in();
	
	
}
function hideMobile(){
	var div=document.getElementById('id_div_mobile');
	if(!div) return false;
	div.style.display='none';
	dim_out();
}
function load_kontakt(betreff){
	xajax_loadKontakt(betreff);
}
function set_flash_gallery_props(){
	var ref=xajax.$('id_flash_gallery');
	var b=document.getElementsByTagName("BODY");
	var h=b[0].offsetHeight;
	if(navigator.userAgent.indexOf("MSIE") != -1){
		ref.style.height=h + "px";	
	
	}
}

window.onload=handleScreenSize;

