///////////////////////////////////////////////////////////
// Konfiguration!
var ext    = '.gif';  // Der Grafiktyp

var over   = '_over';   // Dateinamenerweiterung für
var stay   = '_over'; // die Buttons
var down   = '_over'; // in den verschiedenen Zuständen

///////////////////////////////////////////////////////////
// Funktion: start_mouse_over()
//
function start_mouse_over()
{
    var doc = self.document;
    if(!doc.images) return;

    for(var i = 0; i < doc.images.length; i++)
    {
        var img = doc.images[i];
        ///////////////////////////////////////////////////
        // Button suchen
        // und events zuweisen.
        if( img.name.indexOf('button') == 0) addEventsToImage(img);
    }

	
///////////////////////////////////////////////////////////
// Statuszeilentext festlegen	
window.status = "LIMELIGHTforum - Spass an der Fotografie"

}
///////////////////////////////////////////////////////////
// Funktion: addEventsToImage(img)
//
// die events zuweisen.
function addEventsToImage(img)
{
    var folder = img.src.substring(0, img.src.lastIndexOf('index.html') + 1) ;
    ///////////////////////////////////////////////////////
    // Die Events
    img.onmouseover = on_mouse_over;
    img.onmouseout  = on_mouse_out;
    img.onmousedown = on_mouse_down;
    img.onclick     = on_click;

    ///////////////////////////////////////////////////////
    // Bild vorladen
    img.stay = new Image();
    img.stay.img = img;
    img.stay.onerror = function() { this.img.onclick = null;}
    img.stay.src = folder + img.name + stay + ext;

    img.over = new Image();
    img.over.img = img;
    img.over.onerror = function() { this.img.onmouseover = null;}
    img.over.src = folder + img.name + over + ext;

    img.down = new Image();
    img.down.img = img;
    img.down.onerror = function() { this.img.onmousedown = null;}
    img.down.src = folder + img.name + down + ext;

    ///////////////////////////////////////////////////////
    // die ürsprüngliche Grafik sichern.
    img.out = img.src;

    ///////////////////////////////////////////////////////
    // wurde breits auf die Grafik geklickt?
		/* 	Auskommentiert von R. Kutschat am 13.08.04, 16:25 wegen
				Fehler bzw. Problemen bei Navigation
		
    if(window.name == img.name) img.onclick();
		*/
}
///////////////////////////////////////////////////////////
// Funktion: on_mouse_down()
function on_mouse_down()
{
    if(_click_ == this) return false; // ist bereits angeklickt.
    this.src = this.down.src;
    return true;
}
///////////////////////////////////////////////////////////
// Funktion: on_mouse_over()
function on_mouse_over()
{
    if(_click_ == this) return false; // ist bereits angeklickt.
    this.src = this.over.src;
    return true;
}
///////////////////////////////////////////////////////////
// Funktion: on_mouse_out()
function on_mouse_out()
{
    if(_click_ == this) return false;

    this.src = this.out;
    return true;
}
///////////////////////////////////////////////////////////
// Funktion: on_click()
function on_click()
{
    if(_click_ == this) return false;
    this.src = this.stay.src;

    // den vorherigen Zustand eines angeklickten Buttons herstellen.
    if(_click_) _click_.src = _click_.out;
    _click_ = this;
    window.name = this.name;
    return true;
}
///////////////////////////////////////////////////////////
// globale Deklaration
var _click_       = null;

///////////////////////////////////////////////////////////
// Funktion: on_resize()
function on_resize()
{
    if(_click_) _click_.src = _click_.stay.src;
}

///////////////////////////////////////////////////////////
// das Skript startet automatisch.
if(window.addEventListener) window.addEventListener('onload', start_mouse_over, true);
if(window.addEventListener) window.addEventListener('onresize', on_resize, true);

window.onload   = start_mouse_over;
window.onresize = on_resize;

///////////////////////////////////////////////////////////
// Funktion für neues Fenster
function window_info(url,height,width)
{
var width;
var height;

if(!height){height="345";}
if(!width){width="520";}
var fenster1 = window.open(url,"fenster_info","height="+height+",width="+width+",directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,left=100,top=100");
fenster.focus();
return false;
}

