// Onload
 $(document).ready(function() {
	$(document).inputhelpertext();
    $(".newslettersignupform").validate({
		messages: {
     		emailaddress: {
       			required: "Please enter your email address",
				email: "Your email address must be in the format of name@domain.com"
     		}
   		},
		submitHandler: function(form) {
   			// bind to the form's submit event 
    		$(".newslettersignupform").ajaxSubmit({
				target:			"#newslettercontent",   // target element(s) to be updated with server response 
				beforeSubmit: 	showRequest,   // pre-submit callback 
				success:		showResponse  // post-submit callback 
 
        		// other available options: 
        		//url:       url         // override for form's 'action' attribute 
        		//type:      type        // 'get' or 'post', override for form's 'method' attribute 
        		//dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        		//clearForm: true        // clear all form fields after successful submit 
        		//resetForm: true        // reset the form after successful submit 
 
        		// $.ajax options can be used here too, for example: 
        		//timeout:   3000
			}); 
 
        	// !!! Important !!! 
        	// always return false to prevent standard browser submit and page navigation 
        	return false;
   		}
	});
});
 
function showRequest(formData, jqForm, options) { 
    // formData is an array; here we use $.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    var queryString = $.param(formData);
	
	// sets up a transparent background to hold a loading graphic
	$("#newslettercontent").html("<table width=\"\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><td width=\"300\"><img name=\"spacer3\" src=\"images/spacer3.gif\" width=\"300\" height=\"10\" border=\"0\" alt=\"\"></td><td width=\"427\" valign=\"top\" style=\"font-size: 14px; font-weight: bold; font-family: Arial, Helvetica, sans-serif; color: #FF0000; padding: 2px 0 0 0; text-align: center;\">Loading...</td><td width=\"33\"><img name=\"spacer3\" src=\"images/spacer3.gif\" width=\"33\" height=\"10\" border=\"0\" alt=\"\"></td></table>");
 
    // jqForm is a jQuery object encapsulating the form element.  To access the 
    // DOM element for the form do this: 
    // var formElement = jqForm[0]; 
 
    // here we could return false to prevent the form from being submitted; 
    // returning anything other than false will allow the form submit to continue 
    return true; 
} 
 
//var google_conversion_id = 1070867882;
//var google_conversion_language = "en_GB";
//var google_conversion_format = "1";
//var google_conversion_color = "ffffff";
//var google_conversion_label = "";
//var microsoft_adcenterconversion_domainid = 258463;
//var microsoft_adcenterconversion_cp = 5050;

//function trackConversion(type) {
//	google_conversion_label = type;
//	$("img#googlegraphic").attr("src","http://www.googleadservices.com/pagead/conversion/"+google_conversion_id+"/?label="+google_conversion_label+"&amp;script=0");
	//$("img#msngraphic").attr("src","https://"+microsoft_adcenterconversion_domainid+".r.msn.com/?type=1&cp=1");
	//$(img#yahoographic").attr("src"."-");
//}

function showResponse(responseText, statusText)  { 
	//$('.ajaxfade').remove();
	//$('.loading-graphic').remove();
    // for normal html responses, the first argument to the success callback 
    // is the XMLHttpRequest object's responseText property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'xml' then the first argument to the success callback 
    // is the XMLHttpRequest object's responseXML property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'json' then the first argument to the success callback 
    // is the json data object returned by the server 
	//pageTracker._trackPageview("/property-enquiry-sent.asp?ID="+propCode);
	//Yahoo goes here?
	//trackConversion("lead");
	trackConversionMSN(51212, 5050, "dedup=1");
} 




function trackConversionMSN(intDomainID, intCP, arrConvParams) {
	jQuery("img#msngraphic").attr("src","http://"+intDomainID+".r.msn.com/?type=1&cp="+intCP+"&"+arrConvParams);
};