function addAttributs(){
	var i = 0;
	for(i = 0; i < document.images.length; i++) {
		if ((document.images[i].src.search(/thumbs.+/) != -1) && (document.images[i].getAttribute("id", false) != "galeriethumb")) {
			var srcNeu = document.images[i].src.replace(/thumbs/, "pictures");
			var klickEvent = document.createAttribute("onClick");
			var tempImg = new Image();
			tempImg.src = srcNeu;
			var widthNeu = tempImg.width;
			var heightNeu = tempImg.height;
			klickEvent.nodeValue = "javascript:return popup('" + srcNeu + "',"+ widthNeu+","+heightNeu+")";
			var Element = document.images[i];
			Element.setAttributeNode(klickEvent);
		}
	}

}




function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if ( aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return strReturn;
} 

var site = getURLParam("nav");
var site_id;

switch(site){
	default:
	case "home":
		site_id = "01";
	break;
	case "aktuelles":
		site_id = "02";
	break;
	case "termine":
		site_id = "03";
	break;
	case "mannschaften":
		site_id = "04";
	break;
	case "jugend":
		site_id = "05";
	break;
	case "ergebnisse":
		site_id = "06";
	break;
	case "halle":
		site_id = "07";
	break;
	case "trainer":
		site_id = "08";
	break;
	case "anlage":
		site_id = "09";
	break;
	case "verein":
		site_id = "10";
	break;
	case "galerie":
		site_id = "11";
	break;
	case "blackboard":
		site_id = "12";
	break;
	case "kontakt":
		site_id = "13";
	break;
	case "links":
		site_id = "14";
	break;
	case "impressum": 
		site_id = "15";
	break;
}


function btn_set(){
	//document.images["btn_"+site_id].src = "images/btn_act_"+site_id+".jpg";
}

function btn_over(target){
	var get_id = target.slice(4,6);
	if(site_id != get_id){
		document.images[target].src = "images/btn_over_"+get_id+".jpg";
	}
}

function btn_out(target){
	var get_id = target.slice(4,6);
	if(site_id != get_id){
		document.images[target].src = "images/btn_"+get_id+".jpg";
	}
}

function btn_click(target){
	var get_id = target.slice(4,6);
	if(site_id != get_id){
		document.images[target].src = "images/btn_"+get_id+"_act.jpg";
		document.images["btn_"+site_id].src = "images/btn_"+site_id+".jpg";
		site_id = get_id;
	}
}