// Funktion für bbk popup
function window_pic(url)
{
var width;
var height;
var res;

ScreenRes = screen.width;
if(ScreenRes == "1280") res = "1280";
else if (ScreenRes == "1152") res = "1152";
else if (ScreenRes == "1024") res = "1024";
else if (ScreenRes == "800") res = "800";
else if (ScreenRes == "640") res = "640";

if (res == "1280") {
width = 1280;
height = 1024;
}else if (res >= "1152") {
width = 1152;
height = 864;
}else if (res == "1024") {
width = 1024;
height = 768;
}else if (res <= "800") {
width = 800;
height = 600;
}else {
width = 800;
height = 600;
}
//window.open(url,"fenster_info","height="+height+",width="+width+",directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,left=1,top=1");

popup_name = window.open(url,"fenster_info","height="+height+",width="+width+",directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,left=1,top=1");
self.name = "popup"
if (popup_name.opener == null)
popup_name.opener = self
}

function window_fu_sep(url)
{
popup_name = window.open(url,"fenster_info","height=426,width=339,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,left=100,top=100");
self.name = "popup"
}

function window_linkgen()
{
popup_name = window.open("http://www.limelightforum.de/linkgen.php","fenster_info","height=375,width=560,directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,left=100,top=100");
self.name = "popup"
}
function window_insertimage(url)
{
  var  height = 585;
  var  width = 415;
  var p_select_topic_type_value = 0;
  var p_select_topic_value = 0;
  var p_akt = 0;

	p_id_value = "";
    
    if(document.form.akt){
        p_akt = document.form.akt.value; 
    }
      
	p_comment_url_value = document.form.comment_url.value;
	p_theme_text_value = "";
	if (p_comment_url_value == "http://www.limelightforum.de/ep.php")
  	p_id_value = document.form.member_id.value;
	if (p_comment_url_value == "http://www.limelightforum.de/bbk.php")
	  p_id_value = document.form.id.value;
	if (p_comment_url_value == "http://www.limelightforum.de/tf_new.php") {
	  p_theme_text_value = document.form.theme_text.value;
		p_theme_text_value = p_theme_text_value.replace("\n","<br>");
	}
    if (p_comment_url_value == "http://www.limelightforum.de/mp_new.php") {
        height = 404;
        width = 415;
        p_theme_text_value = document.form.theme_text.value;
        p_theme_text_value = p_theme_text_value.replace("\n","<br>");

        p_select_topic_value = document.form.select_topic.value;
        p_select_topic_type_value = document.form.select_topic_type.value;

    }
    if (p_comment_url_value == "http://www.limelightforum.de/mp_edit.php") {
        height = 404;
        width = 415;
        p_theme_text_value = document.form.theme_text.value;
        p_theme_text_value = p_theme_text_value.replace("\n","<br>");

        p_select_topic_value = document.form.select_topic.value;
        p_select_topic_type_value = document.form.select_topic_type.value;
    }
    p_comment_text_value = document.form.comment_text.value;
	p_comment_text_value = p_comment_text_value.replace("\n","<br>");
    popup_name = window.open(url+"?p_id="+p_id_value+"&p_comment_text="+p_comment_text_value+"&p_comment_url="+p_comment_url_value+"&p_theme_text="+p_theme_text_value+"&p_select_topic_type="+p_select_topic_type_value+"&p_select_topic="+p_select_topic_value+"&p_akt="+p_akt,"fenster_insertimage","height="+height+",width="+width+",directories=no,location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no,left=100,top=100");
    self.name = "popup"
    if (popup_name.opener == null)
  	popup_name.opener = self
}

function close_popup(){
  popup_name = window.open("", "fenster_insertimage", "height=190,width=650")
  if (popup_name && !popup_name.closed)
    popup_name.close()
  self.name = "main"
}

function smilie(smilietext) {
    document.form.comment_text.value += smilietext+" ";
}


