
//Functions	

function funSubmitForm(strQueryString)
	{
		document.frmMainForm.action = 'index.asp?' + strQueryString;
		document.frmMainForm.submit();
	}

function funPopUp(strURL)

{
	var nLeft = (window.screen.availWidth - 600)/2;
	var nTop = (window.screen.availHeight - 490)/2;
	window.open(strURL,'winPopUp','resizeable=no,width=400,height=290,top=' + nTop + ',left=' + nLeft,true); 
}


function funPositionedPopUpWithTitle(strURL, intWidth, intHeight, intLeft, intTop, strTitle)
{
	window.open(strURL,strTitle,'resizeable=no,width=' + intWidth + ',height=' + intHeight + ',top=' + intTop + ',left=' + intLeft,true); 
}

function funDisplayHideDiv(strDivName,strMoreLink)
	{
		if (document.all("" + strDivName + "").style.display == '')
			{
				document.all("" + strDivName + "").style.display = 'none' ;
			}
		else
			{
				document.all("" + strDivName + "").style.display = '' ;
			}
			
		if (document.all("" + strMoreLink + "").innerHTML == 'Show Help')
			{
				document.all("" + strMoreLink + "").innerHTML = 'Hide Help';
			}
		else
			{
				document.all("" + strMoreLink + "").innerHTML = 'Show Help';
			}	
			
	}	
	
function funDisplayToolDIV(strDivname)	
	{
		if (document.all("" + strDivname + "").style.display == '')
			{
				document.all("" + strDivname + "").style.display = 'none' ;
			}
		else
			{
				document.all("" + strDivname + "").style.display = '' ;
			}	
	}
	
function funDisplayHideDisplayDiv(strDivName,strMoreLink,strMoreText)
	{
		
		if (document.all("" + strDivName + "").style.display == '')
			{
				document.all("" + strDivName + "").style.display = 'none' ;
				if (strDivName == 'divCD_MeasureCurrency')
					{
						funBuildDynamicHelp('<i>Currency Conversion Options</i><br><br>Currency Conversion Options are now hidden. Your selections for this report have been retained.<br><br>Click "Show" to redisplay.','divCD_DynamicHelp') ;
					}
				if (strDivName == 'divMeasureCurrency')
					{
						funBuildDynamicHelp('<i>Currency Conversion Options</i><br><br>Currency Conversion Options are now hidden. Your selections for this report have been retained.<br><br>Click "Show" to redisplay.','divDynamicHelpMeasures') ;
					}
			}
		else
			{
				document.all("" + strDivName + "").style.display = '' ;
				if (strDivName == 'divCD_MeasureCurrency')
					{
						funBuildDynamicHelp('<i>Currency Conversion Options</i><br><br>Currency Conversion Options are now displayed. The default currency is euro(EUR).<br><br>Please choose the currency for your report and the exchange conversion type.','divCD_DynamicHelp') ;
					}
				if (strDivName == 'divMeasureCurrency')
					{
						funBuildDynamicHelp('<i>Currency Conversion Options</i><br><br>Currency Conversion Options are now displayed. The default currency is euro(EUR).<br><br>Please choose the currency for your report and the exchange conversion type.','divDynamicHelpMeasures') ;
					}
			}
		
		if (document.all("" + strMoreLink + "").innerHTML == 'Show ' + strMoreText)
			{
				document.all("" + strMoreLink + "").innerHTML = 'Hide ' + strMoreText;
			}
		else
			{
				document.all("" + strMoreLink + "").innerHTML = 'Show ' + strMoreText;
			}	
			
	}		

function funShowHideQuery(strDivName,strMoreLink)
	{
		if (document.all("" + strDivName + "").style.display == '')
			{
				document.all("" + strDivName + "").style.display = 'none' ;
			}
		else
			{
				document.all("" + strDivName + "").style.display = '' ;
			}
			
			if (document.all("" + strMoreLink + "").innerHTML == 'Show Query')
				{
					document.all("" + strMoreLink + "").innerHTML = 'Hide Query';
				}
			else
				{
					document.all("" + strMoreLink + "").innerHTML = 'Show Query';
				}	
			
	}
	
function funShowHideOptions(strDivName,strMoreLink)
	{
		if (document.all("" + strDivName + "").style.display == '')
			{
				document.all("" + strDivName + "").style.display = 'none' ;
			}
		else
			{
				document.all("" + strDivName + "").style.display = '' ;
			}
			
			if (document.all("" + strMoreLink + "").innerHTML == 'Show Your Selected Options')
				{
					document.all("" + strMoreLink + "").innerHTML = 'Hide Your Selected Options';
				}
			else
				{
					document.all("" + strMoreLink + "").innerHTML = 'Show Your Selected Options';
				}	
			
	}	
	
function funBuildDynamicHelp(strHelpText,strDivTag)
	{
		document.all("" + strDivTag + "").innerHTML = strHelpText;
	}


	
function funShowHideDataDiv(strDivName,strMoreLink)
	{
		if (document.all("" + strDivName + "").style.display == '')
			{
				document.all("" + strDivName + "").style.display = 'none' ;
			}
		else
			{
				document.all("" + strDivName + "").style.display = '' ;
			}
	
			if (document.all("" + strMoreLink + "").innerHTML == '+')
				{
					document.all("" + strMoreLink + "").innerHTML = '-';
				}
			else
				{
					document.all("" + strMoreLink + "").innerHTML = '+';
				}				
			
	}

