/* External Registration Click Logging */
var externalHack_pxLoaded = false;

/**
 * Function that will log registration clicks
 */
function externalLogAndWaitRegClick(step_name, campaign_id, profile_id, country_id, profile_ad_data_country_id, form_id, uuid, destinationHostId, destinationId, stepNumber, testId, testVersionId)
{
	var img = new Image();
	
	$(img).load(function() { externalHack_pxLoaded = true; document.getElementById(form_id).submit();});
	setTimeout('if (!externalHack_pxLoaded) { document.getElementById("' + form_id + '").submit(); }',500);
	$(img).attr('src', "http://www.mate1.com/sessions/px/9755.gif?v=" + step_name + "/" + campaign_id + "/" + profile_id + "/" + country_id + "/" + profile_ad_data_country_id + "///" + uuid + "/" + destinationHostId + "/" + destinationId + "/" + stepNumber + "/" + testId + "/" + testVersionId + "&" + Math.random());
	$(img).bind("error", function() { if(!externalHack_pxLoaded) { document.getElementById(form_id).submit(); } });
}

function externalLogRegClick(step_name, campaign_id, profile_id, country_id, profile_ad_data_country_id, uuid, destinationHostId, destinationId, stepNumber, testId, testVersionId)
{
	var img = new Image();
	$(img).attr('src', "http://www.mate1.com/sessions/px/9755.gif?v=" + step_name + "/" + campaign_id + "/" + profile_id + "/" + country_id + "/" + profile_ad_data_country_id + "///" + uuid + "/" + destinationHostId + "/" + destinationId + "/" + stepNumber + "/" + testId + "/" + testVersionId + "&" + Math.random());
}

/**
 * A function that will log re
 */
function externalLogAndWaitRegRedirect(url, step_name, campaign_id, profile_id, country_id, profile_ad_data_country_id, uuid, destinationHostId, destinationId, stepNumber, testId, testVersionId)
{
	var img = new Image();
	
	$(img).load(function() { externalHack_pxLoaded = true; window.location = url;});
	setTimeout('if (!externalHack_pxLoaded) { window.location = url; }',500);
	$(img).attr('src', "http://www.mate1.com/sessions/px/9755.gif?v=" + step_name + "/" + campaign_id + "/" + profile_id + "/" + country_id + "/" + profile_ad_data_country_id + "///" + uuid + "/" + destinationHostId + "/" + destinationId + "/" + stepNumber + "/" + testId + "/" + testVersionId + "&" + Math.random());
	$(img).bind("error", function() { if(!externalHack_pxLoaded) { window.location = url; } });
}

/**
 * Function that will submit a form after a delay
 */
function externalWaitAndSubmitForm(form_id)
{
	setTimeout('if (!externalHack_pxLoaded) { document.getElementById("' + form_id + '").submit(); }',500);
}

