// JavaScript Document
$(document).ready(function() {
        
$("ul#topnav li").hover(function() { //Hover over event on list item
        $(this).css({ 'background' : '#b5cd00 url(media/topnav_active.jpg) repeat-x'}); //Add background color + image on hovered list item
        $(this).find("span").show(); //Show the subnav
} , function() { //on hover out...
        $(this).css({ 'background' : 'none'}); //Ditch the background
        $(this).find("span").hide(); //Hide the subnav
});
        
});


// basic show and hide
 $(document).ready(function() {
                                                        
        $('.toggleh1').click( function()
        {
        
        //$(this).parent('parentpara').next('span.3dots').toggle());
        var $parentpara = $(this).parent().children().prev();
        $parentpara.toggle();
        //$parentpara.toggle();
        //$(this).next('.3dots').css("background", "yellow");
        //$(this).prev('.showhide').toggle();
        //$('.3dots').toggle();
        
        $(this).text($(this).text() == 'more information' ? 'Show less' : 'more information');
   });

});



       $(function() {
            
            
            var feedbackTab = {
                
                speed:300,
                containerWidth:$('.feedback-panel').outerWidth(),
                containerHeight:$('.feedback-panel').outerHeight(),
                tabWidth:$('.feedback-tab').outerWidth(),
                
                init:function(){
                    $('.feedback-panel').css('height',feedbackTab.containerHeight + 'px');
                    
                    $('a.feedback-tab').click(function(event){

                        if ($('.feedback-panel').hasClass('open')) {
                            $('.feedback-panel').animate({left:'-' + feedbackTab.containerWidth}, feedbackTab.speed)
                            .removeClass('open');
                        } else {
                            $('.feedback-panel').animate({left:'0'},  feedbackTab.speed)
                            .addClass('open');
                        }
                        event.preventDefault();
                    });
                }
            };
            
            feedbackTab.init();
            
            $(".button").click(function()
                        { 
            var name = $("input#name").val();
            var email = $("input#e-mail").val();
            var message = $("textarea#message").val();
            var response_message = "Thank you for your enquiry, we will answer your enquiry soon as possible."

            var dataString = 'name=' + name + '&email=' + email + '&message=' + message;
                
                        var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                        var emailnew = document.getElementById('e-mail');
                        if (!filter.test(emailnew.value))
                        {
                        $('.email-missing').show();
                        }
                        else
                        {
                        $('.email-missing').hide();
                        }
                        
                        if (document.cform.name.value == "") {
                        $('.name-missing').show();
                } else {$('.name-missing').hide();}     
                if (document.cform.message.value == "") {
                        $('.message-missing').show();
                } else {$('.message-missing').hide();}  
                        
                        
                        if ((!filter.test(emailnew.value)))
                        {
                        return false;
                        } 
                
                        if ((filter.test(emailnew.value)))
                        {
                                
                                //send the ajax request
                        //$.post('mail.php',{name:$('#name').val(),
                                //                        email:$('#e-mail').val(),
                                        //                message:$('#message').val()}
                                                //        );
                                
                                
             $.ajax({
                  type: "POST",
                  url: "mail.php",
                  data: dataString,
                  success: function()
                                  {
                    $('#form-wrap').html("<div id='response-message'><\/div>");
                    $('#response-message').html("<p>" + response_message +"<\/p>")
                    .hide()
                    .fadeIn(500)
                    .animate({opacity: 1.0}, 1000)
                    .fadeIn(0, function(){
                        $('.feedback-panel')
                        .animate({left:'-' + (feedbackTab.containerWidth)}, 
                        (feedbackTab.speed))
                        .removeClass('open');
                    })//end of fadeIn function

                    
                  }//end of success function
                });//end of ajax function
                return false;
                                }
            });

            
        });
       
