
// HOME PAGE
// <img width="1" height="1" src="https://pixel2355.everesttech.net/2355/p?ev_HomePage=1" />

// LOGIN PAGE
// <img width="1" height="1" src="https://pixel2355.everesttech.net/2355/p?ev_GenericReturning=1" />

// RETURN MALE
// <img width="1" height="1" src="https://pixel2355.everesttech.net/2355/p?ev_MaleReturning=1" />

// RETURN FEMALE
// <img width="1" height="1" src="https://pixel2355.everesttech.net/2355/p?ev_FemaleReturning=1" />


if(typeof(jQuery) === 'function') {
	$(document).ready(function() {
		
		var cidCookie = readEHAffiliateTrackingCookie('cid');
		var cidParameter = getParameter(window.location.href,'cid');
		
		if( cidCookie == '61200' || cidCookie == '61201' || cidCookie == '61202' || cidCookie == '61250' || cidCookie == '61251' || cidCookie == '61300' || cidParameter == '61200' || cidParameter == '61201' || cidParameter == '61202' || cidParameter == '61250' || cidParameter == '61251' || cidParameter == '61300' ) {
			
			var downstreamPixel = '<img width="1" height="1" src="https://pixel2355.everesttech.net/2355/p?ev_GenericReturning=1" />';
			$('body').append(downstreamPixel);
			
		} // End if
				
	}); // End (on ready)
} // End if ( jQuery exists )


function readEHAffiliateTrackingCookie(name) {
	var nameEQ = "eh_aff_tracking=";
	var ca = document.cookie.split(';');
	for( var i=0; i < ca.length; i++ ) {
		var c = ca[i];
		while ( c.charAt(0)==' ' ) {
			c = c.substring(1,c.length);
		}
		if ( c.indexOf(nameEQ) == 0 ) {
			var cookieValue = c.substring(nameEQ.length,c.length);			
			var cookieValueArray = cookieValue.split('|');
						
			for( var j=0; j < cookieValueArray.length; j++ ) {
				var value = cookieValueArray[j];
				
				if( value.indexOf( name + '=' ) == 0 ) {
					return value.substring( name.length+1, value.length );
				} // End if
			} // End for
			
		} // End if
	} // End for
	
	return null;
}


function getParameter(queryString, parameterName) {
	// Add "=" to the parameter name (i.e. parameterName=value)
	var parameterName = parameterName + "=";
	
	if ( queryString.length > 0 ) {
		// Find the beginning of the string
		begin = queryString.indexOf( parameterName );
		// If the parameter name is not found, skip it, otherwise return the value
		if ( begin != -1 ) {
			// Add the length (integer) to the beginning
			begin += parameterName.length;
			// Multiple parameters are separated by the "&" sign
			end = queryString.indexOf( "&" , begin );
			if ( end == -1 ) {
				end = queryString.length
			} // End if
			
			// Return the string
			return unescape( queryString.substring ( begin, end ) );
		} // End if
	} // End if
	return "";
} // End function

