var rechts, z, size;
var x = new Array();
var y = new Array();
var ymov = new Array();

function random(x) {return Math.floor(x * Math.random())}

function schnee() {
	for (i=0;i<=z;i++) {
		y[i] += ymov[i];
		document.getElementById('s'+i).style.left= x[i] + 10 * Math.sin(ymov[i] * y[i] / 70)+"px";
		document.getElementById('s'+i).style.top = y[i]+"px";
	
		if (y[i] >= unten - 40){
			x[i] = rechts/2;
			while(x[i]>=(rechts-800)/2-50 && x[i]<=800+(rechts-800)/2+10) x[i]=random(rechts-40);
			y[i]=0;
		}
	}	
	timer=setTimeout('schnee()',60);
}

function initschnee(){
	document.write("<img alt='*' width='30' height='30' id='s0' src='snowboardschule-main/schnee-flocke.gif' style='position:absolute'>")
	
	if (document.all){
		rechts = document.body.clientWidth;
	}else{
		rechts = window.innerWidth-20;
	}

	if (rechts > 900){
		z = unten / 22 * (rechts - 800) / 20 / 8;

		for (i=1;i<=z;i++) {
			document.write("<img alt='*' id='s"+i+"' src='snowboardschule-main/schnee-flocke.gif' style='position:absolute'>")
		}
		
		for (i=0;i<=z;i++) {
			ymov[i] = random(20)/10+1;
			x[i] = rechts/2;
			while(x[i]>=(rechts-800)/2-50 && x[i]<=800+(rechts-800)/2+10) x[i]=random(rechts-40)
			y[i] = random(unten-40);
			document.getElementById('s'+i).style.left = x[i]+"px";
			document.getElementById('s'+i).style.top  = y[i]+"px";

			size = random(18)+19;
			document.getElementById('s'+i).width = size;
			document.getElementById('s'+i).height = size;
		}

		schnee();
	}else{
		document.getElementById('s0').style.visibility='hidden';
	}
}

function neuaufbau(){location.href=location.href}

initschnee();



function Fensterweite () {
  if (window.innerWidth) {
    return window.innerWidth;
  } else if (document.body && document.body.offsetWidth) {
    return document.body.offsetWidth;
  } else {
    return 0;
  }
}

function Fensterhoehe () {
  if (window.innerHeight) {
    return window.innerHeight;
  } else if (document.body && document.body.offsetHeight) {
    return document.body.offsetHeight;
  } else {
    return 0;
  }
}

function neuAufbau () {
  if (Weite != Fensterweite() || Hoehe != Fensterhoehe())
    location.href = location.href;
}

if (!window.Weite && window.innerWidth) {
  window.onresize = neuAufbau;
  Weite = Fensterweite();
  Hoehe = Fensterhoehe();
}