/***********************************************************************
 *
 * Copyright (c) 2008-2010 ScanScout, Inc. All Rights Reserved.
 *
 */

// Special code to handle campaigns that require Javascdript (ex: widgets, surveys, etc)
// $Revision: $;
// @author: jburke



if (!self.ScanScout) ScanScout = {};

/******************************************************* START Utility Functions ********************************************/
	function getJsURL(theURL){
		var script = document.createElement('script');
		script.type = 'text/javascript';
		script.src = theURL;

		injectScript(script);
	}
	
	function injectScript(scriptObj){
		var head = document.getElementsByTagName('head').item(0);
		window.setTimeout(function() { head.appendChild(scriptObj) });	
	}
	
	


	/**************************** START FactorFG Utility ****************************/
	function _loadFactorFGSurvey(urlSuffix, gid, cre){
		var script = document.createElement('script');
		script.type = 'text/javascript';
		script.id ="FTG";
		script.src = "http://as1.suitesmart.com/" + urlSuffix + ".js";
		script.setAttribute("GID", gid);
		script.setAttribute("CRE", cre);
		injectScript(script);
	}		
	/**************************** END FactorFG Utility ****************************/		

/******************************************************* END Utility Functions ********************************************/




/******************************************************* START Surveys ********************************************/
	
	var surveyCampaignPubs = "|208|427|508|510|511|513|533|553|565|595|596|597|603|611|618|625|631|632|634|641|642|643|644|645|646|647|648|649|650|651|654|655|656|657|659|660|661|662|663|664|665|671|672|673|675|684|686|699|702|705|706|707|711|712|713|718|719|720|730|737|739|743|744|745|749|750|752|753|754|755|757|763|764|769|794|795|796|797|837|840|841|842|843|844|847|853|854|855|861|863|864|865|866|867|868|869|870|878|879|880|884|885|886|887|888|889|900|906|909|910|911|919|930|936|937|938|943|944|947|956|957|963|970|971|972|973|974|989|11002|11003|13002|13003|13004|14019|17003|17005|17006|17007|17008|17009|17010|17011|17012|17013|17014|17015|17016|17017|17018|17019|17020|17021|17022|17023|17024|17025|17026|17027|17028|17029|17030|17031|17032|17033|17034|17035|17036|17037|17038|17039|17040|17041|17042|17043|17044|17045|17046|17047|17048|17049|17050|17051|17052|17053|17054|17055|17056|17057|17058|17059|17060|17061|17062|17063|17064|17065|17066|17067|17068|17069|17070|17071|17072|17073|17074|17075|17076|17077|17078|17079|17080|17081|17082|17083|17084|17085|17086|17087|17088|17089|17090|17091|17092|17093|17094|17095|17096|17097|17098|17099|17100|17101|17102|17103|17104|17105|17106|17107|17108|17109|17110|17111|17112|17113|17114|17115|17116|17117|17118|17119|17120|17121|17122|17123|17124|17125|17126|17127|17128|17129|17130|17131|17132|17133|17134|17135|17136|17137|17138|17139|17140|17141|17142|17143|17144|17145|17146|17147|17148|17149|17150|17151|17152|17153|17154|17155|17156|17157|17158|17159|17160|17161|17162|17163|17164|17165|17166|17167|17168|17169|17170|17171|17172|17173|17174|17175|17176|17177|17178|17179|17180|17181|17182|17183|17184|17185|17186|17187|17188|17189|17190|17191|17192|17193|17194|17195|17196|17197|17198|17199|17200|17201|17202|17203|17204|17205|17206|17207|17208|17209|17210|17211|17212|17213|17214|17215|17216|17217|17218|17219|17220|17221|17222|17223|17224|17225|17226|17227|17228|17229|17230|17231|17232|17233|17234|17235|17236|17237|17238|17239|17240|17241|17242|17243|17244|17245|17246|17247|17248|17249|17250|17251|17252|17253|17254|17255|17256|17257|17258|17259|17260|17261|17262|17263|17264|17265|17266|17267|17268|17269|17270|17271|17272|17273|17274|17275|17276|17277|17278|17279|17280|17281|17282|17283|17284|17285|17286|17287|17288|17289|17290|17291|17292|17293|17294|17295|17296|17297|17298|17299|17300|17301|17302|17303|17304|17305|17306|17307|17308|17309|17310|17311|17312|17313|17314|17315|17316|17317|17318|17319|17320|17321|17322|17323|17324|17325|17326|17327|17328|17329|17330|17331|17332|17333|17334|17335|17336|17337|17338|17339|17340|17341|17342|17343|17344|17345|17346|17347|17348|17349|17350|17351|17352|17353|17354|17355|17356|17357|17358|17359|17360|17361|17362|17363|17364|17365|17366|17367|17368|17369|17370|17371|17372|17373|17374|17375|17376|17377|17378|17379|17380|17381|17382|17383|17384|17385|17386|17387|17388|17389|17390|17391|17392|17393|17394|17395|17396|17397|17398|17399|17401|17402|17403|17404|17405|17406|17407|17408|17409|17410|17411|17412|17413|17414|17415|17416|17417|17418|17419|17420|17421|17422|17423|17424|17425|17426|17427|17428|17429|17430|17431|17432|17433|17434|17435|17436|17437|17438|17439|17440|17441|17442|17443|17444|17445|17446|17447|17448|17449|17450|17451|17452|17453|17454|17455|17456|17457|17458|17459|17460|17461|17462|17463|17464|17465|17466|17467|17468|17469|17470|17471|17472|17473|17474|17475|17476|17477|17478|17479|17480|17481|18001|18002|18003|18004|18005|18006|20002|20003|20004|20005|26002|27002|27003|27004|27005|30002|30003|30004|30005|30006|30007|30008|31003|36032|38001|39004|39005|40004|40005|40006|40007|40008|41002|41003|41004|42002|43002|47002|49002|49003|52001|56002|56015|56018|56021|56022|56028|56033|56034|56035|56040|56043|56044|56045|56048|56049|56052|56057|56058|56061|56062|56066|56069|56070|56077|56081|56084|56086|56088|56089|56117|56120|56122|56123|56124|56125|56126|56127|56128|56129|56130|56186|56187|56191|56205|56207|56209|56210|56211|56215|56216|56217|56218|56219|56220|56221|56222|56223|56224|56227|56228|56229|56230|56231|56232|56233|56234|56235|56236|56237|56238|56239|56240|56241|56242|56247|56248|56249|56250|56251|56254|56255|56262|56266|56267|56270|56277|56278|56279|56280|56281|56282|56283|56284|56285|56286|56290|56291|56292|56293|56294|56295|56298|56299|56301|56302|56303|56311|56319|56320|56323|56332|56333|56334|56337|56338|56339|56340|56342|56344|56347|56348|56352|56362|56365|56366|56367|56369|56382|56394|56395|56396|56397|56398|56399|56400|56401|56402|56403|56404|56405|56406|56407|56409|56415|56416|56417|56418|56419|56420|56421|56422|56423|56424|56425|56426|56427|56428|56429|56430|56431|56432|56433|56434|56435|56436|56437|56438|56439|56440|56441|56442|56443|56444|56445|56446|56447|56448|56449|56450|56451|56452|56453|56454|56455|56456|56457|56459|56463|56464|56465|56466|56467|56468|56469|56470|56471|56472|56473|56474|56475|56476|56477|56485|56486|56487|56491|56492|56499|56500|56501|56506|56509|56510|56511|56517|56518|56519|56520|56521|56522|56523|56524|56525|56526|56527|56529|56535|56548|56551|56552|56553|56556|56561|56565|56567|56568|56569|56571|56572|56573|56574|56575|56576|56577|56578|56579|56580|56581|56582|56583|56584|56585|56588|56589|56592|56593|56597|56601|56603|56605|56607|56608|56609|56613|56614|56615|56616|56617|56618|56619|56620|56621|56622|56623|56625|56626|56628|56632|56636|56639|56643|56645|56646|56647|56648|56650|56653|56654|56655|56656|56658|56659|56660|56661|56662|56663|56664|56665|56666|56667|56668|56669|56670|56672|56673|56674|56675|56676|56677|56678|56679|56680|56681|56682|56683|56684|56685|56686|56687|56688|56689|56691|56954|56949|56950|56948|56945|56942|56941|56933|56921|56885|56888|56891|56892|56893|56894|56895|56896|56897|56898|56903|56904|56905|56907|56908|56909|56919|56921|56923|56929|56933|56941|56942|56945|56946|56948|56949|56950|56954|56956|56958|56960|56961|56963|56968|56971|56972|56976|56977|56978|56979|56980|56981|56982|56983|56984|56985|56986|56987|56988|56996|56997|57000|57002|57003|57006|57007|57008|57009|57010|57011|57012|57017|57022|57023|57024|57025|57026|57027|57028|57029|57031|57035|57036|57038|57040|57046|57047|57049|57050|57054|57060|57074|57076|57077|57078|57079|57080|57081|57082|57083|57084|57085|57086|57087|57088|57089|57090|57091|57092|57093|57094|57095|57096|57097|57098|57099|57100|57101|57103|57104|57105|57106|57110|57113|57115|57116|57117|57118|57119|57120|57122|57123|57124|57125|57126|57127|57132|57135|57136|57138|57139|57140|57141|57142|57143|57146|57147|57148|57149|57159|57161|57162|57163|57164|57165|57167|57168|57170|57171|57173|57174|57175|57176|57184|57186|57189|57190|57191|57192|57193|57194|57202|57203|57204|57205|57206|57207|57212|57213|57214|57215|57216|57217|57218|57219|57223|57227|57233|57234|57235|57237|57239|57241|57243|57249|57250|57256|57257|57258|57259|57260|57266|57268|57270|57272|57273|57274|57275|57276|57277|57282|57285|57287|57290|57294|57296|57297|57298|57299|57300|57301|57305|57316|57318|57319|57324|57327|57329|57330|57331|57332|57333|57334|57335|57336|57337|57338|57339|57340|57341|57342|57343|57344|57345|57346|57347|57349|57350|57352|57353|57354|57355|57356|57358|57359|57361|57363|57366|57367|57368|57369|57370|57371|57373|57374|57375|57376|57377|57378|57379|57380|57381|57382|57384|57385|57387|57388|57389|57390|57392|57395|57396|57398|57399|57400|57401|57402|57403|57404|57405|57406|57407|57408|57409|57410|57411|57412|57413|57416|57417|57419|57420|57421|57422|57423|57425|57426|57429|57430|57431|57433|57435|57439|57441|57442|57443|57444|57445|57446|57448|57451|57452|57453|57454|57455|57456|57457|57458|57459|57460|57462|57464|57466|57467|57468|57469|57470|57471|57472|57473|57474|57475|57476|57477|57478|57479|57481|57482|57484|57486|57487|57488|57489|57491|57495|57496|57498|57499|57505|57507|57512|57516|57519|57522|57532|57535|57540|57541|57542|57545|57548|57553|57554|57555|57561|57562|57566|57568|57572|57574|57577|57578|57579|57580|57581|57582|57583|57584|57585|57586|57587|57588|57589|57590|57591|57592|57593|57594|57595|57596|57597|57598|57599|57600|57601|57602|57603|57604|57605|57606|57607|57609|57610|57611|57612|57613|57614|57615|57616|57617|57618|57619|57620|57624|57635|57638|57655|57656|57657|57659";
	var surveyCampaignIds = ["1276573", "1276573", "1276710", "1276712", "1276711", "1276788", "1276789","1276792", "1276947", "1276948", "1288453", "1276953", "1276963", "1276964", "1288437", "1288439", "1288436", "1288438","1288412", "1343476", "1343496", "1288461", "1343453", "1343450", "1324442", "1343558", "1343575", "1343539", "1343540", "1276687","1324377","1324379","1324382","1324383","1343628","1343629", "1343548", "1343648", "1343706","1343705","1343704","1343707","1343703"]; 
	



	ScanScout.runCampaignFunctionality = function(publisherId, campaignId, adPosition){
		/*		
		if (surveyCampaignPubs.indexOf("|" + publisherId + "|") > -1){
			ss_campaignDebug('surveyCampaignIds: ' + surveyCampaignIds);
			ss_campaignDebug('surveyCampaignIds.length: ' + surveyCampaignIds.length);
			for (var i = 0; i < surveyCampaignIds.length; i++){
			  var _currentCampaignId = surveyCampaignIds[i];
			  ss_campaignDebug('surveyCampaignIds[' + i + ']' + surveyCampaignIds[i]);
			  if (_currentCampaignId == campaignId){
				ScanScout.callTestCampaignSurvey(_currentCampaignId, adPosition);
			  } else {
			 	ss_campaignDebug('this campaign is not ' + _currentCampaignId + ' so call control');
				ScanScout.callControlCampaignSurvey(_currentCampaignId, adPosition);
			  }
			}

		}
		*/
		//do nothing. Managed by the server
		
	}
	ScanScout.callTestCampaignSurvey = function(campaignId, adPosition){	//Only call test function if the current campaign is a survey campaign
		//if (adPosition == 1){  //for now, just run these on the first ad in the schedule
			ss_campaignDebug('call _callSsCampaignTestSurvey_' + campaignId);
			try {
				if(navigator.appName.indexOf("Microsoft") != -1) {
					window['_callSsCampaignTestSurvey_' + campaignId](adPosition);
				} else {
					document['_callSsCampaignTestSurvey_' + campaignId](adPosition);
				}	
			} catch (error){
				ss_campaignDebug('callTestCampaignSurvey: ' + error.message)
			}
		//}
	};
	ScanScout.callControlCampaignSurvey = function(campaignId, adPosition){
		if (adPosition == 1){  //for now, just run these on the first ad in the schedule
			ss_campaignDebug('call _callSsCampaignControlSurvey_' + campaignId);
			try {
				if(navigator.appName.indexOf("Microsoft") != -1) {
					window['_callSsCampaignControlSurvey_' + campaignId](adPosition);
				} else {
					document['_callSsCampaignControlSurvey_' + campaignId](adPosition);
				}							
			} catch (error){
				ss_campaignDebug('callControlCampaignSurvey: ' + error.message)
			}
		}
	}
	

	/********** Start Livescribe Campaigns *******/
	var _hasCalledTestSurvey_1276792= false;
	function _callSsCampaignTestSurvey_1276792(adPosition){
		if (!_hasCalledTestSurvey_1276792){
			getJsURL('http://ar.voicefive.com/bmx3/broker.pli?pid=p59844736&PRAd=60056&AR_C=656');
			_hasCalledTestSurvey_1276792 = true;
		}
	}
	var _hasCalledControlSurvey_1276792= false;
	function _callSsCampaignControlSurvey_1276792(adPosition){
		if (!_hasCalledTestSurvey_1276792){
			_hasCalledTestSurvey_1276792 = true;
		}	
	}
	/********** End Livescribe Campaigns *******/

	/********** Start Post Honey Bunches Campaigns (7/5 - 8/8) *******/
	var _hasCalledTestSurvey_1276573= false;
	function _callSsCampaignTestSurvey_1276573(adPosition){
		if (!_hasCalledTestSurvey_1276573){
			getJsURL('http://amch.questionmarket.com/adsc/d724324/16/752263/randm.js');
			_hasCalledTestSurvey_1276573 = true;
		}
	}
	var _hasCalledControlSurvey_1276573= false;
	function _callSsCampaignControlSurvey_1276573(adPosition){
		if (!_hasCalledTestSurvey_1276573){
			getJsURL('http://amch.questionmarket.com/adsc/d724324/16/726813/randm.js');
			_hasCalledTestSurvey_1276573 = true;
		}	
	}	
	


	var _hasCalledTestSurvey_1276710= false;
	function _callSsCampaignTestSurvey_1276710(adPosition){
		if (!_hasCalledTestSurvey_1276710){
			getJsURL('http://amch.questionmarket.com/adsc/d724324/16/752264/randm.js');
			_hasCalledTestSurvey_1276710 = true;
		}
	}
	var _hasCalledControlSurvey_1276710= false;
	function _callSsCampaignControlSurvey_1276710(adPosition){
		if (!_hasCalledTestSurvey_1276570){
			getJsURL('http://amch.questionmarket.com/adsc/d724324/16/726813/randm.js');
			_hasCalledTestSurvey_1276570 = true;
		}	
	}
	

	var _hasCalledTestSurvey_1276712= false;
	function _callSsCampaignTestSurvey_1276712(adPosition){
		if (!_hasCalledTestSurvey_1276712){
			getJsURL('http://amch.questionmarket.com/adsc/d724324/16/752265/randm.js');
			_hasCalledTestSurvey_1276712 = true;
		}
	}
	var _hasCalledControlSurvey_1276712= false;
	function _callSsCampaignControlSurvey_1276712(adPosition){
		if (!_hasCalledTestSurvey_1276712){
			getJsURL('http://amch.questionmarket.com/adsc/d724324/16/726813/randm.js');
			_hasCalledTestSurvey_1276572 = true;
		}	
	}
	
	var _hasCalledTestSurvey_1276711= false;
	function _callSsCampaignTestSurvey_1276711(adPosition){
		if (!_hasCalledTestSurvey_1276711){
			getJsURL('http://amch.questionmarket.com/adsc/d724324/16/752266/randm.js');
			_hasCalledTestSurvey_1276711 = true;
		}
	}
	var _hasCalledControlSurvey_1276711= false;
	function _callSsCampaignControlSurvey_1276711(adPosition){
		if (!_hasCalledTestSurvey_1276571){
			getJsURL('http://amch.questionmarket.com/adsc/d724324/16/726813/randm.js');
			_hasCalledTestSurvey_1276571 = true;
		}	
	}	
	/********** End Post Honey Bunches Campaigns (7/5 - 8/8) *******/	

	/********** Start HP Campaigns *******/
	var _hasCalledTestSurvey_1276788= false;
	function _callSsCampaignTestSurvey_1276788(adPosition){
		if (!_hasCalledTestSurvey_1276788){
			getJsURL('http://amch.questionmarket.com/adsc/d747416/11/755592/randm.js');
			_hasCalledTestSurvey_1276788 = true;
		}
	}
	var _hasCalledControlSurvey_1276788= false;
	function _callSsCampaignControlSurvey_1276788(adPosition){
		if (!_hasCalledTestSurvey_1276788){
			getJsURL('http://amch.questionmarket.com/adsc/d747416/11/748729/randm.js');
			_hasCalledTestSurvey_1276788 = true;
		}	
	}


	var _hasCalledTestSurvey_1276789= false;
	function _callSsCampaignTestSurvey_1276789(adPosition){
		if (!_hasCalledTestSurvey_1276789){
			getJsURL('http://amch.questionmarket.com/adsc/d747416/11/755589/randm.js');
			_hasCalledTestSurvey_1276789 = true;
		}
	}
	var _hasCalledControlSurvey_1276789= false;
	function _callSsCampaignControlSurvey_1276789(adPosition){
		if (!_hasCalledTestSurvey_1276789){
			getJsURL('http://amch.questionmarket.com/adsc/d747416/11/748729/randm.js');
			_hasCalledTestSurvey_1276789 = true;
		}	
	}


	/********** End HP Campaigns *******/

	
	
	
	/********** Start Buick Regal Campaigns *******/
	var _hasCalledTestSurvey_1343628= false;
	function _callSsCampaignTestSurvey_1343628(adPosition){
		if (!_hasCalledTestSurvey_1343628){
			getJsURL('http://amch.questionmarket.com/adsc/d759769/11/769070/randm.js');
			_hasCalledTestSurvey_1343628 = true;
		}
	}
	var _hasCalledControlSurvey_1343628= false;
	function _callSsCampaignControlSurvey_1343628(adPosition){
		if (!_hasCalledControlSurvey_1343628){
			_hasCalledControlSurvey_1343628 = true;
		}	
	}	
	
	var _hasCalledTestSurvey_1343629= false;
	function _callSsCampaignTestSurvey_1343629(adPosition){
		if (!_hasCalledTestSurvey_1343629){
			getJsURL('http://amch.questionmarket.com/adsc/d759769/11/769070/randm.js');
			_hasCalledTestSurvey_1343629 = true;
		}
	}
	var _hasCalledControlSurvey_1343629= false;
	function _callSsCampaignControlSurvey_1343629(adPosition){
		if (!_hasCalledControlSurvey_1343629){
			_hasCalledControlSurvey_1343629 = true;
		}	
	}
	/********** End Buick Regal Campaigns *******/
	
	
	/********** Start Olive Garden Campaigns *******/
	
	var _hasCalledTestSurvey_1276947= false;
	function _callSsCampaignTestSurvey_1276947(adPosition){
		if (!_hasCalledTestSurvey_1276947){
			getJsURL('http://amch.questionmarket.com/adsc/d763769/11/775951/randm.js');
			_hasCalledTestSurvey_1276947 = true;
		}
	}
	var _hasCalledControlSurvey_1276947= false;
	function _callSsCampaignControlSurvey_1276947(adPosition){
		if (!_hasCalledControlSurvey_1276947){
			getJsURL('http://amch.questionmarket.com/adsc/d763769/11/770950/randm.js');
			_hasCalledControlSurvey_1276947 = true;
		}	
	}	
	
	var _hasCalledTestSurvey_1276948= false;
	function _callSsCampaignTestSurvey_1276948(adPosition){
		if (!_hasCalledTestSurvey_1276948){
			getJsURL('http://amch.questionmarket.com/adsc/d763769/11/775951/randm.js');
			_hasCalledTestSurvey_1276948 = true;
		}
	}
	var _hasCalledControlSurvey_1276948= false;
	function _callSsCampaignControlSurvey_1276948(adPosition){
		if (!_hasCalledControlSurvey_1276948){
			getJsURL('http://amch.questionmarket.com/adsc/d763769/11/770950/randm.js');		
			_hasCalledControlSurvey_1276948 = true;
		}	
	}
	
	var _hasCalledTestSurvey_1288453= false;
	function _callSsCampaignTestSurvey_1288453(adPosition){
		if (!_hasCalledTestSurvey_1288453){
			getJsURL('http://amch.questionmarket.com/adsc/d763769/11/775951/randm.js');
			_hasCalledTestSurvey_1288453 = true;
		}
	}
	var _hasCalledControlSurvey_1288453= false;
	function _callSsCampaignControlSurvey_1288453(adPosition){
		if (!_hasCalledControlSurvey_1288453){
			getJsURL('http://amch.questionmarket.com/adsc/d763769/11/770950/randm.js');
			_hasCalledControlSurvey_1288453 = true;
		}	
	}	
	
	
	var _hasCalledTestSurvey_1343453= false;
	function _callSsCampaignTestSurvey_1343453(adPosition){
		if (!_hasCalledTestSurvey_1343453){
			getJsURL('http://amch.questionmarket.com/adsc/d763769/11/775951/randm.js');
			_hasCalledTestSurvey_1343453 = true;
		}
	}
	var _hasCalledControlSurvey_1343453= false;
	function _callSsCampaignControlSurvey_1343453(adPosition){
		if (!_hasCalledControlSurvey_1343453){
			getJsURL('http://amch.questionmarket.com/adsc/d763769/11/770950/randm.js');
			_hasCalledControlSurvey_1343453 = true;
		}	
	}	

	var _hasCalledTestSurvey_1343450= false;
	function _callSsCampaignTestSurvey_1343450(adPosition){
		if (!_hasCalledTestSurvey_1343450){
			getJsURL('http://amch.questionmarket.com/adsc/d763769/11/775951/randm.js');
			_hasCalledTestSurvey_1343450 = true;
		}
	}
	var _hasCalledControlSurvey_1343450= false;
	function _callSsCampaignControlSurvey_1343450(adPosition){
		if (!_hasCalledControlSurvey_1343450){
			getJsURL('http://amch.questionmarket.com/adsc/d763769/11/770950/randm.js');
			_hasCalledControlSurvey_1343450 = true;
		}	
	}	
	
	
	
	
	/********** End Olive Garden Campaigns *******/	


	/********** Start Bing Campaigns *******/
	
	var _hasCalledTestSurvey_1276963= false;
	function _callSsCampaignTestSurvey_1276963(adPosition){
		if (!_hasCalledTestSurvey_1276963){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=169220');
			_hasCalledTestSurvey_1276963 = true;
		}
	}
	var _hasCalledControlSurvey_1276963= false;
	function _callSsCampaignControlSurvey_1276963(adPosition){
		if (!_hasCalledControlSurvey_1276963){
			_hasCalledControlSurvey_1276963 = true;
		}	
	}	
	
	var _hasCalledTestSurvey_1276964= false;
	function _callSsCampaignTestSurvey_1276964(adPosition){
		if (!_hasCalledTestSurvey_1276964){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=169221');
			_hasCalledTestSurvey_1276964 = true;
		}
	}
	var _hasCalledControlSurvey_1276964= false;
	function _callSsCampaignControlSurvey_1276964(adPosition){
		if (!_hasCalledControlSurvey_1276964){
			_hasCalledControlSurvey_1276964 = true;
		}	
	}	
	
	
	var _hasCalledTestSurvey_1324377= false;
	function _callSsCampaignTestSurvey_1324377(adPosition){
		if (!_hasCalledTestSurvey_1324377){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=171146');
			_hasCalledTestSurvey_1324377 = true;
		}
	}
	var _hasCalledControlSurvey_1324377= false;
	function _callSsCampaignControlSurvey_1324377(adPosition){
		if (!_hasCalledControlSurvey_1324377){
			_hasCalledControlSurvey_1324377 = true;
		}	
	}
	
	var _hasCalledTestSurvey_1324379= false;
	function _callSsCampaignTestSurvey_1324379(adPosition){
		if (!_hasCalledTestSurvey_1324379){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=171146');
			_hasCalledTestSurvey_1324379 = true;
		}
	}
	var _hasCalledControlSurvey_1324379= false;
	function _callSsCampaignControlSurvey_1324379(adPosition){
		if (!_hasCalledControlSurvey_1324379){
			_hasCalledControlSurvey_1324379 = true;
		}	
	}
	
	var _hasCalledTestSurvey_1324382= false;
	function _callSsCampaignTestSurvey_1324382(adPosition){
		if (!_hasCalledTestSurvey_1324382){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=171146');
			_hasCalledTestSurvey_1324382 = true;
		}
	}
	var _hasCalledControlSurvey_1324382= false;
	function _callSsCampaignControlSurvey_1324382(adPosition){
		if (!_hasCalledControlSurvey_1324382){
			_hasCalledControlSurvey_1324382 = true;
		}	
	}
	
	var _hasCalledTestSurvey_1324383= false;
	function _callSsCampaignTestSurvey_1324383(adPosition){
		if (!_hasCalledTestSurvey_1324383){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=171146');
			_hasCalledTestSurvey_1324383 = true;
		}
	}
	var _hasCalledControlSurvey_1324383= false;
	function _callSsCampaignControlSurvey_1324383(adPosition){
		if (!_hasCalledControlSurvey_1324383){
			_hasCalledControlSurvey_1324383 = true;
		}	
	}	
	
		
	/********** End Bing Campaigns *******/	
	
	
	
	/********** Start Post Honey Bunches Campaigns (8/16- 9/19) *******/
	

	var _hasCalledTestSurvey_1288436= false;
	function _callSsCampaignTestSurvey_1288436(adPosition){
		if (!_hasCalledTestSurvey_1288436){
			getJsURL('http://amch.questionmarket.com/adsc/d724324/27/752266/randm.js');
			_hasCalledTestSurvey_1288436 = true;
		}
	}
	var _hasCalledControlSurvey_1288436= false;
	function _callSsCampaignControlSurvey_1288436(adPosition){
		if (!_hasCalledControlSurvey_1288436){
			getJsURL('http://amch.questionmarket.com/adsc/d724324/27/726813/randm.js');
			_hasCalledControlSurvey_1288436 = true;
		}	
	}	

	var _hasCalledTestSurvey_1288437= false;
	function _callSsCampaignTestSurvey_1288437(adPosition){
		if (!_hasCalledTestSurvey_1288437){
			getJsURL('http://amch.questionmarket.com/adsc/d724324/27/752268/randm.js');
			_hasCalledTestSurvey_1288437 = true;
		}
	}
	var _hasCalledControlSurvey_1288437= false;
	function _callSsCampaignControlSurvey_1288437(adPosition){
		if (!_hasCalledControlSurvey_1288437){
			getJsURL('http://amch.questionmarket.com/adsc/d724324/27/726813/randm.js');
			_hasCalledControlSurvey_1288437 = true;
		}	
	}
	
	var _hasCalledTestSurvey_1288438= false;
	function _callSsCampaignTestSurvey_1288438(adPosition){
		if (!_hasCalledTestSurvey_1288438){
			getJsURL('http://amch.questionmarket.com/adsc/d724324/27/752269/randm.js');
			_hasCalledTestSurvey_1288438 = true;
		}
	}
	var _hasCalledControlSurvey_1288438= false;
	function _callSsCampaignControlSurvey_1288438(adPosition){
		if (!_hasCalledControlSurvey_1288438){
			getJsURL('http://amch.questionmarket.com/adsc/d724324/27/726813/randm.js');
			_hasCalledControlSurvey_1288438 = true;
		}	
	}
	
	var _hasCalledTestSurvey_1288439= false;
	function _callSsCampaignTestSurvey_1288439(adPosition){
		if (!_hasCalledTestSurvey_1288439){
			getJsURL('http://amch.questionmarket.com/adsc/d724324/27/752289/randm.js');
			_hasCalledTestSurvey_1288439 = true;
		}
	}
	var _hasCalledControlSurvey_1288439= false;
	function _callSsCampaignControlSurvey_1288439(adPosition){
		if (!_hasCalledControlSurvey_1288439){
			getJsURL('http://amch.questionmarket.com/adsc/d724324/27/726813/randm.js');
			_hasCalledControlSurvey_1288439 = true;
		}	
	}
	

	/********** End Post Honey Bunches Campaigns (8/16- 9/19) *******/	
	
	


	/********** Start MS Bing *******/
	var _hasCalledTestSurvey_1288412= false;
	function _callSsCampaignTestSurvey_1288412(adPosition){
		if (!_hasCalledTestSurvey_1288412){
			_hasCalledTestSurvey_1288412 = true;
		}	
	}
	var _hasCalledControlSurvey_1288412= false;
	function _callSsCampaignControlSurvey_1288412(adPosition){
		if (!_hasCalledControlSurvey_1288412){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=169222');
			_hasCalledControlSurvey_1288412 = true;
		}	
	}		
	
	var _hasCalledTestSurvey_1343476= false;
	function _callSsCampaignTestSurvey_1343476(adPosition){
		if (!_hasCalledTestSurvey_1343476){
			_hasCalledTestSurvey_1343476 = true;
		}	
	}
	var _hasCalledControlSurvey_1343476= false;
	function _callSsCampaignControlSurvey_1343476(adPosition){
		if (!_hasCalledControlSurvey_1343476){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=169223');
			_hasCalledControlSurvey_1343476 = true;
		}	
	}
	
	
	var _hasCalledTestSurvey_1343496= false;
	function _callSsCampaignTestSurvey_1343496(adPosition){
		if (!_hasCalledTestSurvey_1343496){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=169220');
			_hasCalledTestSurvey_1343496 = true;
		}	
	}
	var _hasCalledControlSurvey_1343496= false;
	function _callSsCampaignControlSurvey_1343496(adPosition){
		if (!_hasCalledControlSurvey_1343496){
			_hasCalledControlSurvey_1343496 = true;
		}	
	}	
	
	var _hasCalledTestSurvey_1288461= false;
	function _callSsCampaignTestSurvey_1288461(adPosition){
		if (!_hasCalledTestSurvey_1288461){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=169221');
			_hasCalledTestSurvey_1288461 = true;
		}	
	}
	var _hasCalledControlSurvey_1288461= false;
	function _callSsCampaignControlSurvey_1288461(adPosition){
		if (!_hasCalledControlSurvey_1288461){
			_hasCalledControlSurvey_1288461 = true;
		}	
	}
	
	/********** End MS Bing *******/




	/********** Start Pizza Hut *******/
	var _hasCalledTestSurvey_1343558= false;
	function _callSsCampaignTestSurvey_1343558(adPosition){
		if (!_hasCalledTestSurvey_1343558){
			getJsURL('http://amch.questionmarket.com/adsc/d793570/3/793591/randm.js');		
			_hasCalledTestSurvey_1343558 = true;
		}	
	}
	var _hasCalledControlSurvey_1343558= false;
	function _callSsCampaignControlSurvey_1343558(adPosition){
		if (!_hasCalledControlSurvey_1343558){	
			_hasCalledControlSurvey_1343558 = true;
		}	
	}
	
	var _hasCalledTestSurvey_1343575= false;
	function _callSsCampaignTestSurvey_1343575(adPosition){
		if (!_hasCalledTestSurvey_1343575){
			getJsURL('http://amch.questionmarket.com/adsc/d793570/3/793590/randm.js');
			_hasCalledTestSurvey_1343575 = true;
		}	
	}
	var _hasCalledControlSurvey_1343575= false;
	function _callSsCampaignControlSurvey_1343575(adPosition){
		if (!_hasCalledControlSurvey_1343575){	
			_hasCalledControlSurvey_1343575 = true;
		}	
	}	
	/********** End Pizza Hut *******/


	/********** Start Eureka *******/
	var _hasCalledTestSurvey_1343539= false;
	function _callSsCampaignTestSurvey_1343539(adPosition){
		if (!_hasCalledTestSurvey_1343539){
			_loadFactorFGSurvey('96930/G11400', '11400', 'E4');	
			_hasCalledTestSurvey_1343539 = true;
		}	
	}
	var _hasCalledControlSurvey_1343539= false;
	function _callSsCampaignControlSurvey_1343539(adPosition){
		if (!_hasCalledControlSurvey_1343539){
			_loadFactorFGSurvey('96930/G11396', '11396', 'C0');
			_hasCalledControlSurvey_1343539 = true;
		}	
	}
	var _hasCalledTestSurvey_1343540= false;
	function _callSsCampaignTestSurvey_1343540(adPosition){
		if (!_hasCalledTestSurvey_1343540){	
			_loadFactorFGSurvey('96930/G11400', '11400', 'E4');
			_hasCalledTestSurvey_1343540 = true;
		}	
	}
	var _hasCalledControlSurvey_1343540= false;
	function _callSsCampaignControlSurvey_1343540(adPosition){
		if (!_hasCalledControlSurvey_1343540){
			_loadFactorFGSurvey('96930/G11396', '11396', 'C0');
			_hasCalledControlSurvey_1343540 = true;
		}	
	}
	/********** End Eureka *******/
	
	/********** Start Allybank *******/
	var _hasCalledTestSurvey_1276687= false;
	function _callSsCampaignTestSurvey_1276687(adPosition){
		if (!_hasCalledTestSurvey_1276687){
			getJsURL('http://amch.questionmarket.com/adsc/d647401/46/799689/randm.js');
			_hasCalledTestSurvey_1276687 = true;
		}	
	}
	var _hasCalledControlSurvey_1276687= false;
	function _callSsCampaignControlSurvey_1276687(adPosition){
		if (!_hasCalledControlSurvey_1276687){
			getJsURL('http://amch.questionmarket.com/adsc/d647401/46/794570/randm.js');	
			_hasCalledControlSurvey_1276687 = true;
		}	
	}
	/********** Complete Allybank *******/
	
	
	/********** Start Subaru *******/
	var _hasCalledTestSurvey_1343548= false;
	function _callSsCampaignTestSurvey_1343548(adPosition){
		if (!_hasCalledTestSurvey_1343548){
			getJsURL('http://amch.questionmarket.com/adsc/d798609/10/805370/randm.js');
			_hasCalledTestSurvey_1343548 = true;
		}	
	}
	var _hasCalledControlSurvey_1343548= false;
	function _callSsCampaignControlSurvey_1343548(adPosition){
		if (!_hasCalledControlSurvey_1343548){
			getJsURL('http://amch.questionmarket.com/adsc/d798609/10/805369/randm.js');	
			_hasCalledControlSurvey_1343548 = true;
		}	
	}
	
	var _hasCalledTestSurvey_1343648= false;
	function _callSsCampaignTestSurvey_1343648(adPosition){
		if (!_hasCalledTestSurvey_1343648){
			getJsURL('http://amch.questionmarket.com/adsc/d798609/10/805370/randm.js');
			_hasCalledTestSurvey_1343648 = true;
		}	
	}
	var _hasCalledControlSurvey_1343648= false;
	function _callSsCampaignControlSurvey_1343648(adPosition){
		if (!_hasCalledControlSurvey_1343648){
			getJsURL('http://amch.questionmarket.com/adsc/d798609/10/805369/randm.js');	
			_hasCalledControlSurvey_1343648 = true;
		}	
	}	
	/********** Complete Subaru  *******/	
	
	
	/********** Start GE Ecoimagination  *******/
	var _hasCalledTestSurvey_1343703= false;
	function _callSsCampaignTestSurvey_1343703(adPosition){
		if (!_hasCalledTestSurvey_1343703){
			_hasCalledTestSurvey_1343703 = true;
		}	
	}
	var _hasCalledControlSurvey_1343703= false;
	function _callSsCampaignControlSurvey_1343703(adPosition){
		if (!_hasCalledControlSurvey_1343703){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=172179');	
			_hasCalledControlSurvey_1343703 = true;
		}	
	}
	
	var _hasCalledTestSurvey_1343704= false;
	function _callSsCampaignTestSurvey_1343704(adPosition){
		if (!_hasCalledTestSurvey_1343704){
			_hasCalledTestSurvey_1343704 = true;
		}	
	}
	var _hasCalledControlSurvey_1343704= false;
	function _callSsCampaignControlSurvey_1343704(adPosition){
		if (!_hasCalledControlSurvey_1343704){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=172179');	
			_hasCalledControlSurvey_1343704 = true;
		}	
	}

	var _hasCalledTestSurvey_1343705= false;
	function _callSsCampaignTestSurvey_1343705(adPosition){
		if (!_hasCalledTestSurvey_1343705){
			_hasCalledTestSurvey_1343705 = true;
		}	
	}
	var _hasCalledControlSurvey_1343705= false;
	function _callSsCampaignControlSurvey_1343705(adPosition){
		if (!_hasCalledControlSurvey_1343705){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=172179');	
			_hasCalledControlSurvey_1343705 = true;
		}	
	}
	
	var _hasCalledTestSurvey_1343706= false;
	function _callSsCampaignTestSurvey_1343706(adPosition){
		if (!_hasCalledTestSurvey_1343706){
			_hasCalledTestSurvey_1343706 = true;
		}	
	}
	var _hasCalledControlSurvey_1343706= false;
	function _callSsCampaignControlSurvey_1343706(adPosition){
		if (!_hasCalledControlSurvey_1343706){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=172179');	
			_hasCalledControlSurvey_1343706 = true;
		}	
	}


	var _hasCalledTestSurvey_1343707= false;
	function _callSsCampaignTestSurvey_1343707(adPosition){
		if (!_hasCalledTestSurvey_1343707){
			_hasCalledTestSurvey_1343707 = true;
		}	
	}
	var _hasCalledControlSurvey_1343707= false;
	function _callSsCampaignControlSurvey_1343707(adPosition){
		if (!_hasCalledControlSurvey_1343707){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=172179');	
			_hasCalledControlSurvey_1343707 = true;
		}	
	}
	
	
	var _hasCalledTestSurvey_1343580= false;
	function _callSsCampaignTestSurvey_1343580(adPosition){
		if (!_hasCalledTestSurvey_1343580){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=171893');
			_hasCalledTestSurvey_1343580 = true;
		}	
	}
	var _hasCalledControlSurvey_1343580= false;
	function _callSsCampaignControlSurvey_1343580(adPosition){
		if (!_hasCalledControlSurvey_1343580){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=167465');	
			_hasCalledControlSurvey_1343580 = true;
		}	
	}
	
	
	var _hasCalledTestSurvey_1343581= false;
	function _callSsCampaignTestSurvey_1343581(adPosition){
		if (!_hasCalledTestSurvey_1343581){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=171893');
			_hasCalledTestSurvey_1343581 = true;
		}	
	}
	var _hasCalledControlSurvey_1343581= false;
	function _callSsCampaignControlSurvey_1343581(adPosition){
		if (!_hasCalledControlSurvey_1343581){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=167465');	
			_hasCalledControlSurvey_1343581 = true;
		}	
	}
	
	var _hasCalledTestSurvey_1288418= false;
	function _callSsCampaignTestSurvey_1288418(adPosition){
		if (!_hasCalledTestSurvey_1288418){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=171893');
			_hasCalledTestSurvey_1288418 = true;
		}	
	}
	var _hasCalledControlSurvey_1288418= false;
	function _callSsCampaignControlSurvey_1288418(adPosition){
		if (!_hasCalledControlSurvey_1288418){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=167465');	
			_hasCalledControlSurvey_1288418 = true;
		}	
	}
	
	
	var _hasCalledTestSurvey_1343522= false;
	function _callSsCampaignTestSurvey_1343522(adPosition){
		if (!_hasCalledTestSurvey_1343522){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=171893');
			_hasCalledTestSurvey_1343522 = true;
		}	
	}
	var _hasCalledControlSurvey_1343522= false;
	function _callSsCampaignControlSurvey_1343522(adPosition){
		if (!_hasCalledControlSurvey_1343522){
			getJsURL('http://core.insightexpressai.com/adServer/adServerESI.aspx?bannerID=167465');	
			_hasCalledControlSurvey_1343522 = true;
		}	
	}	
	/********** Complete GE Ecoimagination  *******/		


