

// TOP MESSAGES //////////////////////
var myMessages = ['info','warning','error','success','submit'];
function hideAllMessages()
{
      var messagesHeights = new Array(); // this array will store height for each
      for (i=0; i<myMessages.length; i++)
            {
                messagesHeights[i] = $('.' + myMessages[i]).outerHeight(); // fill array
            $('.' + myMessages[i]).css('top', -messagesHeights[i]-10); //move element outside viewport
             }
}

function showMessage(type)
{
    $('.'+ type +'-trigger').click(function(){
         hideAllMessages();
    $('.'+type).animate({top:"0"}, 500);
        });
}


function showThis(type)
{   
$(function(){
    $('.info').animate({top:"0"}, 1000);
});
}


function hideThis(type)
{   
$(function(){
	$('.info').animate({top:"-90"}, 500);
});
}


function hideMsg()
{
var t=setTimeout("hideThis()",5000);
}
         

$(document).ready(function(){
     // Initially, hide them all
    hideAllMessages();
		   // Show message
		   for(var i=0;i<myMessages.length;i++)
		   {
				  showMessage(myMessages[i]);
		   }
		   // When message is clicked, hide it
		   
		   $('.message').click(function(){ 
		   $('.'+type).animate({top:"-80"}, 500); 
		   });
		   

$('input.close').click(function(){
	$('.message').animate({top: "-80"}, 500);
});

$('input.submit').click(function(){
				 
				 var name = $("input#name1").val();  
				 var email = $("input#email").val();  
				 var msg = $("input#msg").val(); 
				 var dataString = 'name='+ name + '&email=' + email + '&msg=' + msg;  
//alert (dataString);return false;  
$.ajax({  
  type: "POST",  
  url: "includes/bin/process.php",  
  data: dataString,  
  success: function() {  
  
    $('#contact_mssg').html("<div id='message'></div>");  
    $('#message').html("<h2>Contact Form Submitted!</h2>")  
    .append("Your Message: <b>" + msg + "</b>")  
    .hide()  
        .fadeIn(1000, function() {
          $('#message').append("");
        });
		
$('.message').animate({top: "-80"}, 500);

 $('.info').animate({top:"0"}, 1000);
  
 hideMsg();   
  }  
});  
return false; 
});   

});


