// JavaScript Document
	
	//set cookie if it does not exist
	function SetCookie(siteid)
	{
	
	
	    //account for different cases without invalidating case of siteid string
	    siteid = siteid.replace('?siteID=', '?siteid=');
	    siteid = siteid.replace('?SiteID=', '?siteid=');
	    siteid = siteid.replace('?SITEID=', '?siteid=');
	    siteid = siteid.replace('?Siteid=', '?siteid=');
		
		//make sure cookie is not already set.
		//if(document.cookie.length > 0)
		if(document.cookie.indexOf('lscookie') >= 0)
		{
			return "";
		}
		
		//make sure site id was passed before setting cookie
		if(siteid.length <=0)
		{
		    return "";
		}
		
		//if there is a querystring, make sure it contains siteid
		if(siteid.indexOf('?siteid=') < 0)
		{
		    return "";
		}

		if(siteid.indexOf('script') >= 0)
		{
			return "";
		}
	
	    //redirect if url does not include www
	    if (window.location.host.indexOf('www.') < 0)
	        window.location = window.location.protocol + "//www." + window.location.host + window.location.pathname + siteid;
	        
		
		//make sure there are no additional fields passed after siteid
		if(siteid.indexOf('&') >= 0)
		{
		    siteid = siteid.substring(0, siteid.indexOf("&") - 1);
		}
	
	    siteid = siteid.replace('?siteid=', '');
		
		//get "land time" for cookie
		var setdate = new Date();
		setdate.setDate(setdate.getDate());
		
		//get expiration date for cookie
		var expdate=new Date();
		expdate.setDate(expdate.getDate()+365);
		
		var year = setdate.getFullYear().toString();
		var month = setdate.getMonth() + 1;
		var day = setdate.getDate().toString();
		var hour = setdate.getHours().toString();
		var minute = setdate.getMinutes().toString();

		
		month = month.toString();
		if(month.length == 1)
		{
			month = "0" + month;
		}
		
		day = day.toString();
		if(day.length == 1)
		{
			day = "0" + day;
		}
		
		hour = hour.toString();
		if(hour.length == 1)
		{
			hour = "0" + hour;
		}
		
		minute = minute.toString();
		if(minute.length == 1)
		{
			minute = "0" + minute;
		}
		
		
		
		document.cookie = "lscookie=" + siteid + "|" + year + month + day + '_' + hour + minute + ";expires=" + expdate.toUTCString() + "; path=/";
		
	}
	
	function DeleteCookie()
	{
	    //delete cookie by setting expiration date to a past date
	    var expdate = new Date();
	    
	    expdate.setTime(expdate.getTime() - 1);
	    
	    document.cookie = "lscookie=;expires=" + expdate.toGMTString();
	}
	
	function readCookie(name) 
    {
	    var nameEQ = name + "=";
	    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) return c.substring(nameEQ.length,c.length);
	    }
	    return "";
    }
	
	function GetCookieSiteID()
	{
	
	    var CookieString = readCookie('lscookie');
	
	    //make sure cookie exists
	    if(CookieString.length <= 0 || CookieString == null)
	    {
	        return "";
	    }
	
		var CookieData = CookieString.split("|");
		
		return CookieData[0];
	
	}
	
	function GetCookieDate()
	{
	
	    var CookieString = readCookie('lscookie');
	
	    //make sure cookie exists
	    if(CookieString.length <= 0)
	    {
	        return "";
	    }
	
		var CookieData = CookieString.split("|");
		
		return CookieData[1];
	
	}
	
	function NewAccount(AccountID)
	{
	
	    var CookieString = readCookie('lscookie');
	
	    //make sure cookie exists
	    if(CookieString.length <= 0)
	    {
	        return "";
	    }
	    
	    var siteid = GetCookieSiteID();
	    var landdate = GetCookieDate();
	  
		var ImgSrc = "<IMG SRC=\"https://track.linksynergy.com/ep?mid=36280&ord=" + AccountID + "&tr=" + siteid + "&land=" + landdate + "&cur=USD&skulist=signup&qlist=1&amtlist=0&namelist=Swiftpage.com%20trial%20account\" border=\"0\" width=\"1\" height=\"1\" alt=\"\">";
		
		return ImgSrc.toString();
	}
	
	function PurchaseAccount(AccountID, PurchasePrice, PurchaseType)
	{
	
	    //PurchaseType = emailonly or emailplus
	    //PurchasePrice = ##.##
	
	    var CookieString = readCookie('lscookie');
	
	    //make sure cookie exists
	    if(CookieString.length <= 0)
	    {
	        return "";
	    }
	    
	    var siteid = GetCookieSiteID();
	    var landdate = GetCookieDate();
	    
	    PurchasePrice = PurchasePrice.replace(",", "");
	    PurchasePrice = PurchasePrice.replace("$", "");
	    PurchasePrice = PurchasePrice * 100;
	    
	    DeleteCookie();
	    
	    var ImgSrc = "<IMG SRC=\"https://track.linksynergy.com/ep?mid=36280&ord=" + AccountID + "&tr=" + siteid + "&land=" + landdate + "&cur=USD&skulist=" + PurchaseType + "&qlist=1&amtlist=" + PurchasePrice + "&namelist=Swiftpage.com%20email%20only\" border=\"0\" width=\"1\" height=\"1\" alt=\"\">";
	    
	    return ImgSrc;		
	}
	
	function PurchaseAccount(AccountID, PurchasePrice, PurchaseType, siteid, landdate)
	{
	
	    //PurchaseType = emailonly or emailplus
	    //PurchasePrice = ##.##
	
	    //make sure cookie exists
	    if(siteid.length <= 0 || landdate <= 0)
	    {
	        return "";
	    }
	    
	    PurchasePrice = PurchasePrice.replace(",", "");
	    PurchasePrice = PurchasePrice.replace("$", "");
	    PurchasePrice = PurchasePrice * 100;
	    
	    DeleteCookie();
	    
//        set fso = CreateObject("Scripting.FileSystemObject");
//        set s = fso.CreateTextFile("test.txt", True);
//        s.writeline("HI");    
//        s.writeline("Bye");
//        s.writeline("-----------------------------");
//        s.Close();
	    
	    var ImgSrc = "<IMG SRC=\"https://track.linksynergy.com/ep?mid=36280&ord=" + AccountID + "&tr=" + siteid + "&land=" + landdate + "&cur=USD&skulist=" + PurchaseType + "&qlist=1&amtlist=" + PurchasePrice + "&namelist=Swiftpage.com%20email%20only\" border=\"0\" width=\"1\" height=\"1\" alt=\"\">";
	    
	    return ImgSrc;		
	}