/******************************************************* END Surveys ********************************************/


/******************************************************* START ScanScoutLogger ********************************************/
if (!self.ScanScoutLogger) ScanScoutLogger = {};

ScanScoutLogger.logMsg = function(logEntry)
// Display log entry in popup.
{
	var now = new Date();
	var theTime = ScanScoutLogger.sprintf("%d:%'02d:%'02d:%'03d", now.getHours(), now.getMinutes(), now.getSeconds(), now.getMilliseconds());

	logEntry = theTime + ' | ' + logEntry;
	var debugElement = ScanScoutLogger.getElement('ss_debug');
	if (debugElement && debugElement.style.display != 'none')
	{
		debugElement.value = logEntry + '\n' + debugElement.value;
	}
	else if (ScanScoutLogger.debugging)
	{
		// Accumulate it for later, truncated to 5K chars.
		// TODO: append to array instead.
		ScanScoutLogger.initialLog = (ScanScoutLogger.initialLog || '').substring(0, 5000);
		ScanScoutLogger.initialLog = logEntry + '\n' + (ScanScoutLogger.initialLog || '');
	}
};

ScanScoutLogger.getElement = function (idOrName)
// Get an element identified by id or name attribute.
{
	var element = document.getElementById(idOrName);
	if (element) return element;
	var elements = document.getElementsByName(idOrName);
	if (elements && elements.length > 0) return elements[0];
};

