
/*  Omniture code Release 2.0 */

/**************************************************************************************************************************************/
/** Following  are the wrapper functions for the Omniture calls.
/***************************************************************************************************************************************/

		var strSection = "";
		var strSubSection = "";

		/*
		This function reads the META tags. and populates the section and subsections.
		*/
		function readMetaKeywords () {
			var metaElements = document.all ? document.all.tags('META') : document.getElementsByTagName ? document.getElementsByTagName ('META') : new Array(); 
			
			for (var m = 0; m < metaElements.length; m++) {
			
				if (metaElements[m].name == "section") {
					strSection = metaElements[m].content;
				}
				else if (metaElements[m].name == "subsection") {
					strSubSection = metaElements[m].content;
				}		
			}  
		}
		
		/*
		This is  a helper function to calculae the Percentage of video completed.
		Input:
			nTotalVideoLegth - Number. Total length of the video.
			nCompletedVideoLength - Number. Length of the video watched by the user so far.
		Returns:
			Number. Percentage of the Video watched.
		*/
		function calculatePercentage(nTotalVideoLegth, nCompletedVideoLength) {
			
			//Rounding the Percentage to 
			return (Math.round((nCompletedVideoLength/nTotalVideoLegth) * 10) * 10);

		}
		
		/*
		This function makes an Omniture call to record the Video name with 
		total length and watched length of the video.
		Input:
			sVideoName - String. Name of the video.
			sVideoLink - String. URL of the video.
			nTotalVideoLegth - Number. Total length of the video.
			nCompletedVideoLength - Number. Length of the video watched by the user so far.
			sEventName - String. Event name. start/stop

		Returns:
			void.
		*/
		function trackVideo(sVideoName, sVideoLink, nTotalVideoLegth, nCompletedVideoLength, sEventName) {

			var s=s_gi(s_account);

			s.pageName = sVideoName + "_" + sEventName;
			s.pageURL = sVideoLink;
			s.prop4 = nCompletedVideoLength;
			s.prop5 = calculatePercentage(nTotalVideoLegth, nCompletedVideoLength) + "";

			void(s.t());

		}


		/*
		This function makes an Omniture call to record the flash page view.
		Input:
			lnk - Boolean. Pass "true" for all flash calls.
			pageType - String. pass "o" for all flash calls.
			pageName - String. Name/Title of the Flash Page.
		Returns:
			void.
		*/
		function trackFlashPage(lnk, pageType, pageName) {
			var s=s_gi(s_account); 
			void(s.tl(lnk,pageType,pageName));
		}

	
	
		/*
		This function makes an Omniture call to record a simple page view.
		Input:
			pstrPageName - String. Name/Title of the Page.
		Returns:
			void.
		*/
		function omniturePageViewSimple(pstrPageName) {

			s.pageName = pstrPageName;

			s.prop1="";
			s.prop3="";
			s.prop4="";
			s.prop5="";

			s.eVar1="";
			s.eVar2="";
			s.eVar3="";
			s.eVar4="";
			s.eVar5="";
			s.hier1="";

			var s_code=s.t(); 

		}

	
		/*
		This function makes an Omniture call to record a page view with custome values.
		Input:
			pstrPageName - String. Name/Title of the Page.
			Before caling this function, appropriate Custom variables (omnitureCutomVar1...omnitureCutomVar5)
			need to be defined and assigned values. So that this function can pickup the values from those custom 
			variable and pass to omniture through correspnding omniture parameters.
		Returns:
			void.
		*/
		function omniturePageViewExtended(pstrPageName) {

			s.pageName = pstrPageName;
			
			s.prop1 =  (window.omnitureCutomVar1 ? omnitureCutomVar1 : "");
			s.prop2 =  (window.omnitureCutomVar2 ? omnitureCutomVar2 : "");
			s.prop3 =  (window.omnitureCutomVar3 ? omnitureCutomVar3 : "");
			s.prop4 =  (window.omnitureCutomVar4 ? omnitureCutomVar4 : "");
			s.prop5 =  (window.omnitureCutomVar5 ? omnitureCutomVar5 : "");
			s.prop6 =  (window.omnitureCutomVar6 ? omnitureCutomVar6 : "");
			s.prop7 =  (window.omnitureCutomVar7 ? omnitureCutomVar7 : "");
			s.prop8 =  (window.omnitureCutomVar8 ? omnitureCutomVar8 : "");
			s.prop9 =  (window.omnitureCutomVar9 ? omnitureCutomVar9 : "");
			s.prop10 =  (window.omnitureCutomVar10 ? omnitureCutomVar10 : "");

			s.eVar1="";
			s.eVar2="";
			s.eVar3="";
			s.eVar4="";
			s.eVar5="";
			s.hier1="";

			var s_code=s.t(); 

		}

	/*				*** This custom function is added for sales.map.ge.com application. ***

		This function makes an Omniture call with eVar values.
		Input:
			pstrPageName - String. Name/Title of the Page.
			
			Variable no.of arguments - Values of eVars. You can pass this function any number of arguments (Upto 9 variables will only be used) 
			after the first argument (page name). These arguments will be populated into omniture eVar variable froms eVar2,....eVar10.
			
			Note:  since eVar1 is reserved for succesfull search term, only the evars from eVar2 will be populated by this fucntion.

			Example Function calls:
			----------------------
			omniturePageViewWithEvars("Test Page 1")   -- Omniture call with no eVars set.
			omniturePageViewWithEvars("Test Page 1" , "My value 2", "My value 3") -- Omniture call with eVar2, eVar3 set.
			omniturePageViewWithEvars("Test Page 1" , "999999003", "Newyork", "Ge Corporate", "100 miles") -- 
			Omniture call with eVar2, eVar3, eVar4, eVar5 set with corresponding arguments("999999003", "Newyork", "Corporate", "100 miles").						

		Returns:
			void.
		*/
		function omniturePageViewWithEvars(pstrPageName) {
			var nLength;

			s.pageName = pstrPageName;
			nLength = arguments.length;			
			
			s.eVar2  = (nLength > 1) ? arguments[1] : "";
			s.eVar3  = (nLength > 2) ? arguments[2] : "";
			s.eVar4  = (nLength > 3) ? arguments[3] : "";
			s.eVar5  = (nLength > 4) ? arguments[4] : "";
			s.eVar6  = (nLength > 5) ? arguments[5] : "";
			s.eVar7  = (nLength > 6) ? arguments[6] : "";
			s.eVar8  = (nLength > 7) ? arguments[7] : "";
			s.eVar9  = (nLength > 8) ? arguments[8] : "";
			s.eVar10 = (nLength > 9) ? arguments[9] : "";

			var s_code=s.t(); 

		}

		/*
		This function makes an Omniture call to record addition of a portal to the page. 
		This is specific to the Inside GE portal.
		Input:
			pstrPageName - String. Name/Title of the Flash Page.
			pstrNewPortalName - String. Name/Title of the portal being added.
		Returns:
			void.
		*/
		function omnitureAddPortal(pstrPageName, pstrNewPortalName) {

			s.pageName = pstrPageName;

			s.prop1="";
			s.prop3="";
			s.prop4="";
			s.prop5="";

			s.eVar1="";
			s.eVar2="";
			s.eVar3=pstrNewPortalName;
			s.eVar4="";
			s.eVar5="";
			s.hier1="";

			var s_code=s.t(); 

		}

		/*
		This function makes an Omniture call to record removal of a portal to the page. 
		This is specific to the Inside GE portal.
		Input:
			pstrPageName - String. Name/Title of the Flash Page.
			pstrNewPortalName - String. Name/Title of the portal being removed.
		Returns:
			void.
		*/
		function omnitureRemovePortal(pstrPageName, pstrDeletedPortalName) {

			s.pageName = pstrPageName;

			s.prop1="";
			s.prop3="";
			s.prop4="";
			s.prop5="";

			s.eVar1="";
			s.eVar2="";
			s.eVar3="";
			s.eVar4=pstrDeletedPortalName;
			s.eVar5="";
			s.hier1="";

			var s_code=s.t(); 

		}