function openCenteredWindow(theURL,winName,features,myWidth,myHeight,isCenter) 
{ 
	var windowSize;
	if(window.screen)if(isCenter)if(isCenter=="true")
	{
		var myLeft = (screen.width-myWidth)/2;
		var myTop = (screen.height-myHeight)/2;
		features+=(features!='')?',':'';
		features+=',left='+myLeft+',top='+myTop;
  }
  if (myWidth != '') 
  {
  	windowSize= 'width='+myWidth+',height='+myHeight;
  } 
  else 
  {
  	windowSize = '';
  }  
  window.open(theURL,winName,features+((features!='' && windowSize!='')?',':'')+ windowSize);  	
}

function openwin(url,isCentered,param)
{
	var winprops = param;
	if(isCentered == 'Yes')
	{
		if(winprops.indexOf('width=') != -1)
		{
			var width =winprops.substring(6);
			width = width.substring(winprops.indexOf('width='),width.indexOf(','));
		}
		if(winprops.indexOf('height=') != -1)
		{
			var height =winprops.substring(winprops.indexOf('height='));
			height = height.substring(7,height.indexOf(','));
		}
		openCenteredWindow(url,'',winprops,width,height,'true');
	}
	else
	{
		window.open(url,'',winprops);
	}
}

function getArray(id)
{
	if(typeof(Callout_Array) != 'undefined')
	{
		var CalloutArray = eval(Callout_Array);
		var NoOfRows = CalloutArray.length;
		var tempId;
		for(i=0;i<NoOfRows;i++)
		{
			tempId = CalloutArray[i][1];
			var arrayId = parseInt(tempId);
			var paramId =  parseInt(id);
			if(arrayId == paramId)
			{
				return CalloutArray[i];
			}
		}
	}
}

function createLink(array)
{
		tempArray = eval(array);
		if(typeof(tempArray) != 'undefined')
		{
			var url='';
			var name = tempArray[0];
			var linkUrl = tempArray[4];
			var windowProps = tempArray[5];
			var center = tempArray[6];
			if(windowProps != 'null')
			{
				var url = "<a href=\"javascript:openwin(\'" + linkUrl + "\',\'" + center + "\',\'" +windowProps + "\')\">";
				url = url + "<b>" + name + "</b></a><br>";
				return url
			}
			else
			{
				url = url+"<a href='"+linkUrl+"'><b>"+name+"</b></a><br>";
				return url;
			}
	}
}

function buildcellfor2data(cssstyle, array)
{
		tempArray = eval(array);
		if(typeof(tempArray) != 'undefined')
		{
				var border;
				var anchor='';
				var link = createLink(tempArray);
				var name = tempArray[0];
				var imageUrl = tempArray[2];
				var bodyText = tempArray[3];
				var linkUrl = tempArray[4];
				var windowProps = tempArray[5];
				var center = tempArray[6];
				var flashUrl = tempArray[7];

				if(windowProps != 'null')
				{
					anchor = "<a href=\"javascript:openwin(\'" + linkUrl + "\',\'" + center + "\',\'" +windowProps + "\')\">";
				}
				else
				{
					anchor = "<a href='"+linkUrl+"'>";
				}
				document.write("<td width='180' class='"+cssstyle+"'>");
				if(flashVersion >= 6)
				{
					if ((flashUrl != 'null') && (flashUrl != undefined))
					{
						document.write(anchor);
						document.write("<object align='left' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='53' height='53'>");
						document.write("<param name='movie' value='"+flashUrl+"'>");
						document.write("<param name='quality' value='high'>");
						document.write("<embed src='"+flashUrl+"' ");
						document.write(" width='53' height='53' align='left' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed></object>");
						document.write("</a>");
					} else if(imageUrl != 'null')
					{
						document.write(anchor+"<img align='left' class='imgsmall' src='"+imageUrl+"' width='53' height='53' border='0'></a>");
					}
				} else {
					if(imageUrl != 'null') {
						document.write(anchor+"<img align='left' class='imgsmall' src='"+imageUrl+"' width='53' height='53' border='0'></a>");
					}
				}
				document.write(link+bodyText+"</td>");
						
		}
	
}

