function isSet( variable ){
	return( typeof( variable ) != 'undefined' );
};

function inputClearRestore( sFormName ){
	
	$(':input', sFormName).each(function() {

		$(this).focus(function(){
			
			var sVal = $(this).attr('value');
			var sTitle = $(this).attr('title');
			
			if ( sVal == sTitle ){
				$(this).attr("value", '');
			} 

		});
		
		$(this).blur(function(){
			
			var sVal = $(this).attr('value');
			var sTitle = $(this).attr('title');
			
			if ( sVal == "" ){
				$(this).attr("value", sTitle);
			}

		});

	});
		
};

function validateForm( sFormName ){

/*
	Check voor elke input in het formulier, of de value veranderd is (mbv title-attribute)
	Is dit niet het geval, element toevoegen aan error-message.
*/

	var sErrorMsg;
	var sTemp;
	
	$(':input', sFormName).each(function() {

		var sVal = $(this).val();
		var sTitle = $(this).attr('title');
		
		if ( sTitle && sVal == sTitle ){
			if ( isSet( sTemp ) ){
				sTemp += "- " + sTitle + "\n";
			} else {
				sTemp = "- " + sTitle + "\n";
			}
			
		}

	});
	
	if ( isSet( sTemp ) ){
		
		sErrorMsg = "De volgende velden zijn nog leeg. Vul deze svp volledig in.\n\n" + sTemp;
		alert( sErrorMsg );
		return false;
		
	} else {
		
		return true;
	
	}

};

function activatePhotoTriggers(){
	
	$('#msgphotos').click(function(){
	});
	
	$('#iconphoto').click(function(){
	});
	
};

function showPhotoMessage(){

	$('#msgphotos').fadeIn(1000).fadeTo(2000, 1.0, function(){
		$(this).fadeOut(1000);
	});

}


$(document).ready(function(){
	
	//$( '#ballon' ).cas( 'opacity', 0 );
	
	//if ( $("form").length > 0 ) inputClearRestore( $("form") );
	
	//if ( $('#iconphoto').length > 0 ) activatePhotoTriggers();
	
	if (  $('#msgphotos').length > 0 ) showPhotoMessage();
	
	// Mouseover
	$( '.has_balloon' ).each( function() {
	
		// Mouse over
		$( this ).mousemove( function( e ) {
			if( 'member_' + currentID != $( this ).attr( 'rel' ) ) {
				currentID = $( this ).attr( 'rel' ).substr( 7 ); 
			}
			
			$( '#ballon' ).text( infoList[ parseInt( currentID ) ] );
			$( '#ballon' ).fadeIn( "def" );
	  
			$( '#ballon' ).css({
				top: ( e.pageY + 15 ) + 'px',
				left: ( e.pageX + 15 ) + 'px'
			});
		});
			
		// Mouse out
		$( this ).mouseleave( function( e ) {
			$( '#ballon' ).fadeOut( "def" );
		});
	});

});
