﻿// JScript File
function confirm_delete()
{
    if (confirm("Diesen Eintrag wirklich entfernen?"))
        return true;
    else return false;
}

//function copyContent(id) 
//{   
//    var control = document.getElementById(id);
//   
//    if (control == null)
//    {
//        alert('ERROR - control not found - ' + controlId); 
//    }
//    else {        
//        //determine the value of the control
//        var controlValue = control.value;
//        alert('value: ' + controlValue);
//        //copy to clipboard         
//        window.clipboardData.setData('Text', controlValue);
//        alert('Copied text to clipboard : ' + controlValue); 
//    }
//}


//******************* WEB-Service************************//
var origColor;
var origFontColor;
function HandleOver( row )
{
    origColor = row.style.backgroundColor;
    origFontColor = row.style.color;
    row.style.backgroundColor = "#0072bb";
    row.style.color = "#FFFFFF";
}

function HandleOut( row )
{
    isOK = true;
    row.style.backgroundColor = origColor;
    row.style.color = origFontColor;
}

function openFoto (selectedItem, event_idx, eventname)
{
    fenster1 = window.open("foto.aspx?selectedItem=" + selectedItem + "&event_idx=" + event_idx + "&eventname=" + eventname, "foto", "toolbar=0, scrollbars=0, location=0, status=1, menubar=0, resizable=0, width=792, height=792");
    fenster1.focus();
}

function setSize(bildnameid){
	var x = document.getElementById(bildnameid).width;
	var y = document.getElementById(bildnameid).height;		
	//var randhoehe = -6;
	var randhoehe = 0;
	//alert("x: "+x + " / y: " +y);
	
	// für IE und Firefox
	//self.resizeTo(x+11,y+57+randhoehe);
	self.resizeTo(x+11,y+57+randhoehe);
	
	// korrektur für firefox	
	//self.resizeBy(x-window.innerWidth,y+randhoehe+7-window.innerHeight);
	self.resizeBy(0,y+randhoehe+7-window.innerHeight);
   // alert("wx: "+ window.height + " / wy: " +window.width);		
	
	//self.moveTo((screen.width-x)/2,(screen.height-y)/2);	
	if(window.left < 0) window.left = 0;
	if(window.top < 0) window.top = 0;	
//	alert("x: " + mouseX + "  y: " + mouseY);
//	window.left = mouseX;
//	window.top = mouseY;
	self.focus();
}

//******************************* N E W S ***************************************//
function insert(input, aTag, eTag) 
{
  input = document.getElementById(input);
  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 openBildauswahl(targetid)
{
  mywindow = window.open("bildauswahl.aspx?targetid=" + targetid + "&select=none", "Hilfe", "toolbar=0, scrollbars=1, location=0, status=1, menubar=0, resizable=0, width=450, height=280");
  mywindow.focus();
}

function setPreviewImage(source_id)
{
    var img;
    img = document.getElementById("imgUpload");
    
    img.src = document.getElementById(source_id).value;
}

function chooseImg(listClientID, targetID)
{
    var list = document.getElementById(listClientID);
    var img = document.getElementById(targetID);
    
    img.src = "news_images/" + list.value;
    img.alt = list.value;
}

function setBBImageUrl(imageUrl, targetid, sourceID)
{ 
    targetid = opener.document.getElementById(targetid);
    var imgsrc;
    if (sourceID != "")
    {
        imgsrc = document.getElementById(sourceID).value;
    }
    else
    {
        imgsrc = imageUrl;
    }
//    alert(imgsrc + "\n" + myimg.src + "\n" + hostUrl);
    targetid.focus();
    /* für Internet Explorer */
    if(typeof opener.document.selection != "undefined") 
    {
        var range = opener.document.selection.createRange();
        range.text = "[img=" + imgsrc + "]";
    }
    // für Geckobasierende Browser
    else if(typeof targetid.selectionStart != "undefined")
    {        
        var start = targetid.selectionStart;
        var end = targetid.selectionEnd;
        var insText =  "[img=" + imgsrc + "]";
        targetid.value = targetid.value.substr(0, start) + insText + targetid.value.substr(end);
    }
    window.close();
}

/*********** BB Code **************/

function openBBCode_Help()
{
  mywindow = window.open("bbcode_help.aspx", "Hilfe", "toolbar=0, scrollbars=1, location=0, status=0, menubar=0, resizable=0, width=600, height=400");
  mywindow.focus();
}