ScanScoutLogger.init = function (e)
{
	// Append a new DIV to the body. 
	var debugWrapper = document.createElement('div');
	debugWrapper.id = 'ss_debug_wrapper';
	debugWrapper.style.position = 'absolute';
	debugWrapper.style.top = '100px';
	debugWrapper.style.left = '100px';
	debugWrapper.style.width = '900px';
	debugWrapper.style.border = '2px outset';
	debugWrapper.style.backgroundColor = 'lightblue'; 
	debugWrapper.style.padding = '2px';
	debugWrapper.style.fontSize = 'small';

	var body = document.getElementsByTagName('body').item(0);
	body.appendChild(debugWrapper);

	var debugHTML =
		'<div id="ss_debug_titlebar" style="padding:2px" title="Drag slowly"><nobr>' +
		'ScanScout Debugger' +
		'&nbsp;&nbsp;&nbsp;' +
		'<button onClick="ScanScoutLogger.toggleShowDebug(); return false;" title="Hide or Show the log">Hide/Show</button>' +
		'<button onClick="ScanScoutLogger.clearDebug(); return false;" title="Clear the log">Clear</button>' +
		'&nbsp;&nbsp;&nbsp;' +

		'</nobr></div>' +
		'<textarea id="ss_debug" cols=120 rows=20 style="width:100%">' + 
		(ScanScoutLogger.initialLog || '') + 
		'</textarea>';
	debugWrapper.innerHTML = debugHTML;

	var debugTitlebar = document.getElementById('ss_debug_titlebar');
	debugTitlebar.style.cursor = 'move';
	debugTitlebar.onmousedown = ScanScoutLogger.debugDragStart;
	debugTitlebar.onmousemove=ScanScoutLogger.debugDrag;
	debugTitlebar.onmouseup=ScanScoutLogger.debugDragEnd;

}