function editor(divclassIE, height, width, content, css){
	var objIE = "document";
	var objMoz = "document.getElementById('myeditor').contentWindow.document";
	
	var focusMoz = "document.getElementById('myeditor').contentWindow.focus()";

	var BoldIE = objIE+".execCommand('Bold', false, null)";
	var BoldMoz =objMoz+".execCommand('Bold',false, null);"+focusMoz;
	var ItalicIE = objIE+".execCommand('Italic', false, null)";
	var ItalicMoz =objMoz+".execCommand('Italic',false, null);"+focusMoz;
	var UlineIE = objIE+".execCommand('Underline', false, null)";
	var UlineMoz =objMoz+".execCommand('Underline',false, null);"+focusMoz;
	var h1IE = objIE+".execCommand('FormatBlock', false, '<H1>')";
	var h1Moz =objMoz+".execCommand('FormatBlock',false, '<H1>');"+focusMoz;
	var h2IE = objIE+".execCommand('FormatBlock', false, '<H2>')";
	var h2Moz =objMoz+".execCommand('FormatBlock',false, '<H2>');"+focusMoz;
	var pIE = objIE+".execCommand('FormatBlock', false, '<p>')";
	var pMoz =objMoz+".execCommand('FormatBlock',false, '<p>');"+focusMoz;
	var LeftIE = objIE+".execCommand('JustifyLeft', false, null)";
	var LeftMoz =objMoz+".execCommand('JustifyLeft',false, null);"+focusMoz;
	var CenterIE = objIE+".execCommand('JustifyCenter', false, null)";
	var CenterMoz =objMoz+".execCommand('JustifyCenter',false, null);"+focusMoz;
	var RightIE = objIE+".execCommand('JustifyRight', false, null)";
	var RightMoz =objMoz+".execCommand('JustifyRight',false, null);"+focusMoz;
	var OListIE = objIE+".execCommand('InsertOrderedList', false, null)";
	var OListMoz =objMoz+".execCommand('InsertOrderedList',false, null);"+focusMoz;
	var UListIE = objIE+".execCommand('InsertUnorderedList', false, null)";
	var UListMoz =objMoz+".execCommand('InsertUnorderedList',false, null);"+focusMoz;
	var LinkIE = objIE+".execCommand('CreateLink', true, null)";
	var LinkMoz =objMoz+".execCommand('CreateLink', false, prompt('URL?','http://'));"+focusMoz;
	
	//var string = "thumbs/"+imgPath;
	var ImgIE =objIE+".execCommand('InsertImage', false, 'thumbs/'+prompt('Dateiname?', ''))";
	var ImgMoz =objMoz+".execCommand('InsertImage',false, 'thumbs/'+prompt('Dateiname?',''));"+focusMoz;
	
	
	var editableIE = "<div id='myeditor' contentEditable style='padding:0px; height="+(height-40)+"; border-style:solid; border-width:1px;'>"+content+"</div>";
	var editableMoz = "<iframe id='myeditor' name='myeditor' height='"+height+"' width='"+width+"' frameborder='1'></iframe>";
	
	if(((document.all) && (window.offscreenBuffering))){
		document.write(editableIE);
		document.write("<div align='left' style=\"padding-top: 10px\">");
		document.write("<img src=\"images/button-bold.gif\" alt=\"Fett\" onClick=\""+BoldIE+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("<img src=\"images/button-italic.gif\" alt=\"Kursiv\" onClick=\""+ItalicIE+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("<img src=\"images/button-underline.gif\" alt=\"Unterstrichen\" onClick=\""+UlineIE+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("&nbsp;&nbsp;");
		document.write("<img src=\"images/button-h1.gif\" alt=\"&Uuml;berschrift 1\" onClick=\""+h1IE+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("<img src=\"images/button-h2.gif\" alt=\"&Uuml;berschrift 2\" onClick=\""+h2IE+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("<img src=\"images/button-p.gif\" alt=\"Normalformat\" onClick=\""+pIE+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("&nbsp;&nbsp;");
		document.write("<img src=\"images/button-left.gif\" alt=\"Linksbündig\" onClick=\""+LeftIE+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("<img src=\"images/button-center.gif\" alt=\"Zentriert\" onClick=\""+CenterIE+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("<img src=\"images/button-right.gif\" alt=\"Rechtsbündig\" onClick=\""+RightIE+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("&nbsp;&nbsp;");
		document.write("<img src=\"images/button-olist.gif\" alt=\"Nummerierte Liste\" onClick=\""+OListIE+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("<img src=\"images/button-ulist.gif\" alt=\"Unnummerierte Liste\" onClick=\""+UListIE+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("&nbsp;&nbsp;");
		document.write("<img src=\"images/button-link.gif\" alt=\"Link einfügen\" onClick=\""+LinkIE+"\" style=\"cursor: pointer\">&nbsp;");
		if(getURLParam("site") != "brandaktuell") {
			document.write("<img src=\"images/button-link-Bild.gif\" alt=\"Bild\" onClick=\""+ImgIE+"\" style=\"cursor: pointer\">&nbsp;");
		}
		document.write("</div>");
		
	}else{
		document.open();
		document.write(editableMoz);
		document.getElementById('myeditor').contentWindow.document.designMode='On';
		document.getElementById('myeditor').contentWindow.document.open();
		document.getElementById('myeditor').contentWindow.document.write("<html><link href='"+css+"' rel='stylesheet' type='text/css'><body>");
		document.getElementById('myeditor').contentWindow.document.write(content);
		document.getElementById('myeditor').contentWindow.document.write("</body></html>");
		document.getElementById('myeditor').contentWindow.document.close();
		document.write("<div align='left' style=\"padding-top: 10px\">");
		document.write("<img src=\"images/button-bold.gif\" alt=\"Fett\" onClick=\""+BoldMoz+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("<img src=\"images/button-italic.gif\" alt=\"Kursiv\" onClick=\""+ItalicMoz+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("<img src=\"images/button-underline.gif\" alt=\"Unterstrichen\" onClick=\""+UlineMoz+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("&nbsp;&nbsp;");
		document.write("<img src=\"images/button-h1.gif\" alt=\"&Uuml;berschrift 1\" onClick=\""+h1Moz+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("<img src=\"images/button-h2.gif\" alt=\"&Uuml;berschrift 2\" onClick=\""+h2Moz+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("<img src=\"images/button-p.gif\" alt=\"Normalformat\" onClick=\""+pMoz+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("&nbsp;&nbsp;");
		document.write("<img src=\"images/button-left.gif\" alt=\"Linksbündig\" onClick=\""+LeftMoz+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("<img src=\"images/button-center.gif\" alt=\"Zentriert\" onClick=\""+CenterMoz+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("<img src=\"images/button-right.gif\" alt=\"Rechtsbündig\" onClick=\""+RightMoz+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("&nbsp;&nbsp;");
		document.write("<img src=\"images/button-olist.gif\" alt=\"Nummerierte Liste\" onClick=\""+OListMoz+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("<img src=\"images/button-ulist.gif\" alt=\"Unnummerierte Liste\" onClick=\""+UListMoz+"\" style=\"cursor: pointer\">&nbsp;");
		document.write("&nbsp;&nbsp;");
		document.write("<img src=\"images/button-link.gif\" alt=\"Link einfügen\" onClick=\""+LinkMoz+"\" style=\"cursor: pointer\">&nbsp;");
		if(getURLParam("site") != "brandaktuell") {
			document.write("<img src=\"images/button-link-Bild.gif\" alt=\"Bild\" onClick=\""+ImgMoz+"\" style=\"cursor: pointer\">&nbsp;");
		}
		document.write("<br>");
		document.write("</div>");
		document.close();
	}
	
}

function getEditorHTML(){
	
	if(((document.all) && (window.offscreenBuffering)))
		var obj = document.getElementById('myeditor').innerHTML;
	else
		var obj = frames.myeditor.document.body.innerHTML;
	
	return obj;
}

function makeComm(command ,param) {
	alert(document.getElementById("myeditor").contentWindow.document.queryCommandValue('FontSize'));
	if(command == 'FormatBlock' && document.getElementById("myeditor").contentWindow.document.queryCommandValue('FontSize') != null) param = '<p>';
	if(navigator.appName=='Netscape' && command=='CreateLink'){
		if(param=='') param=prompt('URL?','http://');
		if ((param != null) && (param != ""))
      		document.getElementById("myeditor").contentWindow.document.execCommand(command,false, param);		
	}else if(navigator.appName!='Netscape' && command=='CreateLink' && param==''){
		document.getElementById("myeditor").contentWindow.document.execCommand(command,true,null);
	}else{
		if (param=='')
			document.getElementById("myeditor").contentWindow.document.execCommand(command,false,null);
		else
			document.getElementById("myeditor").contentWindow.document.execCommand(command,false, param);
	}
	document.getElementById("myeditor").contentWindow.focus();	
}


function popup(url,width,height) {
if(((document.all) && (window.offscreenBuffering))){
 if(width>height)
 	fenster=window.open("include/popup.php?pic="+url, "quer", "width="+(width+2)+",height="+(height+2)+",resizable=no,scrollbars=no");
 else
 	fenster=window.open("include/popup.php?pic="+url, "hoch", "width="+(width+2)+",height="+(height+2)+",resizable=no,scrollbars=no");
 fenster.focus();
}else{
 if(width>height)
 	fenster=window.open("include/popup.php?pic="+url, "quer", "width="+(width+2)+",height="+(height+2)+",resizable=no,scrollbars=no");
 else
 	fenster=window.open("include/popup.php?pic="+url, "hoch", "width="+(width+2)+",height="+(height+2)+",resizable=no,scrollbars=no");
 fenster.focus();
}
 return false;
}

