//<!--

var last_click;             // zuletzt angeklickter Button
var windows = new Array();  // Array mit Win-Objekten

function set_over(obj) {
   document.getElementById(obj).style.borderTopColor = "white";
   document.getElementById(obj).style.borderLeftColor = "white";
   document.getElementById(obj).style.borderBottomColor = "black";
   document.getElementById(obj).style.borderRightColor = "black";
}

function set_out(obj) {
   document.getElementById(obj).style.borderColor = "ButtonFace";
}

function set_click(obj) {
   document.getElementById(obj).style.borderTopColor = "black";
   document.getElementById(obj).style.borderLeftColor = "black";
   document.getElementById(obj).style.borderBottomColor = "white";
   document.getElementById(obj).style.borderRightColor = "white";
}

function Win(ref, posx, posy) {
   this.ref  = ref;
   this.posx = posx;
   this.posy = posy;
}

function check_windows() {
   windows_new = new Array();
   for (i=0; i<windows.length; i++)
   {
    var found = false;
    try{
        if(!windows[i].ref.closed)
            found = true;
    }
    catch(e){
        found = false;
    }
    if (found && windows[i] && windows[i].ref && !windows[i].ref.closed) {
         windows_new.push(windows[i]);
         windows[i].ref.focus();
      }
   }
   windows = windows_new;
}

function window_open(url, w_width, w_height, scroll, type) {
   check_windows();
   ind = windows.length - 1;
   if (windows[ind]) {
      posx = windows[ind].posx + 20;
      posy = windows[ind].posy + 20;
   }
   else {
      posx = (screen.width - w_width) / 2;
      posy = (screen.height - w_height) / 2 - 30;
   }
   if (type == 'resizeable')  proper = 'titlebar=no,toolbar=no,menubar=no,scrollbars='+scroll+',width='+w_width+',height='+w_height+',resizable=yes,left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
   if (type == 'normal')      proper = 'titlebar=no,toolbar=no,menubar=no,scrollbars='+scroll+',width='+w_width+',height='+w_height+',resizable=no,left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
   if (type == 'menu')        proper = 'titlebar=no,toolbar=no,menubar=yes,scrollbars='+scroll+',width='+w_width+',height='+w_height+',resizable=no,left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
   if (type == 'mresizeable') proper = 'titlebar=no,toolbar=no,menubar=yes,scrollbars='+scroll+',width='+w_width+',height='+w_height+',resizable=yes,left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
   if (type == 'minimized')   proper = 'titlebar=no,toolbar=no,menubar=yes,scrollbars='+scroll+',width='+w_width+',height='+w_height+',resizable=no,left='+screen.width+',top='+screen.height+',screenX='+screen.width+',screenY='+screen.height;

   win_ref = window.open(url, '', proper);
   if (win_ref) {
      tmp = new Win(win_ref, posx, posy);
      windows.push(tmp);
      win_ref.focus();
   }
   return win_ref;
}

function modal_open(url, w_width, w_height, scroll, type) {
   if (type == 'normal')     proper = 'dialogHeight:'+w_height+'px;dialogWidth:'+w_width+'px;center:yes;edge:raised;help:no;resizable:no;scroll:'+scroll+';status:no;';
   if (type == 'resizeable') proper = 'dialogHeight:'+w_height+'px;dialogWidth:'+w_width+'px;center:yes;edge:raised;help:no;resizable:yes;scroll:'+scroll+';status:no;';
   return window.showModalDialog(url, window, proper);
}

function modless_open(url, w_width, w_height, scroll, type) {
   if (type == 'normal')     proper = 'dialogHeight:'+w_height+'px;dialogWidth:'+w_width+'px;center:yes;edge:raised;help:no;resizable:no;scroll:'+scroll+';status:no;';
   if (type == 'resizeable') proper = 'dialogHeight:'+w_height+'px;dialogWidth:'+w_width+'px;center:yes;edge:raised;help:no;resizable:yes;scroll:'+scroll+';status:no;';
   return window.showModelessDialog(url, window, proper);
}

function show_hide_div(c_obj, div_id) {
   div_obj = document.getElementById(div_id);
   if (!c_obj || !div_obj) return false;
   if (c_obj.checked) div_obj.style.display = 'none';
   else               div_obj.style.display = 'block';
}

function show_payment(obj)
{
   if (!obj) return false;
   idx = obj.selectedIndex;
   if (!idx) idx = 0;
   div0 = document.getElementById('payment0_div');
   div1 = document.getElementById('payment1_div');
   div2 = document.getElementById('payment2_div');
   if (idx == 0) {
      if (div0) div0.style.display = 'block';
      if (div1) div1.style.display = 'none';
      if (div2) div2.style.display = 'none';
   }
   else if (idx == 1) {
      if (div0) div0.style.display = 'none';
      if (div1) div1.style.display = 'block';
      if (div2) div2.style.display = 'none';
   }
   else if (idx == 2) {
      if (div0) div0.style.display = 'none';
      if (div1) div1.style.display = 'none';
      if (div2) div2.style.display = 'none';
   }
   else if (idx == 3) {
      if (div0) div0.style.display = 'none';
      if (div1) div1.style.display = 'none';
      if (div2) div2.style.display = 'block';
   }
}

