$(function() {
$('a.new-window').click(function(){
	window.open(this.href);
	return false;
});
$( "#dialog-signin" ).dialog({
	autoOpen: false,
	draggable: false,
	resizable: false,
	width: 450,
	modal: true
	});
$( "#dialog-createaccount" ).dialog({
	autoOpen: false,
	draggable: false,
	resizable: false,
	width: 450,
	modal: true
	});
$( "#dialog-offer" ).dialog({
	autoOpen: false,
	draggable: false,
	resizable: false,
	width: 450,
	modal: true
	});
});
function openNew(url){
window.open(url);
return false;
}
function signIn() {
$("#signInResult").html('');
$("#signInSubmitButton").html('<span class="ajaxSubmit"><p>Inloggen...</p></span>');
$.ajax({
	type: "POST",
	async: true,
	url: "http://"+document.domain+"/login.php",
	data: $("#signIn").serialize(),
	success: function(data){
if(data == 1){
window.location.replace("http://www.rakeback-poker.nl/my-account/");
_gaq.push(['_trackEvent', 'Account', 'Login']);
} else {
$("#signInResult").html(data);
$("#signInSubmitButton").html('<input class="submit" type="submit" onclick= "signIn();" value="Log in" />');
}}});}

function registerTracker() {
$("#registerTrackerResult").html('');
$("#registerTrackerSubmitButton").html('<div class="ajaxSubmit"><p>Tracker registreren...</p></div>');
$.ajax({
	type: "POST",
	async: true,
	url: "http://"+document.domain+"/create-tracker.php",
	data: $("#submitTracker").serialize(),
	success: function(data){
if(data.substr(1,1) == '<'){
$("#registerTrackerResult").html(data);
$("#registerTrackerSubmitButton").html('<input class="submit" type="submit" onclick="registerTracker();" value="Registreer tracker" />');
} else {
$("#dialog-offer").html(data);
}}});}

function createAccount() {
$("#createAccountResult").html('');
$("#createAccountSubmitButton").html('<div class="ajaxSubmit"><p>Account aanmaken...</p></div>');
$.ajax({
	type: "POST",
	async: true,
	url: "http://"+document.domain+"/create-account.php",
	data: $("#submitAccount").serialize(),
	success: function(data){
if(data.substr(1,1) == '<'){
$("#createAccountResult").html(data);
$("#createAccountSubmitButton").html('<input class="submit" type="submit" onclick="createAccount();" value="Voltooi aanmelding" />');
} else {
$("#dialog-offer").html(data);
$('#dialog-createaccount').html(data);
}}});}

function menuCreateAccount() {
$("#dialog-createaccount").dialog("open");
$.get("http://"+document.domain+"/create-account.php", function(data) {
$('#dialog-createaccount').html(data);
});
}
