//*******************
function CheckInhalt(frm,feld,wert,bed,str)
{
 if(wert == "") {
  alert(str);
  eval('document.'+frm+'.'+feld+'.focus()');
  return false;
 }
}


//*******************
function go_seite(frm,wert)
{
document.forms[frm].elements['CurrentPage'].value=wert;
document.forms[frm].elements['seitenschaltung'].value=wert;
document.forms[frm].submit();
return true;
}
//*******************
function loeschen_ok(meldung)
  {
  check=confirm(meldung+" ?");
  if (check==true)
    {
    return true;
    }
  else
    {
    document.frm_del.reset();
    return false;
    }
  }
//*******************
function submitorder(frm,feld)
{
document.forms[frm].order.value=feld;
document.forms[frm].submit();
return true;
}
//*******************
function submit_feld(frm,feld,wert,sprache)
{
//alert(feld+wert);
if (frm=="frmsprachwahl")
  {
  document.forms[frm].elements['sprache'].value=sprache;
  }
document.forms[frm].elements[feld].value=wert;
document.forms[frm].submit();
return true;
}

//**********************************
function start_window(datei,w,h)
{
//winprops = 'height='+h+',width='+w+',left=195,right=0';
l=screen.width/2-(w+16)/2
t=screen.height/2-(h+120)/2;
winprops = 'fullscreen=no,height='+h+',width='+w+',top='+t+',left='+l+',toolbar=No,menubar=0,scrollbars=1,resizable=no,statusbar=yes';
fenster_anzeige = window.open(datei,"fenster_anzeige",winprops);
fenster_anzeige.focus();
}

//**********************************
function start_window_edit(datei)
{
h=screen.availHeight-40;
w=700;
//winprops = 'height='+h+',width='+w+',left=195,right=0';
l=screen.width/2-(w+16)/2
t=screen.height/2-(h+120)/2;
winprops = 'fullscreen=no,height='+h+',width='+w+',top='+t+',left='+l+',toolbar=no,scrollbars=1,resizable=yes,statusbar=yes';
fenster_anzeige = window.open(datei,"fenster_anzeige",winprops);
fenster_anzeige.focus();
}

