	
		var _session = new SessionClass();

		function SessionClass()
		{
			this.Id = -1;
			this.Language;
			this.SessionInfo = new SessionInfo();
			this.CurrentPage = new PageView();
			this.ViewedSubMaps = new Array();
			this.TrackingData = new TrackingData();
			this.ECoastCampaignSuffix = '';
			
			this.SelectLanguage = function(language)
			{
				this.Language = language;
			}
			this.SetSessionInfo = function(region,industry,pciLevel)
			{
				//all are required inputs
				this.SessionInfo.Region = region;
				this.SessionInfo.Industry = industry;
				this.SessionInfo.PCILevel = pciLevel;
			}
			this.ViewPage = function(toolpageNumber)//
			{
				if(this.Language==null)
				{
					alert("Can't view pages until SelectLanguage() is called");
				}
				
				if(toolpageNumber==1)
				{
					this.ECoastCampaignSuffix = $get('customdata').value;
				}
				else if(toolpageNumber==2)
				{
					if(this.SessionInfo.Region==-1)
					{
						alert("Can't view the Articles page until SetSessionInfo() is called");
					}
					this.CurrentPage = new ArticlePageView();
				}
				else
				{
					this.CurrentPage = new PageView();
				}
				this.CurrentPage.Id = toolpageNumber;
				
				callback = new ViewPageCallback();
				Cisco.SaveDataService.ViewPage(this,this.OnViewPageComplete,this.OnViewPageError,callback);//
			}
			this.FinishSessionInfo = function(pciConfidenceRating,pciCritical1,pciCritical2,pciCritical3,pciCritical4,pciCritical5,pciCritical6,pciCritical7,
				pciCritical8,pciCritical9,pciCritical10,pciCritical11,pciCritical12)
			{
				//set session id cookie for when 3rd party returns to Thank You page
				//var domain = GetDomain();
				Set_Cookie('pciSessionId',this.Id,3,'/','.pcicomplianceadvisor.com','');
				Set_Cookie('pciSessionLanguage',this.Language,3,'/','.pcicomplianceadvisor.com','');
				Set_Cookie('pciSessionId',this.Id,3,'/','.ciscowebtools.com','');
				Set_Cookie('pciSessionLanguage',this.Language,3,'/','.ciscowebtools.com','');
				
				//Save off the last of the session info
				this.SessionInfo.PCIConfidenceRating = pciConfidenceRating;
				this.SessionInfo.PCICritical1 = pciCritical1;
				this.SessionInfo.PCICritical2 = pciCritical2;
				this.SessionInfo.PCICritical3 = pciCritical3;
				this.SessionInfo.PCICritical4 = pciCritical4;
				this.SessionInfo.PCICritical5 = pciCritical5;
				this.SessionInfo.PCICritical6 = pciCritical6;
				this.SessionInfo.PCICritical7 = pciCritical7;
				this.SessionInfo.PCICritical8 = pciCritical8;
				this.SessionInfo.PCICritical9 = pciCritical9;
				this.SessionInfo.PCICritical10 = pciCritical10;
				this.SessionInfo.PCICritical11 = pciCritical11;
				this.SessionInfo.PCICritical12 = pciCritical12;
				
				Cisco.SaveDataService.FinishSessionInfo(this,null,this.OnFinishSessionInfoError);
			}
			this.DownloadReport = function(firstName,lastName,companyName,phoneNumber,email,countryCode,emailLinks,contactMe,notifyAlsoEmail)
			{
				this.SessionInfo.FirstName = firstName;
				this.SessionInfo.LastName = lastName;
				this.SessionInfo.CompanyName = companyName;
				this.SessionInfo.Email = email;
				this.SessionInfo.NotifyAlsoEmail = notifyAlsoEmail;
				this.SessionInfo.Phone = phoneNumber;
				this.SessionInfo.EmailLinks = emailLinks;
				this.SessionInfo.ContactMe = contactMe;
				this.SessionInfo.CountryCode = countryCode;

				Cisco.SaveDataService.DownloadReport(this,null,this.OnDownloadReportError);
			}
			this.ViewArticle = function(articleId)
			{
				//save article hits to be reported on next page visit
				this.TrackingData.AddTrackingItem(this.TrackingData.ViewedArticles,articleId);
			}
			this.SaveArticle = function(articleId)
			{
				//save article saves to be reported on next page visit
				this.TrackingData.AddTrackingItem(this.TrackingData.SavedArticles,articleId);
			}
			this.ViewSubMap = function(subMapId)
			{
				//save submap hits to be reported on next page visit
				this.TrackingData.AddTrackingItem(this.TrackingData.ViewedSubMaps,subMapId);
			}
			this.ViewProduct = function(productId)
			{
				//save product hits to be reported on next page visit
				this.TrackingData.AddTrackingItem(this.TrackingData.ViewedProducts,productId);
			}
			this.SaveProduct = function(productId)
			{
				//save product saves to be reported on the next page visit
				this.TrackingData.AddTrackingItem(this.TrackingData.SavedProducts,productId);
			}
			this.OnViewPageComplete = function(result,userContext)
			{
				//update the object with the functions with the data added on the other side
				//do not just replace object with updated one, as they are not the same and
				//the methods will disappear!
				_session.Id = result.Id;
				_session.CurrentPage = result.CurrentPage;
				
				userContext.Invoke(result.CurrentPage);
			}
			this.OnViewPageError = function(error)
			{
				alert('ViewPage: error \n' + error._message + '\n' + error._stackTrace);
			}
			this.OnDownloadReportError = function(error)
			{
				alert('DownloadReport: error \n' + error._message + '\n' + error._stackTrace);
			}
			this.OnFinishSessionInfoError = function(error)
			{
				alert('FinishSessionInfo: error \n' + error._message + '\n' + error._stackTrace);
			}
			this.End = function()
			{
				if(this.TrackingData.HasPendingData)
				{
					Cisco.SaveDataService.AbandonSession(this);
				}
			}
		}
		function SessionInfo()
		{
			this.Region = -1;
			this.Industry = -1;
			this.PCILevel = 1;
			this.PCIConfidenceRating = 1;
			this.FirstName = '';
			this.LastName = '';
			this.CompanyName = '';
			this.Email = '';
			this.NotifyAlsoEmail = '';
			this.Phone = '';
			this.EmailLinks = false;
			this.ContactMe = false;
			this.PCICritical1 = 0;
			this.PCICritical2 = 0;
			this.PCICritical3 = 0;
			this.PCICritical4 = 0;
			this.PCICritical5 = 0;
			this.PCICritical6 = 0;
			this.PCICritical7 = 0;
			this.PCICritical8 = 0;
			this.PCICritical9 = 0;
			this.PCICritical10 = 0;
			this.PCICritical11 = 0;
			this.PCICritical12 = 0;
			this.CountryCode = '';
		}
		function PageView()
		{
			this.Id = -1;
			this.TextElements = new Array();
		}

		function ArticlePageView()
		{
			this.Articles = null;
		}
		ArticlePageView.prototype = new PageView;
		
		function TrackingData()
		{
			this.ViewedArticles = new Array();
			this.ViewedSubMaps = new Array();
			this.SavedArticles = new Array();
			this.ViewedProducts = new Array();
			this.SavedProducts = new Array();
			this.HasPendingData = false;

			this.AddTrackingItem = function(category,id)
			{
				initem = category.grep(id);
				if(initem==null)
				{
					category[category.length] = id;
					this.HasPendingData = true;
				}
			}
		}