function funDisplayRetailerBanner()
	{
		
		
		if ((document.all("divRetailerTab").style.display == '') || (document.all("divRetailerChildTab").style.display == ''))
			{
				
					funBuildDynamicHelp('You can now select banners from this tab. If you picked specific retailers in the previous view, these selections have been saved and will feature in your report.<br><br>To refine your selection of retailers, click on the "Retailers" button at the top of the tab. Any banner choices made here will be retained.','divDynamicHelp') ;

					document.all("radRetailer").checked = false ;
					document.all("radBanners").checked = true ;

					document.all("divRetailerChildTab").style.display = 'none' ;
					document.all("divRetailerTab").style.display = 'none' ;
					
					document.all("divRetailerChildChk").style.display = 'none' ;
					document.all("divRetailerBannerChk").style.display = '' ;
					
					document.all("divRetailerSelectAll").style.display = 'none' ;
					document.all("divBannerSelectAll").style.display = '' ;
					
					document.all("divIncludeFascia").style.display = 'none' ;
					
				if (document.all("chkDisplayBanner").checked == true)
					{
						document.all("divBannerChildTab").style.display = 'none' ;
						document.all("divBannerTab").style.display = '' ;					
					}
				else
					{
						document.all("divBannerTab").style.display = 'none' ;
						document.all("divBannerChildTab").style.display = '' ;					
					}
					
					document.all("trMessageSpacer").style.display = '' ;
					document.all("trMessageSpacer2").style.display = 'none' ;
					document.all("trMessage").style.display = '' ;

			}
		else
			{
					funBuildDynamicHelp('You can now select retailers from this tab.<br><br>If you picked specific banners in the previous view, these selections have been saved and will feature in your report.<br><br>To refine your selection of banners, click on the Banners button at the top of the tab. Any retailer choices made here will be retained.','divDynamicHelp') ;

					document.all("radRetailer").checked = true ;
					document.all("radBanners").checked = false ;

					document.all("divBannerChildTab").style.display = 'none' ;
					document.all("divBannerTab").style.display = 'none' ;
					
					document.all("divRetailerChildChk").style.display = '' ;
					document.all("divRetailerBannerChk").style.display = 'none' ;	
					
					document.all("divRetailerSelectAll").style.display = '' ;
					document.all("divBannerSelectAll").style.display = 'none' ;
					
					document.all("divIncludeFascia").style.display = '' ;				
					
				if (document.all("chkDisplayChildren").checked == true)
					{
						document.all("divRetailerTab").style.display = 'none' ;
						document.all("divRetailerChildTab").style.display = '' ;					
					}
				else
					{
						document.all("divRetailerChildTab").style.display = 'none' ;
						document.all("divRetailerTab").style.display = '' ;					
					}
					
					document.all("trMessageSpacer").style.display = 'none' ;
					document.all("trMessageSpacer2").style.display = '' ;
					document.all("trMessage").style.display = 'none' ;
			}	
	}
	
function funDisplayCountryDatabase()
	{
		if (document.all("divDBCountries").style.display == '')		
			{
				//funBuildDynamicHelp('On this tab you can choose the countries / regions in your report.<br><br>You can also access detailed country-specific data by clicking on the "map" icon<br><br>Click on "Show Help" for more about what you can do here.','divDynamicHelp') ;
				
				//document.all("divNormalCountries").style.display = '' ;
				//document.all("divDBCountries").style.display = 'none' ;	
				
				//document.all("divinActiveTabs").style.display = 'none' ;
				//document.all("divActiveTabs").style.display = '' ;	
				
				//document.all("divCountryCDHelp").style.display = 'none' ;
				//document.all("divCountryHelp").style.display = '' ;					
				
				//funResetCurrentQueryTool();		

				window.location = 'index.asp?ttid=3&resetcd=1' ;		
			}
		else
			{
				funBuildDynamicHelp('You have selected to use the "Country Database", all the selection for this query must be done and genereated through this tab.<br><br>Any data you have selected from the main tool will have been lost.','divCD_DynamicHelp')	;	
				
				document.all("divDBCountries").style.display = '' ;
				document.all("divNormalCountries").style.display = 'none' ;		
				
				document.all("divinActiveTabs").style.display = '' ;
				document.all("divActiveTabs").style.display = 'none' ;	
				
				document.all("divCountryHelp").style.display = 'none' ;
				document.all("divCountryCDHelp").style.display = '' ;					
				
				funResetCurrentQueryTool()	;				

			}
	}	
	
function funDisplayRetailerChildren()
	{
		
		
		if (document.all("divRetailerChildTab").style.display == 'none')
			{
				funBuildDynamicHelp('<i>Show retailer relationships in selection list</i><br><br>Retailer relationships are now shown in the selection list.<br><br>To return to the original alphabetical retailer list, untick the box.','divDynamicHelp') ;
				document.all("divRetailerChildTab").style.display = '' ;
				document.all("divRetailerTab").style.display = 'none' ;
				
				document.all("selRetailersWithChild").selectedIndex = -1;

				for (i=0;i<document.all("selRetailers").length;i++)
					{
						
						if (document.all("selRetailers").options[i].selected == true)
							{
								intSelectedIndex = document.all("selRetailers").options[i].value
	
								for (x=0;x<document.all("selRetailersWithChild").length;x++)
									{
										if (document.all("selRetailersWithChild").options[x].value == intSelectedIndex)
											{
												document.all("selRetailersWithChild").options[x].selected = true ;
											}									
									}
							}
					}
			}
		else
			{
				funBuildDynamicHelp('<i>Show retailer relationships in selection list</i><br><br>Retailers are now displayed in simple alphabetical order.<br><br>To return to the retailer relationships view, tick the box once again.','divDynamicHelp') ;	
				document.all("divRetailerChildTab").style.display = 'none' ;
				document.all("divRetailerTab").style.display = '' ;
				
				document.all("selRetailers").selectedIndex = -1;

				for (i=0;i<document.all("selRetailersWithChild").length;i++)
					{
						
						if (document.all("selRetailersWithChild").options[i].selected == true)
							{
								intSelectedIndex = document.all("selRetailersWithChild").options[i].value
	
								for (x=0;x<document.all("selRetailers").length;x++)
									{
										if (document.all("selRetailers").options[x].value == intSelectedIndex)
											{
												document.all("selRetailers").options[x].selected = true ;
											}									
									}
							}
					}
			}	
	}
	
