/* navig.js */

var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=1 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)

/////No further editting needed
var linkObj;
var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden){
if (ie5||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-700
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID){
linkObj=obj;
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
if (typeof dropmenuobj!="undefined") //hide previous menu
dropmenuobj.style.visibility="hidden"
clearhidemenu()
if (ie5||ns6){
obj.onmouseout=delayhidemenu
dropmenuobj=document.getElementById(dropmenuID)
if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
dropmenuobj.onmouseover=clearhidemenu
dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
showhide(dropmenuobj.style, e, "visible", "hidden")
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
/* Added the following check for DOT-288 */
if(dropmenuobj.offsetWidth>160)
			dropmenuobj.style.width =  dropmenuobj.clientWidth; 
		else
			dropmenuobj.style.width = "160px";
 dropmenuobj.zindex=2000;
}
return clickreturnvalue()
}

function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie5&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("if( document.getElementById(linkObjClicked)!=linkObj && document.getElementById(linkObjSelected)!=linkObj){linkObj.style.color=\"#6ea3ba\";linkObj.style.background=\"#ffffff\";}dropmenuobj.style.visibility='hidden'",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

/* End of file navig.js*/

/* nielsenSWF.js*/
/* Generic SwfObject embed script*/

/** Function to embed default flash content using SWFObject
@parameters
@flashPath - path of the flash file to be displayed
@flashName - Unique name of the object holding the flash file
@height - Height of the flash object container 
@width - Width of the flash object container
@flashVersion - Version of the flash player to display the file
@divId - Div id to load the flash content
**/

function nielsenGenericSwf(flashPath,flashName,height,width,flashVersion,divId)
		{		
		var so = new SWFObject(flashPath, flashName, height, width, flashVersion);
		so.addParam("wmode", "transparent");
		so.addParam("scale", "noscale");		
		so.write(divId);			
		}

/** Function to embed flash content with custom parameters using SWFObject
@flashPath - path of the flash file to be displayed
@flashName - Unique name of the object holding the flash file
@height - Height of the flash object container 
@width - Width of the flash object container
@flashVersion - Version of the flash player to display the file
@divId - Div id to load the flash content
@var1, var2, var3 -  Name of the variables to be set for the flash objects
@value1, value2, value3 - Value for the variables set for the flash object
@param1, param2, param3 - Name of the parameters to be set for the flash objects
@paramValue1, paramValue2, paramValue3 - Value of the parameters set for the flash objects
**/

function nielsenGenericSwf(flashPath,flashName,height,width,flashVersion,divId,var1,value1,var2,value2,var3,value3,param1,paramValue1,param2,paramValue2,param3,paramValue3)
		{		
		var so = new SWFObject(flashPath, flashName, height, width, flashVersion);
		so.addVariable(var1, value1);
		so.addVariable(var2, value2);
		so.addVariable(var3, value3);
		so.addParam(param1, paramValue1);
		so.addParam(param1, paramValue2);
		so.addParam(param1, paramValue3);
		if(param1!="wmode" || param2!="wmode" || param3!="wmode")
		so.addParam("wmode", "transparent");
		if(param1!="scale" || param2!="scale" || param3!="scale")
		so.addParam("scale", "noscale");	
		so.write(divId);			
		}
/* End of file nielsenSWF.js*/

/* swfobject.js*/
/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) {
	if (!document.getElementById) { return; }
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
	if (!window.opera && document.all && this.installedVer.major > 7) {
		// only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
		deconcept.SWFObject.doPrepUnload = true;
	}
	if(c) { this.addParam('bgcolor', c); }
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('useExpressInstall', false);
	this.setAttribute('doExpressInstall', false);
	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
	this.setAttribute('xiRedirectUrl', xir);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
	useExpressInstall: function(path) {
		this.xiSWFPath = !path ? "expressinstall.swf" : path;
		this.setAttribute('useExpressInstall', true);
	},
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs[variablePairs.length] = key +"="+ variables[key];
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "PlugIn");
				this.setAttribute('swf', this.xiSWFPath);
			}
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '/>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "ActiveX");
				this.setAttribute('swf', this.xiSWFPath);
			}
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	write: function(elementId){
		if(this.getAttribute('useExpressInstall')) {
			// check to see if we need to do an express install
			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
				this.setAttribute('doExpressInstall', true);
				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			return true;
		}else{
			if(this.getAttribute('redirectUrl') != "") {
				document.location.replace(this.getAttribute('redirectUrl'));
			}
		}
		return false;
	}
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ // if Windows CE
		var axo = 1;
		var counter = 3;
		while(axo) {
			try {
				counter++;
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
//				document.write("player v: "+ counter);
				PlayerVersion = new deconcept.PlayerVersion([counter,0,0]);
			} catch (e) {
				axo = null;
			}
		}
	} else { // Win IE (non mobile)
		// do minor version lookup in IE, but avoid fp6 crashing issues
		// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		}catch(e){
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
				axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
			} catch(e) {
				if (PlayerVersion.major == 6) {
					return PlayerVersion;
				}
			}
			try {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			} catch(e) {}
		}
		if (axo != null) {
			PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
		}
	}
	return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
	this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
	this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
	this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
	getRequestParameter: function(param) {
		var q = document.location.search || document.location.hash;
		if (param == null) { return q; }
		if(q) {
			var pairs = q.substring(1).split("&");
			for (var i=0; i < pairs.length; i++) {
				if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
					return pairs[i].substring((pairs[i].indexOf("=")+1));
				}
			}
		}
		return "";
	}
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
	var objects = document.getElementsByTagName("OBJECT");
	for (var i = objects.length - 1; i >= 0; i--) {
		objects[i].style.display = 'none';
		for (var x in objects[i]) {
			if (typeof objects[i][x] == 'function') {
				objects[i][x] = function(){};
			}
		}
	}
}
// fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
if (deconcept.SWFObject.doPrepUnload) {
	if (!deconcept.unloadSet) {
		deconcept.SWFObjectUtil.prepUnload = function() {
			__flash_unloadHandler = function(){};
			__flash_savedUnloadHandler = function(){};
			window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
		}
		window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
		deconcept.unloadSet = true;
	}
}
/* add document.getElementById if needed (mobile IE < 5) */
if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;
/* End of file swfobject.js*/