function insert_account_owner(obj) {
   fin_vorname = document.getElementById('fin_vorname');
   fin_name    = document.getElementById('fin_name');
   if (!obj || !fin_vorname || !fin_name) return false;
   if (!obj.value) {
      if (fin_vorname.value) obj.value = fin_vorname.value+' '+fin_name.value;
      else                   obj.value = fin_name.value;
   }
}

function insert_img(img) {
	if (parent && parent.opener) {
	  txtarea = parent.opener.document.getElementById('tmpl_content');
	  txtarea.focus();
	  if(typeof document.selection != 'undefined') {
	     if (range = parent.opener.document.selection.createRange()) range.text = '<img src="'+img+'" border=0>';
	  }
	  else if(typeof txtarea.selectionStart != 'undefined') {
	  	 var start = txtarea.selectionStart;
         var end = txtarea.selectionEnd;
         txtarea.value = txtarea.value.substr(0, start) + '<img src="'+img+'" border=0>' + txtarea.value.substr(end);
	  }
	}
}

function insert_link(lnk, name) {
	if (parent && parent.opener) {
	  txtarea = parent.opener.document.getElementById('tmpl_content');
	  txtarea.focus();
	  if(typeof document.selection != 'undefined') {
	     if (range = parent.opener.document.selection.createRange()) range.text = '<a href="'+lnk+'">'+name+'</a>';
	  }
	  else if(typeof txtarea.selectionStart != 'undefined') {
	  	 var start = txtarea.selectionStart;
         var end = txtarea.selectionEnd;
         txtarea.value = txtarea.value.substr(0, start) + '<a href="'+lnk+'">'+name+'</a>' + txtarea.value.substr(end);
	  }
	}
}

function insert_owner_data() {
	owner_firma   = document.getElementById('owner_firma');
	owner_anrede  = document.getElementById('owner_anrede');
	owner_titel   = document.getElementById('owner_titel');
	owner_vorname = document.getElementById('owner_vorname');
	owner_name    = document.getElementById('owner_name');
	owner_strasse = document.getElementById('owner_strasse');
	owner_plz     = document.getElementById('owner_plz');
	owner_ort     = document.getElementById('owner_ort');
	owner_land    = document.getElementById('owner_land');
	owner_telefon = document.getElementById('owner_telefon');
	owner_telefax = document.getElementById('owner_telefax');
	owner_email   = document.getElementById('owner_email');

	fin_firma   = document.getElementById('fin_firma');
	fin_anrede  = document.getElementById('fin_anrede');
	fin_titel   = document.getElementById('fin_titel');
	fin_vorname = document.getElementById('fin_vorname');
	fin_name    = document.getElementById('fin_name');
	fin_strasse = document.getElementById('fin_strasse');
	fin_plz     = document.getElementById('fin_plz');
	fin_ort     = document.getElementById('fin_ort');
	fin_land    = document.getElementById('fin_land');
	fin_telefon = document.getElementById('fin_telefon');
	fin_telefax = document.getElementById('fin_telefax');
	fin_email   = document.getElementById('fin_email');

	if (fin_firma && fin_titel && fin_vorname && fin_name &&
	    !fin_firma.value && !fin_titel.value &&
	    !fin_vorname.value && !fin_name.value) {
	    if (owner_firma && fin_firma) fin_firma.value = owner_firma.value;
	    if (owner_anrede && fin_anrede) fin_anrede.selectedIndex = owner_anrede.selectedIndex;
	    if (owner_titel && fin_titel) fin_titel.value = owner_titel.value;
	    if (owner_vorname && fin_vorname) fin_vorname.value = owner_vorname.value;
	    if (owner_name && fin_name) fin_name.value = owner_name.value;
	    if (owner_strasse && fin_strasse) fin_strasse.value = owner_strasse.value;
	    if (owner_plz && fin_plz) fin_plz.value = owner_plz.value;
	    if (owner_ort && fin_ort) fin_ort.value = owner_ort.value;
	    if (owner_land && fin_land) fin_land.selectedIndex = owner_land.selectedIndex;
	    if (owner_telefon && fin_telefon) fin_telefon.value = owner_telefon.value;
	    if (owner_telefax && fin_telefax) fin_telefax.value = owner_telefax.value;
	    if (owner_email && fin_email) fin_email.value = owner_email.value;
	}
}

var base_url;
var win_url2;
var win_w;
var win_h;

function win_init(b_url, url2, w, h) {
	base_url = b_url;
    win_url2 = '&img='+url2;
    win_w    = w;
	win_h    = h;
}

function win_click(url, url2, w, h) {
	pic = document.getElementById('picnorm');
	if (pic) pic.src = url;
	win_url2 = '&img='+url2;
	win_w = w;
	win_h = h;
}

//--> end hide JavaScript