function funDisplayBannerChildren()
	{
		
		
		if (document.all("divBannerChildTab").style.display == 'none')
			{
				funBuildDynamicHelp('<i>Display banners alphabetically</i><br><br>The selection list is now grouped by simple retailer relationship.<br><br>To return to the list sorted alphabetically by banner name, tick the box again.','divDynamicHelp')
				document.all("divBannerChildTab").style.display = '' ;
				document.all("divBannerTab").style.display = 'none' ;
				
				document.all("selBannersWithChild").selectedIndex = -1;
				
				for (i=0;i<document.all("selBanners").length;i++)
					{
						
						if (document.all("selBanners").options[i].selected == true)
							{
								intSelectedIndex = document.all("selBanners").options[i].value
	
								for (x=0;x<document.all("selBannersWithChild").length;x++)
									{
										if (document.all("selBannersWithChild").options[x].value == intSelectedIndex)
											{
												document.all("selBannersWithChild").options[x].selected = true ;
											}									
									}
							}
					}				
			}
		else
			{
				funBuildDynamicHelp('<i>Display banners alphabetically</i><br><br>The selection list is now sorted alphabetically by banner name.<br><br>To return to the original list grouped by retailer relationship, untick the box.','divDynamicHelp')	
				document.all("divBannerChildTab").style.display = 'none' ;
				document.all("divBannerTab").style.display = '' ;
				
				document.all("selBanners").selectedIndex = -1;
				
				for (i=0;i<document.all("selBannersWithChild").length;i++)
					{
						
						if (document.all("selBannersWithChild").options[i].selected == true)
							{
								intSelectedIndex = document.all("selBannersWithChild").options[i].value
	
								for (x=0;x<document.all("selBanners").length;x++)
									{
										if (document.all("selBanners").options[x].value == intSelectedIndex)
											{
												document.all("selBanners").options[x].selected = true ;
											}									
									}
							}
					}				
			}	
	}	
	
function funDisplayFormatChildren(intVisualOption)
	{
		
		var intSelectedIndex
		
		if (intVisualOption == 0)
			{

				funBuildDynamicHelp('<i>Show formats in the selection list which are:</i><br><br>The selection list now displays all available formats.','divDynamicHelp')
				document.all("divFormatBothTab").style.display = '' ;
				document.all("divFormatChildTab").style.display = 'none' ;
				document.all("divFormatTab").style.display = 'none' ;
				
				document.all("selFormatsBoth").selectedIndex = -1;

				for (i=0;i<document.all("selFormats").length;i++)
					{
						
						if (document.all("selFormats").options[i].selected == true)
							{
								intSelectedIndex = document.all("selFormats").options[i].value
	
								for (x=0;x<document.all("selFormatsBoth").length;x++)
									{
										if (document.all("selFormatsBoth").options[x].value == intSelectedIndex)
											{
												document.all("selFormatsBoth").options[x].selected = true ;
											}									
									}
							}
					}	
				for (i=0;i<document.all("selFormatsWithChild").length;i++)
					{
						
						if (document.all("selFormatsWithChild").options[i].selected == true)
							{
								intSelectedIndex = document.all("selFormatsWithChild").options[i].value
	
								for (x=0;x<document.all("selFormatsBoth").length;x++)
									{
										if (document.all("selFormatsBoth").options[x].value == intSelectedIndex)
											{
												document.all("selFormatsBoth").options[x].selected = true ;
											}									
									}
							}
					}				
				
			}
		if (intVisualOption == 1)
			{
			
				funBuildDynamicHelp('<i>Show formats in the selection list which are:</i><br><br>The selection list now only displays formats classified as grocery.','divDynamicHelp')	
				document.all("divFormatBothTab").style.display = 'none' ;
				document.all("divFormatChildTab").style.display = 'none' ;
				document.all("divFormatTab").style.display = '' ;
				document.all("selFormats").selectedIndex = -1;
				for (i=0;i<document.all("selFormatsBoth").length;i++)
					{
						
						if (document.all("selFormatsBoth").options[i].selected == true)
							{
								intSelectedIndex = document.all("selFormatsBoth").options[i].value
	
								for (x=0;x<document.all("selFormats").length;x++)
									{
										if (document.all("selFormats").options[x].value == intSelectedIndex)
											{
												document.all("selFormats").options[x].selected = true ;
											}									
									}
							}
					}	
			}	
		if (intVisualOption == 2)
			{
				funBuildDynamicHelp('<i>Show formats in the selection list which are:</i><br><br>The selection list now only displays formats classified as non grocery.','divDynamicHelp')	
				document.all("divFormatBothTab").style.display = 'none' ;
				document.all("divFormatChildTab").style.display = '' ;
				document.all("divFormatTab").style.display = 'none' ;
				
				document.all("selFormats").selectedIndex = -1;

				for (i=0;i<document.all("selFormatsBoth").length;i++)
					{
						
						if (document.all("selFormatsBoth").options[i].selected == true)
							{
								intSelectedIndex = document.all("selFormatsBoth").options[i].value
	
								for (x=0;x<document.all("selFormats").length;x++)
									{
										if (document.all("selFormats").options[x].value == intSelectedIndex)
											{
												document.all("selFormats").options[x].selected = true ;
											}									
									}
							}
					}	
			}			
	}	

