/**
 * SendToFriend.js
 * - requires jQuery
 **/

/**
 * $(document).ready();	
 * - on DOM load, this function will remove the redirect portion of the HREF link, and will load the data in a mock-popup.
 * - only happends for js enabled users.
 **/
 $(document).ready(function(){
	var link;
	$('.sendtofriend-link').each(function(){
		link = $(this).attr('href');
		link = link.split('&redirect')[0];
		$(this).attr('href',link+'&format=ajax');
	});
	/*$('.sendtofriend-link').colorbox({fixedWidth:'557',fixedHeight:'544',iframe:true,transition:'none'}); */
	$('.sendtofriend-link').click( function(e) {
		e.preventDefault();
		$.get($(this).attr('href'), function(data){
			$('#modalTemplate #modalContentArea').html(data);
			$('#modalTemplate').modal({
				opacity:48,
				overlayClose: false,
				zIndex: 2000
			});
		});
	});
 });
 /**
  * _close(); 	closes the sendto friend popup (friggered after e-mails sent)
  **/
  function SendToFriend_close(no_wait){
	if(no_wait) $('#modalClose').click();
	else setTimeout("$('#modalClose').click();",2000);
  }
  
    
  function sendToFriendSubmit()	{
	var form = $('#send-to-friend-form');
	$.post(form.attr('action')+'?format=ajax',form.serializeArray(),function(data){
	 $('#modalContentArea').html(data);
	});
	return false;
  }
