function checkall(form){
	if (form == '') form = forms[0];
    for(a=0;a<document.form.elements.length;a++){
      if(document.form.elements[a].type == 'checkbox'){
        if(document.form.elements[a].checked){
          document.form.elements[a].checked = false;
        }else{
          document.form.elements[a].checked = true;
        }
      }
    }
  }

function textCounter(field, countfield, maxlimit) {
    if (field.value.length > maxlimit) // wenn die eingegebene LŠnge grš§er als erlaubt ist
        field.value =field.value.substring(0, maxlimit); // es wird keine weitere Eingabe mehr zugelassen
    else
        countfield.value = maxlimit - field.value.length;
}

function copytext(id)
{
	document.getElementById(id).focus();
	document.getElementById(id).select();
	if(document.all)
	{
		Bereich=document.getElementById(id).createTextRange();
		Bereich.execCommand("Copy");
	}
}

// versteckte Divs anzeigen
function show_div($show) {
  
    document.getElementById($show).style.display = "block";
}

// Divs verstecken
function hide_div($hide) {

    document.getElementById($hide).style.display = "none";
}

// Hintergrund ändern
function setBg($hide,$color) {
    if (document.getElementById)
    document.getElementById($hide).style.backgroundColor = "#"+$color;
}

function clearBg($hide) {
    if (document.getElementById)
    document.getElementById($hide).style.backgroundColor = "";
}

// Loginbox hervorheben
function showLoginBox() {
	document.getElementById('loginBox').style.backgroundColor = "#ffdfdf";
}




// Add 2 bookmarks

function addNet(url,titel){
if ((typeof window.sidebar=="object") && (typeof window.sidebar.addPanel=="function")){
	window.sidebar.addPanel(titel,url,""); 
} else {
alert("Sie Nutzen eine veralterte Netscape Version!\nLesezeichen hinzufügen ist nicht möglich!");
}}

function bookmark(){
var url="http://www.motorsport.de",t="Motorsport.de",ap=navigator.appName;

if(ap=="Microsoft Internet Explorer"){ 
	window.external.AddFavorite(url,t); 

} else { 

	if(ap=="Netscape"){
		addNet(url,t);
	} else {
	
	alert("Ihr Browser unterstuetzt die Favoritenfunktion leider nicht. Bitte fügen Sie die Seite manuell Ihren Favoriten hinzu.\nURL:"+url);
	
	}
	
}}

// showhide
function showhide($id) 
{
	if (document.getElementById($id).style.display == "none")
	{
		document.getElementById($id).style.display = "block";
		document.getElementById($id).style.height = "20%";
		document.getElementById($id).style.overflow = "hidden";
	} else {
		document.getElementById($id).style.display = "none";
	}
}

// gallery insert

function insert(form, field, aTag, eTag) {
  var input = window.opener.document.forms[form].elements[field];
  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 get_val()
{
var val = 0;

for( i = 0; i < document.form.gallery.length; i++ )
{
if( document.form.gallery[i].checked == true )
val = document.form.gallery[i].value;
}
return val;
}

function erase(id)
{
  slideup(id);
  endHeight[id] = getDynamicHeight(id);

}

function slideFolio(col){
	var x = ((col-1)*-505)
	var folioChange = new Fx.Style('folio', 'left', {duration:2000});
	folioChange.start(x);
	var cur = "trigger"+col;
	$(cur).addClass('current');

	for (i=1;i<=8;i++){
		var loopLI = "trigger"+i;
		if (cur==loopLI){}else{
			$(loopLI).removeClass('current');
		}
	}
}


