function downtime(){
	var d=new Date().getTime();
	$.ajax({
  url: 'scripts/downtime.php?'+d,
  success: function(data) {
  	if (data == 5){
  		$('#video').html('<embed id="video_stream" 
  		src="http://www.simplethoughtproductions.com/wp-content/plugins/simple-flash-video/mediaplayer.swf" 
  		allowfullscreen="true" 
  		allowscriptaccess="always" 
  		bgcolor="undefined" 
  		flashvars="file=http://simplethoughtproductions.com/foxdaycam/2012.xml&image=http://foxdaycam.com/images/outage.jpg&streamer=rtmp://simplethoughtproductions.com/foxdaycam&autostart=true&config=http://simplethoughtproductions.com/wp-content/plugins/simple-flash-video/config.xml&height=360&width=640" 
  		width="640" 
  		height="360">
  		</embed>');
    	$('#video').attr('status', 1);
    	//alert("switched to video");
    	var notNothing=3;
    	wait_dowtime(60);
  	}
    if (($('#video').attr('status') == 0 || $('#video').attr('status') == 2) && data == 1){
    	$('#video').html('<embed id="video_stream" 
  		src="http://www.simplethoughtproductions.com/wp-content/plugins/simple-flash-video/mediaplayer.swf" 
  		allowfullscreen="true" 
  		allowscriptaccess="always" 
  		bgcolor="undefined" 
  		flashvars="file=http://simplethoughtproductions.com/foxdaycam/2012.xml&image=http://foxdaycam.com/images/outage.jpg&streamer=rtmp://simplethoughtproductions.com/foxdaycam&autostart=true&config=http://simplethoughtproductions.com/wp-content/plugins/simple-flash-video/config.xml&height=360&width=640" 
  		width="640" 
  		height="360">
  		</embed>');
    	$('#video').attr('status', 1);
    	//alert("switched to video");
    	var notNothing=3;
    	wait_dowtime(60);   	
    }else if (data != $('#video').html() && data != 1 && data !=5){
    	$('#video').html(data); 
    	$('#video').attr('status', 2);
    	//alert('switched photo\n'+$("#video").html()+'\n'+data);
    	var notNothing=3;
    	wait_dowtime(30);
    }else if (notNothing!=3){
    	if ($('#video').attr('status') == 1){
    		//alert("nothing changed is video");
    		wait_dowtime(60);
    	}
    	if ($('#video').attr('status') == 2){
    		//alert("nothing changed is photo");
    		wait_dowtime(30);
    	}
    }else{
    	//alert("hmmm");
    	wait_dowtime(15);
    }
    
  }
});}

function wait_dowtime(wait){
	//alert("wait downtime - "+wait);
	wait=wait*1000;
	setTimeout("downtime()", wait);
}