//*********************************
function zeig_meldung(meldung)
{
h=screen.availHeight-100;
w=500;
//winprops = 'height='+h+',width='+w+',left=195,right=0';
l=screen.width/2-(w+16)/2
t=screen.height/2-(h+120)/2;
winprops = 'fullscreen=no,height='+h+',width='+w+',top='+t+',left='+l+',toolbar=no,scrollbars=1,resizable=yes,statusbar=yes';
fenster_anzeige = window.open("","fenster_anzeige",winprops);
fenster_anzeige.document.write("<html><head><title>"+meldung.substr(0,30)+" ...</title></head><body bgcolor='#EEEEEE'><p style='text-align: left; font-family: verdana, arial, helvetica, geneva; font-weight : normal; font-size: 11px'>"+meldung+"</p></body></html>");
fenster_anzeige.document.close();
fenster_anzeige.focus();
}
//******************************
function startClock()
{
frm="frm_edit";
x = x+1;
if (sek_2>30)
  {
//  sek_2=1;
  }
if (sek>59)
  {
  sek=0;
  m++;
  }
if (m>59)
  {
  st++;
  m=0;
  }

if (show_timer)
  {



  var mx=(screen.availWidth/2)-200;
  var my=(screen.availHeight/2)-100;
  var otimer=document.getElementById("upload_timer");
  if (document.all)
    {
//    mx=window.event.clientX+70;
//    my=window.event.clientY-400;
    mx=(document.all.SITEBODY.offsetWidth/2)-200;
    }
  else
    {
    mx=(window.innerWidth/2)-200;
    my=(window.pageYOffset+200);
    }

  eval('otimer.style.left = "'+mx+'px"');
  eval('otimer.style.top = "'+my+'px"');
  otimer.style.visibility = "visible";

  for (var i=0;i<eval('document.'+frm+'.elements.length');i++)
    {
    if (eval('document.'+frm+'.elements['+i+'].type')=='select-one')
      {
      eval('document.'+frm+'.elements['+i+'].style.visibility = "hidden"');
      }
    }
  show_timer=false;
  }

var ofort=document.getElementById("upload_fortschritt");
var w_fort=(380*(1-(1/sek_2)));
if ((sek_2*12)<w_fort)
  {
  w_fort=(sek_2*12);
  }

eval('document.'+frm+'.sekunden.value = '+sek);
eval('document.'+frm+'.minuten.value = '+m);
eval('document.'+frm+'.stunden.value = '+st);

//eval('ofort.style.width = "'+(sek_2*12)+'px"');
eval('ofort.style.width = "'+(w_fort)+'px"');
//eval('document.'+frm+'.warten.value = "bitte warten ..."');
//alert("sek_2"+sek_2);
sek++;
sek_2++;
time_out=window.setTimeout("startClock()", 1000);
al=eval('document.'+frm+'.sekunden.value = '+sek);
}
function stop_timer()
{
window.clearTimeout(time_out);
time_out="";
}
//***************************************************
var dsz_aktiv='';
var dsz_color_old='#FFFFFF';
function highlight_tr(name)
{
//alert(name);
if (dsz_aktiv!='')
  {
  eval('document.getElementById("'+dsz_aktiv+'").bgColor = "'+dsz_color_old+'"');
  }
dsz_color_old=eval('document.getElementById("'+name+'").bgColor');
//alert(dsz_color_old);
eval('document.getElementById("'+name+'").bgColor = "#C7C9DA"');
//this.bgColor='#FFFF00';
dsz_aktiv=name;
return 1;
}
//***************************************************
var dsz_aktiv='';
var dsz_color_old='#FFFFFF';
function highlight_tr_out(name)
{
eval('document.getElementById("'+dsz_aktiv+'").bgColor = "'+dsz_color_old+'"');
return 1;
}
//***************************************************
function bold(feld)
{
var sel;

 if (document.selection)
 {
  var str = document.selection.createRange().text;
  document.frm_edit.elements[feld].focus();
  var sel = document.selection.createRange();
  sel.text = "<b>" + str + "</b>";
 }
 else
 {
  alert("FETT <b>text</b> einfügen wird nur von IE unterstützt! ");
 }
}
//**************************************************************
function insert_code(id,tag1,tag2)
{
 if(id=='multiple')
 {
  id=$j("#focused_textarea").val();
 }
 var input = document.getElementById(id);
 input.focus();
 if (typeof document.selection != 'undefined')
 {
  var range = document.selection.createRange();
  var insText = range.text;
  range.text = tag1 + insText + tag2;
  range = document.selection.createRange();

  if (insText.length == 0)
  {
   range.move('character', -tag2.length);
  }
  else
  {
   range.moveStart('character', tag1.length + insText.length + tag2.length);
  }
  range.select();
 }
 else if (typeof input.selectionStart != 'undefined')
 {
  var start = input.selectionStart;
  var end = input.selectionEnd;
  var insText = input.value.substring(start, end);
  input.value = input.value.substr(0, start) + tag1 + insText + tag2 + input.value.substr(end);
  var pos;

  if (insText.length == 0)
  {
   pos = start + tag1.length;
  }
  else
  {
   pos = start + tag1.length + insText.length + tag2.length;
  }

  input.selectionStart = pos;
  input.selectionEnd = pos;
 }
 else
 {
  var pos;
  var re = new RegExp('^[0-9]{0,3}$');
  while (!re.test(pos))
  {
   pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0");
  }
  if (pos > input.value.length)
  {
   pos = input.value.length;
  }
  var insText = prompt("Bitte geben Sie den zu formatierenden Text ein:");
  input.value = input.value.substr(0, pos) + tag1 + insText + tag2 + input.value.substr(pos);
 }
}
//***************************************************
function lade_video(w, h, video_id, absatz_nr)
{
 var video_html = '<object style="float:right; margin-left:10px;margin-bottom:10px" width="'+w+'" height="'+h+'"><param name="movie" value="http://www.youtube.com/v/'+video_id+'&hl=de_DE&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+video_id+'&hl=de_DE&fs=1&autoplay=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+w+'" height="'+h+'"></embed></object>';

 $j("#youtube_video_"+absatz_nr).html(video_html);
}
