function getNavi(wo, color) {
    obj = document.getElementsByTagName('div');
    obj[wo].style.borderTop = '3px solid #' + color;   
}

var win=null;

function getPopUP(mypage,myname,w,h,pos,infocus){
if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings);
win.focus();
}

window.addEvent('domready', function(){
	var iconInfo = new Tips($$('.iconInfo'));
 	$$('.CTitle').each(function(heading){

		new Element('a', {
		'href': '#MainTopic',
		'class': 'toTop'
		}).setHTML('top').injectBefore(heading.getFirst());
	});
	new SmoothScroll();
}); 

function sendRequest(url, wo, woher, variable)
{

    if(!variable){ variable = "id="; }
    var log = $(wo).empty().addClass('ajax-loading');


    new Ajax(url, {
        method: 'post',
        postBody: variable + $(woher).getValue(),
        update: $(wo),
	onComplete: function() {
			log.removeClass('ajax-loading');
		}

}).request();
}

function sendRequest2(url, wo, woher, id)
{
    
	var log = $(wo).addClass('ajax-loading2');

    new Ajax(url, {
        method: 'post',
        postBody: 'id=' + id +  $(woher).getValue(),
        update: $(wo),
	onComplete: function() {
			log.removeClass('ajax-loading2');
		}

}).request();

}
function sendRequest3(url, wo, woher, id)
{
    
	var log = $(wo).addClass('ajax-loading2');

    new Ajax(url, {
        method: 'post',
        postBody: 'feld1=' + id +  $(woher).getValue(),
        update: $(wo),
	onComplete: function() {
			log.removeClass('ajax-loading2');
		}

}).request();

}	
function loadContent(url, wo, was)
{

    var log = $(wo).empty().addClass('ajax-loading');

    new Ajax(url, {
        method: 'post',
        postBody: 'id=' + was,
        update: $(wo),
	onComplete: function() {
			log.removeClass('ajax-loading');
	}
    }).request();
}
function loadContent2(url, wo, was)
{
   new Ajax(url, {
        method: 'post',
        postBody: 'id=' + was,
        update: $(wo)
    }).request();
}

// ------------------------------------------------- Formular Kontrolle  -----------------------------------------



function FormCheck(erste, zweite, wo, formname, error) {

	obj = document.getElementsByTagName('form');
 
	if(obj[formname].text.value.length <= 2){
  		obj[formname].text.style.borderLeft = '4px solid #FF0000';
		obj2 = document.getElementsByTagName('span');
  		obj2[error].innerHTML = '<span style="color:#FF0000;font-weight: bold;">!!</span> Bitte alles ausfüllen!';

  	return false;
 	}else{
 		var log = $(erste).addClass('ajax-loading2');
	}
}


/*
	Bild Upload
*/

function FormCheckBild(erste, zweite, wo, formname, error) {
i = 0;
obj = document.getElementsByTagName('form');

if(obj[formname].text.value.length <= 2){
  
	obj[formname].text.style.borderLeft = '4px solid #FF0000';
  	i = 1;
 }else{
	obj[formname].text.style.borderLeft = '1px solid #000000';
 }

if(obj[formname].bild.value.length <= 2){

  	obj[formname].bild.style.borderLeft = '4px solid #FF0000';
  	i = 1;
 }else{
	obj[formname].bild.style.borderLeft = '1px solid #000000';
 }



if(i == 1){
	obj2 = document.getElementsByTagName('span');
  	obj2[error].innerHTML = '<span style="color:#FF0000;font-weight: bold;">!!</span> Bitte alles ausfüllen!';
  	i = 0;
   return false;
}else{
	Laden(erste, zweite, wo);
}}



function FormCheckCheck(erste, zweite, wo, formname, error, anzahl, checker) {
	i = 0;
	obj = document.getElementsByTagName('form');

	for(c=1; c<=anzahl; c++){
	
		if(obj[formname]['feld'+c].value.length <= 2){  
			obj[formname]['feld'+c].style.borderLeft = '4px solid #FF0000';
  			i = 1;
 		}else{
			obj[formname]['feld'+c].style.borderLeft = '1px solid #000000';
 		}
	}

	if(checker == 1){
	if(obj[formname].AGB.checked){
		obj2 = document.getElementsByTagName('p');
   		obj2['agb'].style.border = '1px solid #CCCCCC';
 	}else{
		obj2 = document.getElementsByTagName('p');
   		obj2['agb'].style.border = '1px solid #FF0000';
  		i = 1;
	}}

	if(i == 1){
		obj2 = document.getElementsByTagName('span');
  	obj2[error].innerHTML = '<span style="color:#FF0000;font-weight: bold;">!!</span> Bitte alles ausfüllen!<br /><br />';
  		i = 0;
   		return false;
	}else{
		var log = $(erste).addClass('ajax-loading2');
	}
}






// ------------------------------------------------- Formular Kontrolle  ENDE -----------------------------------------

function loadImage(wo) {
    obj = document.getElementsByTagName("img");
    obj["bild"].src = wo;
}


function Laden(erste, zweite, wo) {
    obj = document.getElementsByTagName(wo);
    obj[erste].style.display = 'none';
    obj[zweite].style.display = '';
}


function hauptNavi(id, bild){
 
obj = document.getElementsByTagName('img');
 
obj[id].src = "/Grafiken/navi/" +bild +"_h.gif"; 

}

function hauptNaviOut(id, bild){
 
obj = document.getElementsByTagName('img');
 
obj[id].src = "/Grafiken/navi/" +bild +".gif"; 

}

function gross(id, action) {
    obj = document.getElementById(id);

    if(action == 'minus'){
    	obj.rows = obj.rows - 10;    	
    }else{
    	obj.rows = obj.rows + 10;    	
    }
}
function getImage(bild, wo) {
    obj = document.getElementsByTagName('div');
    obj[bild].innerHTML = '<img src="' + wo +'" style="width: 100px;" alt="">';   
}

function ShowHide(id, wo) {
    obj = document.getElementsByTagName(wo);
    if (obj[id].style.display == 'none'){
    obj[id].style.display = '';
    }
    else {
    obj[id].style.display = 'none';
    }
}
function ShowHideSec(id) {
    obj = document.getElementById(id);
    if (obj.style.display == 'none'){
    obj.style.display = '';
    }
}
function insert(aTag, eTag) {
  var input = document.forms['editor'].elements['texteditor'];
  input.focus();
  if(typeof document.selection != 'undefined') {
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = aTag + insText + eTag;
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', aTag.length + insText.length + eTag.length);
    } else {
      range.moveStart('character', aTag.length + insText.length + eTag.length);      
    }
    range.select();
  }
  else if(typeof input.selectionStart != 'undefined')
  {
    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);
    var pos;
    if (insText.length == 0) {
      pos = start + aTag.length + insText.length + eTag.length;
    } else {
      pos = start + aTag.length + insText.length + eTag.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  else
  {
    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;
    }
    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);
  }
}