function funDisplayCD_CountryChildren()
	{
		
		
		if (document.all("divCD_CountryChildTab").style.display == 'none')
			{
				funBuildDynamicHelp('The country list is now grouped by Region.','divCD_DynamicHelp')
				document.all("divCD_CountryChildTab").style.display = '' ;
				document.all("divCD_CountryTab").style.display = 'none' ;
				
				//document.all("txtCD_WhichSelectList").value = '2';

				document.all("selCD_CountriesWithChild").selectedIndex = -1;

				for (i=0;i<document.all("selCD_Countries").length;i++)
					{
						
						if (document.all("selCD_Countries").options[i].selected == true)
							{
								intSelectedIndex = document.all("selCD_Countries").options[i].value
	
								for (x=0;x<document.all("selCD_CountriesWithChild").length;x++)
									{
										if (document.all("selCD_CountriesWithChild").options[x].value == intSelectedIndex)
											{
												document.all("selCD_CountriesWithChild").options[x].selected = true ;
											}									
									}
							}
					}

			}
		else
			{
				funBuildDynamicHelp('The country list has is now sorted alphabetically by Country.','divCD_DynamicHelp')	
				document.all("divCD_CountryChildTab").style.display = 'none' ;
				document.all("divCD_CountryTab").style.display = '' ;
				
				//document.all("txtCD_WhichSelectList").value = '1';
				
				document.all("selCD_Countries").selectedIndex = -1;

				for (i=0;i<document.all("selCD_CountriesWithChild").length;i++)
					{
						
						if (document.all("selCD_CountriesWithChild").options[i].selected == true)
							{
								intSelectedIndex = document.all("selCD_CountriesWithChild").options[i].value
	
								for (x=0;x<document.all("selCD_Countries").length;x++)
									{
										if (document.all("selCD_Countries").options[x].value == intSelectedIndex)
											{
												document.all("selCD_Countries").options[x].selected = true ;
											}									
									}
							}
					}				
			}	
	}	

function funDisplayCountryChildren()
	{
		
		
		if (document.all("divCountryChildTab").style.display == 'none')
			{
				funBuildDynamicHelp('<i>Show region grouping in selection list</i><br><br>The selection list is now ordered with countries grouped by region and continent.<Br><br>To return to the original alphabetical list, untick the box','divDynamicHelp')
				document.all("divCountryChildTab").style.display = '' ;
				document.all("divCountryTab").style.display = 'none' ;

				document.all("selCountriesWithChild").selectedIndex = -1;

				for (i=0;i<document.all("selCountries").length;i++)
					{
						
						if (document.all("selCountries").options[i].selected == true)
							{
								intSelectedIndex = document.all("selCountries").options[i].value
	
								for (x=0;x<document.all("selCountriesWithChild").length;x++)
									{
										if (document.all("selCountriesWithChild").options[x].value == intSelectedIndex)
											{
												document.all("selCountriesWithChild").options[x].selected = true ;
											}									
									}
							}
					}

			}
		else
			{
				funBuildDynamicHelp('<i>Show region grouping in selection list</i><br><br>The selection list is now ordered alphabetically by country.<br><br>To return to the list ordered with countries grouped by region and continent, tick the box again.','divDynamicHelp')	
				document.all("divCountryChildTab").style.display = 'none' ;
				document.all("divCountryTab").style.display = '' ;
				
				document.all("selCountries").selectedIndex = -1;

				for (i=0;i<document.all("selCountriesWithChild").length;i++)
					{
						
						if (document.all("selCountriesWithChild").options[i].selected == true)
							{
								intSelectedIndex = document.all("selCountriesWithChild").options[i].value
	
								for (x=0;x<document.all("selCountries").length;x++)
									{
										if (document.all("selCountries").options[x].value == intSelectedIndex)
											{
												document.all("selCountries").options[x].selected = true ;
											}									
									}
							}
					}				
			}	
	}		

function funSelectAllCD_Countries()
{

    if (document.all("chkCD_CountrySelectAll").checked == false)
		{
		    for (i=0;i<document.all("selCD_Countries").length;i++)
				{
					document.all("selCD_Countries").options[i].selected = false;
					document.all("dynamicCountries").innerHTML = '';
				}	
				
		    for (i=0;i<document.all("selCD_CountriesWithChild").length;i++)
				{
					document.all("selCD_CountriesWithChild").options[i].selected = false;
					document.all("dynamicCountries").innerHTML = '';
				}	
		}
	else
		{
		    for (i=0;i<document.all("selCD_Countries").length;i++)
				{
					document.all("selCD_Countries").options[i].selected = true;
					document.all("dynamicCountries").innerHTML = 'All Selected<table width="90%" cellpadding="0" cellspacing="0"><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td width="100%" height="1" class="bg"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr></table>';
				}	
				
		    for (i=0;i<document.all("selCD_CountriesWithChild").length;i++)
				{
					document.all("selCD_CountriesWithChild").options[i].selected = true;
					document.all("dynamicCountries").innerHTML = 'All Selected<table width="90%" cellpadding="0" cellspacing="0"><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td width="100%" height="1" class="bg"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr></table>';
				}
		}	

}

