<!--
	// ============================================================================================
	// ============================================================================================
	// 
	// This Javascript Code is part of the Synergyx (http://www.synergyx.com) affiliate tracking 
	// system, and is used for tracking affiliates across multiple domains.
	//
	// This code is Copyright 2010, Paul Galloway. All Rights Reserved
	//
	// Use of this code in part or in full is expressly forbidden except by 
	// written permission from Paul Galloway, paulg@paulgalloway.com
	//
	// ============================================================================================
	// ============================================================================================
	
	var inhouseNumber = 10000;
	var cookieExpiration = 365; //specified in days
	
	function GetAffnumCookie()
	{
		var cookiecontent;
		if(document.cookie.length > 0) 
		{
   			var cookiename = 'affnum=';
   			var cookiebegin = document.cookie.indexOf(cookiename);
   			var cookieend = 0;
   			if(cookiebegin > -1) 
   			{
      				cookiebegin += 7;
      				cookieend = document.cookie.indexOf(";",cookiebegin);
      				if(cookieend < cookiebegin) 
      				{ 
      					cookieend = document.cookie.length; 
				}
				cookiecontent = document.cookie.substring(cookiebegin,cookieend);
			}
			else { cookiecontent = 'none'; }
		}
		else { cookiecontent = 'none'; }
		
		if (cookiecontent == inhouseNumber) 
		{ 
			cookiecontent = 'none'; //want to ignore in-house affiliate number in favor of REAL affiliate number
		}
		return cookiecontent;
	}
	
	function PrintAffiliateCode(prefix) 
	{
		var anum = inhouseNumber; //default
		var u_anum = 'none'; //Affnum in URL
		var c_anum = GetAffnumCookie(); // Affnum in Cookie -- is set to 'none' if cookie affnum is inhouseNumber

		//var args = location.search;
		//if (args.charAt(0) == '?')
		//{
		//	u_anum = args.substring(1);
		//	//alert('u_anum=' + u_anum);
		//	if (u_anum == inhouseNumber) { u_anum = 'none'; }
		//}
		//
		//if (u_anum != 'none') { anum = u_anum; } //URL-passed affiliate number takes precedence over cookie affiliate number (except in cases where cookie affnum is inhouse affnum)
		//else if (c_anum != 'none') { anum = c_anum; }
		if (c_anum != 'none') { anum = c_anum; }
		prefix = prefix.replace(/_AFFNUM_/g, anum);
		document.write(prefix);
	}
	// Insert this anywhere in your page where you want the affiliate number to show up
	//  <SCRIPT Language="Javascript" type=text/javascript>PrintAffiliateCode('Affnum is _AFFNUM_');</SCRIPT>
//-->