ScanScoutLogger.toggleShowDebug = function ()
{
	var log = document.getElementById('ss_debug');
	var display = log.style.display;
	log.style.display = (display == 'none' ? 'block' : 'none');
}


ScanScoutLogger.clearDebug = function ()
{
	document.getElementById('ss_debug').value = '';
}

ScanScoutLogger.debugDragStart = function (e)
{
	ScanScoutLogger.debugDrag.dragging = true;
	if (document.body.attachEvent)
		document.body.attachEvent("move", ScanScoutLogger.debugDrag)
	else
		document.body.addEventListener("move", ScanScoutLogger.debugDrag, false);

	e = e || window.event;	
	ScanScoutLogger.getMouseXY(e);

	var debugWrapper = document.getElementById('ss_debug_wrapper');
	if (!debugWrapper) return;
	
	debugWrapper.style.top;
	ScanScoutLogger.debugDrag.xOffset = ScanScoutLogger.debugDrag.x - debugWrapper.offsetLeft;
	ScanScoutLogger.debugDrag.yOffset = ScanScoutLogger.debugDrag.y - debugWrapper.offsetTop;
}

ScanScoutLogger.getMouseXY = function (e)
{
  	// grab the x-y pos.s if browser is NS
	ScanScoutLogger.debugDrag.x = e.pageX;
	ScanScoutLogger.debugDrag.y = e.pageY;
	if (ScanScoutLogger.getBrowserType() == 0)
 	{ 
		// grab the x-y pos.s if browser is IE
		ScanScoutLogger.debugDrag.x = e.clientX + document.body.scrollLeft;
		ScanScoutLogger.debugDrag.y = e.clientY + document.body.scrollTop;
 	}
}