function funSelectAll(strItem)
{

    if (document.all("" + strItem + "").options[0].selected == true)
		{
		    for (i=0;i<document.all("" + strItem + "").length;i++)
				{
					document.all("" + strItem + "").options[i].selected = false;
				}		
		}
	else
		{
		    for (i=0;i<document.all("" + strItem + "").length;i++)
				{
					document.all("" + strItem + "").options[i].selected = true;
				}			
		}	


}

function funSelectAllRetailers()
{

    if (document.all("chkRetailerSelectAll").checked == false)
		{
		    for (i=0;i<document.all("selRetailers").length;i++)
				{
					document.all("selRetailers").options[i].selected = false;
					document.all("dynamicRetailer").innerHTML = '';
				}	
				
		    for (i=0;i<document.all("selRetailersWithChild").length;i++)
				{
					document.all("selRetailersWithChild").options[i].selected = false;
					document.all("dynamicRetailer").innerHTML = '';
				}
				
			funBuildDynamicHelp('You have deselected all retailers from the selection list.<Br><br>You must select at least one retailer or banner before you can generate your report.','divDynamicHelp') ;
					
		}
	else
		{
		    for (i=0;i<document.all("selRetailers").length;i++)
				{
					document.all("selRetailers").options[i].selected = true;
					document.all("dynamicRetailer").innerHTML = 'All Selected<table width="90%" cellpadding="0" cellspacing="0"><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td width="100%" height="1" class="bg"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr></table>';
				}	
				
		    for (i=0;i<document.all("selRetailersWithChild").length;i++)
				{
					document.all("selRetailersWithChild").options[i].selected = true;
					document.all("dynamicRetailer").innerHTML = 'All Selected<table width="90%" cellpadding="0" cellspacing="0"><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td width="100%" height="1" class="bg"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr></table>';
				}	
				
			funBuildDynamicHelp('You have selected one or more retailers.<br><br>Your choices have appeared in the "Your Selections" area below.<br><br>You can now<ul><li>change options on this tab</li><li>go to another tab</li><li>hit Generate Report*</li></ul><br><i>*provided a measure has been selected.</i>','divDynamicHelp') ;	
				
		}	


}

