$(document).ready(function(){var baseUrl=$('#baseImagesUrl').val();var ajaxLoader=$('<img/>',{src:baseUrl+'/images/ajax-loader2.gif'});var socialBox=$('#socialBox');socialBox.data('feedbackOpened',false);socialBox.data('twitterOpened',false);socialBox.boxOpen=function(type){this.data(type+'Opened',true);socialBox.children('.socialContent').html($('#'+type+'Box'));this.animate({left:'0px'},'normal','easeOutBounce');};socialBox.boxClose=function(callback){$('#socialContainer').prepend($('#twitterBox'));$('#socialContainer').prepend($('#feedbackBox'));var box=this;box.animate({left:'-303px'},'normal','easeOutBounce',function(){box.data('feedbackOpened',false);box.data('twitterOpened',false);if($.isFunction(callback))callback();});};$('.twitterTrigger').click(function(){if(socialBox.data('feedbackOpened')===true){socialBox.boxClose(function(){socialBox.boxOpen('twitter');});}else if(socialBox.data('twitterOpened')===true){socialBox.boxClose();}else{socialBox.boxOpen('twitter');}});$('.feedbackTrigger').click(function(){if(socialBox.data('twitterOpened')===true){socialBox.boxClose(function(){socialBox.boxOpen('feedback');});}else if(socialBox.data('feedbackOpened')===true){socialBox.boxClose();}else{socialBox.boxOpen('feedback');}});var validate=new Validate;$('#feedbackForm').submit(function(e){e.preventDefault();var valid=true;var error='';if(!validate.email($('#feedbackForm #email').val())){valid=false;error='Invalid email provided !';}else if(validate.isEmpty($('#feedbackForm #message').val())){valid=false;error='Message should not be empty !';}
if(valid){$('#feedback_errors').html(ajaxLoader.clone());var serialized=$(this).serialize();var feedbackUrl=$('#feedbackUrl').val();$.ajax({url:feedbackUrl,type:'post',datatype:'json',data:serialized,success:function(response){if(response.success==true){$('#feedback_errors').attr('id','feedback_success').html('Feedback has been successfully send!');$('#feedbackForm input, #feedbackForm textarea').attr('disabled','disabled');}}});}else{$('#feedback_errors').html(error);}});});
