/*
Channel 4 Omniture
Version 1.2
Date of version 19/12/2006
*/
function c4getParams(qs) {
	splitItems = qs.split("&");
	finalObj = {};
	for (var i=0; i<splitItems.length; i++) {
		thisItem=splitItems[i].split("=");
		finalObj[thisItem[0]] = thisItem[1];
	}
	return finalObj;
}

function c4getBrandParams(){
		/* Remove / at the beginning of the path and remove double slashes
		 * some people may insert into URL's
		 */
		var path = (arguments[0] || window.location.pathname).replace(/^\/+/, '').replace(/\/{2,}/mg, '/').split('/'),		
			brand = {};
		
		if (path[0] != 'programmes') {
			brand.name = "";
			brand.section = "";
			brand.series = "";
			brand.episode = "";
			brand.clipTitle = "";
		}
		else {
		
			brand.name = path[1] || "";
			
			if (brand.name != 'epg') {
			
				brand.section = path[2] || "";
				
				if (brand.section != 'articles') {
					brand.series = path[3] || "";
					brand.episode = path[4] || "";
					brand.clipTitle = path[5] || "";
				}
				else {
					brand.series = "";
					brand.episode = "";
					brand.clipTitle = path[3] || "";
				}
				
			}
			else {
				brand.section = path[2] || "";
				brand.series = path[3] || "";
			}
			
		}
		
		return brand;
		
	}