function funSelectAllBanners()
{

    if (document.all("chkBannerSelectAll").checked == false)
		{
		    for (i=0;i<document.all("selBanners").length;i++)
				{
					document.all("selBanners").options[i].selected = false;
					document.all("dynamicBanner").innerHTML = '';
				}	
				
		    for (i=0;i<document.all("selBannersWithChild").length;i++)
				{
					document.all("selBannersWithChild").options[i].selected = false;
					document.all("dynamicBanner").innerHTML = '';
				}	
				
			funBuildDynamicHelp('You have deselected all banners from the selection list.<br><br>You must select at least one banner or retailer before you can generate your report.','divDynamicHelp') ;			
		}
	else
		{
		    for (i=0;i<document.all("selBanners").length;i++)
				{
					document.all("selBanners").options[i].selected = true;
					document.all("dynamicBanner").innerHTML = 'All Selected<table width="90%" cellpadding="0" cellspacing="0"><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td width="100%" height="1" class="bg"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr></table>';
				}	
				
		    for (i=0;i<document.all("selBannersWithChild").length;i++)
				{
					document.all("selBannersWithChild").options[i].selected = true;
					document.all("dynamicBanner").innerHTML = 'All Selected<table width="90%" cellpadding="0" cellspacing="0"><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td width="100%" height="1" class="bg"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr></table>';
				}	
				
			funBuildDynamicHelp('You have selected one or more banners. Your choices have appeared in the "Your Selections" area below.<br><br>You can now:<br> &bull;make further refinements on this tab<Br> &bull;go to another tab<br> &bull;hit Generate Query*<br><br><i>*provided a measure has been selected.</i>','divDynamicHelp') ;		
		}	


}
function funSelectAllFormats()
{

    if (document.all("chkFormatSelectAll").checked == false)
		{

			funBuildDynamicHelp('You have deselected all formats from the selection list.<br><br>When none are selected, the resulting report assumes all formats have been selected but does not display a formats column.','divDynamicHelp') ;
		 
		    for (i=0;i<document.all("selFormats").length;i++)
				{
					document.all("selFormats").options[i].selected = false;
					document.all("dynamicFormat").innerHTML = '';
				}	
				
		    for (i=0;i<document.all("selFormatsWithChild").length;i++)
				{
					document.all("selFormatsWithChild").options[i].selected = false;
					document.all("dynamicFormat").innerHTML = '';
				}	
				
		    for (i=0;i<document.all("selFormatsBoth").length;i++)
				{
					document.all("selFormatsBoth").options[i].selected = false;
					document.all("dynamicFormat").innerHTML = '';
				}						
		}
	else
		{
		    
		    funBuildDynamicHelp('You have selected one or more formats. Your choices have appeared in the "Your Selections" area below.<br><br>You can now:<br>&bull;make further refinements on this tab<br>&bull;go to another tab<br>&bull;hit Generate Query*<br><br><i>*provided a measure and a retailer/banner has been selected.</i>','divDynamicHelp') ;
		    
		    for (i=0;i<document.all("selFormats").length;i++)
				{
					document.all("selFormats").options[i].selected = true;
					document.all("dynamicFormat").innerHTML = 'All Selected<table width="90%" cellpadding="0" cellspacing="0"><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td width="100%" height="1" class="bg"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr></table>';
				}	
				
		    for (i=0;i<document.all("selFormatsWithChild").length;i++)
				{
					document.all("selFormatsWithChild").options[i].selected = true;
					document.all("dynamicFormat").innerHTML = 'All Selected<table width="90%" cellpadding="0" cellspacing="0"><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td width="100%" height="1" class="bg"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr></table>';
				}		
				
		    for (i=0;i<document.all("selFormatsBoth").length;i++)
				{
					document.all("selFormatsBoth").options[i].selected = true;
					document.all("dynamicFormat").innerHTML = 'All Selected<table width="90%" cellpadding="0" cellspacing="0"><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td width="100%" height="1" class="bg"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr></table>';
				}					
		}	
}
function funSelectAllYears()
{

    if (document.all("chkYearsSelectAll").checked == false)
		{
		    funBuildDynamicHelp('<i>Select the years</i><br><br>You have deselected all years from the selection list.<br><br>You must select at least one year before generating your report.','divDynamicHelpMeasures') ;
		    
		    for (i=0;i<document.all("selMeasureDateRange").length;i++)
				{
					document.all("selMeasureDateRange").options[i].selected = false;
					document.all("dynamicYears").innerHTML = '';
				}		

		}
	else
		{
		    funBuildDynamicHelp('<i>Select the years</i><br><br>You have selected one or more years as the time period for your report. Your choices have appeared in the "Your Selections" area below.','divDynamicHelpMeasures') ;
		    
		    for (i=0;i<document.all("selMeasureDateRange").length;i++)
				{
					document.all("selMeasureDateRange").options[i].selected = true;
					document.all("dynamicYears").innerHTML = 'All Selected<table width="90%" cellpadding="0" cellspacing="0"><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td width="100%" height="1" class="bg"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr></table>';
				}	
		
		}	
}
function funSelectAllCountries()
{

    if (document.all("chkCountrySelectAll").checked == false)
		{
		    for (i=0;i<document.all("selCountries").length;i++)
				{
					document.all("selCountries").options[i].selected = false;
					document.all("dynamicCountries").innerHTML = '';
				}	
				
				funBuildDynamicHelp('You have deselected all countries from the selection list.<br><br>When none are selected, the resulting report assumes all countries have been selected but does not display a countries column.','divDynamicHelp') ;
				
		    for (i=0;i<document.all("selCountriesWithChild").length;i++)
				{
					document.all("selCountriesWithChild").options[i].selected = false;
					document.all("dynamicCountries").innerHTML = '';
				}	
				
				
		}
	else
		{
		    for (i=0;i<document.all("selCountries").length;i++)
				{
					document.all("selCountries").options[i].selected = true;
					document.all("dynamicCountries").innerHTML = 'All Selected<table width="90%" cellpadding="0" cellspacing="0"><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td width="100%" height="1" class="bg"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr></table>';
				}	
				
		    for (i=0;i<document.all("selCountriesWithChild").length;i++)
				{
					document.all("selCountriesWithChild").options[i].selected = true;
					document.all("dynamicCountries").innerHTML = 'All Selected<table width="90%" cellpadding="0" cellspacing="0"><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td width="100%" height="1" class="bg"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr></table>';
				}	
				
funBuildDynamicHelp('You have selected one or more countries. Your choices have appeared in the "Your Selections" area below.<br><br>You can now:<br><br>&bull;make further refinements on this tab<br>&bull;go to another tab<br>&bull;hit Generate Query*<br><br><i>*provided a measure and a retailer/banner has been selected.</i>','divDynamicHelp') ;											
		}	


}
function funBuildCurrentQuery(strLocation,strDestination,strDynamicContent,strHiddenDestination)
{

	var strHiddenFieldContent ;	
	var intSelectedIndex ;
	
	strHiddenFieldContent = '';
	strDynamicContent = '';
	divDisplay = 0;
	divOKDisplay = 0;

	
		for (i=0;i<document.all("" + strLocation + "").length;i++)
			{

				if (document.all("" + strLocation + "").options[i].selected == true)
					{
						strDynamicContent = strDynamicContent + document.all("" + strLocation + "").options[i].innerHTML + '<table width="90%" cellpadding="0" cellspacing="0"><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td width="100%" height="1" class="bg"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr><tr><td height="3"><img src="/images/spacer.gif" height="1" alt="*" border="0"></td></tr></table>';
						strHiddenFieldContent = strHiddenFieldContent + document.all("" + strLocation + "").options[i].innerHTML + ',';
					    if (strDestination == 'dynamicCountries') 
					        {				           
					            if ((document.all("" + strLocation + "").options[i].innerHTML != 'United Kingdom') && (document.all("" + strLocation + "").options[i].innerHTML != 'Ireland'))
					                {					                
					                    
					                    divDisplay = 1 ;
					                }
					           else
					                {
					                    divOKDisplay = 1 ;
					                }
					        }
					}

			}
			
		if (strDestination == 'dynamicCountries') 
		    {
		        if (((divDisplay == 1) && (divOKDisplay != 0)) || ((divDisplay == 1) && (divOKDisplay != 1)))
		            {
		                document.all("txtHiddenNotes").value = '1' ;
		                document.all("txtHiddenDivNotes").value = '1' ;	
		                document.all("divCountryWarning").style.display = '' ;	
		            }
	            else
	                {
	                    document.all("txtHiddenNotes").value = '0' ;
	                    document.all("txtHiddenDivNotes").value = '0' ;
	                    document.all("divCountryWarning").style.display = 'none' ;
	                }
	        }
		
		
		document.all("" + strDestination + "").innerHTML = strDynamicContent;
		document.all("" + strHiddenDestination + "").value = strHiddenFieldContent;		
	
	if (strLocation == 'selCD_Measures')
		{
			funBuildCountryDBMeasures() ;	
		}
		
	if (strLocation == 'selMeasures')
		{
			funBuildDynamicHelp('<i>Choose your measure</i><br><br>You have selected one or more measures. Your choices have appeared in the "Your Selections" area below.','divDynamicHelpMeasures') ;
			funBuildMeasures() ;	
		}
	if ((strLocation == 'selCD_Countries') || (strLocation == 'selCD_CountriesWithChild'))
		{
			if (document.all("chkCD_CountrySelectAll").checked == true)
				{
					document.all("chkCD_CountrySelectAll").checked = false ;
				}
		}
					

	if (strLocation != 'intCD_MeasureDateRange')
		{
			if (strDestination == 'dynamicYears') 
				{
					funBuildDynamicHelp('<i>Select the years</i><br><br>You have selected one or more years as the time period for your report. Your choices have appeared in the "Your Selections" area below.','divDynamicHelpMeasures') ;
				}	
		}	
	
	if (strDestination == 'dynamicFormat') 
		{
			funBuildDynamicHelp('You have selected one or more formats. Your choices have appeared in the "Your Selections" area below.<br><br>You can now:<br>&bull;make further refinements on this tab<br>&bull;go to another tab<br>&bull;hit Generate Query*<br><br><i>*provided a measure and a retailer/banner has been selected.</i>','divDynamicHelp') ;
		
			if (document.all("chkFormatSelectAll").checked == true)
				{
					document.all("chkFormatSelectAll").checked = false
				}
		}	
		
	if (strDestination == 'dynamicBanner') 
		{
			funBuildDynamicHelp('You have selected one or more banners. Your choices have appeared in the "Your Selections" area below.<br><br>You can now:<br> &bull;make further refinements on this tab<Br> &bull;go to another tab<br> &bull;hit Generate Query*<br><br><i>*provided a measure has been selected.</i>','divDynamicHelp') ;
			
			if (document.all("chkBannerSelectAll").checked == true)
				{
					document.all("chkBannerSelectAll").checked = false
				}
		}	
		
	if (strDestination == 'dynamicRetailer') 
		{
			funBuildDynamicHelp('You have selected one or more retailers.<br><br>Your choices have appeared in the "Your Selections" area below.<br><br>You can now<ul><li>change options on this tab</li><li>go to another tab</li><li>hit Generate Report*</li></ul><br><i>*provided a measure has been selected.</i>','divDynamicHelp') ;
			
			if (document.all("chkRetailerSelectAll").checked == true)
				{
					document.all("chkRetailerSelectAll").checked = false
				}
		}	
		
	if (strDestination == 'dynamicCountries') 
		{
			funBuildDynamicHelp('You have selected one or more countries. Your choices have appeared in the "Your Selections" area below.<br><br>You can now:<br><br>&bull;make further refinements on this tab<br>&bull;go to another tab<br>&bull;hit Generate Query*<br><br><i>*provided a measure and a retailer/banner has been selected.</i>','divDynamicHelp') ;
			
			if (document.all("chkCountrySelectAll").checked == true)
				{
					document.all("chkCountrySelectAll").checked = false
				}
		}	
		


}

