var currentPage = window.location.pathname;
var ivwCategory="Home";
var owaCategory="RedCont/Homepage/Homepage/viva.tv";
//remove start and slashs
if(currentPage.lastIndexOf("/")==currentPage.length-1) 
	currentPage = currentPage.substr(1, currentPage.length-2);
else
	currentPage = currentPage.substr(1, currentPage.length-1);

if (currentPage.length == 0) {
	ivwCategory = "Home";
	owaCategory = "RedCont/Homepage/Homepage/viva.tv";
} else {
	//split url path
	var urlItems = currentPage.toLowerCase().split('/');
	switch (urlItems[0]) {
	case "stars":
		ivwCategory = "Stars";
		owaCategory = "RedCont/Nachrichten/GesellschaftUndLeute/viva.tv";
		if (urlItems.length==1)
			ivwCategory = ivwCategory.concat("/Home");
		break;
	case "news":
		ivwCategory = "News";
		owaCategory = "RedCont/KulturUndFreizeit/Musik/viva.tv";
		if (urlItems.length==1) {
			ivwCategory = ivwCategory.concat("/Home");
		} else if (urlItems[1] == "magazin") {
			ivwCategory = "Magazin";
		}
		;
		break;
	case "videos":
		ivwCategory = "Videos";
		owaCategory = "RedCont/KulturUndFreizeit/Musik/viva.tv";
		if (urlItems.length==1)
			ivwCategory = ivwCategory.concat("/Home");
		break;
	case "shows":
			ivwCategory = "Shows";
			owaCategory = "Service/ProgrammeUndLokalfuehrer/Tvprogramme/viva.tv";
			switch (urlItems.length) {
				case 1:ivwCategory = ivwCategory.concat("/Home");break;
				case 3:if (urlItems[1] == "programm") ivwCategory = "Programm";break;
				case 6:if(urlItems[4] == "video") ivwCategory=ivwCategory.concat("_Video");break;
			}//inner-switch
		break;
	case "vjs":
		ivwCategory = "TV";
		owaCategory = "Service/Unternehmenskommunikation/Unternehmenskommunikation/viva.tv";
		break;
	case "musik":
		ivwCategory = "Stars";
		if (urlItems[1] == "artists") {
			if ((urlItems.length) > 3) {
				if (urlItems[3] == "videos")
					ivwCategory = "Music_Video";
			}
		}
		break;
	case "minisite":
			if(urlItems[1]=="videoquiz") {
				ivwCategory = "videoquiz_home";
			}
			else if(urlItems[1]=="travel") {
				ivwCategory = "travel";
			}
		break;
	case "games":
		ivwCategory = "Games";
		owaCategory = "UnterhaltungGames/Games/Sonstiges/viva.tv";
		if (urlItems.length==1)
			ivwCategory = ivwCategory.concat("/Home");
		break;
	case "win":
		ivwCategory = "Win";
		owaCategory = "UnterhaltungGames/Games/Gewinnspiele/viva.tv";
		if (urlItems.length==1)
			ivwCategory = ivwCategory.concat("/Home");
		break;
	case "lifestyle":
		ivwCategory = "Lifestyle";
		owaCategory = "RedCont/Lifestyle/Sonstiges/viva.tv";
		if (urlItems.length==1)
			ivwCategory = ivwCategory.concat("/Home");
		break;
	case "artists":
		ivwCategory = "Stars";
		owaCategory = "RedCont/Nachrichten/GesellschaftUndLeute/viva.tv";
		if (urlItems.length==1)
			ivwCategory = ivwCategory.concat("/Home");
		break;
	case "charts":
		ivwCategory = "Charts";
		owaCategory = "RedCont/KulturUndFreizeit/Musik/viva.tv";
		if (urlItems.length==1) {
			ivwCategory = ivwCategory.concat("/Home");
		} else {
			if (urlItems.length > 2) {
				if (urlItems[2] == "video")
					ivwCategory = ivwCategory.concat("/Videos");
			}
		}
		;
		break;
	case "vivavideos":
		ivwCategory = "Videos";
		owaCategory = "RedCont/KulturUndFreizeit/Musik/viva.tv";
		if (urlItems.length==1){
			if(window.location.href.indexOf('?clip=')==-1)
				ivwCategory = ivwCategory.concat("/Home");
			else
				ivwCategory = "Music_Video";
		}
		break;
	case "splash":
		ivwCategory = "Vorschaltseite";
		break;
	case "clipquiz":
		ivwCategory = "Clipquiz";
		owaCategory = "RedCont/KulturUndFreizeit/Musik/viva.tv";
		break;
	default: ivwCategory = urlItems[0];
	}// switch

}// if-else