/*Dot-570 To handle data coming from CRX with quotes*/
function replaceQuote(str)
{
	//str=str.replace('"','\"');
	return str;
}

/* Function to display the print preview of the current page */
var panelsArrayID=new Array('panel_2','panel_3','panel_4');
var removedPortlets=new Array("MMP","RMM","ADI","ADF");

var panelsArray=new Array();
var panelHTML="";
var panelsID=new Array();
var previewHTML="";
var preview_window;
var useDojo=false;
var browserName;
var ieVersion=-1;
var MBCImg=new Array();

function print_preview()
{	
	previewHTML=buildPreviewHTML();
	useDojo=checkDojo();
	//alert(useDojo);
	MBCImg=getMBCImg();
	browserName=navigator.appName;
	if(browserName=="Microsoft Internet Explorer")
	{
		ieVersion=getIEVersion();
	}
	else
	{		
		ieVersion=-1;
	}
	//alert(ieVersion);
	if(preview_window!=null)
	{
		preview_window.close();	
	}
	preview_window = window.open("","myWin","toolbar=yes, directories=no, location=no, status=yes, menubar=yes, resizable=no, scrollbars=yes, width=800,height=600, address=yes"); 		
		if(useDojo==true)
		{
			//preview_window.document.write("<style type=\"text/css\">@import \"/nielsen/js/dojo-1.0.0/dojo/resources/dojo.css\";");
			preview_window.document.write("<style type=\"text/css\">@import \"/nielsen/js/dojo-1.0.0/dijit/themes/tundra/tundra.css\";<\/style>");
		}
		preview_window.document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/nielsen/css/nielsencustom.css\"><\/style>");
		//preview_window.document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/nielsen/css/print.css\"><\/style>");
		preview_window.document.write("<html><head><\/head><body><div id=\"loadDiv\">Loading...<\/div><div id=\"mainDiv\" style=\"visibility:hidden\"><\/div><\/body><\/html>");	
		
		preview_window.document.write("<script type=\"text/javascript\">");
		preview_window.document.write("var JSdocs = [\"/nielsen/js/dojo-1.0.0/dojo/dojo.js\"];");
		preview_window.document.write("var removedPortletsArr=window.opener.removedPortlets;");
		preview_window.document.write("var notWhitespace = /\\S/;");
		preview_window.document.write("var panelArr=window.opener.panelsID;");	
		preview_window.document.write("var prntCount=0;");		//2/11
		preview_window.document.write("var PrntIntervalId = 0;");	//2/11
		

		//preview_window.document.write("alert(\"dojo\"+window.opener.useDojo);");
		preview_window.document.write("if(window.opener.useDojo==true){");
		preview_window.document.write("loadJSFiles();");
		preview_window.document.write("if(window.opener.browserName==\"Microsoft Internet Explorer\"){");
		preview_window.document.write("setTimeout(\"showPreviewHTML()\",3000);}");
		preview_window.document.write("else{");
		preview_window.document.write("showPreviewHTML();}}");
		preview_window.document.write("else{");
		preview_window.document.write("showPreviewHTML();}");

		preview_window.document.write("function showPreviewHTML(){");	
		preview_window.document.write("document.getElementById(\"mainDiv\").innerHTML=window.opener.previewHTML;");			
		preview_window.document.write("cleanWhitespace((document.getElementsByTagName(\"table\"))[0]);");
		preview_window.document.write("removePortlets();");			
		//preview_window.document.write("setPageWidth();");
		preview_window.document.write("hideImages();");		
		preview_window.document.write("removeImages();");
		preview_window.document.write("EnableLinks(false);");
		preview_window.document.write("disableSubmit();");
		preview_window.document.write("document.getElementById(\"mainDiv\").style.visibility=\"visible\";");				
		preview_window.document.write("document.getElementById('logoImg').style.visibility='visible';");
		preview_window.document.write("(document.getElementById(\"loadDiv\").parentNode).removeChild(document.getElementById(\"loadDiv\"));");
		preview_window.document.write("showMBCImages();");	
		preview_window.document.write("if(window.opener.browserName!=\"Microsoft Internet Explorer\")");
		preview_window.document.write("setTimeout(\"checkPrintImages(window.opener.MBCImg)\",5000);}");

		/*Function to hide all images except arrows and icons */
		preview_window.document.write("function hideImages(){");
			//preview_window.document.write("alert(\"isnide funciton\");");
			preview_window.document.write("var imgArr=document.getElementsByTagName(\"img\");");
			preview_window.document.write("for(var i=0;i<imgArr.length;i++){");
			//preview_window.document.write("alert(\"isnide for\");");
			preview_window.document.write("imgClass=(imgArr[i].parentNode).className;");
			preview_window.document.write("if((imgClass!=\"icon\") && (imgClass!=\"arrow\"))");
			preview_window.document.write("imgArr[i].style.visibility=\"hidden\";}");
			preview_window.document.write("var inpArr=document.getElementsByTagName(\"input\");");
			//preview_window.document.write("alert(\"array leng\"+inpArr.length);");
			preview_window.document.write("for(var i=0;i<inpArr.length;i++){");
			preview_window.document.write("if((inpArr[i].type==\"image\") && (inpArr[i].className!=\"icon\") && (inpArr[i].className!=\"arrow\"))");
			//preview_window.document.write("alert(\"isnide if\"+inpArr[i].type);");
			preview_window.document.write("inpArr[i].style.visibility=\"hidden\";}}");


		/* Function to remove image if it is the first element in a panel*/
		preview_window.document.write("function removeImages(){");
			preview_window.document.write("panelsLoop:for(var i=0;i<panelArr.length;i++){");
			//preview_window.document.write("alert(\"isnide first for - \"+i);");
			preview_window.document.write("var thisPanel=document.getElementById(panelArr[i]);");
			preview_window.document.write("divArr=thisPanel.getElementsByTagName(\"DIV\");");
			preview_window.document.write("for(var j=0;j<divArr.length;j++){");
			preview_window.document.write("if(divArr[j].className!=\"\" && divArr[i].className!=null){");
			//preview_window.document.write("alert(\"isnide first if\"+divArr[j].className);");
			preview_window.document.write("var childNodeArray = divArr[j].childNodes;");
			//preview_window.document.write("alert(\"isnide first if child node - \"+divArr[j].innerHTML);");
			//preview_window.document.write("alert(\"isnide first if child node - \"+childNodeArray[0].tagName);");
			preview_window.document.write("if(childNodeArray[0].tagName==\"IMG\" || childNodeArray[0].tagName==\"img\"){");
			//preview_window.document.write("alert(\"isnide first if\"+childNodeArray[0].src);");
			preview_window.document.write("(childNodeArray[0].parentNode).removeChild(childNodeArray[0]);}");
			preview_window.document.write("continue panelsLoop;}}}}");

		/* This function can be used to set the page width to 800px. This function is not being used now as the width of panels is being controlled by nielcustom.css.*/
		/*preview_window.document.write("function setPageWidth(){");		
			preview_window.document.write("var totalWidth=0;");		
			preview_window.document.write("var widthsArr=new Array();");
			preview_window.document.write("for(var i=0;i<panelArr.length;i++){");
			preview_window.document.write("var thisPanel=document.getElementById(panelArr[i]);");
			//preview_window.document.write("alert(\"panel width\"+parseInt(thisPanel.width));");
			preview_window.document.write("widthsArr[i]=parseInt(thisPanel.width);");
			preview_window.document.write("totalWidth=totalWidth+widthsArr[i];}");	
			//preview_window.document.write("alert(\"total width\"+totalWidth);");	
			preview_window.document.write("if(totalWidth>800){");
			preview_window.document.write("for(var i=0;i<widthsArr.length;i++){");
			//preview_window.document.write("alert(\"in for\");");
			preview_window.document.write("percentWidth=(widthsArr[i]/totalWidth)*100;");
			preview_window.document.write("var thisPanel=document.getElementById(panelArr[i]);");
			preview_window.document.write("thisPanel.width=(800/100)*percentWidth;}}}");*/

		/* Function to remove all white spaces from the page */
		preview_window.document.write("function cleanWhitespace(node){");
			preview_window.document.write("for (var x = 0; x < node.childNodes.length; x++){");
			preview_window.document.write("var childNode = node.childNodes[x];");
			preview_window.document.write("if ((childNode.nodeType == 3)&&(!notWhitespace.test(childNode.nodeValue))){");
			preview_window.document.write("node.removeChild(node.childNodes[x]);");
			preview_window.document.write("x--;}");
			preview_window.document.write("if (childNode.nodeType == 1){");
			preview_window.document.write("cleanWhitespace(childNode);}}}");

		/* Function to remove the portlets that are not to be shown in print preview page*/
		/*preview_window.document.write("function removePortlets(){");
			preview_window.document.write("divsArr=document.getElementsByTagName(\"div\");");
			preview_window.document.write("for(var i=0;i<removedPortletsArr.length;i++){");
			//preview_window.document.write("alert(\"first for - \"+removedPortletsArr[i]);");
			preview_window.document.write("for(var j=0;j<divsArr.length;j++){");
			preview_window.document.write("var theParent;");
			//preview_window.document.write("alert(\"second for - \"+divsArr[j].className);");
			preview_window.document.write("if(divsArr[j].className==removedPortletsArr[i]){");
			//preview_window.document.write("alert(\"portlet name\"+divsArr[j].className);");
			preview_window.document.write("theParent=divsArr[j].parentNode;");
			preview_window.document.write("theParent.removeChild(divsArr[j]);}}}}");
			//preview_window.document.write("alert(theParent.innerHTML);");	*/

		/*Function to import all js files needed */
		preview_window.document.write("function loadJSFiles(){");
			//preview_window.document.write("alert(\"isnide func\");");
			preview_window.document.write("var head = document.getElementsByTagName(\"head\")[0];");
			preview_window.document.write("for (var i=0; i<JSdocs.length; i++) {");
			preview_window.document.write("var script = document.createElement(\"script\");");
			preview_window.document.write("script.setAttribute(\"type\",\"text/javascript\");");
			preview_window.document.write("script.setAttribute(\"src\",JSdocs[i]);");
			//preview_window.document.write("alert(\"isnide for\");");
			preview_window.document.write("head.appendChild(script);}}");	

			
			
		preview_window.document.write("function getElementsByClassName(classNameVal){");
			preview_window.document.write("var elArr=new Array();");
			preview_window.document.write("var elCount=0;");
			preview_window.document.write("var el=document.getElementsByTagName(\"*\");");
			preview_window.document.write("for(var i=0;i<el.length;i++){");
			preview_window.document.write("if(el[i].className==classNameVal){");
			preview_window.document.write("elArr[elCount]=el[i];");
			preview_window.document.write("++elCount;}}");
			preview_window.document.write("return elArr;}");

		/* Function to remove the portlets that are not to be shown in print preview page*/
		preview_window.document.write("function removePortlets(){");
			preview_window.document.write("for(var i=0;i<removedPortletsArr.length;i++){");
			preview_window.document.write("var arr=getElementsByClassName(removedPortletsArr[i]);");
			preview_window.document.write("for(var j=0;j<arr.length;j++){");	
			preview_window.document.write("theParent=arr[j].parentNode;");
			preview_window.document.write("theParent.removeChild(arr[j]);}}}");	

		/* Function to disable all links*/
		preview_window.document.write("function returnTrue(){return true;}");
			preview_window.document.write("function returnFalse(){return false}");
			preview_window.document.write("function EnableLinks(enable){");
			preview_window.document.write("objLinks = document.getElementsByTagName(\"a\"); ");
			preview_window.document.write("if(enable){");
			preview_window.document.write("for(i=0;i<objLinks.length;i++){");
			preview_window.document.write("var link = objLinks[i];");
			preview_window.document.write("link.onclick=returnTrue;");
			preview_window.document.write("link.style.textDecoration=\"underline\";");
			preview_window.document.write("link.style.cursor=\"pointer\";}}");
			preview_window.document.write("else{");
			preview_window.document.write("for(i=0;i<objLinks.length;i++){");  
			preview_window.document.write("var link = objLinks[i]; ");
			preview_window.document.write("link.onclick=returnFalse;");
			preview_window.document.write("link.style.textDecoration=\"none\";");
			preview_window.document.write("link.style.cursor=\"default\";}}}");

		/* Function to disable button and submit buttons */
		preview_window.document.write("function disableSubmit(){");
			preview_window.document.write("var subArr=document.getElementsByTagName(\"input\");");
			preview_window.document.write("for(var i=0;i<subArr.length;i++){");
			preview_window.document.write("if(subArr[i].type==\"button\" || subArr[i].type==\"submit\")");
			preview_window.document.write("subArr[i].disabled=\"true\";}}");

	

		preview_window.document.write("function checkPrintImages(obj){");
			preview_window.document.write("var imagesLoad=allPrintImagesLoaded(obj);");
			//preview_window.document.write("alert(\"img load\"+imagesLoad);");
			preview_window.document.write("if(imagesLoad==true || prntCount>7){");
			preview_window.document.write("window.stop();");
			preview_window.document.write("if(PrntIntervalId!=0)");
			preview_window.document.write("clearInterval(PrntIntervalId);");
			preview_window.document.write("prntCount=0;");
			preview_window.document.write("PrntIntervalId = 0;}");
			preview_window.document.write("else{");
			preview_window.document.write("if(prntCount==0)");
			preview_window.document.write("PrntIntervalId=setInterval(\"checkPrintImages(obj)\", 2000);");
			preview_window.document.write("++prntCount;}");
			preview_window.document.write("return;}");

		preview_window.document.write("function allPrintImagesLoaded(obj){ ");
			preview_window.document.write("var images =obj;");
			preview_window.document.write("for (var i = 0;i<images.length;i++){");
			//preview_window.document.write("alert(\"isnide func\"+images[i].complete);");
			preview_window.document.write("if(images[i].complete == false){");
			preview_window.document.write("return false;}");
			preview_window.document.write("else if (typeof images[i].naturalWidth != \"undefined\" && images[i].naturalWidth == 0){");
			preview_window.document.write("return false;}}");
			preview_window.document.write("return true;}");

		/* Function to show all images in MBC */
		preview_window.document.write("function showMBCImages(){");			
			preview_window.document.write("var mbcArr=getElementsByClassName(\"MBC\");");	
			preview_window.document.write("for(var i=0;i<mbcArr.length;i++){");
			preview_window.document.write("var imgArr=mbcArr[i].getElementsByTagName(\"img\");");		
			preview_window.document.write("for(var j=0;j<imgArr.length;j++)");
			preview_window.document.write("imgArr[j].style.visibility=\"visible\";");
			preview_window.document.write("var inpArr=mbcArr[i].getElementsByTagName(\"input\");");		
			preview_window.document.write("for(var j=0;j<inpArr.length;j++){");
			preview_window.document.write("if(inpArr[i].type==\"image\")");
			preview_window.document.write("inpArr[j].style.visibility=\"visible\";}}}");							
		
		/* dot 655- Disable Right Click */
		 preview_window.document.write("var isNS = (navigator.appName == \"Netscape\") ? true : false;"); 
			 preview_window.document.write("if(navigator.appName == \"Netscape\")");    
			 preview_window.document.write(" document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);");
			 preview_window.document.write("function mischandler(){   return false; }");
			 preview_window.document.write("function mousehandler(e){");	
			 preview_window.document.write("var myevent = (isNS==true) ? e : event;");
			 preview_window.document.write("var eventbutton = (isNS==true) ? myevent.which : myevent.button;");    
			 preview_window.document.write("if((eventbutton==2)||(eventbutton==3)) return false;}");
			 preview_window.document.write("document.oncontextmenu = mischandler;");
			 preview_window.document.write("document.onmousedown = mousehandler;"); 
			 preview_window.document.write("document.onmouseup = mousehandler;"); 

		preview_window.document.write("<\/script>");		
		/*if(navigator.appName=="Microsoft Internet Explorer"){ 
		preview_window.location.reload(true);
		preview_window.focus();}*/
}