function funBuildCountryDBMeasures()
{

var intCounter = 0;	
var strSelectedCD_Measure= new String();

	document.all("strCD_CurrencyMoreLink").innerHTML = '' ;
	
	for (i=0;i<document.all("selCD_Measures").length;i++)
		{
			if (document.all("selCD_Measures").options[i].selected == true)
				{
					//get the selected measure
					strSelectedCD_Measure = document.all("selCD_Measures").options[i].value;
					
					//The value is MeasureID-Measure_Cat_I. We need to obtain the measure id
					var arrMeasures = strSelectedCD_Measure.split('-')
					strSelectedCD_MeasureID = arrMeasures[0];
					
					for(intCounter=0;intCounter< arrCD_Measures.length;intCounter++)
						{
							//alert(arrCD_Measures[intCounter] +'==' + strSelectedCD_MeasureID)
							if(arrCD_Measures[intCounter] == strSelectedCD_MeasureID)
							{
								document.all("strCD_CurrencyMoreLink").innerHTML = 'Show ' ;
								document.all("intCD_ShowCurrency").value = '1' ;
							}
							else
							{
								document.all("divCD_MeasureCurrency").style.display = 'none' ;
								document.all("intCD_ShowCurrency").value = '0' ;
								
							}
						}	
				}
			else
				{
					document.all("divCD_MeasureCurrency").style.display = 'none' ;
					document.all("intCD_ShowCurrency").value = '0' ;
					
				}
		}	

}

function funBuildMeasures()
{

var intCounter = 0;	
var strSelectedMeasure= new String();

	document.all("strCurrencyMoreLink").innerHTML = '' ;
	
	for (i=0;i<document.all("selMeasures").length;i++)
		{
			if (document.all("selMeasures").options[i].selected == true)
				{
					//get the selected measure
					strSelectedMeasure = document.all("selMeasures").options[i].value;
					//The value is MeasureID-Measure_Cat_I. We need to obtain the measure id
					var arrMeasuresAndCat = strSelectedMeasure.split('-')				
					strSelectedMeasureID = arrMeasuresAndCat[0];
					
					for(intCounter=0;intCounter< arrMeasures.length;intCounter++)
						{
							
							if(arrMeasures[intCounter] == strSelectedMeasureID)
							{
								document.all("strCurrencyMoreLink").innerHTML = 'Show ' ;
								document.all("intShowCurrency").value = '1' ;
							}
							else
							{
								document.all("divMeasureCurrency").style.display = 'none' ;
								document.all("intShowCurrency").value = '0' ;
								
							}
						}	
				}
			else
				{
					document.all("divMeasureCurrency").style.display = 'none' ;
					document.all("intShowCurrency").value = '0' ;
					
				}
		}	

}

