/**********************************************************************************************************
/* Written By Cary Buchmann. (cjbuchmann)
/* 
/* April 09, 2011
/*
/* JS SendToFriend
/*
/* param site_url - the base url of the site.
/*
/* JS SendToFriend allows the user to send any given page to a friend.
/* The user can also sign up to the mailing list and request a copy of the email.
/*********************************************************************************************************/

function JSSendToFriend(site_url)
{
	this.toggleAction = "#vimeo_roll";
	this.openAction = "";
	this.closeAction = "#friend_cancel_button";
	this.submitAction = "#friend_submit_button";
	
	this.form = "#email_form";
	this.contentFrame = "#email_frame";
	
	this.preloaderFrame = "#friend_preloader";
	
	var _gui = new JSGUI(this.contentFrame);
	var _ajax = new JSAjaxPost(this.form, site_url+"sendToFriend/sendrequest", 'post', true);
	var _obj = this;
	
	this.init = function()
	{
		_gui.init();
		_ajax.init();
		this.loadListeners();
	}
	
	this.loadListeners = function()
	{
		$(_obj.openAction).click(function(){
			_gui.showFrame(true);
			return false;
		});	
		
		$(_obj.closeAction).click(function(){
			_gui.hideFrame();
			return false;
		});
		
		$(_obj.toggleAction).click(function(){
			_gui.toggleFrame(true);
			return false;	
		});
		
		$(_obj.submitAction).click(function(){
			
			_ajax.sendAjaxRequest(function(){
				if(_ajax.getLastRequestStatus() == true)
				{
					_gui.hideFrame();
				}
			});

			return false;
		});
	}
	
	this.showFrame = function()
	{
		_gui.showFrame(true);
	}
}
