
function smiley (smiley) {
	document.getElementById('nachricht').value += smiley;
	document.getElementById('nachricht').focus();
}

function insert_bbc(aTag, eTag, $formular, $feld) {
  var input = document.forms[$formular].elements[$feld];
  input.focus();
  /* für Internet Explorer */
  if(typeof document.selection != 'undefined') {
    /* Einfügen des Formatierungscodes */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = aTag + insText + eTag;
    /* Anpassen der Cursorposition */
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -eTag.length);
    } else {
      range.moveStart('character', aTag.length + insText.length + eTag.length);      
    }
    range.select();
  }
  /* für neuere auf Gecko basierende Browser */
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Einfügen des Formatierungscodes */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
    /* Anpassen der Cursorposition */
    var pos;
    if (insText.length == 0) {
      pos = start + aTag.length;
    } else {
      pos = start + aTag.length + insText.length + eTag.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  /* für die übrigen Browser */
  else
  {
    /* Abfrage der Einfügeposition */
    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;
    }
    /* Einfügen des Formatierungscodes */
    var insText = prompt("Bitte geben Sie den zu formatierenden Text ein:");
    input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
  }
}


function download(theURL) {
	win = window.open(theURL,'download','scrollbars=no,width=200px,height=100px');
	//win.setTimeout ('window.close ()', 5000); 
}

function info(theURL) {
  window.open(theURL,'info','scrollbars=yes,width=800px,height=500px');
}

function transaction_info(theURL) {
  window.open(theURL,'transaction_info','scrollbars=yes,width=1000px,height=700px');
}

function stornos(theURL) {
  window.open(theURL,'stornos','scrollbars=yes,width=700px,height=500px');
}


function chat(theURL,user) {
  //window.open(theURL,'chat_'+user,'resizable=no,scrollbars=no,width=525px,height=500px');
  window.open(theURL,'chat_'+user,'resizable=no,scrollbars=no,width=820px,height=600px');
}

function cam(theURL,user) {
  window.open(theURL,'cam_'+user,'resizable=no,scrollbars=no,width=1000px,height=700px');
}

function cam_konsole(theURL,user) {
  window.open(theURL,'cam_'+user,'resizable=yes,scrollbars=no,width=915px,height=630px');
}

function upload(theURL) {
  window.open(theURL,'upload','scrollbars=no,width=500px,height=200px');
}


/*
function confirmLink(theLink, day)
{
	var confirmMsg  = 'Wollen Sie diese Buchung wirklich stornieren? ';	
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(confirmMsg);
    if (is_confirmed) {
        if ( typeof(theLink.href) != 'undefined' ) {
            theLink.href += '&is_js_confirmed=1';
        } else {
			href += 'index.php?site=Abrechnung&day=' + day;
		}
    }

    return is_confirmed;
} // end of the 'confirmLink()' function
*/

function confirmLink(theLink, day)
{
	var confirmMsg  = 'Wollen Sie diese Buchung wirklich stornieren?';	
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(confirmMsg);
    if (is_confirmed) {
        if ( typeof(theLink.href) != 'undefined' ) {
            theLink.href += '&is_js_confirmed=1';
        } else {
			href += day;
		}
    }

    return is_confirmed;
}


// Chatverlauf löschen
function del(theLink, query, mess)
{
	var confirmMsg  = mess;	
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    /*
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }
	*/
    var is_confirmed = confirm(confirmMsg);
    if (is_confirmed) {
        if ( typeof(theLink.href) != 'undefined' ) {
            theLink.href += '&'+query;
        } else {
			href;
		}
    }

    return is_confirmed;
}



function navigateAndClose(sUrl)
{
   if (opener != null)
  {
    opener.document.location = sUrl;
    return true;
  }
}


// Videothek
function preview_video (url) {
	fenster = window.open(url, "preview_video", "width=860,height=400,status=no,scrollbars=no,resizable=no");
	fenster.focus();
}


function open_div(id) {
	document.getElementById(id).className  = 'div_show';
}

function close_div(id) {
	document.getElementById(id).className  = 'div_none';
}

