/*
jQuery Url Plugin
	* Version 1.0
	* 2009-03-22 19:30:05
	* URL: http://ajaxcssblog.com/jquery/url-read-get-variables/
	* Description: jQuery Url Plugin gives the ability to read GET parameters from the actual URL
	* Author: Matthias Jäggli
	* Copyright: Copyright (c) 2009 Matthias Jäggli 
	* Licence: dual, MIT/GPLv2
*/
(function($){$.url={};$.extend($.url,{_params:{},init:function(){var paramsRaw="";try{paramsRaw=(document.location.href.split("?",2)[1]||"").split("#")[0].split("&")||[];for(var i=0;i<paramsRaw.length;i++){var single=paramsRaw[i].split("=");if(single[0])this._params[single[0]]=unescape(single[1]);}}catch(e){alert(e);}},param:function(name){return this._params[name]||"";},paramAll:function(){return this._params;}});$.url.init();})(jQuery);

$(document).ready(function() {	

//Assign the referral id to a variable
var refID = $.url.param('ref');
	//If there's a referral id in the url...
	if(refID.length > 0 )
		{
			//Create a new cookie, use the referral id as the cookie value
			$.cookie('spsreferral', refID, { expires: 31, path: '/' });
		};
	
	//If a cookie called 'spsreferral' already exists...
	var cookieValue = $.cookie('spsreferral');
	if($.cookie('spsreferral') != null)
		{	
			//And populate the hidden campaign input
			$('input[value="701C0000000ckSJ"]').val(cookieValue);
		};
		
});