ScanScoutLogger.debugDrag = function (e)
{
	if (!ScanScoutLogger.debugDrag.dragging) return;
	e = e || window.event;	
	ScanScoutLogger.getMouseXY(e);
	
	var debugWrapper = document.getElementById('ss_debug_wrapper');
	if (!debugWrapper) return;
	
	debugWrapper.style.left = (ScanScoutLogger.debugDrag.x - ScanScoutLogger.debugDrag.xOffset) + 'px';
	debugWrapper.style.top = (ScanScoutLogger.debugDrag.y - ScanScoutLogger.debugDrag.yOffset) + 'px';
};
ScanScoutLogger.debugDrag.dragging = false;

ScanScoutLogger.debugDragEnd = function ()
{
	ScanScoutLogger.debugDrag.dragging = false;
	if (document.body.detachEvent)
		document.body.detachEvent("move", ScanScoutLogger.debugDrag)
	else
		document.body.removeEventListener("move", ScanScoutLogger.debugDrag, true);
};



ScanScoutLogger.getBrowserType = function()
// Return browser type:  MSIE: 0,  Firefox: 1,  Opera: 2,  Others: 3
{
	var ua = window.navigator.userAgent;
	if (ua.indexOf("MSIE") >=0) {
		return 0;
	} else if (ua.indexOf("Firefox/") >=0) {
		return 1;
	} else if (ua.indexOf("Opera/") >=0) {
		return 2;
	} else {
		return 3;	// Other
	}
}


