function timestamp(){
	return Math.floor(new Date().getTime() / 1000);
}

function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}


(function($){
	$(document).ready(function(){
		var webcam={
			refresh_seconds:30,
			img_src : false,
			img : $('#sidebar-webcam-img img')[0],
			img_fallback_src : '/images/webcam.jpg',
			msg_block : $('#sidebar-webcam-msg')[0],
			error_block : $('#sidebar-webcam-error')[0],
			error : false,
			loaded : false
		};
		
		$(webcam.img).error(function(){
//			console.log('!!error',this);
			webcam.error=true;
			this.src=webcam.img_fallback_src;
		});
		
		$(webcam.img).load(function(){
//			console.log('?load',this);
			if(webcam.img && !webcam.error && !webcam.loaded){			
//				console.log('$$interval');
				webcam.img_src=webcam.img.src;
				webcam.loaded=true;
	
				setInterval(function(){
//					console.log('###',this.complete,this.natrualWidth);
					webcam.img.src=webcam.img_src+'?refresh-'+timestamp(); 
				},webcam.refresh_seconds*1000);	
			}else if(webcam.error){
				$(webcam.msg_block).hide();
				$(webcam.error_block).show();
			}
		});

		
		$(document).ready(function(){
			$("#sidebar--property-search .search-button-wrapper > input").click(calHelper.validate);

			var theForm = document.forms['ctl02'];
			if (!theForm) {
			    theForm = document.ctl02;
			}
			
			$('#contact-form').validate();
			
		}); 
		
	})
})(jQuery);
