// JavaScript Document
$(function(){
		   


       
 $('#name').focus(function(){
         if(this.value=='Name'){this.value=''}
       });
      
       $('#name').blur(function(){
         if(this.value==''){this.value='Name'}
       });
	   
 $('#email').focus(function(){
         if(this.value=='Email'){this.value=''}
       });
      
       $('#email').blur(function(){
         if(this.value==''){this.value='Email'}
       });
	   
$('#phone').focus(function(){
         if(this.value=='Phone'){this.value=''}
       });
      
       $('#phone').blur(function(){
         if(this.value==''){this.value='Phone'}
       });
$('#message').value='Message222';	   
$('#message').focus(function(){
         if(this.value=='Message'){this.value=''}
		 alert(this.text());
       });
      
       $('#message').blur(function(){
         if(this.value==''){this.value='Message'}
       });




$("#ajax-contact-form").submit(function(){
test=true;

var str = $(this).serialize();

   $.ajax({
   type: "POST",
   url: "contact.php",
   data: str,
   success: function(msg){
    
$("#note").ajaxComplete(function(event, request, settings){

if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
{
result = '<div class="notification_ok"><p>Your message has been sent. Thank you!</p></div>';
$("#fields").hide();
$(this).html(result);
}
else
{
result = msg;

if(test){
alert (result);
test=false;
}
}

//$(this).html(result);

});

}

 });

return false;

});		   
		   
		   
		   
		   
		   
  // Document is ready
function getLeaf(url) {
 var splited=url.split('?');
 url=splited[0];
 return url.substring(url.lastIndexOf("/")+1);
} 

jQuery.fn.extend({
 enter: function() {
     return this.each(function() {
       var pth = $(this).find("img")[0];
	   //alert($(this).children().attr("href"));
	    if($(this).children().attr("href")==getLeaf(document.location.href)){
           $(pth).attr("src",pth.src.replace(/.gif/g, '-active.gif'));
		 } else{
               $(this).hover(function(){
                  $(pth).attr("src",pth.src.replace(/.gif/g, '-active.gif'));
                  },function(){
                      $(pth).attr("src",pth.src.replace(/-active.gif/g, '.gif'));
                      });
               }
               });
     }
});
 $("#nav li").enter();
});
