$(document).ready(function() {
//	$('.date').datepicker({ dateFormat: 'yy-mm-dd', duration: 'fast', numberOfMonths: 1 });

/*	if (typeof(towatch) != 'undefined') {
		for ( var i=0, len=towatch.length; i<len; ++i ){
			$('#'+towatch[i][0]).bind('keyup blur', { field: towatch[i][0], regexp: towatch[i][1]}, handleKeyupEvent);
		}
	}
*/

/*
*/

/*
	if (typeof(toflash) != 'undefined') {
		for ( var i=0, len=toflash.length; i<len; ++i ) {
			$('#'+toflash[i][0]+'_msg').effect("pulsate", { times:2 }, 300);
		}
	}

*/

	$('#profile_fotos img').click(function() { $('#profile_left #foto').attr('src', this.src); }); 

	if (typeof(json_update) != 'undefined') {
		setTimeout("next_rotate()", 30000);
	}

	$('a.swap_pb').click(function(event) {
		$(this).parent().parent().find(".data_profiel").toggle();
		$(this).parent().parent().find(".data_bellen").toggle();
		return false;
	}); 


});

function next_rotate() {
	$.getJSON("update.php", function(json){
		for ( var i=0, len=json.length; i<len; ++i ) {
			$('#box'+json[i][0]+' div.status img.phone').attr('src','img/status_phone'+json[i][1]+'.gif');
			$('#box'+json[i][0]+' div.status img.webcam').attr('src','img/status_webcam'+json[i][2]+'.gif');

			if (json[i][1] == 0 && $('#box'+json[i][0]+' .data_bellen').is(':visible') ) {
				$('#box'+json[i][0]+' .data_profiel').toggle();
				$('#box'+json[i][0]+' .data_bellen').toggle();
			}

			if (json_update == 'hide') {
				if (json[i][1] == 0 && json[i][2] == 0) {
					$('#box'+json[i][0]).fadeOut(1200);
				}
				if (json[i][1] > 0 || json[i][2] == 1) {
					$('#box'+json[i][0]).fadeIn(1200);
				}
			}
		}
		setTimeout("next_rotate()", 10000);
	});
}