function PopUp( url ) {
  myWin = window.open( url, "Galerie", "left=75,top=75,width=600,height=540,toolbar=no,scrollbars=no,menubar=no,status=no,resizable=no" );
}

function MyPopUp( url , width, height ) {
  myWin = window.open( url, "Bild", "left=75,top=75,width="+width+",height="+height+",toolbar=no,scrollbars=no,menubar=no,status=no,resizable=no" );
}

function Katalog( url ) {
  myWin = window.open( url, "Galerie", "left=75,top=75,width=820,height=650,toolbar=no,scrollbars=no,menubar=no,status=no,resizable=no" );
}

function importLightbox(path, pathR)
{
	pathRoot = pathR;
	var files = Array("prototype.js", "scriptaculous.js", "lightbox.js");
	for(i=0; i<files.length; i++)
	{
		document.write('<script type="text/javascript" src="'+path+files[i]+'"></script>');
	}
	
	document.write('<link rel="stylesheet" type="text/css" href="'+path+'lightbox.css">');
}

function swapClass( id, className ) {
	if ( document.getElementById( id ) ) {
		document.getElementById( id ).className = className;
	}
}

//### tauscht ein Bild aus (nach img-id)
function swapImg( id, newImg ) {
  if ( document.getElementById( id ) ) {
		document.getElementById( id ).src = newImg;
  }
}

//### blendet je ein Element ein & aus
function showhide( showid, hideid ) {
	if ( showid == hideid && document.getElementById( showid ) ) {
		if ( document.getElementById( hideid ).style.visibility == 'hidden' ) {
			hideid = '';
		}
		else {
			showid = '';
		}
	}
  if ( document.getElementById( showid ) ) {
    document.getElementById( showid ).style.visibility = 'visible';
    document.getElementById( showid ).style.display = '';
  }
  if ( document.getElementById( hideid ) ) {
    document.getElementById( hideid ).style.visibility = 'hidden';
    document.getElementById( hideid ).style.display = 'none';
  }
}

//### blendet je ein Sonstigesfeld ein wenn sonstiges ausgewählt wird
function checksonstiges( welches_reitanlage ){
    if (welches_reitanlage == 'sonstiges'){
        document.getElementById( 'divsonstiges' ).style.visibility = 'visible';
        document.getElementById( 'divsonstiges' ).style.display = '';
    }
    
}


//### Ein-/ bzw. ausblenden des Kalenders
function calendar( modus, evt, name ) {
  element = document.getElementById( 'div_calendar_'+name );
  
  if( element != null ) {
  	modus = ( modus==1 ) ? 'visible' : 'hidden';
    
  	if( modus == 'visible' ) {
      var e = ( window.event ) ? window.event : evt;
      var offX = document.body.scrollLeft;
      var offY = document.body.scrollTop;
      
      element.style.left = offX + e.clientX;
      element.style.top  = offY + e.clientY;
      element.style.display = '';
      element.style.visibility = modus;
    }
  }
  else {
    elemARR = document.getElementsByName( 'calendar' );
    for ( i=0; i<elemARR.length; i++ )
    {
      elem_name = elemARR[i].style;
      elem_name.visibility = 'hidden';
      elem_name.display = 'none';
    }
  }
}

//### Setzt das gewählte Datum aus dem Kalender in die passenden Felder (field)
function calendar_set_date(field, day, month, year) {
  with (top.main.document) {
		getElementsByName( field+'_tag' )[0].value = day;
		getElementsByName( field+'_monat' )[0].value = month;
		getElementsByName( field+'_jahr' )[0].value = year;
    
    getElementById( 'div_calendar_'+field ).style.visibility = 'hidden';
    getElementById( 'div_calendar_'+field ).style.display = 'none';
	}
}

// ### Checken aller Checkboxen (Mehrfachauswahl)
function check_mehrfach_reverse( group )  {
	boxgroup = document.getElementsByName( group+'[]' );
	
	for ( var i=0; i<boxgroup.length; i++ ) {
		checkbox = boxgroup[i];
    
		if ( checkbox.checked == false ) {
			checkbox.checked = true;
		} else {
			checkbox.checked = false;
		}
	} 
}

//###
function showMinus( id, tds, anzahl ) 
{
  farbe = '#5C0000';
  showhide( 'minus_'+id, 'plus_'+id );
  
  for ( i=0; i<anzahl; i++ )
  {
    showhide( 'children_'+id+'_'+i, '' );
    document.getElementById( 'data1_'+id+'_'+i ).style.borderLeftColor = farbe;
    document.getElementById( 'data'+tds+'_'+id+'_'+i ).style.borderRightColor = farbe;
  }
  for ( i=1; i<tds; i++ )
  {
    document.getElementById( 'data'+i+'_'+id+'_'+(anzahl-1) ).style.borderBottomColor = farbe;
    document.getElementById( 'data'+i+'_'+id ).style.borderTopColor = farbe;
  }
  document.getElementById( 'data'+'1_'+id ).style.borderLeftColor = farbe;
  document.getElementById( 'data'+tds+'_'+id ).style.borderTopColor = farbe;
  document.getElementById( 'data'+tds+'_'+id+'_'+(anzahl-1) ).style.borderBottomColor = farbe;
  document.getElementById( 'data'+tds+'_'+id ).style.borderRightColor = farbe;
}

//###
function showPlus( id, tds, anzahl ) 
{
  showhide( 'plus_'+id, 'minus_'+id );
  for ( i=0; i<anzahl; i++ )
  {
    showhide( '', 'children_'+id+'_'+i );
  }
  document.getElementById( 'data'+'1_'+id ).style.borderLeftColor = '';
  document.getElementById( 'data'+tds+'_'+id ).style.borderRightColor = '';
  document.getElementById( 'data'+tds+'_'+id ).style.borderTopColor = '';

  for ( i=1; i<tds; i++ )
  {
    document.getElementById( 'data'+i+'_'+id ).style.borderTopColor = '';
  }
}


//Random password generator- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use
var keylist="abcdefghijklmnopqrstuvwxyz123456789"
var temp=''

function generatepass(plength){
temp=''
for (i=0;i<plength;i++)
temp+=keylist.charAt(Math.floor(Math.random()*keylist.length))
return temp
}

function populateform(enterlength){
document.pgenerate.output.value=generatepass(enterlength)
}

function checkturnier(turnierid){
	//alert("turnierid"+turnierid);
	/*
	if ( turnierid > 0 ) {
		showhide( '', 'headline' );
		showhide( '', 'ort' );
		showhide( '', 'datum' );
	} else {
		showhide( 'headline', '' )
		showhide( 'ort', '' )
		showhide( 'datum', '' )
	}*/
	
	if ( turnierid == -1 ) {
		showhide( 'headline', '' )
		showhide( 'ort', '' )
		showhide( 'datum', '' )
	} else {
		showhide( '', 'headline' );
		showhide( '', 'ort' );
		showhide( '', 'datum' );
	}

}