function buildcellforonedata(cssstyle,array, bshowCollspan)
{
	var anchor='';
	var tmpNoOfCell = 1;
	var COLSPAN = "";
	tempArray = eval(array);
	if(typeof(tempArray) != 'undefined')
	{
		var link = createLink(tempArray);
		var name = tempArray[0];
		var imageUrl = tempArray[2];
		var bodyText = tempArray[3];
		var linkUrl = tempArray[4];
		var windowProps = tempArray[5];
		var center = tempArray[6];
		var flashUrl = tempArray[7];
		if(windowProps != 'null')
		{
			anchor = "<a href=\"javascript:openwin(\'" + linkUrl + "\',\'" + center + "\',\'" +windowProps + "\')\">";
		}
		else
		{
			anchor = "<a href='"+linkUrl+"'>";
		}
		document.write("<tr valign='top'>");	

		if(flashVersion >= 6)
		{
			if ((flashUrl != 'null') && (flashUrl != undefined))
			{
				document.write("<td class='"+cssstyle+"' width='58'>");
				document.write(anchor);
				document.write("<object align='left' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='53' height='53'>");
				document.write("<param name='movie' value='"+flashUrl+"'>");
				document.write("<param name='quality' value='high'>");
				document.write("<embed src='"+flashUrl+"' ");
				document.write(" width='53' height='53' align='left' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed></object>");
				document.write("</a>");
				document.write("</td>");
				tmpNoOfCell = 2;
			} else if(imageUrl != 'null')
			{
				document.write("<td class='"+cssstyle+"' width='58'>");
				document.write(anchor+"<img align='left' class='imgsmall' src='"+imageUrl+"' width='53' height='53' border='0'></a>");
				document.write("</td>");
				tmpNoOfCell = 2;
			}
		} else {
			if(imageUrl != 'null')
			{
				document.write("<td class='"+cssstyle+"' width='58'>");
				document.write(anchor+"<img align='left' class='imgsmall' src='"+imageUrl+"' width='53' height='53' border='0'></a>");
				document.write("</td>");
				tmpNoOfCell = 2;
			}
			
		}
		if(tmpNoOfCell ==1 && bshowCollspan)
		{
			COLSPAN = "colspan='2'";
			tmpNoOfCell = 2;
		}
		document.write("<td "+COLSPAN+"class='"+cssstyle+"'>");
		document.write(link);
		document.write(bodyText);
		document.write("</td>");
		document.write("</tr>");
	}
	if(tmpNoOfCell == 2)
		return true;
	else
		return false;
}

