// get the title of the content
/*function getFactOfTheDayTitle(){
	alert(0);
	var root = document.getElementById("factoftheday");
	var richTitle = root.childNodes[0].childNodes[0].innerHTML;
	// filter special tags for AS
	richTitle = replaceHTML(richTitle);
	return richTitle;
}*/

// get the main content of The Fact of The Day
function getFactOfTheDayContent(){
	/*var root = document.getElementById("factoftheday");
	if(window.ActiveXObject)
		var richTextContent = root.childNodes[0].childNodes[1].innerHTML; //IE
	else if(document.implementation&&document.implementation.createDocument)
		var richTextContent = root.childNodes[0].childNodes[2].innerHTML; //FF
	// filter special tags for AS
	richTextContent = replaceHTML(richTextContent);
	return richTextContent;*/
	var root = document.getElementById("factoftheday");
	if(window.ActiveXObject)
	{//IE
		//var richTextContent = root.childNodes[0].childNodes[0].innerHTML;
		var richTextContent = root.childNodes[0].innerHTML;
		richTextContent = replaceHTML(richTextContent);
	} 
	else if(document.implementation&&document.implementation.createDocument)
	{//FF
		var richTextContent = root.childNodes[0].innerHTML;
		// filter special tags for AS
		richTextContent = replaceHTML2(richTextContent);
	}
	return richTextContent;
}

// get vote infomation
function getVoteElement(i){
	var voteID = getVoteID();
    //var strVote = document.getElementById("f268254885");
	var strVote = document.getElementById(voteID);
    var strVoteQ = strVote.getElementsByTagName("li")[0].childNodes[0].nodeValue;
    var strVoteA = strVote.getElementsByTagName("label");
    var voteNumber = strVoteA.length;
    var item = new Array();
	var itemString = "";
    for (var a = 0; a < voteNumber; a++) {
        item[a] = strVoteA[a].childNodes[0].nodeValue;
    }
	for (var j = 0; j< voteNumber; j++)
	{
		if(j == voteNumber-1)
			itemString += item[j];
		else
			itemString += item[j] + "|" ;
	}
    switch (i) {
        case 1:	// vote number
            return voteNumber;
            break;
        case 2: // vote question
            return strVoteQ;
            break;
        case 3: // vote choice items array
			return itemString;
            break;
        default:
            return false;
            break;
    }
}

// get vote result
function getVoteResult(i){
    var rsltID = getRsltID();
    //var strVoteResMod = document.getElementById("d268254885rv");
	var strVoteResMod = document.getElementById(rsltID);

    var strVoteResult = strVoteResMod.getElementsByTagName("cite")[0].childNodes[0].nodeValue;

    var strVotePct = strVoteResMod.getElementsByTagName("li")[0].getElementsByTagName("strong");

    var voteNumber = strVotePct.length;
    var itemPct = new Array(); ;
	var itemString = "";
    for (var a = 0; a < voteNumber; a++) {
        itemPct[a] = strVotePct[a].childNodes[0].nodeValue;

    }
	for (var j = 0; j< voteNumber; j++){
		if(j == voteNumber-1)
			itemString += itemPct[j];
		else
			itemString += itemPct[j] + '|'; 
	}
    switch (i) {
        case 1:
            return strVoteResult;
            break;
        case 2:
            return itemString;
            break;
        default:
            return false;
            break;
    }
}
function doVote(n) {
	var voteID = getVoteID();
	var rsltID = getRsltID();
	var genID = voteID.substr(1);
	newSwitchAndVote(genID, voteID, rsltID, false, '', 'Please choose an answer for every question', 'Please choose an answer for at least one question', 'http://specials.uk.msn.com/niveasilver/default.aspx', n+1);
//	newSwitchAndVote('268254885', 'f268254885', 'd268254885rv', false, '', 'Please choose an answer for every question', 'Please choose an answer for at least one question', 'http://specials.uk.msn.com/niveasilver/default.aspx', n+1);
}
function newSwitchAndVote(f, m, l, e, g, i, j, k, n) {
	var voteID = getVoteID();
	var pollID = voteID.substr(1);
	pollID = "p"+pollID;
	var contentID = getPollContentID();
   // var c = "pollId=p268254885&vote=1&mv=1&voteshowresults=0&pollcontent=64856798&jsdisabled=false&q1=c" + n;
	var c = "pollId="+pollID+"&vote=1&mv=1&voteshowresults=0&pollcontent="+contentID+"&jsdisabled=false&q1=c" + n;
       Switch(m, l);
	   var h=document.getElementById("img"+f);
		if(g!="")h.src=g+"?"+c;
		else h.src=k+"?"+c;
    return false
}
//function doVote(n) {
	//SwitchAndVote('268254885', 'f268254885', 'd268254885rv', true, '','','','http://specials.uk.msn.com/niveasilver/default.aspx');
    //newSwitchAndVote('268254885', 'f268254885', 'd268254885rv', true, '', 'Please choose an answer for every question', 'Please choose an answer for at least one question', 'http://specials.uk.msn.com/niveasilver/default.aspx',n+1);
