/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$(document).ready(function(){
                // Client Hover Effect script

               $("li.haschildren").hover(
                   function()
                   {
                        $(this).find('span.arrow').css('background','transparent url(/images/menuDownArrow_white.png) no-repeat');
                   },
                   function()
                   {
                        $(this).find('span.arrow').css('background','transparent url(/images/menuDownArrow.png) no-repeat');
                    }
                );
                    
               $("div.inner-box").hover(
                   function()
                   {
                        $(this).children("img").animate({'margin-top':'20px'}, 500);
                   },
                   function()
                   {
                        $(this).children("img").animate({'margin-top':'0px'}, 500);
                    }
                );

               // Submit contact form 
               $(".sub-button").mouseup(function(){
                    
                    var errStyle = "{ 'border' : '#FF0000 solid 1px' }";
                    var rege = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;


                    var name = $(".contact-form input.name").val();
                    var email = $(".contact-form input.email").val();
                    var comment = $(".contact-form textarea.comment").val();                    

                    // Revert input fields to normal style
                    $("input.name, input.email, textarea.comment").css({'border' : '#DDD solid 1px'});

                    // Highlight input fileds on error
                    if(!$.trim(name)){$(".contact-form input.name").css({'border' : '#FF0000 solid 1px'});}
                    if(!$.trim(email) || !rege.test(email)){$(".contact-form input.email").css({'border' : '#FF0000 solid 1px'});}
                    if(!$.trim(comment)){$(".contact-form textarea.comment").css({'border' : '#FF0000 solid 1px'});}

                    if($.trim(name) && $.trim(email) && rege.test(email) && $.trim(comment)){
                                                
                        $("p.receive-msg").fadeIn('fast').html("<img src='/images/ajax-loader2.gif' alt='sending mail />");
                        $.ajax({
                            type: 'POST',
                            url: 'contactUs/sendMail',
                            data: 'name='+name+"&email="+email+"&comment="+comment+"&ts="+new Date().getTime(),
                            success: function(msg){

                                $("p.receive-msg").empty().html(msg);
                                $(this).attr("disabled","enabled");
                            }
                        });
                    }
               });

});