//set the AGOF param
try{
	var scriptBlock="<!--SZMFRABO VERSION=\"1.2\" -->\n";
	scriptBlock+="<script type=\"Text/Javascript\">\n";
	scriptBlock+="<!--\n";
	scriptBlock+="var szmvars=\"vivatv//CP//"+ivwCategory+"\";\n";
	scriptBlock+="// -->\n";
	scriptBlock+="</script>\n";
	scriptBlock+="<script src=\"http://vivatv.ivwbox.de/2004/01/survey.js\"></script>\n";
	scriptBlock+="<!-- /SZMFRABO -->\n";
	if(ivwCategory!="Home") document.write(scriptBlock);
}catch(ex){}

// IVW
var IVW = "http://vivatv.ivwbox.de/cgi-bin/ivw/CP/" + ivwCategory + ";ivwpixel";
// netmetrix
var WEMF = "http://vivatv.wemfbox.ch/cgi-bin/ivw/CP/" + ivwCategory;
// ÖWA
var OEWA = "http://viacom.oewabox.at/cgi-bin/ivw/CP/" + owaCategory;

document.write("<img id=\"ivw_pixel\" src=\"" + IVW + "?r="
		+ escape(document.referrer) + "&d=" + (Math.random() * 100000)
		+ "\" width=\"1\" height=\"1\" alt=\"szmtag\" />");
// make the calls for local reporting
if (adRegion == "CH") {
	document.write("<img src=\"" + WEMF + "?r=" + escape(document.referrer)
			+ "&d=" + (Math.random() * 100000)
			+ "\" width=\"0\" height=\"0\" alt=\"\" />");
} else if (adRegion == "AT") {
	document.write("<div><img src=\"" + OEWA + "?r="
			+ escape(document.referrer) + "&d=" + (new Date()).getTime()
			+ "\" width=\"0\" height=\"0\" alt=\"oewapixel\" /></div>");
}

document.write("<iframe style=\"display: none;\" id=\"tracker\"></iframe>");

function trackFlipbook() {
	
	var callURL = "";
	
	/*KM(04102010) - OMNITURE + GA calls moved to gallerific.js - so will be removed from here: START*/
	// call google analytics
	//pageTracker._trackPageview();
	// omniture
	//mtvn.btg.Controller.sendPageCall(params);
	/*KM(04102010) - OMNITURE + GA calls moved to gallerific.js - so will be removed from here: END*/
	
	// call ivw
	callURL = IVW + "?r=" + escape(document.referrer) + "&d="
			+ (Math.random() * 100000);
	// update the tracker iframe's src attribute
	document.getElementById('tracker').src = callURL;

	// check ad region for AT & CH
	if (adRegion == "CH") {
		callURL = WEMF + "?r=" + escape(document.referrer) + "&d="
				+ (Math.random() * 100000);
		// update the tracker iframe's src attribute
		document.getElementById('tracker').src = callURL;
	} else if (adRegion == "AT") {
		callURL = OEWA + "?r=" + escape(document.referrer) + "&d="
				+ (new Date()).getTime();
		// update the tracker iframe's src attribute
		document.getElementById('tracker').src = callURL;
	}//if adRegion

}//trackFlipbook

