<!-- Script to handle the campains on the page x

// this is to get the campaign query parameter to be appended to the acquisition url
//check if there is a WT.mc_id tag in the url
//check if WT.mc_id campaign id is the last parameter in the url
//validate the campaign id
function getCampaignUrlQueryParameter() {
	var currentUrl = new String(window.location); 
	var splitArray = currentUrl.split( 'WT.mc_id=' );
	var campaignAndTheRest = splitArray[1];
	
	var campaignUrlQueryParameter;
	
	//if there is a campaign id in the url (campaignAndTheRest has data)
	if ( campaignAndTheRest != null && ( ( new String( campaignAndTheRest ) ) != 'undefined' ) && campaignAndTheRest != "" ) {
		var campaignId;
		
		//if campaignAndTheRest has an '&'
		if ( campaignAndTheRest.indexOf( '&' ) > 1 ){
			campaignId = campaignAndTheRest.substring( 0, campaignAndTheRest.indexOf( '&' ) );
		}
		//if campaignAndTheRest doesn't have an '&' (campaignAndTheRest is the campaign id)
		else{
			campaignId = campaignAndTheRest;
		}
		
		//validate the campaign id
		if( isValidCampaignId(campaignId) ){
			campaignUrlQueryParameter = '&campaignId=' + campaignId;	//having an extra '&' before the first query parameter wouldn't cause any problem
		}
		else{
			campaignUrlQueryParameter = '';
		}
	}
	else {
		campaignUrlQueryParameter = '';
	}
	return campaignUrlQueryParameter;
}

function isValidCampaignId(campaignId){
	//this is to check if the campaign id is an integer
	//please check javascript parseInt function. 
	//	if the first character of this string is not a numeric digit, it would return NaN. NaN.length returns undefined
	//	if a String has any character, the length of its parseInt result would be shorter than the length of itself. 
	var newString = new String( parseInt( campaignId ) );
	return ( 'undefined' != new String( newString.length ) && newString.length == campaignId.length ) ? true : false;
}


-->