//}

function replaceHTML(inStr) {
    var outStr = inStr.replace(/\<STRONG\>/g, '<B>').replace(/\<\/STRONG\>/g, '</B>');
    var outStr = inStr.replace(/target=_blank/g, 'target=\"_blank\"');
    var startFont = outStr.indexOf("<FONT");
    var endFont = outStr.indexOf(">", startFont);
    while (startFont != -1) {
        if (outStr.indexOf("color=", startFont) != -1 && outStr.indexOf("color=", startFont) > startFont && outStr.indexOf("color=", startFont) < endFont) {
            var startColor = outStr.indexOf("color=", startFont) + 6;
            var endSpacesColor = outStr.indexOf(" ", startColor);
            var endRColor = outStr.indexOf(">", startColor);
            if (endSpacesColor <= endRColor && endSpacesColor != -1) {
                var endColor = endSpacesColor
            } else { var endColor = endRColor }
            var colorNo = outStr.substring(startColor, endColor);
            outStr = outStr.substring(0, startColor) + "\"" + colorNo + "\"" + outStr.substring(endColor);
        }
        if (outStr.indexOf("size=", startFont) != -1 && outStr.indexOf("size=", startFont) > startFont && outStr.indexOf("size=", startFont) < endFont) {
            var startSize = outStr.indexOf("size=",startFont) + 5;
            var endSpacesSize = outStr.indexOf(" ", startSize);
            var endRSize = outStr.indexOf(">", startSize);
            if (endSpacesSize <= endRSize && endSpacesSize != -1) {
                var endSize = endSpacesSize
            } else { var endSize = endRSize }
            var sizeNo = outStr.substring(startSize, endSize);
            outStr = outStr.substring(0, startSize) + "\"+" + sizeNo + "\"" + outStr.substring(endSize);
        }    
		/*if (outStr.indexOf("face=", startFont) != -1 && outStr.indexOf("face=", startFont) > startFont && outStr.indexOf("face=", startFont) < endFont) {
            var startSize = outStr.indexOf("face=",startFont) + 5;
            var endSpacesSize = outStr.indexOf(" ", startSize);
            var endRSize = outStr.indexOf(">", startSize);
            if (endSpacesSize <= endRSize && endSpacesSize != -1) {
                var endSize = endSpacesSize
            } else { var endSize = endRSize }
            var sizeNo = outStr.substring(startSize, endSize);
            outStr = outStr.substring(0, startSize) + "\"" + sizeNo + "\"" + outStr.substring(endSize);
        }  */
        if (outStr.indexOf("face=", startFont) != -1 && outStr.indexOf("face=", startFont) > startFont && outStr.indexOf("face=", startFont) < endFont) {
				var startPoint = outStr.indexOf("face=", startFont);
				var endPoint = outStr.indexOf(" ", outStr.indexOf("face=", startFont));
				var endPoint2 = outStr.indexOf(">", outStr.indexOf("face=", startFont));
				if(endPoint > endPoint2)
					endPoint = endPoint2;
				outStr = outStr.replace(outStr.substring(startPoint,endPoint),"");		
        }    
        startFont = outStr.indexOf("<FONT", endFont);
        endFont = outStr.indexOf(">", startFont);
    }
	outStr = outStr.replace(/\r\n/ig,'');
    return outStr;
}

