function loadImage(id, link, comment)
	{
		var img = document.getElementById("img"+id);
		if(img != null)
		{
			img.src = "../cms/thumbs/"+link;
		}
	}
	
	function writeStatus(id, currindex, maxindex)
	{
		var stat = document.getElementById("site"+id)
		if(stat != null)
		{
			stat.innerHTML = currindex + " / " + maxindex;
		}
	}

var old_h = 0;

function setHeight() { 
  window.clearTimeout("heighttime");
	var scr_h = getWindowHeight();
	var scr_w = getWindowWidth();
	if(scr_h != old_h) {
		if(scr_w < 1190)
			scr_h = scr_h - 17;

		if(document.getElementById("cse-search-results") && window.location.search.indexOf('?cx=') > -1) {
			var div = document.getElementById("cse-search-results");
			if(scr_h > 461) {
				div.style.overflow = 'auto';
				div.style.height = (scr_h-230)+"px";
			} else div.style.overflow = 'static';
			if(document.getElementById("menu")) {
				old_h = scr_h;
				var div = document.getElementById("menu");
				if(scr_h > 461) {
					div.style.overflow = 'auto';
					div.style.height = (scr_h-229)+"px";
				} else {
					div.style.overflow = 'static';
				}
			}
		} else if(document.getElementById("inhalt")) {
			var div = document.getElementById("inhalt");
			if(scr_h > 461) {
				div.style.overflow = 'auto';
				div.style.height = (scr_h-187)+"px";
			} else div.style.overflow = 'static';
			if(document.getElementById("menu")) {
				old_h = scr_h;
				var div = document.getElementById("menu");
				if(scr_h > 461) {
					div.style.overflow = 'auto';
					div.style.height = (scr_h-229)+"px";
				} else {
					div.style.overflow = 'static';
				}
			}
  		if(document.getElementById("fotoarchivvorschau")) {
				  old_h = scr_h;
  				var div = document.getElementById("fotoarchivvorschau");
  				if(scr_h > 461) {
  					div.style.overflow = 'auto';
  					div.style.height = (scr_h-248)+"px";
  				} else {
  					div.style.overflow = 'static';
  				}
  		}
  		if(document.getElementById("fotoarchivbild")) {
				  old_h = scr_h;
  				var div = document.getElementById("fotoarchivbild");
  				if(scr_h > 461) {
  					div.style.overflow = 'auto';
  					div.style.height = (scr_h-248)+"px";
  				} else {
  					div.style.overflow = 'static';
  				}
  		}
		} 
	}
	heighttime = window.setTimeout("setHeight();",300);
}

/* get height of window */
function getWindowHeight(){
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myHeight = window.innerHeight;
			ie = false;
		} else if( document.documentElement &&
			( document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myHeight = document.documentElement.clientHeight;
		  
		} else if( document.body &&  document.body.clientHeight ) {
			//IE 4 compatible
			myHeight = document.body.clientHeight;
		}
		  
		return myHeight;
	}	
/* get height of window */
function getWindowWidth(){
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
			ie = false;
		} else if( document.documentElement &&
			( document.documentElement.clientWidth ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
		  
		} else if( document.body &&  document.body.clientWidth ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
		}
		  
		return myWidth;
	}

/* helper method */
function resize2()
{
	DivResizer.resizeAll();
}

/* register on windowresize */
var heighttime = window.setTimeout("setHeight();",200);


var startindx = 0;
function getNextImage(val) {
  var imgcont = document.getElementById("bild");
	startindx += val;
	if(startindx < 0)
		startindx = arrimages.length-1;
	if(startindx >= arrimages.length)
		startindx = 0;
	imgcont.src = "grafik/Bilder/"+arrimages[startindx];
}

function startKids() {
  var menudiv = document.getElementById('unsrekids');
  for(var i=0; (t=kids[i]); i++) {
    var d = document.createElement('div');
    d.innerHTML = "<div><a href='javascript:showKids("+i+")'>"+t.name+"</a></div>";
    menudiv.appendChild(d);
  }
  
  showKids(Math.round(kids.length*Math.random())-1);
}

function showKids(i) {
  var t = kids[i];
  document.getElementById('bild').src = "grafik/kids/"+t.name.replace(" ","_").replace("ö","oe").toLowerCase()+".jpg";
  if(t.motto.length > 0) {
	document.getElementById('kidsmotto').innerHTML = "<h3>\""+t.motto+"\"</h3>";	document.getElementById('kidsmotto').style.display = "block";  } else document.getElementById('kidsmotto').style.display = "none";
  var s = "<h2>"+t.name+"</h2><table class='kidstable' cellspacing=0 cellpadding=0><tr><td width='130px'>Alter</td><td width='140px'>"+t.alter+"</td></tr>";
  if(t.erfolge.length > 0)
	s += "<tr><td>Erfolge</td><td>"+t.erfolge+"</td></tr>";
  s += "<tr><td>Lieblingsdisziplin</td><td>"+t.lieblingsdisziplin+"</td></tr>";
  if(t.vorbild.length > 0)
    s += "<tr><td>Vorbild</td><td>"+t.vorbild.replace(/;/g,"<br>")+"</td></tr>";
  s += "<tr><td>Hobbys</td><td>"+t.hobbies.replace(/;/g,"<br>")+"</td></tr></table>";
  document.getElementById('kidstext').innerHTML = s;
}

function Kid(name,alter,lieblingsdisziplin,erfolge, vorbild, hobbies,motto) {
    this.name = name;
    this.alter = alter;
    this.lieblingsdisziplin = lieblingsdisziplin;
    this.erfolge = erfolge;
    this.hobbies = hobbies;
    this.vorbild = vorbild;
    this.motto = motto;
}





    /**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Bitte geben Sie das korrekte Geburtsdatum ein.")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Bitte geben Sie das korrekte Geburtsdatum ein.")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Bitte geben Sie das korrekte Geburtsdatum ein.")
		return false
	}
return true
}



function echeck(str) {
		if (str.length < 4){
		   return false
		}

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		 
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		 
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		 
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		 
		    return false
		 }
		 
 		 return true					
	}


function showLongText(id) {
  document.getElementById('short'+id).style.display = 'none';
  document.getElementById('long'+id).style.display = 'block';
}
