/*
 * contactable 1.2 - jQuery Ajax contact form
 *
 * Copyright (c) 2009 Philip Beel (http://www.theodin.co.uk/)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Revision: $Id: jquery.contactable.js 2009-09-24 $
 *
 */

(function($){$.fn.contactable=function(options){var defaults={
	name:'Name',
	empresa:'Empresa',
	cargo:'cargo',
	email:'email',
	telf:'telf',
	mensaje:'mensaje',
	testinput:'testinput',
	combo1:'combo1',
	recipient:'danielc_floyd@hotmail.com',
	subject:'Clientes Anonimos',
	recievedMsg:'Gracias por su mensaje',
	notRecievedMsg:'Su mensaje No a podido ser enviado, trate de nuevo'};
	var options=$.extend(defaults,options);
	return this.each(function(options){
$('div#contactable').toggle(function(){
	$('#overlay').css({display:'block'});
	$(this).animate({"marginLeft":"-=5px"},"fast");
	$('#contactForm').animate({"marginLeft":"-=0px"},"fast");
	$(this).animate({"marginLeft":"+=387px"},"slow");
	$('#contactForm').animate({"marginLeft":"+=390px"},"slow")},function(){$('#contactForm').animate({"marginLeft":"-=390px"},"slow");
	$(this).animate({"marginLeft":"-=387px"},"slow").animate({"marginLeft":"+=5px"},"fast");
	$('#overlay').css({display:'none'})});
	$("#testform").validate({rules:
	{name:{
		required:true,minlength:2},
	email:{
		required:true,email:true},
		telf:{
			required:true, minlength: 7, number:true},
		mensaje:{
			required:true},
	empresa:{
		required:true,minlength:2},
		cargo:{
			required:true,minlength:2},
		combo1:{
			required:true},
		
		testinput:{
			required:true,minlength:2}},
			messages:{name:"",email:"", telf:"", mensaje:"", cargo:"", empresa:"", testinput:"", combo1:""},submitHandler:function(){$('.holder').hide();$('#loading').show();
			$.get('mail.php',{recipient:$('#recipient').val(),subject:$('#subject').val(),name:$('#name').val(),empresa:$('#empresa').val(),cargo:$('#cargo').val(),email:$('#email').val(),telf:$('#telf').val(),mensaje:$('#mensaje').val(),testinput:$('#testinput').val(),combo1:$('#combo1').val()},function(data){$('#loading').css({display:'none'});if(data){$('#callback').show().append(defaults.recievedMsg)}else{$('#callback').show().append(defaults.notRecievedMsg)}})}})})}})(jQuery);