function BuildDisplayPromos(CalloutId1,CalloutId2,CalloutId3,CalloutId4,CalloutStyle,CalloutBorder,divTagRequired)
{	
	if(CalloutStyle == 'Style1')
	{
		var array;
		var booleanCell;
		var style;
		if(CalloutBorder == 'WithOutBorder')
		{
			style = 'yeltop';
		}
		if(CalloutBorder == 'WithBorder')
		{
			style = 'yeltopbot';
		}
		document.write("<table width='242' border='0' cellspacing='0' cellpadding='0'>");
		
		if(CalloutId1 != '-1')
		{
			array = getArray(CalloutId1);
			booleanCell = buildcellforonedata(style,array,false);
		}
		if(CalloutId2 != '-1')
		{
			array = getArray(CalloutId2);
			booleanCell = buildcellforonedata(style,array,booleanCell);
		}
		if(CalloutId3 != '-1')
		{
			array = getArray(CalloutId3);
			booleanCell = buildcellforonedata(style,array,booleanCell);
		}
		if(CalloutId3 != '-1')
		{
			array = getArray(CalloutId4);
			booleanCell = buildcellforonedata(style,array,booleanCell);
		}
		document.write("</table>");
	}




	/*
			For integration from Home and Audience page

	*/



	if(CalloutStyle == 'Style2')
	{
		balwayYeltop = false;	
		b4cells = false;	
		if(CalloutBorder == 'WithOutBorder')
		{
			style = 'yeltop';
			balwayYeltop = true;
		}

		var array1 = getArray(CalloutId1);
		var array2 = getArray(CalloutId2);
		var array3 = getArray(CalloutId3);
		var array4 = getArray(CalloutId4);

		if(typeof(array1) != 'undefined' && typeof(array2) != 'undefined' && typeof(array3) != 'undefined' && typeof(array4) != 'undefined')
		{
			b4cells = true;	
		}




		
		
		/*
			OPENING DIV TAGS FOR PROMOS STARTS
		*/

		if(true)
		{
			if(CalloutStyle == 'Style2')
			{

				if(divTagRequired == 'WithDivTag')
				{
					//alert(isDisplayPromosInTop)
					if (isDisplayPromosInTop!='undefined' && isDisplayPromosInTop==true)
					{
						document.write("<div >");
					}
					else
					{
						document.write("<div class='sp10'>");
					}
					document.write("<table width='368' border='0' cellspacing='0' cellpadding='0'>");
					document.write("<tr><td>");
					if (isDisplayPromosInTop)
					{
						document.write("<div class='sp5'>");
					}
					else
					{
						document.write("<div class='sp5'>");
					}
				}
			}
		}

		/*
			OPENING DIV TAGS FOR PROMOS ENDS
		*/


		document.write("<table width='368' border='0' cellspacing='0' cellpadding='0'>");
		
		if(CalloutId1 != '-1' && CalloutId2 != '-1')
		{
			if(!balwayYeltop)
			{
				if(b4cells)
				{
					style = 'yeltop';
				}
				else
				{
					style = 'yeltopbot';
				}
			}				
			
			if(typeof(array1) != 'undefined' && typeof(array2) != 'undefined')
			{
				document.write("<tr valign='top'>");			
				buildcellfor2data(style,array1);
				//alert(style);				
				document.write("<td width='8' class='"+style+"'>&nbsp;</td>");		
				buildcellfor2data(style,array2);
				document.write("</tr>");				
			}
		}
		if(CalloutId3 != '-1' && CalloutId4 != '-1')
		{
			
			if(typeof(array3) != 'undefined' && typeof(array4) != 'undefined')
			{
				if(!balwayYeltop)
				{
					if(b4cells)
					{
						style = 'yeltopbot';
					}
				}
				else
				{
					style = 'yeltop';
				}

				document.write("<tr valign='top'>");
				buildcellfor2data(style,array3);
				document.write("<td width='8' class='"+style+"'>&nbsp;</td>");
				buildcellfor2data(style,array4);
				document.write("</tr>");
			}
		}
		document.write("</table>");

		/*
			CLOSING DIV TAGS FOR PROMOS STARTS
		*/

		if(true)
		{
			if(CalloutStyle == 'Style2')
			{
				if(divTagRequired == 'WithDivTag')
				{
					document.write("</div>");
					document.write("</td></tr>");
					document.write("</table>");
					document.write("</div>");
				}
			}
		}

		/*
			CLOSING DIV TAGS FOR PROMOS ENDS
		*/

	}
}