function replaceHTML2(inStr) {
    var outStr = inStr.replace(/\<STRONG\>/g, '<B>').replace(/\<\/STRONG\>/g, '</B>');
    var outStr = inStr.replace(/target=_blank/g, 'target=\"_blank\"');
    var startFont = outStr.indexOf("<font");
    var endFont = outStr.indexOf(">", startFont);
    while (startFont != -1) {
        if (outStr.indexOf("color=", startFont) != -1 && outStr.indexOf("color=", startFont) > startFont && outStr.indexOf("color=", startFont) < endFont) {
            var startColor = outStr.indexOf("color=", startFont) + 6;
            var endSpacesColor = outStr.indexOf(" ", startColor);
            var endRColor = outStr.indexOf(">", startColor);
            if (endSpacesColor <= endRColor && endSpacesColor != -1) {
                var endColor = endSpacesColor
            } else { var endColor = endRColor }
            var colorNo = outStr.substring(startColor, endColor);
            outStr = outStr.substring(0, startColor) + "\"" + colorNo + "\"" + outStr.substring(endColor);
        }
        if (outStr.indexOf("size=", startFont) != -1 && outStr.indexOf("size=", startFont) > startFont && outStr.indexOf("size=", startFont) < endFont) {
            var startSize = outStr.indexOf("size=",startFont) + 5;
            var endSpacesSize = outStr.indexOf(" ", startSize);
            var endRSize = outStr.indexOf(">", startSize);
            if (endSpacesSize <= endRSize && endSpacesSize != -1) {
                var endSize = endSpacesSize
            } else { var endSize = endRSize }
            var sizeNo = outStr.substring(startSize, endSize);
            outStr = outStr.substring(0, startSize) + "\"+" + sizeNo + "\"" + outStr.substring(endSize);
        }    
		/*if (outStr.indexOf("face=", startFont) != -1 && outStr.indexOf("face=", startFont) > startFont && outStr.indexOf("face=", startFont) < endFont) {
            var startSize = outStr.indexOf("face=",startFont) + 5;
            var endSpacesSize = outStr.indexOf(" ", startSize);
            var endRSize = outStr.indexOf(">", startSize);
            if (endSpacesSize <= endRSize && endSpacesSize != -1) {
                var endSize = endSpacesSize
            } else { var endSize = endRSize }
            var sizeNo = outStr.substring(startSize, endSize);
            outStr = outStr.substring(0, startSize) + "\"" + sizeNo + "\"" + outStr.substring(endSize);
        }  */
        if (outStr.indexOf("face=", startFont) != -1 && outStr.indexOf("face=", startFont) > startFont && outStr.indexOf("face=", startFont) < endFont) {
				var startPoint = outStr.indexOf("face=", startFont);
				var endPoint = outStr.indexOf(" ", outStr.indexOf("face=", startFont));
				var endPoint2 = outStr.indexOf(">", outStr.indexOf("face=", startFont));
				if(endPoint > endPoint2)
					endPoint = endPoint2;
				outStr = outStr.replace(outStr.substring(startPoint,endPoint),"");		
        }    
        startFont = outStr.indexOf("<font", endFont);
        endFont = outStr.indexOf(">", startFont);
    }
	outStr = outStr.replace(/\r\n/ig,'');
	outStr = outStr.replace(new RegExp("<br><br>","gm"),"<BR>");
	outStr = outStr.replace(new RegExp("\n","gm"),"");
    return outStr;
}

//Get vote form id
function getVoteID(){
	var pollParentNode = document.getElementById("poll");

	var voteID = pollParentNode.childNodes[0].childNodes[0].childNodes[0].getAttribute('id');

	return voteID;
}

//Get result DIV id
function getRsltID(){
	var pollParentNode = document.getElementById("poll");
	
	var rsltID = pollParentNode.childNodes[0].childNodes[0].childNodes[2].getAttribute('id');

	return rsltID;
}

//Get poll content ID
function getPollContentID(){
	var pollParentNode = document.getElementById("poll");
	
	var contentID = pollParentNode.childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[5].value;

	return contentID;
}

//----------------------3rd party tracking 1--------------------

document.write("<script type='text/javascript' src='http://amch.questionmarket.com/adsc/d578221/9/590361/randm.js'></script>");

//----------------------3rd party tracking 2--------------------

//<!-- Start of DoubleClick Spotlight Tag: Please do not remove-->
//<!-- Activity Name for this tag is:Poll -->
//<!-- Web site URL where tag should be placed: http://www.MSN.com -->
//<!-- This tag must be placed within the opening <body> tag, as close to the beginning of it as possible-->
//<!-- Creation Date:4/22/2009 -->

var axel = Math.random()+"";
var a = axel * 10000000000000;
document.write('<IMG SRC="http://fls.uk.doubleclick.net/activityi;src=1001566;type=2009n403;cat=pollo855;ord='+ a + '?" WIDTH=1 HEIGHT=1 BORDER=0></IMG>');