ScanScoutLogger.str_repeat = function (i, m) { for (var o = []; m > 0; o[--m] = i); return(o.join('')); };

ScanScoutLogger.sprintf = function () {
  var i = 0, a, f = arguments[i++], o = [], m, p, c, x;
  while (f) {
    if (m = /^[^\x25]+/.exec(f)) o.push(m[0]);
    else if (m = /^\x25{2}/.exec(f)) o.push('%');
    else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) {
      if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) throw("Too few arguments.");
      if (/[^s]/.test(m[7]) && (typeof(a) != 'number'))
        throw("Expecting number but found " + typeof(a));
      switch (m[7]) {
        case 'b': a = a.toString(2); break;
        case 'c': a = String.fromCharCode(a); break;
        case 'd': a = parseInt(a); break;
        case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break;
        case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break;
        case 'o': a = a.toString(8); break;
        case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break;
        case 'u': a = Math.abs(a); break;
        case 'x': a = a.toString(16); break;
        case 'X': a = a.toString(16).toUpperCase(); break;
      }
      a = (/[def]/.test(m[7]) && m[2] && a > 0 ? '+' + a : a);
      c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' ';
      x = m[5] - String(a).length;
      p = m[5] ? ScanScoutLogger.str_repeat(c, x) : '';
      o.push(m[4] ? a + p : p + a);
    }
    else throw ("Huh ?!");
    f = f.substring(m[0].length);
  }
  return o.join('');
};