function BuildDisplayPromos6(CalloutId1,CalloutId2,CalloutId3,CalloutId4,CalloutId5,CalloutId6,CalloutStyle,CalloutBorder,divTagRequired)
{	
	if(CalloutStyle == 'Style1')
	{
		var array;
		var booleanCell;
		var style;
		if(CalloutBorder == 'WithOutBorder')
		{
			style = 'yeltop';
		}
		if(CalloutBorder == 'WithBorder')
		{
			style = 'yeltopbot';
		}
		document.write("<table width='242' border='0' cellspacing='0' cellpadding='0'>");
		
		if(CalloutId1 != '-1')
		{
			array = getArray(CalloutId1);
			booleanCell = buildcellforonedata(style,array,false);
		}
		if(CalloutId2 != '-1')
		{
			array = getArray(CalloutId2);
			booleanCell = buildcellforonedata(style,array,booleanCell);
		}
		if(CalloutId3 != '-1')
		{
			array = getArray(CalloutId3);
			booleanCell = buildcellforonedata(style,array,booleanCell);
		}
		if(CalloutId4 != '-1')
		{
			array = getArray(CalloutId4);
			booleanCell = buildcellforonedata(style,array,booleanCell);
		}
		if(CalloutId5 != '-1')
		{
			array = getArray(CalloutId5);
			booleanCell = buildcellforonedata(style,array,booleanCell);
		}
		if(CalloutId6 != '-1')
		{
			array = getArray(CalloutId6);
			booleanCell = buildcellforonedata(style,array,booleanCell);
		}
		document.write("</table>");
	}




	/*
			For integration from Home and Audience page

	*/



	if(CalloutStyle == 'Style2')
	{
		balwayYeltop = false;	
		b4cells = false;	
		if(CalloutBorder == 'WithOutBorder')
		{
			style = 'yeltop';
			balwayYeltop = true;
		}

		var array1 = getArray(CalloutId1);
		var array2 = getArray(CalloutId2);
		var array3 = getArray(CalloutId3);
		var array4 = getArray(CalloutId4);
		var array5 = getArray(CalloutId5);
		var array6 = getArray(CalloutId6);

		if(typeof(array1) != 'undefined' && typeof(array2) != 'undefined' && typeof(array3) != 'undefined' && typeof(array4) != 'undefined' && typeof(array5) != 'undefined' && typeof(array6) != 'undefined')
		{
			b4cells = true;	
		}




		
		
		/*
			OPENING DIV TAGS FOR PROMOS STARTS
		*/

		if(true)
		{
			if(CalloutStyle == 'Style2')
			{
				if(divTagRequired == 'WithDivTag')
				{
					document.write("<div class='sp10'>");
					document.write("<table width='368' border='0' cellspacing='0' cellpadding='0'>");
					document.write("<tr><td>");
					document.write("<div class='sp5'>");
				}
			}
		}

		/*
			OPENING DIV TAGS FOR PROMOS ENDS
		*/


		document.write("<table width='368' border='0' cellspacing='0' cellpadding='0'>");
		
		if(CalloutId1 != '-1' && CalloutId2 != '-1')
		{
			if(!balwayYeltop)
			{
				if(b4cells)
				{
					style = 'yeltop';
				}
				else
				{
					style = 'yeltopbot';
				}
			}				
			
			if(typeof(array1) != 'undefined' && typeof(array2) != 'undefined')
			{
				document.write("<tr valign='top'>");			
				buildcellfor2data(style,array1);
				//alert(style);				
				document.write("<td width='8' class='"+style+"'>&nbsp;</td>");		
				buildcellfor2data(style,array2);
				document.write("</tr>");				
			}
		}
		if(CalloutId3 != '-1' && CalloutId4 != '-1')
		{
			
			if(typeof(array3) != 'undefined' && typeof(array4) != 'undefined')
			{
				if(!balwayYeltop)
				{
					if(b4cells)
					{
						style = 'yeltopbot';
					}
				}
				else
				{
					style = 'yeltop';
				}

				document.write("<tr valign='top'>");
				buildcellfor2data(style,array3);
				document.write("<td width='8' class='"+style+"'>&nbsp;</td>");
				buildcellfor2data(style,array4);
				document.write("</tr>");
			}
		}
		if(CalloutId5 != '-1' && CalloutId6 != '-1')
		{
			
			if(typeof(array5) != 'undefined' && typeof(array6) != 'undefined')
			{
				if(!balwayYeltop)
				{
					if(b4cells)
					{
						style = 'yeltopbot';
					}
				}
				else
				{
					style = 'yeltop';
				}

				document.write("<tr valign='top'>");
				buildcellfor2data(style,array5);
				document.write("<td width='8' class='"+style+"'>&nbsp;</td>");
				buildcellfor2data(style,array6);
				document.write("</tr>");
			}
		}
		document.write("</table>");

		/*
			CLOSING DIV TAGS FOR PROMOS STARTS
		*/

		if(true)
		{
			if(CalloutStyle == 'Style2')
			{
				if(divTagRequired == 'WithDivTag')
				{
					document.write("</div>");
					document.write("</td></tr>");
					document.write("</table>");
					document.write("</div>");
				}
			}
		}

		/*
			CLOSING DIV TAGS FOR PROMOS ENDS
		*/

	}
}
