if (typeof pch == "undefined")
{
	pch = {};
}




$(document).ready(function(){


//START PCH INIT
	pch.init = function() {
		//Modify String function for simple ajax requests
		String.prototype.replaceVars = function(hash) {
			var replaceAll = function(txt, replace, with_this) {
				return txt.replace(new RegExp(replace, 'g'),with_this);
			}	
			
			if (typeof hash == "undefined")
			{
				return this;
			}

			var s = this;

			for (prop in hash)
			{	
				s = replaceAll(s, "{"+prop+"}", hash[prop]);			
			}
			
			return s;
		}; //end String.replaceVars

		
		//IndexOf (Add support for older javascript versions (i.e, js 1.5))
		if (!Array.prototype.indexOf)  
		{  
		  Array.prototype.indexOf = function(elt /*, from*/)  
		  {  
			var len = this.length >>> 0;  
		  
			var from = Number(arguments[1]) || 0;  
			from = (from < 0)  
				 ? Math.ceil(from)  
				 : Math.floor(from);  
			if (from < 0)  
			  from += len;  
		  
			for (; from < len; from++)  
			{  
			  if (from in this &&  
				  this[from] === elt)  
				return from;  
			}  
			return -1;  
		  };  //end Array
		} //end indexOf
		

		//Identify the browser
		pch.core.identifyBrowser();

		//Fix any PNGs (fires only for IE6)
		pch.core.fixPNG();

	}; //end pch.init
//END PCH INIT



//START PCH CORE
	pch.core = {
		getCookie: function(c_name) {
				if (document.cookie.length>0) {
					c_start=document.cookie.indexOf(c_name + "=");
					if (c_start!=-1) {
						c_start=c_start + c_name.length+1;
						c_end=document.cookie.indexOf(";",c_start);
						if (c_end==-1) c_end=document.cookie.length;
						return unescape(document.cookie.substring(c_start,c_end));
					}
				}
				return null;
		}, //end getCookie
		
		setCookie: function(c_name,value,expiredays,path,domain,secure) {
				/* 
				 |Example: setCookie('foo','bar',365)
				 */
				var exdate=new Date();
				exdate.setDate(exdate.getDate()+expiredays);
				document.cookie=c_name+ "=" +escape(value)+
					((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+
					((path) ? "; path=" + path : "")+
					((domain) ? "; domain=" + domain : "")+
					((secure) ? "; secure" : "");
		}, //end setCookie

		identifyBrowser: function() {
				var userAgent = navigator.userAgent.toLowerCase();
				var sVersion = (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1];
				var vendor = ("vendor" in navigator) ? navigator.vendor.toLowerCase(): "";

				if ($._browser === undefined)
				{
					// Figure out what browser is being used
					//Depeciated as of JQuery 1.3 but kept alive here. Very useful.
					//Changed to $._browser instead of $.browser to avoid any conflicts
					$._browser = {
						version: sVersion,
						fullVersion: parseFloat(sVersion),
						webkit: /webkit/.test( userAgent ),
						safari: /apple/.test( vendor ),
						chrome: /google/.test ( vendor ),
						opera: /opera/.test( userAgent ),
						msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
						mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
					};
				}

				//add browser class to document - helps with CSS browser targeting
				var msie = ($._browser.msie) ? "ie" : false;
				var mozilla = ($._browser.mozilla) ? "mozilla": false;
				var safari = ($._browser.safari) ? "safari": false;
				var chrome = ($._browser.chrome) ? "chrome": false;
				var webkit = ($._browser.webkit) ? "webkit": false;
				var opera = ($._browser.opera) ? "opera": false;
				var browser = (msie || mozilla || safari || chrome || opera);
				var browserVer = parseInt($._browser.version);
				var platform = null;
								
				//check webkit browsers
				if (safari || chrome)
				{
					browserVer = webkit + " " + (webkit + browserVer);
				}
				else
				{
					browserVer = browser + browserVer;
				}

				//check for ff2
				if (mozilla)
				{
					if ($._browser.fullVersion < 1.9)
					{
						browserVer+= " ff2";
					}
					else
					{
						browserVer+= " ff3";
					}
				}

				//check for upgraded versions of IE
				if (browser == "ie")
				{
					var browserVersionArray = userAgent.match(/msie ([\d/.]+)/g);
					var highestBrowserVersion = 0;
					for (var i=0; i<browserVersionArray.length; i++)
					{
						browserVersionArray[i] = parseInt(browserVersionArray[i].replace("msie",""));
						highestBrowserVersion = (browserVersionArray[i] > highestBrowserVersion) ? browserVersionArray[i]: highestBrowserVersion;
					}
					if (highestBrowserVersion != 0)
					{
						browserVer = $._browser.version = String(highestBrowserVersion);
						browserVer = browser + browserVer;
					}
				}


				$("body")
					.addClass(browser)
					.addClass(browserVer);
				
				if ( navigator.platform.substr(0, 3).toLowerCase() !== "win" ) {
					platform = 'macOS';
					$('body').addClass('macOS');
				}						

				//add the version for these very specific cases
				var specific_class = (platform == null) ? "": platform + '_'; 
				specific_class += (browser + '_v' + $._browser.version.replace(/\./g, "_"));
				$('body').addClass(specific_class);

			}, //identifyBrowser

			fixPNG: function() {
				//Fix PNG for IE6
				var isBrowserIE6 = $("body").hasClass("ie6");
				var classSelector = ".fixPNG";

				if (isBrowserIE6)
				{
					$(classSelector)
						.each(
							function()
							{								
								try {
									var src = (this.src) ? this.src : this.currentStyle.backgroundImage.split('"')[1];									
									if (src && src != "none")
									{
										this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + src + ")";
										this.style.background = "none";
									}
								}catch(e){
									alert(e.name+": "+e.message);
								}								
							}
						);
				} //endif (isBrowserIE6)
			} //fixPNG

	}; //end pch.core
//END PCH CORE



//START PCH LOTTO
	pch.lotto = {

			//Constants
			NO_GAME_PLAY: -99,

			//Set to false for production
			DEBUG: false,

			//Init
			init: function(gameID, bAutoBuildCard) {

				bAutoBuildCard = (typeof bAutoBuildCard == "undefined") ? true: bAutoBuildCard;
				gameID = (typeof gameID == "undefined") ? null: gameID;
				
				//Extend gameID functionality						
				pch.lotto.customerData.gamesPlayed.addGameID = function(id) {							
					if (!isNaN(parseInt(id))){																

						//Already entered?
						if (pch.lotto.customerData.gamesPlayed.indexOf(id) == -1)
						{
							pch.lotto.customerData.gamesPlayed.push(id);
						}
					}

				};
				
				pch.lotto.customerData.gameID = gameID;
				
				var greetUser = function() {
					var name = pch.lotto.customerData.firstName;
					name = (!name) ? 'Guest': name;
					$("#userGreeting > span.firstName").text(name);
				};
				
				//Greet user on save
				pch.lotto.customerData.onsave = greetUser;						

				//Get customer data from cookie
				pch.lotto.webServices.GetCustomerDetailsFromCookie();

				//Pull game card data and filter out contest already played
				var filterGamesPlayed = function() {							
					pch.lotto.webServices.GetContestsPlayedByUser(
							function()
							{
								if (pch.lotto.lottoGameCard.length > 0 && bAutoBuildCard)
								{											
									pch.lotto.buildCard();										
								}
								else if (bAutoBuildCard)
								{
									//There are no game cards to play!
									//$(".moreFromPCH").show();
									pch.lotto.gameFlow.allDoneGameExit();
								}
							}
					);
				};
				pch.lotto.webServices.GetActiveContests(function() {							
					filterGamesPlayed();

					//Load status bar if user registered before playing a game
					if (pch.lotto.customerData.currGameCardIndex == pch.lotto.NO_GAME_PLAY)
					{								
						lottoGameStatusBar(true);
					}

				});
			},

			buildCard: function(gameID) {

				gameID = (typeof gameID == "undefined") ? pch.lotto.customerData.gameID: gameID;

				if (gameID == null)
				{
					//load first unplayed game id
					pch.lotto.customerData.gameID = pch.lotto.lottoGameCard[0].gameID;
				}
		
				//find game in array and set as first game
				var gameCard = pch.lotto.lottoGameCard;
				for (var i=0; i < gameCard.length; i++)
				{
					if (gameCard[i].gameID == gameID)
					{
						gameCard.splice(0,0,gameCard.splice(i,1)[0]);
						pch.lotto.lottoGameCard = gameCard;
						break;
					}
				} //end for
				
				//Populate inital game data on first load
				if (parseInt(pch.lotto.customerData.gameID) == 0)
				{
					pch.lotto.customerData.gameID = pch.lotto.lottoGameCard[pch.lotto.customerData.gameID].gameID;
					pch.lotto.customerData.gameName = pch.lotto.lottoGameCard[pch.lotto.customerData.gameID].gameName;
				}

				buildCard(0,false);
			},

			gameFlow: {
				allDoneGameExit: function() {
					testMe();
				},

				allowUserRegBeforeGame: function() {
					pch.lotto.init(null, true)
				},

				showPreRoll: function(hash) {
					hash.adWait   = (typeof hash.adWait != "undefined") ? hash.adWait: null;
					hash.callback = (typeof hash.callback != "undefined") ? hash.callback: null;

					var nGamesBeforeSpecialFeature = showSponsorSelectAfterGameNumber;
					var cookie_name = 'ss'+pch.lotto.customerData.id;
					var ssCookie = pch.core.getCookie(cookie_name);
					var cookie_expiration = 3; //In days							
					var three_min_timeout = 180000;

					//SPONSOR SELECT LOGIC: START
						//check number of games played already							
						if (pch.lotto.DEBUG) 
						{
							console.log("Pre Roll:");
							console.log("pch.lotto.customerData.gamesPlayed.length: "+pch.lotto.customerData.gamesPlayed.length);
							console.log("nGamesBeforeSpecialFeature: "+nGamesBeforeSpecialFeature);
							console.log("ssCookie: "+ssCookie);
						}
						
						if (pch.lotto.customerData.gamesPlayed.length == nGamesBeforeSpecialFeature && nGamesBeforeSpecialFeature > 0)
						{
							//Show the special feature?								
							if (ssCookie == null)
							{
								//after inital show make sure ss isn't show within next 72 hours
								var cookie_name = 'ss'+pch.lotto.customerData.id;
								pch.core.setCookie(cookie_name, 'sponser select', cookie_expiration);
								window.ssWindowOpen = true;

								//load the ss window
								loadSponsorSelect(SponsorSelectUrl);

								//timeout after three mins and load next game card.
								window.setTimeout("if(window.ssWindowOpen) window.unloadSponsorSelect()", three_min_timeout);

								return false;
							}
						}
					//SPONSOR SELECT LOGIC: END

					
					//Show normal ad
					loadAd("http://ad.doubleclick.net/adi/pch.pchlotto/flash;s1=flash;url=flash;kw=;pch=ad;pos=box;dcopt=ist;sz=300x250;tile=1;", hash.adWait, hash.callback);
				}

			}, //pch.lotto.gameFlow

			trackingCode: function(event) {
				if (pch.lotto.DEBUG)
				{
					console.log("Firing Tracking code: "+event);
					if (arguments[1])
					{
						console.log("argument: "+arguments[1]);
					}
				}//end debug

				event = (typeof event == "undefined") ? false: event;
				var gameId = pch.lotto.customerData.gameID;
				var getGameName = function() {
					$.each(pch.lotto.lottoGameCard, 
						function() 
						{
							if (parseInt(this.gameID) == parseInt(gameId))
							{
								pch.lotto.customerData.gameName = this.gameName;
								return false;
							}
						}
					);
				}
				getGameName();						

				switch(event)
				{
					case "OnSubmitClickEventUnknownUserNoCookie":
						eDialogConversion(gameId, "NoCookie");
						break;
					
					case "OnSubmitClickEventUserKnownWithCookie":
						eDialogConversion(gameId, "Cookie");
						break;
					
					case "OnLoginClickEvent":
						eDialogConversion(gameId, "Login");
						break;

					case "OnRegistrationClickEvent":
						eDialogConversion(gameId, "Reg");
						break;
					
					case "DFA_EmailOptIn":
						var emailOptin = eval(arguments[1]);
						DFAConversion(emailOptin);
						break;

					case "DFA_PopulateRegistrationForm":
						populateRegistrationLightBox();
						break;

					 case "QuickPickClickEvent":
						cmCreatePageElementTag('Quick Pick', 'Microsite:Lotto');
						break;

					case "EraseButtonClickEvent":
						cmCreatePageElementTag('Erase', 'Microsite:Lotto');
						break;

					case "LottoGameOnLoadEvent":								
						cmCreateConversionEventTag(pch.lotto.customerData.gameName,'1','Microsite:Lotto','0');								
						break;

					case "LottoGameOnSumbitEvent":
						cmCreateConversionEventTag(pch.lotto.customerData.gameName,'2','Microsite:Lotto','0');								
						break;

					default:
						if (pch.lotto.DEBUG)
						{
							console.log("Error firing tracking code: "+event);									
						}
				}
			}, //pch.lotto.trackingCode

			customerData: {
				id: null,
				title: null,
				firstName: null,
				lastName: null,
				emailAddress: null,
				address1: null,
				address2: null,
				city: null,
				state: null,
				zip: null,
				dob: null,
				avatarID: null,
				gamesPlayed: [],
				totalGames: 0,
				currGameCardIndex: 0,
				gameID: null,
				gameName: null,
				save: function(hash) {
					if (typeof hash == "undefined")
					{
						return false;
					}
					this.id				= hash.id;
					this.title			= hash.title;
					this.firstName		= hash.firstName;
					this.lastName		= hash.lastName;
					this.emailAddress	= hash.emailAddress;
					this.address1		= hash.address1;
					this.address2		= hash.address2;
					this.city			= hash.city;
					this.state			= hash.state;
					this.zip			= hash.zip;
					this.dob			= hash.dob;
					this.avatarID		= hash.avatarID;

					//Set greeting name
					$(this.greetingLabelID).text(this.firstName);

					return this.onsave();
				},
				onsave: function(){},
				greetingLabelID: "#userGreeting > span.firstName"

			}, //end customerData

			"forms": {
				registerForm: {
					errorMessage: function(array) {							
						if (typeof array != "undefined")
						{
							var $msgObj = $(".error_message");
							var $msgObjText = $msgObj.find(".message ul");
							$msgObjText.children().remove();
							for(var i=0; i < array.length; i++)
							{
								$msgObjText.append("<li><label class='error'>"+array[i]+"</label></li>");
							}
							$msgObj.show();
							$msgObjText.show();
						}
					},
					
					clearErrorMessage: function(bHide) {
						var $msgObj = $(".error_message");
						var $msgObjText = $msgObj.find(".message ul");
						$msgObjText.children().remove();
						if (bHide)
						{
							$msgObj.hide();
						}
					}

				} //end pch.lotto.forms.register

			}, //end pch.lotto.forms

			lottoGameCard: [],

			webServices: {
					lottoContestWebServiceURL: lottoContestWebSvcURL+"/",

					_errorDefault: function() {
						alert('Sorry an error occurred!\nTry refreshing the page!');
					},

					_postSubmitEntryProcess: function(bSuccess) {

							//Pass false when user logs in from reg page and already
							//played the current game being submitted.

							bSuccess = (typeof bSuccess == "undefined") ? true: bSuccess;
						
							//Was submitEntry a success?
							if(bSuccess)
							{
								//Update games played
								pch.lotto.customerData.gamesPlayed.addGameID(pch.lotto.lottoGameCard[pch.lotto.customerData.currGameCardIndex].gameID);
							}

							var gameIndex = pch.lotto.customerData.currGameCardIndex;
							var totalGames = pch.lotto.customerData.totalGames;
							var totalGamesPlayed = pch.lotto.customerData.gamesPlayed.length;
							if (totalGamesPlayed == totalGames)
							{
								//Games finished exit to co-reg									
								var adWait;
								var callback = function() { unloadAd(); pch.lotto.gameFlow.allDoneGameExit(); }
								
								if (pch.lotto.lottoGameCard.length > 0)
								{
									adWait = pch.lotto.lottoGameCard[pch.lotto.customerData.currGameCardIndex].adLen;
								}
								else
								{
								  //Default to 10 if user logs in and has no games to play
								  //therefore there is no game to pull the adWait from.
								  adWait = 10;
								}
								
								//loadAd("http://ad.doubleclick.net/adi/pch.pchlotto/flash;s1=flash;url=flash;kw=;pch=ad;pos=box;dcopt=ist;sz=300x250;tile=1;", adWait, callback);
								var hash = {
									'callback': callback,
									'adWait': adWait
								};
								pch.lotto.gameFlow.showPreRoll(hash);
							}
							else 
							{
								
								var prevGameIndex = pch.lotto.customerData.currGameCardIndex;

								if (bSuccess)
								{
									//play next game in queue 
									pch.lotto.customerData.currGameCardIndex++;
									prevGameIndex = pch.lotto.customerData.currGameCardIndex-1;											
								}
								
								//Update current game info
								pch.lotto.customerData.gameID = pch.lotto.lottoGameCard[pch.lotto.customerData.currGameCardIndex].gameID;

								//Backwards compatibility
								currlottoGameCard = pch.lotto.customerData.currGameCardIndex;

								//show ad (next game is automatically shown after ad)
								//lottoGameAnimateAd();
								var adWait = pch.lotto.lottoGameCard[prevGameIndex].adLen;
								var callback;
								
								if (totalGamesPlayed == totalGames)
								{
									callback = function() { unloadAd(); pch.lotto.gameFlow.allDoneGameExit() };
								}
								else
								{
									callback = function() { unloadAd(); loadNextGameCard() };
								}

								//loadAd("http://ad.doubleclick.net/adi/pch.pchlotto/flash;s1=flash;url=flash;kw=;pch=ad;pos=box;dcopt=ist;sz=300x250;tile=1;", adWait, callback);
								var hash = {
									'callback': callback,
									'adWait': adWait
								};
								pch.lotto.gameFlow.showPreRoll(hash);

							} //endif

					},	//end pch.lotto.webServices._postSubmitEntryProcess 

					Authenticate: function(hash, successFunc, errorFunc) {
							if (hash === undefined)
							{
								return false;
							}
							var getCustomerDetails = function(data, textStatus, XMLHttpRequest){
									if($(data).find("AccountResponseCodes").text().toLowerCase() == "ok")
									{
										pch.lotto.webServices.GetCustomerDetailsFromCookie();
									}
							};
							$.ajax({
								url: pch.lotto.webServices.lottoContestWebServiceURL+"Authenticate",
								type: "GET",									
								data: {'emailAddress': hash.emailAddress, 'password': hash.password},
								success: (typeof successFunc == "undefined") ? getCustomerDetails: function(data, textStatus, XMLHttpRequest) { if(successFunc(data, textStatus, XMLHttpRequest) != false) getCustomerDetails(data, textStatus, XMLHttpRequest)},
								error: (typeof errorFunc == "undefined") ? function(data, textStatus, XMLHttpRequest){pch.lotto.webServices._errorDefault()}: errorFunc
							});
					},

					GetCustomerDetailsFromCookie: function(successFunc, errorFunc) {
							var populateCustomerData = function(data, textStatus, XMLHttpRequest) {								
								var $data = $(data);
								var hash = {
									'id':			$data.find("Id").text(),
									'title':		$data.find("Title").text(),
									'firstName':	$data.find("FirstName").text(),
									'lastName':		$data.find("LastName").text(),
									'emailAddress': $data.find("EmailAddress").text(),
									'address1':		$data.find("Address1").text(),
									'address2':		$data.find("Address2").text(),
									'city':			$data.find("City").text(),
									'state':		$data.find("State").text(),
									'zip':			$data.find("Zip").text(),
									'dob':			$data.find("DateOfBirth").text(),
									'avatarID':		$data.find("AvatarID").text()
								};
								pch.lotto.customerData.save(hash);
							};
							
							$.ajax({
								url: pch.lotto.webServices.lottoContestWebServiceURL+"GetCustomerDetailsFromCookie",
								type: "GET",
								dataType: "xml",							
								success: (typeof successFunc == "undefined") ? populateCustomerData: function(data, textStatus, XMLHttpRequest){if (successFunc(data, textStatus, XMLHttpRequest) != false) populateCustomerData(data, textStatus, XMLHttpRequest)},
								error: (typeof errorFunc == "undefined") ? function(data, textStatus, XMLHttpRequest){pch.lotto.webServices._errorDefault()}: errorFunc,
								contentType: "text/xml; charset=\"utf-8\""
							});					
					}, //end pch.lotto.webServices.GetCustomerDetailsFromCookie

					GetActiveContests: function(successFunc, errorFunc) {
							var populateLottoGameCards = function(data, textStatus, XMLHttpRequest) {
								var $data = $(data);
                                
								pch.lotto.customerData.totalGames = $data.find("LottoContest").size();
								for (ii=0;ii<=pch.lotto.customerData.totalGames;ii++) 
                                 { 
                                 $data 
                                              .find("LottoContest") 
                                              .each(function(){ 
                                                   var $this = $(this); 
                                                   var gameID = parseInt($this.find('Id').text()); 
  
                                                   if (!isNaN(gameID)) 
                                                   { 
                                                       if (gameID == flashcardvars[ii]) 
                                                        { 
                                                            //Add game card data 
                                                            pch.lotto.lottoGameCard.push( 
                                                                 { 
                                                                      'pickLimit':     $this.find('NumbersToPick').text(), 
                                                                      'numChoices':     $this.find('NumbersToPickFrom').text(), 
                                                                      'gameID':          gameID, 
                                                                      'status':          0, 
                                                                      'adLen':          10, 
                                                                      'gameName':          $this.find('Name').text() 
                                                                 } 
                                                            );                                                                  
                                                        } 
                                                   } 
                                              }); //end each                                         
                                 } // end for loop  
                            }; 
							$.ajax({
								url: pch.lotto.webServices.lottoContestWebServiceURL+"GetActiveContests",
								type: "GET",
								dataType: "xml",
								data: {'applicationCode': 'LottoGame'},
								success: (typeof successFunc == "undefined") ? populateLottoGameCards: function(data, textStatus, XMLHttpRequest) { populateLottoGameCards(data, textStatus, XMLHttpRequest); successFunc(data, textStatus, XMLHttpRequest);},
								error: (typeof errorFunc == "undefined") ? function(data, textStatus, XMLHttpRequest){pch.lotto.webServices._errorDefault()}: errorFunc,
								contentType: "text/xml; charset=\"utf-8\""
							});
					}, //end pch.lotto.webServices.GetActiveContests
					
					GetContestsPlayedByUser: function(successFunc, errorFunc) {
						
							var filterGames = function(data, textStatus, XMLHttpRequest) {

								//Filter games that where played
								var $data = $(data);																			
								$data
									.find("LottoContest")
									.each(function(index) {
										var $this = $(this);
										var gameID = parseInt($this.find('Id').text());
										
										$.each(pch.lotto.lottoGameCard,
											function(i)
											{														
												if (pch.lotto.lottoGameCard[i].gameID == gameID)
												{
													pch.lotto.lottoGameCard.splice(i,1);
													pch.lotto.customerData.gamesPlayed.addGameID(gameID);
													return false;
												}
											}
										);
										
										if (pch.lotto.lottoGameCard.length > 0 && pch.lotto.customerData.currGameCardIndex != pch.lotto.NO_GAME_PLAY)
										{
											pch.lotto.customerData.gameID = pch.lotto.lottoGameCard[pch.lotto.customerData.currGameCardIndex].gameID;
										}

									}); //end each																											

								lottoGameCard = pch.lotto.lottoGameCard;
							} //end filterGames
							
							$.ajax({
								url: pch.lotto.webServices.lottoContestWebServiceURL+"GetContestsPlayedByUser",
								type: "GET",
								dataType: "xml",
								data: {'applicationCode': 'LottoGame'},
								success: (typeof successFunc == "undefined") ? filterGames: function(data, textStatus, XMLHttpRequest) { filterGames(data, textStatus, XMLHttpRequest); successFunc(data, textStatus, XMLHttpRequest);},
								error: (typeof errorFunc == "undefined") ? function(data, textStatus, XMLHttpRequest){pch.lotto.webServices._errorDefault()}: errorFunc,
								contentType: "text/xml; charset=\"utf-8\""
							});
					},
					
					SubmitEntry: function(hash, successFunc, errorFunc) {
							if (typeof hash == "undefined")
							{
								return false;
							}

							var postSubmitProcess = function() { pch.lotto.webServices._postSubmitEntryProcess(); };

							$.ajax({
								url: pch.lotto.webServices.lottoContestWebServiceURL+"SubmitEntry",
								type: "GET",
								dataType: "xml",
								data: {'contestId': hash.contestId, 'selectedNumbersAsString': hash.selectedNumbersAsString},
								success: (typeof successFunc == "undefined") ? postSubmitProcess: function(data, textStatus, XMLHttpRequest) { postSubmitProcess(data, textStatus, XMLHttpRequest); successFunc(data, textStatus, XMLHttpRequest);},
								error: (typeof errorFunc == "undefined") ? function(data, textStatus, XMLHttpRequest){pch.lotto.webServices._errorDefault()}: errorFunc,
								contentType: "text/xml; charset=\"utf-8\""
							});
					}, //end SubmitEntry

					CreateCustomer2: function(hash, successFunc, errorFunc) {
							if (typeof hash == "undefined")
							{
								return false;
							}
							var getCustomerID = function() {
								pch.lotto.webServices.GetCustomerDetailsFromCookie();
							}
							$.ajax({
									type: "GET",
									url: pch.lotto.webServices.lottoContestWebServiceURL+"CreateCustomer2",																						
									data: hash,
									success: (typeof successFunc == "undefined") ? getCustomerID: function(data, textStatus, XMLHttpRequest) { if (successFunc(data, textStatus, XMLHttpRequest) != false) getCustomerID()},
									error: (typeof errorFunc == "undefined") ? function(data, textStatus, XMLHttpRequest){pch.lotto.webServices._errorDefault()}: errorFunc											
								});
					}

			} //end pch.lotto.webServices					

		}; //end pch.lotto
	//END PCH LOTTO


	//First run
	pch.init();

});	//end document.ready



if (typeof console == "undefined")
{
	var console = {
		_handle: undefined,

		log: function(s) {
			if (typeof console._handle == "undefined" && pch.lotto.DEBUG)
			{				
				console._handle=window.open('about:blank');				
			}
			if (typeof console._handle != "undefined" && pch.lotto.DEBUG)
			{
				console._handle.document.body.innerHTML+=(s+"<br/><hr/>");
			}
		}
	};
}