
function show_invite_form(id, type) {


	$.ajax({
	   type: "GET",
	   url: '/invite/' + id + '?type=' + type,
	   success: function(result){
	  		$("#inviteFormDiv").html(result);

			if ($.browser.msie) {
				document.getElementById('invite-form').style.top = document.documentElement.scrollTop + 250 + 'px';
				document.getElementById('invite-form').style.left = document.documentElement.scrollLeft + 500 + 'px';
			} else {
				document.getElementById('invite-form').style.top = window.pageYOffset + 250 + 'px';
				document.getElementById('invite-form').style.left = window.pageXOffset + 250 + 'px';
			}
	   }
	 });


}

function invite_submit() {

	values = $("#inviteForm").serializeArray();
   	$.post('/invite', values, function(response) {

		if (response.errors == 0) {
			$("#inviteFormDiv").html(response.data);
			if (document.documentElement) {
				document.getElementById('invite-form').style.top = document.documentElement.scrollTop + 250 + 'px';
				document.getElementById('invite-form').style.left = document.documentElement.scrollLeft + 500 + 'px';
			} else {
				document.getElementById('invite-form').style.top = window.pageYOffset + 250 + 'px';
				document.getElementById('invite-form').style.left = window.pageXOffset + 250 + 'px';
			}
			return;
		}

		document.getElementById('name').className = '';	
		document.getElementById('email').className = '';	
		document.getElementById('friend_email').className = '';	

		$.each(response.errors, function() {
			document.getElementById(this).className = 'inviteFormError';
		}); 

	}, "json");


}

function invite_close() {
	document.getElementById('invite-form').style.display = 'none';
}


/*	
function x_invite_form(content, fn)
{
	content += '<br/><br/><span class="button yes"><small>Envoyer</small></span> <span class="button no"><small>Cancel</small></span>';
	
	x_popup('x_invite_form', content);
	
	$('#x_invite_form > .xPopupContainer > .xPopupContent > .yes').one('click', {fn: fn}, function(e){
		if (e.data.fn) {
			fn.call();
		}
		x_popup_close('x_invite_form');
	});
	
	$('#x_invite_form > .xPopupContainer > .xPopupContent > .no').one('click', function(e){
		x_popup_close('x_invite_form');
	});
}

function show_invite_form(id, type) 
{
	$.ajax({
	   type: "GET",
	   url: '/invite/' + id + '?type=' + type,
	   success: function(result){
			x_invite_form(result, function(){alert('asd')});
	   }
	 });
}*/