function c4GetId(teststring) {

	idmatch=/(?:^|&|\?)id=(\d+)/;
	endidmatch=/(?:^|&|\?)[^=&]+id=(\d+)/;
	partidmatch=/(?:^|&|\?)[^=&]+id[^=&]+=(\d+)/;
	anydigitsmatch=/(?:^|&|\?)[^=&]+=(\d+)(?:&|$)/;
	directorymatch=/(?:^|\/)(\d+)(?:\/|$)/;

	if(teststring.match(idmatch)) {
		idno = teststring.match(idmatch)[1];
	} else if(teststring.match(endidmatch)) {
		idno = teststring.match(endidmatch)[1];
	} else if(teststring.match(partidmatch)) {
		idno = teststring.match(partidmatch)[1];
	} else if(teststring.match(anydigitsmatch)) {
		idno = teststring.match(anydigitsmatch)[1];
	} else if(teststring.match(directorymatch)) {
		idno = teststring.match(directorymatch)[1];
	} else {
		idno = "";
	}

	return idno;
}
c4urlmatch = /(\w+):\/\/([\w\-.]+)\/?(\S*)/;
c4domainmatch = /^https?:\/\/(?:[\w-]+\.)?([\w-]+)\./;
c4result = document.location.href.match(c4urlmatch);
c4prop5Verticals = ["Bigbrother","4car","Film","Music","4talent"];
if(c4result) {
	var c4Url = c4result[0];
	var c4Protocol = c4result[1];
	var c4Host = (c4result[2].indexOf("//")!=-1)?c4result[2].replace(/\/\//g,"/"):c4result[2];
	var c4Path = (c4result[3].indexOf("//")!=-1)?c4result[3].replace(/\/\//g,"/"):c4result[3];
	var c4Dirs = c4Path.indexOf("/")!=-1?c4Path.split("/"):null;
	var c4Filename = (c4Dirs&&c4Dirs.length&&c4Dirs[c4Dirs.length-1].indexOf('.')!=-1)?c4Dirs[c4Dirs.length-1]:'';
	var c4QueryString = c4Path.indexOf("?")!=-1?c4Path.split("?")[1]:null;
	var c4Params = c4QueryString!=null?c4getParams(c4QueryString):null;
}
function c4pageType() {
 v = document.errorPage != null?document.errorPage:"";
	return v;
}
function c4GetOmniProps () {
	if (typeof s != "undefined") {
		OmniPropertyAccount = s_account;
		OmniPropertyFullPath = c4props(18);
		OmniPropertyVertical = c4props("vertical");
		OmniPropertySubDir = c4props(3);
		OmniProps = new Object();
		OmniProps.account = OmniPropertyAccount;
		OmniProps.fullpath = OmniPropertyFullPath;
		OmniProps.vertical = OmniPropertyVertical;
		OmniProps.subdir = OmniPropertySubDir;
	} else {
		OmniProps = null;
	}
	return OmniProps; 
}
function c4props(w) {
	var v="";
	ncBrand = c4getBrandParams();
	if(c4Host.indexOf("cms.")!=-1 || c4Host.match(/\d+.\d+.\d+.\d+/)!=null ) {

	return "";
	}
	switch(w) {
	case "pagename":
	if(document.c4pname==null || document.c4pname=="") {
			if(c4Path) {
				v = c4Path;
				if(v.indexOf("microsites/")!=-1) {
					v = c4Url.replace(c4Url.match(/(microsites\/([A-Z]|[0-9\-?]+))/)[0],"...");
				}
				// strip domain
				v = v.replace(c4Protocol+"://"+c4Host+"/","");
				//strip query
				v = v.indexOf("?")!=-1?v.split("?")[0]:v;
				//check community
				if (c4Host.indexOf("community")!=-1) {
					if (document.title.match(/^(.+) -/)) {
						v = "Forum Page - ";
						appendTitle = (document.title.match(/^(.+) -/).length>1)?document.title.match(/^(.+) -/)[1]:document.title;
						v += appendTitle;
					} else {
						v = "Forum Page - " + document.title;
					}
				}
				//check external domain
				v = c4Host.indexOf("channel4")!=-1?v:c4Host+":"+v;
				v = c4Path.indexOf("search")!=-1 && c4Path.indexOf("index")!=-1?v.substring(0,c4Path.indexOf("/index")):v;

				//check for index//check for trailing slash
				v = v.lastIndexOf("/")==v.length-1?v.substring(0,v.length-1):v;  // used to be append HOME

				//v = v.indexOf("index.")!=-1 && c4Dirs==null?"Home Page":v;
				if (v.indexOf("index.")!=-1 && c4Dirs==null){

					if (c4Host.indexOf("www.channel4.com")!=-1){
						v = "Home Page";
					} else {
						v = "Home Page - " + c4Host;
					}

				}
				//v = v.indexOf(".")==-1 && v.indexOf(": Home")==-1 && v.indexOf("seacrh")!=-1?v+": Home":v;

			    // check index for query
				//v = c4Url.indexOf(c4Host+"/?")!=-1?"Home Page":v;
				if (c4Url.indexOf(c4Host+"/?")!=-1){

					if (c4Host.indexOf("www.channel4.com")!=-1){
						v = "Home Page ";
					} else {
						v = "Home Page - " + c4Host;
					}

				}

				//if error Pages
				if(document.errorPage != null) {
				v = document.errorPage==""?v:document.errorPage+" : URL "+c4Path;
				}
				v = (v.indexOf("/index.html")!=-1)?v.substring(0,v.indexOf("/index.html")):v;
				// ADDED New Concept What's Hot page
				if(c4Path.match(/programmes\/?$/)) {
					v = "Programmes Homepage"
				}
			} else {
				// Added to give identification to Home Pages that are not the C4 root
				// such as 'picturethis.channel4.com'
				if (c4Host.indexOf("www.channel4.com")!=-1){
					v = "Home Page";
				} else {
					v = "Home Page - " + c4Host;
				}
			}
		} else {
			v=document.c4pname;
	}

	break;
	case "domain":
	c4domain = c4Url.match(c4domainmatch);
	v = (c4domain) ? c4domain[1] : "";
	break;
	case "server":
	c4server = c4Url.match(c4domainmatch);
	v = (c4server) ? c4server[1] : "";
	break;
	case "vertical":
	//external domain

	if(c4props(2).indexOf("external domain")!=-1) {
		v = (document.c4Vertical)?document.c4Vertical.replace(document.c4Vertical.charAt(0),document.c4Vertical.charAt(0).toUpperCase()):"External site, vertical not set"
	} else {
		if (document.c4Vertical==null||document.c4Vertical=="") {
			if(c4Path && (!document.errorPage ||document.errorPage=="") && c4Dirs!=null) {
				v = c4Path.match(/(\w+)/)[0].replace((c4Path.match(/(\w+)/)[0].charAt(0)),(c4Path.match(/(\w+)/)[0].charAt(0).toUpperCase()));
			}
		  	// extract community pages
		  	v = c4Host.indexOf("community")!=-1?"Community":v;
		  	// verify is external domain
		  	v = c4Host.indexOf("channel4")==-1?"external domain":v;
		  	//check for query on root
		  	v = c4Url.indexOf(c4Host+"/?")!=-1?"":v;
			//check for sitewide apps, skip to second level if 'appXX' is at first level
			try {
				v = c4Path.match(/^apps\d+\//)?c4Path.match(/(\w+)/g)[1].replace((c4Path.match(/(\w+)/g)[1].charAt(0)),(c4Path.match(/(\w+)/g)[1].charAt(0).toUpperCase())):v;
			} catch(e) {v=v;}
		} else {
			v = document.c4Vertical.replace(document.c4Vertical.charAt(0),document.c4Vertical.charAt(0).toUpperCase());
		}
		if (v&&v=="Blogs") {
			v = (document.c4Vertical)?document.c4Vertical.replace(document.c4Vertical.charAt(0),document.c4Vertical.charAt(0).toUpperCase()):v;
		}
		if (v&&v=="Lifestyle") v="Life";
		
		// New Concept only - If atoz page, vertial should be programmes
    	if(c4Path.match(/^programmes\/?$/) || c4Path.match(/^programmes\/atoz\/?/) || c4Path.match(/^programmes\/tags\/?/) || c4Path.match(/^programmes\/catch-up\/?/)) {
    		v = 'Programmes';
   	 	}
		if(c4Path.match(/^programmes\/epg\/?/)|| c4Path.match(/^tv-listings\/?/)) {
			v = "TV Listings";	
		}
		if(document.errorPage) {
			if(document.errorPage.match(/page not found/)) {
				v = "ErrorPage";
			}
		}
	}
	break;
	case 1:
	//retrieves domain
	 v = c4Url.match(c4domainmatch)[1]||"";
	break;
	case 2:

	//retrieves vertical - contains override for variable document.c4Vertical
	if (document.c4Vertical==null||document.c4Vertical=="") {
		if(c4Path && (!document.errorPage ||document.errorPage=="") && c4Dirs!=null) {
			v = c4Path.match(/(\w+)/)[0].replace((c4Path.match(/(\w+)/)[0].charAt(0)),(c4Path.match(/(\w+)/)[0].charAt(0).toUpperCase()));
			// extract community pages
			v = c4Host.indexOf("community")!=-1?"Community":v;
			// verify is external domain
			v = c4Host.indexOf("channel4")==-1?"external domain":v;
			//check for query on root
			v = c4Url.indexOf(c4Host+"/?")!=-1?"":v;
			//check for sitewide apps, skip to second level if 'appXX' is at first level
			try {
				v = c4Path.match(/^apps\d+\//)?c4Path.match(/(\w+)/g)[1].replace((c4Path.match(/(\w+)/g)[1].charAt(0)),(c4Path.match(/(\w+)/g)[1].charAt(0).toUpperCase())):v;
			} catch(e) {v=v;}
		}
	} else {
		v = document.c4Vertical.replace(document.c4Vertical.charAt(0),document.c4Vertical.charAt(0).toUpperCase());
	}
	if (v&&v=="Blogs") {
		v = (document.c4Vertical)?document.c4Vertical.replace(document.c4Vertical.charAt(0),document.c4Vertical.charAt(0).toUpperCase()):v;
	}
	if (v&&v=="Lifestyle") {
		 v="Life"; 
	}
	// New Concept only - If atoz page, categories page, catch-up page, or strand page, vertial should be Programmes
    if(c4Path.match(/^programmes\/?$/) || c4Path.match(/^programmes\/atoz\/?/) || 
	   c4Path.match(/^programmes\/tags\/?/) || c4Path.match(/^programmes\/catch-up\/?/) || c4Path.match(/^programmes\/themes\/?/) ) {
	   v = 'Programmes';
    }
	if(c4Path.match(/^programmes\/epg\/?/) || c4Path.match(/^tv-listings\/?/)) {
		v = "TV Listings";	
	}
	// Set vertical to 'Showcases' for all conent lounge pages
	if(c4Path.match(/^showcases\/?/)) {
		v = "Showcases";
	}
	if(document.errorPage) {
		if(document.errorPage.match(/page not found/)) {
			v = "ErrorPage";
		}
	}
	break;
	case 3:

	//catch sub directory if there is one - contains override for document.c4subdirectory
	if (document.c4SubDirectory==null||document.c4SubDirectory=="") {
		if(c4Path && (!document.errorPage ||document.errorPage=="") && c4Dirs!=null) {
			v = c4Path.split("/").length>2?c4Path.split("/")[1]:"";
			var tset  = c4Path.split("/")[2];
			if (c4Host.indexOf('community')!=-1) v = c4GetId(c4Path);
			//check for sitewide apps, skip to third level if 'appXX' is at first level
			try {
				v =  c4Path.match(/^apps\d+\//)?c4Path.match(/(\w+)/g)[2]:v;
			} catch(e) {v=v;}
			// Blogs override
			if (c4Dirs[1]=="blogs"||c4Dirs[0]=="blogs") {
				v = "Blogs - ";
				blognameloc = (c4Dirs[0]=="blogs")?2:3;
				blogname = (c4Dirs[blognameloc]!=null&&c4Dirs[blognameloc]!="")?c4Dirs[blognameloc]:"Unknown";
				blogname = blogname.match(/([\d\w]+)(?:\?|$)/)?blogname.match(/([\d\w]+)(?:\?|$)/)[1]:blogname;
				v += blogname;
			}
			
			if(c4Path.match(/^explore\/\S+\//)){
				v = "microsite";
			}
			
			// Must be new concept
			if(c4Path.match(/^programmes\/?/)) {
				if(c4Path.match(/^programmes\/?$/)) {
					v = '';
				} else {
					if(c4Path.match(/^programmes\/atoz\/?/)) {
						v = 'atoz'
					} else if (c4Path.match(/^programmes\/tags\/?/)) { 
						v = 'Category Page: '+c4Path.split("/")[2]; // category name i.e. comedy 
					} else if ((c4Path.match(/^programmes\/catch-up\/?/)) || (c4Path.match(/^programmes\/4od\/?/i))) {
						v = c4Path.split("/")[1]; // category name i.e. comedy 						
					} else if(c4Path.match(/^programmes\/themes\/?/)) {
						v = 'themes';
					} else {
						v = 'Brand Pages';
					}
					
				}
			}
			// Must be new concept EPG these can be removed when the URL change from epg to tv-listings is enforced
			if (c4Path.match(/^programmes\/epg\/?/) || c4Path.match(/^programmes\/epg\/daily\/?/) ) {
                v = 'Daily';
            }
			if(c4Path.match(/^programmes\/epg\/weekly\/?/)) {
				v = 'Weekly';	
			}
			if (c4Path.match(/^tv-listings\/?/) || c4Path.match(/^tv-listings\/daily\/?/) ) {
                v = 'Daily';
            }
			if(c4Path.match(/^tv-listings\/weekly\/?/)) {
				v = 'Weekly';	
            }
			if(c4Path.match(/^showcases\/?/)) {
				v = 'content lounges';
			}
		}		
	} else {
		if(!document.errorPage ||document.errorPage=="") {
			v = document.c4SubDirectory;
		}
	}
	
	break;
	case 4:
	//catch microsites
	//current LOGIC -- retrieves

	if(!document.c4microsite || document.c4microsite=="") {
	 if(c4Path && (!document.errorPage || document.errorPage=="") && c4Dirs!=null ) {
	 	if(c4Path.indexOf("microsites")!=-1) {
			v = c4Url.match(/(microsites\/([A-Z]|[0-9\-?]+))\/(\S+[^\/])/)[3];
			v = v.substring(0,v.indexOf("/")!=-1?v.indexOf("/"):v.length);
		} else {
			if(c4Path.indexOf('ontv')!=-1) {
				//other mirosites added 31/01/07
				if(c4Url.match(/(ontv)\/(\S+[^\/])/)!=null) {
				v = c4Url.match(/(ontv)\/(\S+[^\/])/)[2];
				v = v.substring(0,v.indexOf("/")!=-1?v.indexOf("/"):v.length);
				}
			} else if(c4Path.indexOf('on-tv')!=-1) {
				if(c4Url.match(/(on-tv)\/(\S+[^\/])/)!=null) {
				v = c4Url.match(/(on-tv)\/(\S+[^\/])/)[2];
				v = v.substring(0,v.indexOf("/")!=-1?v.indexOf("/"):v.length);
				}
			} else if(c4Path.indexOf("explore")!=-1){
				if(c4Url.match(/(explore)\/(\S+[^\/])\//)!=null) {
				v = c4Url.match(/explore\/(\S[^\/]+){1}/)[1];
				}
			} else {
				v="";

			}
		}
	 }
	} else {
	 v = document.c4microsite;
	}
	 if(!document.errorPage || document.errorPage=="") {
	// Must be new concept
	if(c4Path.match(/^programmes\/?/)){
		//catch EPG, ATOZ 
		if(c4Path.match(/^programmes\/?$/) || c4Path.match(/^programmes\/atoz\/?/) || c4Path.match(/^programmes\/tags\/?/) || c4Path.match(/^programmes\/catch-up\/?/) || c4Path.match(/^programmes\/4od\/?/i) ) {
			v = '';
		}
		// for strand (theme) pages, set v to strand name (web-safe title) in the URL
		else if(c4Path.match(/^programmes\/themes\/?/)) {
			var splitPos = parseInt(c4Path.indexOf('themes/') + ('themes/').length);
			v = c4Path.substr(splitPos);
		}
		else {
			v = 'BIP: ' + ncBrand.name;
		}
	}
	if (c4Path.match(/^search\/?/)) {
		v = '';
	}
	if(c4Path.match(/^tv-listings\/?/) || c4Path.match(/^programmes\/epg\/?/) ) {
		v='';	
	}
	// for showcase pages, set v to the showcase name in the URL
	if(c4Path.match(/^showcases\/?/)) {
		var splitPos = parseInt(c4Path.indexOf('showcases/') + ('showcases/').length);
		v = c4Path.substr(splitPos);
	}
	//Catch new Quiz section of site /play-win
	if(document.c4Vertical=="Programmes" && c4Path.match(/^play-win\/?/) && c4Dirs!=null) {
		v = "BIP: " + c4Dirs[1];
	} 
	} else {
		v='';
	}
	break;
	case 5:
		var validProp5 = false;
		var currentVertical = c4props(2);
		for(i=0;i<c4prop5Verticals.length;i++) {
			if (c4prop5Verticals[i]==currentVertical) validProp5 = true;
		}
		v = (validProp5)?c4props(7):"";
	break;
	case 6:
	// Time of day reporting
	v = "";//s.getTimeParting('h','0','2008');
	break;
	case 7:
	if(c4Path && (!document.errorPage ||document.errorPage=="") && c4Dirs!=null) {
	 	//page detail ID and title or blank
		teststring=c4Path;
		idno = c4GetId(teststring);
		if (idno!="") v = "ID:" + idno + ":" + document.title;
	}
	break;
	case 8:
	//Search Keywords - uses the googleResult object if present
	if ( typeof( window.googleResult ) !== "undefined" ) {
		if (
				typeof( googleResult.internal ) !== "undefined" ||
				typeof( googleResult.external ) !== "undefined"
		) { /* Google Search */
			site	= ( googleResult.internal === "true" ) ? googleResult.site || "Unknown" : ( googleResult.external === "true" ) ? "websearch" : googleResult.site || "Unknown" ;
			query	= ( googleResult.query || "" ).replace( "|", "" ).toLowerCase();
			v 		= ( site + ": " + query ).toLowerCase();
		} else { /* previous Search */
			site	= googleResult.site || "Unknown" ;
			query	= ( googleResult.query || "" ).replace( "|", "" ).toLowerCase();
			v 		= ( site + ": " + query ).toLowerCase();
		}
	} else if ( c4Host=="search.channel4.com" ) {
		site	= "search_" + ( c4Params["site"] || "all" );
		query	= c4Params["q"] || "" ;
		v		= ( site + ": " + query ).toLowerCase();
	} else if ( c4Path =="/search") {
       	 	query   = c4Params["user_query"] || "";
        	v       = ( global + ": " + query).toLowerCase();
    	}
	if(v.match(/^channel4/)) {
		v= v.replace(/^channel4/,"Global")
	}
	break;
	case 9:
	//Search Results - uses the googleResult object if present
	if (typeof(googleResult) != 'undefined') {
		v = (googleResult.size || 0).toString();
	} else if (c4Path == "/search") {
        if (c4Url.indexOf('page-') == -1 && (typeof(c4ResultCount) != "undefined")) {
            v = c4ResultCount;
        }
    }
	break;
	// 10,11,12 managed by plug in

	case 13:
	// possibble page number - uses the googleResult object if present
	if (typeof(googleResult) != 'undefined') {
		gStart = googleResult.start || 0;
		gNum = googleResult.num || 0;
		if (gStart < 0) gStart = 0;
		if (typeof(googleResult.page) != 'undefined') {
			v = googleResult.page;
		} else {
			v = (gNum == 0) ? 0 : Math.floor(gStart / gNum) + 1;
		}
	} else if (c4Host=="search.channel4.com") { // else if we are in generic search results
		gStart = c4Params["start"] || 0;
		if (gStart < 0) gStart = 0;
		v = Math.floor(gStart/10) + 1;
	} else { // make a best guess
		if(c4Path && (!document.errorPage ||document.errorPage=="") && c4Dirs!=null) {

		 if(c4Url.indexOf("search")!=-1) {
		 v = c4Path.indexOf("&")!=-1?c4Path.split("&")[1]:v;

		 } else {
		 if(c4Path.indexOf(".jsp")!=-1) {
		 v = c4Path.indexOf("?")!=-1?c4Path.split("?")[1]:v;
		 v = v.indexOf("&page=")!=-1?v.split("&page=")[1]:"1";
		 }
		 }
		}
	}
	break;	
	case 16:
	if(c4Path) {
		v = c4Path.indexOf("?")!=-1?c4Path.split("?")[1]:""

	}
	break;
	case 18:
	// Full URL for debugging within Omniture
	v = c4Url;
	break;
	case "hier":
	ppsyn ="channel4";
	ppsyn+=c4props(2)!=""?ppsyn="|"+c4props(2):"";
	ppsyn+=c4props(3)!=""?ppsyn="|"+c4props(3):"";
	ppsyn+=c4props(4)!=""?ppsyn="|"+c4props(4):"";
	ppsyn+=c4props(36)!= "" ? ppsyn="|"+c4props(36):"";
	ppsyn+=c4props("pagename")!=""?ppsyn="|"+c4props("pagename"):"";
	ppsyn+=c4props(7)!=""?ppsyn="|"+c4props(7):"";
	ppsyn+=c4props(8)!=""?ppsyn="|"+c4props(8):"";
	v=ppsyn;
	
	break;
	case 19:// full URL without domain infor
		if(c4Path && c4Dirs!=null) {
			v = c4Path;
		}
	break;
	case 34:
		// these catch the homepage, the New concept pages and the new search
		// These should not be deployed to production untill we move new search and new landing pages to prod.
		if(c4Path.match(/^play-win\/?/) || c4Path.match(/^explore\/?/) || c4Path=="" || c4Path.match(/^homepage/) || c4Path.match(/^programmes\/?/) || c4Path.match(/^search\/?/) || c4Path.match(/^tv-listings\/?/) || c4Path.match(/^programmes\/epg\/?/)){
			v = 'New Concept';
		} else {
			v = 'Before New Concept'
		}
	break;
	case 36: // New Concept Brand Quick Links
		if (typeof document.errorPage != "undefined" || (document.errorPage!="" && document.errorPage=="undefined") || c4Path.match(/^tv-listings\/?/) || c4Path.match(/^programme\/epg\/?/) || c4Path.match(/^programmes\/tags\/?/)) {
			v = '';
		} else {
			if(c4Path.match(/^play-win\/?/)) {
			v = 'play-win';	
			}else if(c4Path.match(/^explore\/\S+/)){
				v = c4Url.match(/explore\/(\S[^\/]*){2}/)[1].substring(1);	
			} else {
			v = ncBrand.section;
			}
		}
	
	break;
	case 37:
		if (c4Path.match(/^programmes\/tags\/?/)) {
			v = '';
		} else {	
			v = brand.name;
		}
	break;
	case 42: // epg selected date
         if (c4Path.match(/^programmes\/epg\/?/) || c4Path.match(/^tv-listing\/?/)) {
            if (document.getElementById) {
                var selectedDate = document.getElementById('selectedDate');
                if (selectedDate) {
                    v = selectedDate.innerHTML;
					//reorder date to dd/mm/yyyy from yyyy/mm/dd
					vM = v.match(/(\d{4})(\/\d{2}\/)(\d{2})/);
					if (vM) {
						v = v.replace(v, vM[3] + vM[2] + vM[1])
					}
				}
            }
        } 
    break;
    case 48: // epg days away from current date
        if (c4Path.match(/^programmes\/epg\/?/)|| c4Path.match(/^tv-listing\/?/)) {
            // epg date
            if (document.getElementById) {
                var selectedDate = document.getElementById('selectedDate');
                selectedDate = selectedDate.innerHTML.split('/');
                selectedDate = new Date(selectedDate[0], selectedDate[1]-1, selectedDate[2]);
                var todaysDate = document.getElementById('todaysDate');
                todaysDate = todaysDate.innerHTML.split('/');
                todaysDate = new Date(todaysDate[0], todaysDate[1]-1, todaysDate[2]);
                var difference = (((((selectedDate.getTime() - todaysDate.getTime()) / 1000) / 60) / 60) / 24);
                v = difference.toString();
            }
        }
        break;
	}
	return v;
}

function c4pageInfluenceEvent() {
	s.events=(s.events)?s.events+",event7":"event7";
	
		//Trigger foresee survery VOC
	document.write('<scr'+'ipt src="http://www.channel4.com/foresee_c4/foresee-trigger.js" type="text/javascr'+'ipt"><\/scr'+'ipt>');
	document.write('<scr'+'ipt type="text/javascr'+'ipt" src="http://www.channel4.com/foresee_c4/CPPS_omni.js"></scr'+'ipt>');

}

function c4searchResultsEvent() {
	if(!s.products&&s.prop9&&!isNaN(parseInt(s.prop9,10))) {
		s.products = ";;;;event8="+parseInt(s.prop9,10);
		s.events=(s.events)?s.events+",event8":"event8";
	}
}