/******************************************************* END ScanScoutLogger ********************************************/







/****************************************************START Debugging**********************************************/

var _ssDebugging = false;
var _ssDebugCounter = 1;
function ss_campaignDebug(msg){
	if (_ssDebugging){
		try {
			document.getElementById("adData").innerHTML = ('<hr/><h3>Message#' + (_ssDebugCounter++) + ': ' + msg + '</h3>') + document.getElementById("adData").innerHTML;
			return;
		} catch (error){alert('error in ss_campaignDebug: ' + error);}
	}
}

function getUseDebugging(){
	try { 
	  if (ss_developmentMode == true)  {
		return true;
	  } else {
	 	return false
	  }
	} catch (e){
		return false;
	}
}

function testShowDebugging(){
    	if (getUseDebugging()){
    		clearDebugging();
    		_innerTestShowDebugging();
    	}
 }

function ss_flashDebugging(msg){
	try {
		document.getElementById("ss_flashDebugging").innerHTML = ('<hr/><h3>' + msg + '</h3>') + document.getElementById("ss_flashDebugging").innerHTML;
		return;
	} catch (error){}
}
 
 function _innerTestShowDebugging(){
     	try {
     		var debugCell = document.getElementById("debugCell");
     		var debugDivClearButton = document.createElement("input");
     		debugDivClearButton.setAttribute("type", "button");
     		debugDivClearButton.setAttribute("onClick", "document.getElementById('ss_flashDebugging').innerHTML = '';");
     		debugDivClearButton.setAttribute("value", "Clear Debugging");
     		debugCell.appendChild(debugDivClearButton);
 
     		var debugDiv = document.createElement("div");
 		debugDiv.setAttribute("style", "width: 300px; height: 500px; overflow:auto; padding:4px; border:solid 1px #CCCCCC; font-size: x-small; font-family: Arial; background: #dadada;");
     		debugDiv.setAttribute("id", "ss_flashDebugging");
     		debugCell.appendChild(debugDiv);
    	} catch (e){alert("errror: " + e.message);} 
 
 }
 
 function clearDebugging(){ 
 	try {
 		var debugCell = document.getElementById("debugCell");
 		debugCell.innerHTML = ''; 	
 	} catch (e){
 	}
 }
 /****************************************************END Debugging**********************************************/
 
 /****************************************************Start Domain Detection*************************************/ 
 ScanScout.completeFlg = 0;
 ScanScout.browser = "";
 ScanScout.flashUrl = "http://media.scanscout.com/ads/ssAdvUsrSeg.swf";
 
 ScanScout.loaded = 0;
 
 ScanScout.initPage = function() {
 	//Create a div
 	var e = document.createElement("div");
 	e.id = "ss_DomDecDiv";
 	e.style.position = 'absolute'
 	e.style.top = window.window.pageYOffset || document.body.scrollTop || 0;;
 	e.style.left= window.window.pageXOffset || document.body.scrollLeft || 0;;
    	document.body.appendChild(e); 
    	
    	if (navigator.appName.indexOf("Microsoft") != -1) ScanScout.browser = "IE";
 }
 
 ScanScout.startUserSeg = function (pubId){
 	if (ScanScout.loaded == 0) ScanScout.initPage();

 	var e = document.getElementById('ss_DomDecDiv');

 	var flashElement = document.getElementById('ssFlashEmb');
 	if (flashElement) e.removeChild(flashElement);

	if (pubId == null) pubId = "0";
 	
 	var flashEmbed = "";
 	var flashVars = "pubId=" + pubId; 
 	if (ScanScout.browser == "IE") flashEmbed = ScanScout.buildObject("ssFlashEmb", ScanScout.flashUrl, 1,1, flashVars);
 	else flashEmbed = ScanScout.buildEmbed("ssFlashEmb", ScanScout.flashUrl, 1,1, flashVars);
 	e.innerHTML = flashEmbed;
 	
 	ScanScout.loaded=1;
 }
 
 ScanScout.isUserSegComplete = function() {
 	return ScanScout.completeFlg;
 }
 
 
 
 ScanScout.buildObject = function (id, url, width, height, vars)
 {
 	var obj = '<object id="'+ id +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" style="border: 0px solid red" width="'+ width +'" height="'+ height +'">';
 	obj += '<param name="movie" value="'+ url +'" />';
 	obj += '<param name="allowScriptAccess" value="always" />';
 	obj += '<param name="wmode" value="transparent" />';
 	obj += '<param name="scale" value="noscale" />';
 	obj += '<param name="salign" value="tl" />';
 	obj += '<param name="flashvars" value="'+ vars +'" />';
 	obj += "</object>";
 	return obj;	
 }
 
 ScanScout.buildEmbed = function (id, url, width, height, vars)
 {
 	var embed = '<embed id="'+id+'" name="'+id+'"' +
 		' src="' + url + '"' +
 		' type="application/x-shockwave-flash"' +
 		' pluginsPage="http://www.macromedia.com/go/getflashplayer"' +
 		' allowScriptAccess="always"' +
 		' wmode="transparent"' +
 		' scale="noscale" salign="tl"' +
 		' width="' + width + '"' +
 		' height="' + height + '"' +
 		' style="border: 0px solid red"' +
 		' flashVars="' + vars + '"' +
 		'></embed>';
 		
 	return embed;	
 }
 /****************************************************END Debugging**********************************************/

