share = {
		settings : {},
		
		show : function() {
			$el = $('#sharepanel');
			var scrollPos = share.getScroll();

			$('#sharebackground').css({
				'top': ($(window).height()/2) + scrollPos['scrollTop'] - 200,
				'left': ($(window).width()/2) + scrollPos['scrollLeft'] - ($('#sharebackground').width()/2)
			});
			
			$el.animate({'height':300},'slow',function(){});
			$('#ajaxLoader').remove(); 
		},
		
		showtab : function(el,caller) {
			// Deselect all the selected tabs
			$(caller).parents('ul:first').find('.current').removeClass('current');
			$(caller).parent().addClass('current')
			
			// Hide the visible content, then fade the selected one.
			$('.shareContent > div:visible:not(.hide)').fadeOut('fast',function(){
				$(el).removeClass('hide').fadeIn();
				
				share.settings.height = $('.prettyPopin .prettyContent .prettyContent-container').height() + parseFloat($('.prettyPopin .prettyContent .prettyContent-container').css('padding-top')) + parseFloat($('.prettyPopin .prettyContent .prettyContent-container').css('padding-bottom'));

				scrollPos = share.getScroll();
				$('.prettyPopin').animate({
					'top': ($(window).height()/2) + scrollPos['scrollTop'] - (share.settings.height/2),
					'height' : share.settings.height
				});
			});
		},
		
		getScroll : function() {
			scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0;
			scrollLeft = window.pageXOffset || document.documentElement.scrollLeft || 0;
			return {scrollTop:scrollTop,scrollLeft:scrollLeft};
		}
}




email = {
	send:function(lang,template){

		var params = {}; 
		inputs = $("#shareSendEmail").find("input[@type='text'], input[@type='textarea'], input[@type='hidden'], input[@type='submit'], option[@selected], input[@checked], textarea");
		 		inputs.each(function() { 
				params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value; 
		});
			 
		var rand_no = Math.random();
				
				
				$('#from_email').html('');
				$('#to_email').html('');
				$('#message').html('');
				
				
				$.ajax({
					type:"POST",
					url:"/share/" + lang +  "/send_email/" +  template + "/?rand=" + rand_no,
					data : params,
					dataType: "json",
					timeout: 20000,
					success: function(errors){
							var msg_errors='';
							if (errors.success==false) {	
								$.each(errors, function(field,error) {
									if (field!='success'){
										$('#error_'+field).html(error);
									}
								});
								
								share.settings.height = $('.prettyPopin .prettyContent .prettyContent-container').height() + parseFloat($('.prettyPopin .prettyContent .prettyContent-container').css('padding-top')) + parseFloat($('.prettyPopin .prettyContent .prettyContent-container').css('padding-bottom'));

								scrollPos = share.getScroll();
								$('.prettyPopin').animate({
									'top': ($(window).height()/2) + scrollPos['scrollTop'] - (share.settings.height/2),
									'height' : share.settings.height
								});
							}else{
								$('#sendtofriend').addClass('hide').fadeOut();
								$('div.thankyou').removeClass('hide').fadeIn(function(){
									share.settings.height = $('.prettyPopin .prettyContent .prettyContent-container').height() + parseFloat($('.prettyPopin .prettyContent .prettyContent-container').css('padding-top')) + parseFloat($('.prettyPopin .prettyContent .prettyContent-container').css('padding-bottom'));

									scrollPos = share.getScroll();
									$('.prettyPopin').animate({
										'top': ($(window).height()/2) + scrollPos['scrollTop'] - (share.settings.height/2),
										'height' : share.settings.height
									});
								});
							}
					}
			
				});
						
	}
	
}
