
jQuery(document).ready(function () {

        // initalise nivo slider
        $('#slider').nivoSlider();

        var dl = $('<dl>');

		//Appending the definition list:
		$('#faqSection').append(dl);
		
		$('dt').live('click',function(){
			var dd = $(this).next();
			
			// If the title is clicked and the dd is not currently animated,
			// start an animation with the slideToggle() method.
			
			if(!dd.is(':animated')){
				dd.slideToggle();
				$(this).toggleClass('opened');
			}
			
		});//

    $('a[rel*=facebox]').facebox({
        loadingImage : 'images/loading.gif',
        closeImage   : 'images/closelabel.png'
    })
	
	$('#faq').hide();

    $("#msgbox").html('Fill out the form below:<a href="#" class="close"><img src="admin/images/notification_close.png" alt="close" /></a>');

	jQuery('.map').click(function (e) {
		jQuery.modal('<iframe src="'+this.href+'&output=embed"></iframe><p class="larger"><a target="_blank" href="'+this.href+'">view larger</a></p>');
		return false;
	});
});

$(function() {
    $('.highlight').hover(function() {
        $(this).children().addClass('datahighlight');
    },
    function() {
        $(this).children().removeClass('datahighlight');
    });
	
	
    $('#contactform').submit(function() {
        var query = $(this).serialize();
        
		$("#msgbox").removeClass().addClass('notification information').html('checking....').fadeIn(1000);
        
		$.ajax({
            type: "POST",
            url: "send.php",
            data: query,
            success: function(data) {
               
			   if (jQuery.trim(data.substring(0,7))=="success") // if contact form submitted correctly
		       {
		  	        $("#msgbox").fadeTo(200,0.1,function()  // start fading the messagebox
			        { 
			            // add message and change the class of the box and start fading
			            $(this).html('e-mail sent! Thanks, we will be in touch shortly<a href="#" class="close"><img src="admin/images/notification_close.png" alt="close" /></a> ').addClass('notification success').fadeTo(900,1,
                        function()
			            { 
			  	            // do something if we want?
							$('#contactform').fadeOut('slow');
			            });	  
			        });
		        }
				
				if (jQuery.trim(data.substring(0,10))==="blank-name") // no password
		        {
		  	        $("#msgbox").fadeTo(200,0.1,function() // start fading the messagebox
			        { 
			            // add message and change the class of the box and start fading
			            $(this).html('no name was entered <a href="#" class="close"><img src="admin/images/notification_close.png" alt="close" /></a>').addClass('notification error').fadeTo(900,1);
			        });		
                }
				
				if (jQuery.trim(data.substring(0,10))==="short-name") // no password
		        {
		  	        $("#msgbox").fadeTo(200,0.1,function() // start fading the messagebox
			        { 
			            // add message and change the class of the box and start fading
			            $(this).html('is your name really less than 3 characters? <a href="#" class="close"><img src="admin/images/notification_close.png" alt="close" /></a>').addClass('notification error').fadeTo(900,1);
			        });		
                }
				
				
				if (jQuery.trim(data.substring(0,11))==="blank-email") // no password
		        {
		  	        $("#msgbox").fadeTo(200,0.1,function() // start fading the messagebox
			        { 
			            // add message and change the class of the box and start fading
			            $(this).html('we need an e-mail address to contact you! <a href="#" class="close"><img src="admin/images/notification_close.png" alt="close" /></a>').addClass('notification error').fadeTo(900,1);
			        });		
                }
				
				if (jQuery.trim(data.substring(0,13))==="invalid-email") // no password
		        {
		  	        $("#msgbox").fadeTo(200,0.1,function() // start fading the messagebox
			        { 
			            // add message and change the class of the box and start fading
			            $(this).html('please provide a valid e-mail address for replying to your message! <a href="#" class="close"><img src="admin/images/notification_close.png" alt="close" /></a>').addClass('notification error').fadeTo(900,1);
			        });		
                }
				
				if (jQuery.trim(data.substring(0,13))==="blank-comment") // no password
		        {
		  	        $("#msgbox").fadeTo(200,0.1,function() // start fading the messagebox
			        { 
			            // add message and change the class of the box and start fading
			            $(this).html('enter a comment please! <a href="#" class="close"><img src="admin/images/notification_close.png" alt="close" /></a>').addClass('notification error').fadeTo(900,1);
			        });		
                }
				
				if (jQuery.trim(data.substring(0,13))==="short-comment") // no password
		        {
		  	        $("#msgbox").fadeTo(200,0.1,function() // start fading the messagebox
			        { 
			            // add message and change the class of the box and start fading
			            $(this).html('please enter a more... meaningful message! <a href="#" class="close"><img src="admin/images/notification_close.png" alt="close" /></a>').addClass('notification error').fadeTo(900,1);
			        });		
                }
            }
        });
        return false;
    });
});
