function show_language_notice() {
	$("#language_notice").fadeIn(500);
};

function hide_floaters() {
	$("#float_impressum").hide();
	$("#float_links").hide();
	$("#float_trip").hide();
		$("#float_trip #frm_defined").hide();
		$("#float_trip #frm_undefined").hide();
	$("#float_overlay").fadeOut(300);
}
    
function show_float_impressum() {
	$("#float_overlay").fadeIn(300, function()
		{
		$("#float_impressum").show();
		}
	);
}

function show_float_links() {
	$("#float_overlay").fadeIn(300, function()
		{
			$("#float_links").show();
		}
	);
}


function validate_comment()
{
	var color_default 	= '#fff';
	var color_error 	= '#ffeeee';
	
	var class_selector 	= 'validate';
	
	var error = false;


	$( '.' + class_selector ).each
	(
		function( i, obj )
		{
			// ako je prazno polje
			if( $( obj ).val() == '' )
			{
				error = true;
				$( obj ).css( 'background-color', color_error );
			}
			// nije prazno polje
			else
			{
				$( obj ).css( 'background-color', color_default );
			}
			
			$( obj ).keydown
			(
				function ()
				{
					$( this ).css
					(
						'background-color',
						( $( this ).val().length > 1 )
							? color_default
							: color_error
					);
				}
			);
		}
	);

	if( error == false )
	{
		$( 'form#elem_frm_comment' ).submit();
	}
	
}









function highlightDates(date, inst)
{
	// default css
	var css_state = 'ui-state-default';
	
	//testiraj datum i postavi css class ovisno o tome da li postoji
	for( var a in arr_dates )
	{
		var date_calendar = $.datepicker.formatDate('dd-mm-yy', date );
		
		var date_held = arr_dates[ a ].dateCompare;
		var date_onmouseover = arr_dates[ a ].dateString + ' / ' + arr_dates[ a ].timeString + 'h' + ' / ' + arr_dates[ a ].language + ' / ' + arr_dates[ a ].description;
		
		if( date_calendar == date_held )
		{
			css_state = 'ui-state-accent';
			break;
		}
	}
	
	var option = new Array();
	
	option[ 0 ] = true;
	option[ 1 ] = css_state;
	option[ 2 ] = date_onmouseover;
	
	return option;
}

function clickedDate( date, inst )
{
	var trip_id = 0;
	var trip_data = new Array();
	
	for( var a in arr_dates )
	{
		if( date == arr_dates[ a ].dateCompare )
		{
			trip_data = arr_dates[ a ];
		}
	}
	
	showTourForm( trip_data, date );
	
	return false; 
}

function showTourForm( trip, date )
{
	// default states
	$("#float_trip .module div#elem_frm_user_defined input").val( '' );
	$("#float_trip .module div#elem_frm_cms_defined input").val( '' );
	$("#float_trip .module div#elem_frm_data *").val( '' );
	$("#float_trip .module #elem_tour_trip_id" ).val( 0 );
	$("#float_trip .module #elem_tour_trip_date" ).val( 0 );
	
	$("#float_overlay").fadeIn
	(
		300,
		function()
		{
			$("#float_trip").show();
			
			if( trip.trip_id > 0 )
			{
				$( "#float_trip .module #elem_frm_user_defined" ).hide();
				
				$( "#float_trip .module #elem_tour_trip_id" ).val( trip.trip_id );
				
				$( "#elem_date_cms" ).text( date );
				
				$( "#float_trip .module #elem_frm_cms_defined #elem_language" ).text( trip.language );
				$( "#float_trip .module #elem_frm_cms_defined #elem_time" ).text( trip.timeString );

				$( "#float_trip .module #elem_frm_cms_defined" ).show();
				
			}
			else
			{
				$( "#float_trip .module #elem_frm_cms_defined" ).hide();
				
				$( "#elem_date_user" ).text( date );
				
				$( "#float_trip .module #elem_tour_trip_date" ).val( date );
				
				$( "#float_trip .module #elem_frm_user_defined").show();
			}
		}
	);
}

function submitOrder()
{
	var error = false;
	
	// tour_id
	if( $( 'input#elem_tour_id' ).val() == 0 )
	{
		error = true;
	}
	
	// nedefinirani trip_id
	$( 'div#elem_frm_data input' ).each
	(
		function( index, inst )
		{
			if( $( inst ).val() == '' )
			{
				$( inst ).css( 'background', '#ffcccc' );
				error = true;
			}
			else
			{
				$( inst ).css( 'background', '#ffffff' );
				error = false;
			}
		}
	);
	
	if( error == false )
	{
		$( 'form#elem_frm_order' ).submit();
	}
	
}