function buildPreviewHTML()
{
	var headerArea="<div><a href='nielsen_home'><img id=\"logoImg\" border='0' src='/nielsen/images/nielsen_85.gif'/></a></div>";
	var footerArea="";
	if(document.getElementById("copyright_data")!=null)
		footerArea=document.getElementById("copyright_data").innerHTML;
	panelHTML="";	
	panelCount=0;
	for(var i=0;i<panelsArrayID.length;i++)
	{
		if(document.getElementById(panelsArrayID[i])!=null && document.getElementById(panelsArrayID[i])!="")
		{
			panelsArray[panelCount]=document.getElementById(panelsArrayID[i]);
			tempHTML="<td id=\""+panelsArrayID[i]+"\" width=\""+panelsArray[i].width+"\">"+panelsArray[i].innerHTML+"</td>";
			panelsID[panelCount]=panelsArrayID[i];
			++panelCount;
		}
		else
		{
			tempHTML="";
		}	
		//alert("panel content - "+tempHTML);
		panelHTML=panelHTML+tempHTML;		
	}	
	if(panelHTML=="" || panelHTML==null)
	{
		panelHTML="<td></td>";
	}	
	//alert("no of panels"+panelsID.length);
	prevHTML="<table><tr><td>"+headerArea+"</td></tr><tr>"+panelHTML+"</tr><tr><td>"+footerArea+"</td></tr></table>";
	return prevHTML;
}

