function sendInvitation(params){
	$("#invite_form *").each(function(){$(this).removeClass("payment-error");});
	$.ajax({
		type: "POST",
		url: "index.php",
		data: params.serialize() + "&eID=tx_imagetaginvitations_eid",
		dataType: "json",
		success: function(result){
			if (result.status == 0) {
				$.each(result,function(idx,el){
					element = "#" + idx;
					if ($(element)) $(element).addClass("payment-error");
				});
			}
			else {
				$("#invite_form input[type=text]").each(function(){$(this).val("");});
				$("#invite_form textarea").each(function(){$(this).val("");});
			}

			$("#dialog_inv").dialog("destroy");
			$("#dialog_inv").html(result.message);

			$("#dialog_inv").dialog({
				modal: true,
				buttons: {
					Ok: function() {
						$(this).dialog("close");

					}
				}
			});

		}
	});
}

function showInviteForm() {
  $('#invite_form').dialog("destroy");
	$('#invite_form').dialog({
			autoOpen: true,
			height: 500,
			width: 570,
			modal: true,
			resizable: false,
			closeText: 'Schließen',
			buttons: { "Schließen": function() { $(this).dialog("close"); } }
	});

}

function showTestPremiumOffer(hash) {
	showDialog(600,320,'Testen Sie 60 Tage die kostenlose Premium-Mitgliedschaft','dialog_inv');
	$("#dialog_inv").html('<br />Testen Sie vollkommen unverbindlich und kostenlos 60 Tage lang die Premium-Mitgliedschaft von Erfahrungsschatz (endet automatisch, ohne dass Sie diese kündigen müsssen).<br /><br />Grundsätzlich erhalten Sie für jeden Einkauf über Erfahrungsschatz ab 5,00 Euro Kaufsumme eine Euro-Gutschrift. Als Faustregel gilt, dass mindestens 0,50 Euro pro Einkauf über Erfahrungsschatz auf Ihr Gutschriften-Konto gebucht werden.<br/><br /><input id="getpremium" type="checkbox" value="1" onmousedown="ET_Event.click(\'Klick%20auf%20%22Ja%2C%20ich%20will%20Testpremium-Mitglied%20werde\', \'Test-Premium\')" onclick="getTestPremiummemberhip(\'' + hash + '\');" /> <label for="getpremium">Ja, ich möchte mir das persönliche <strong>Gutschriften-Konto</strong>  sichern</label>');
}

function getTestPremiummemberhip(hash) {
	$.ajax({
		type: "POST",
		url: "fileadmin/php/ajax.php",
		data: {'hash':hash},
		dataType: "json",
		success: function(result){
				if (result.status == 1) {
					$('#dialog_inv').dialog("destroy");
					$('#dialog_inv').dialog({
							autoOpen: true,
							height: 350,
							width: 520,
							modal: true,
							resizable: false,
							closeText: 'Schließen',
							title: 'Ihr Gutschriften-Konto',
							buttons: { "Schließen": function() { $(this).dialog("close"); location.reload(); } }
					});

			  $("#dialog_inv").html(result.message);
			}
			else {
				$('#dialog_inv').dialog("destroy");
					$('#dialog_inv').dialog({
							autoOpen: true,
							height: 350,
							width: 520,
							modal: true,
							resizable: false,
							closeText: 'Schließen',
							title: 'Ihr Gutschriften-Konto',
							buttons: { "Schließen": function() { $(this).dialog("close");} }
					});
				$("#dialog_inv").html(result.message);

			}
		}
	 });
}
function activateAccount(hash) {
	$.ajax({
		type: "POST",
		url: "fileadmin/php/ajax.php",
		data: {'hash':hash,'g':1},
		dataType: "json",
		success: function(result){
				if (result.status == 1) {
					$('#dialog_inv').dialog("destroy");
					$('#dialog_inv').dialog({
							autoOpen: true,
							height: 350,
							width: 520,
							modal: true,
							resizable: false,
							closeText: 'Schließen',
							title: 'Ihr Gutschriften-Konto',
							buttons: { "Schließen": function() { $(this).dialog("close"); location.reload(); } }
					});

			  $("#dialog_inv").html(result.message);
			}
			else {
				$('#dialog_inv').dialog("destroy");
					$('#dialog_inv').dialog({
							autoOpen: true,
							height: 350,
							width: 520,
							modal: true,
							resizable: false,
							closeText: 'Schließen',
							title: 'Ihr Gutschriften-Konto',
							buttons: { "Schließen": function() { $(this).dialog("close");} }
					});
				$("#dialog_inv").html(result.message);

			}
		}
	 });
}


function showDialog(width,height,title,element) {
  $('#'+element).dialog("destroy");
	$('#'+element).dialog({
			autoOpen: true,
			height: height,
			width: width,
			modal: true,
			resizable: false,
			closeText: 'Schließen',
			title: title
	});

}

function showSearchResults(params) {
	$('#ajaxloader').show();
	$.ajax({
		type: "POST",
		url: "api/affilinet_search_products.php",
		data: params.serialize(),
		dataType: "html",
		success: function(result){
			$('#ajaxloader').hide();
			$('#searchresults').html(result).show();

		}
	});
}

function showSearchResultsPage(page,searchstring,anzahl,subid) {
	$('#ajaxloader').show();
	$.ajax({
		type: "POST",
		url: "api/affilinet_search_products.php",
		data: {'page':page, 'searchstring':searchstring, 'anzahl':anzahl, 'subid':subid},
		dataType: "html",
		success: function(result){
			$('#ajaxloader').hide();
			$('#searchresults').html(result).show();
			$('html,body').animate({scrollTop: $("#searchtop").offset().top},'fast');

		}
	});
}