//		function GetDomain()
//		{
//			//var domain = document.domain;
//			var domain = 'www.ciscowebtools.com';
//			var index = domain.indexOf('.');
//			alert(index);
//		}
		
		function Set_Cookie(name,value,expires,path,domain,secure) 
		{
			// set time, it's in milliseconds
			var today = new Date();
			today.setTime(today.getTime());

			/*
			if the expires variable is set, make the correct 
//			expires time, the current script below will set 
			it for x number of days, to make it for hours, 
			delete * 24, for minutes, delete * 60 * 24
			*/
			if(expires)
			{
				expires = expires * 1000 * 60;
			}
			var expires_date = new Date(today.getTime() + (expires));

			document.cookie = name + "=" + escape(value) +
				((expires)?";expires=" + expires_date.toGMTString():"" ) + 
				((path)?";path=" + path:"" ) + 
				((domain)?";domain=" + domain:"" ) +
				((secure)?";secure":"" );
		}

		function grep(match,index)
		{
			var output = new Array();
			for(var i=0;i<this.length;i++)
			{
				if(this[i].length>1)
				{
					if(index==null) {index = 0;}
					
					try
					{
						if(this[i][index].indexOf(match)>-1)
						{
							output.push(this[i][index]);
						}
					}
					catch(error)
					{
						if(this[i][index]==match)
						{
							output.push(this[i][index]);
						}
					}
				}
				else
				{
					try
					{
						if(this[i].indexOf(match)>-1)
						{
							output.push(this[i]);
						}
					}
					catch(error)
					{
						if(this[i]==match)
						{
							output.push(this[i]);
						}
					}
				}
			}
			if(output.length>0)
			{
				return output;
			}
			else
			{
				return null;
			}
		}
		Array.prototype.grep=grep;

		function ViewPageCallback()
		{
			this.Invoke = function(pageData)
			{
				//trackingData.Clear();
				_session.TrackingData = new TrackingData();
				
				//DAVE Flash call here
				thisMovie("mymovie").ReturnFromViewPage(_session);
			}
		}

//function thisMovie(movieName)
//{
//	var isIE = navigator.appName.indexOf("Microsoft") != -1;
//	return (isIE) ? window[movieName] : document[movieName];
//}

function thisMovie(movieName)
{
	// IE and Netscape refer to the movie object differently.
	// This function returns the appropriate syntax depending on the browser.
	//alert(navigator.userAgent);
	if((navigator.appName.indexOf("Microsoft")>-1) || (navigator.userAgent.indexOf("Firefox")>-1) || (navigator.userAgent.indexOf("Opera")>0))
	{
		return document[movieName];
	}
	else
	{
		return window[movieName];
	}
}