function checkDojo()
{
	var divsArr=document.getElementsByTagName("div");
	for(var i=0;i<divsArr.length;i++)	
	{
		if(divsArr[i].className=="tundra")
			return true;
	}
	return false;
}


function getIEVersion()
{
	var ver;
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
	{ //test for MSIE x.x;
		ver=new Number(RegExp.$1) // capture x.x portion and store as a number			
	}
	return ver;
}

function getMBCImg()
{
	var imgArr=new Array();
	var imgCount=0;
	var mbcArr=getElementsByClassName("MBC");
	for(var i=0;i<mbcArr.length;i++)
	{
		var imgsArr=mbcArr[i].getElementsByTagName("img");
		for(var j=0;j<imgsArr.length;j++)
		{
			imgArr[imgCount]=imgsArr[j];
			++imgCount;
		}
		var inpArr=mbcArr[i].getElementsByTagName("input");
		for(var j=0;j<inpArr.length;j++)
		{
			if(inpArr[j].type=="image")
			{
				imgArr[imgCount]=inpArr[j];
				++imgCount;
			}
		}
	}
return imgArr;
}

function getElementsByClassName(classNameVal)
{
		var elArr=new Array();
		var elCount=0;
		var el=document.getElementsByTagName("*");
		for(var i=0;i<el.length;i++)
		{
			if(el[i].className==classNameVal)
			{
				elArr[elCount]=el[i];
				++elCount;
			}
		}
	return elArr;
}