function ShowHideMeasuresDiv()
{
	for (i=0;i<document.all("selCD_Measures").length;i++)
	{
		if (document.all("selCD_Measures").options[i].selected == true)
			{
				for(intCounter=0;intCounter<=arrCD_Measures.length;intCounter++)
					{
						if(arrCD_Measures[intCounter] == document.all("selCD_Measures").options[i].value)
						{
							document.all("intCD_ShowCurrency").value = '1' ;
							return true;
						}
					}	
			}
	}	
			
}
function ShowHideOtherMeasuresDiv()
{
	for (i=0;i<document.all("selMeasures").length;i++)
	{
		if (document.all("selMeasures").options[i].selected == true)
			{
				for(intCounter=0;intCounter<arrMeasures.length;intCounter++)
					{
						if(arrMeasures[intCounter] == document.all("selMeasures").options[i].value)
						{
							document.all("intShowCurrency").value = '1' ;
							return true;
						}
					}	
			}
	}	
			
}
function funResetCurrentQueryTool()
{

	document.all("dynamicRetailer").innerHTML = '' ;
	document.all("dynamicBanner").innerHTML = '' ;
	document.all("dynamicCountries").innerHTML = '' ;
	document.all("dynamicFormat").innerHTML = '' ;
	document.all("dynamicMeasures").innerHTML = '' ;
	document.all("dynamicYears").innerHTML = '' ;

}


function funSubmitMainForm()
{
	if (document.all("divDBCountries"))
		{
			if (document.all("divDBCountries").style.display == '')
				{
				document.frmMainForm.action= 'index.asp?cd=1&generate=1&fg=1#datatable' ;
				}
			else
				{
				document.frmMainForm.action= 'index.asp?generate=1&fg=1#datatable' ;
				}
		}	
	else
		{
			document.frmMainForm.action= 'index.asp?generate=1&fg=1#datatable' ;
		}	
	
	document.frmMainForm.submit() ;
}

function funResetQuery(ResetType)
{
	var answer = confirm ("Are you sure you want to reset?");
	
	if (answer)
		{   
		      if(ResetType == 1)
		      {		        
			    window.location='index.asp?reset=1' + '&cd=' + ResetType;
		      }
		      else
		      {
		        window.location='index.asp?reset=1';    
		      }
		}
	
}

function funIncludeBanners()
{
	if (document.all("chkRetailerIncludeFascia").checked == true)
		{
		funBuildDynamicHelp('<i>Include banners in results</i><br><br>You have chosen for your data in your report to be split out by the banners (fascias) belonging to the retailers you have chosen in the selection list.','divDynamicHelp') ;
		}
	else
		{
		funBuildDynamicHelp('<i>Include banners in results</i><br><br>You have deselected this option and consequently banners (fascias) will not appear in your report.<br><br>To reinstate this option, simply retick this option.','divDynamicHelp') ;
		}
}

function funCurrentQueryOptions(chkCheckBox,strSpan)
{
	if (document.all("" + chkCheckBox + "").checked == true)
		{
			document.all("" + strSpan + "").innerHTML = 'Included';
			
			if (chkCheckBox == 'txtOptUnconsolidated')
				{
					funBuildDynamicHelp('You have chosen to include Unconsolidated Operations in the data in your report.','divDynamicHelpMeasures') ;
				}
			if (chkCheckBox == 'txtOptFranchise')
				{
					funBuildDynamicHelp('You have chosen to include Franchises and Affiliates in the data in your report.','divDynamicHelpMeasures') ;
				}
			if (chkCheckBox == 'txtOptHistorical')
				{
					funBuildDynamicHelp('You have chosen to include Discontinued Operations in the data in your report.','divDynamicHelpMeasures') ;
				}
		}
	else
		{
			document.all("" + strSpan + "").innerHTML = 'Not Included';
			
			if (chkCheckBox == 'txtOptUnconsolidated')
				{
					funBuildDynamicHelp('You have chosen NOT to include Unconsolidated Operations in the data in your report.','divDynamicHelpMeasures') ;
				}
			if (chkCheckBox == 'txtOptFranchise')
				{
					funBuildDynamicHelp('You have chosen NOT to include Franchises and Affiliates in the data in your report.','divDynamicHelpMeasures') ;
				}
			if (chkCheckBox == 'txtOptHistorical')
				{
					funBuildDynamicHelp('You have chosen NOT to include Discontinued Operations in the data in your report.','divDynamicHelpMeasures') ;
				}			
		}	
}
	
function funCurrencyCurrentQuery(SelOpt)
{
		
	if (SelOpt == 'selCD_OptCurrency')
		{
			funBuildDynamicHelp('You have changed the selected currency for this report.','divcd_DynamicHelp') ;
		}
	else
		{
			funBuildDynamicHelp('You have changed the selected currency for this report.','divDynamicHelpMeasures') ;
		}
		
		
		for (i=0;i<document.all("" + SelOpt + "").length;i++)
			{

				if (document.all("" + SelOpt + "").options[i].selected == true)
					{
						document.all("strCurrencyCQ").innerHTML = document.all("" + SelOpt + "").options[i].innerHTML 
						//strHiddenFieldContent = strHiddenFieldContent + document.all("" + strLocation + "").options[i].innerHTML + ',';
					}

			}	
}	
					
		
		
			