


function generateEquityGraph(isUserLogged)
{ 
	var start_day = document.equityGraphForm.start_day.value
	var start_month = document.equityGraphForm.start_month.value
	var start_year = document.equityGraphForm.start_year.value

	var end_day = document.equityGraphForm.end_day.value
	var end_month = document.equityGraphForm.end_month.value
	var end_year = document.equityGraphForm.end_year.value
	
	var default_time = document.equityGraphForm.default_time.value
	
	if(isUserLogged)
	{
		var showHL = document.equityGraphForm.showHL.checked
		var showVolume = document.equityGraphForm.showVolume.checked 
		var showMarkcap = document.equityGraphForm.showMarkcap.checked
		var showTurnover = document.equityGraphForm.showTurnover.checked
		var showNumberTrades = document.equityGraphForm.showNumberTrades.checked
		var showBids = document.equityGraphForm.showBids.checked
		var showOffers = document.equityGraphForm.showOffers.checked
	}
	else
	{
		var showHL = ""
		var showVolume = ""
		var showMarkcap = ""
		var showTurnover = ""
		var showNumberTrades = ""
		var showBids = ""
		var showOffers = ""
	}
	
	if(default_time == "")
	{ 
		if(end_day == -1 || end_month == -1 || end_year == -1)
		{
			alert("You have not selected a valid start date")
		}
		else if(start_day == -1 || start_month == -1 || start_year == -1)
		{
			alert("You have not selected a valid end date")
		}
		else
		{
			var jsStartDate = new Date(start_year, start_month -1, start_day)
			var jsEndDate = new Date(end_year, end_month -1, end_day)
			
			if(jsStartDate > new Date())
			{
				alert("The end date should not be later than todays date")
			}
			else
			{
				if(jsEndDate >= jsStartDate)
				{
					alert("The end date should be later than the start date")
				}
				else
				{
					var eToGraph = document.equityGraphForm.eToGraph.value
					var eToCompare = document.equityGraphForm.eToCompare.value
					var cwToCompare = document.equityGraphForm.cwToCompare.value
					var indexToCompare = document.equityGraphForm.indexToCompare.value
					var etfToCompare = document.equityGraphForm.etfToCompare.value
					
					var URL = GraphURL+"/app/equityGenerateGraphTemp.asp?start_day="+start_day+"&start_month="+start_month+"&start_year="+start_year+"&end_day="+end_day+"&end_month="+end_month+"&end_year="+end_year
					URL += "&eToGraph="+eToGraph+"&eToCompare="+eToCompare+"&etfToCompare="+etfToCompare+"&cwToCompare="+cwToCompare+"&indexToCompare="+indexToCompare+"&showHL="+showHL+"&showVolume="+showVolume+"&showMarkcap="+showMarkcap+"&showTurnover="+showTurnover+"&showNumberTrades="+showNumberTrades+"&showBids="+showBids+"&showOffers="+showOffers
					
					var graphHeight = 430
					
					// in this case bids and offers are shown on a separate graph
					// so add additional 170 pixels
					if( (eToCompare != "" || indexToCompare != "")
					    &&
					    (showBids || showOffers)
					  )
					{
						graphHeight += 170		
					}
					
					if(showVolume == true)
					{
						graphHeight += 170
					}
					if(showMarkcap == true)
					{
						graphHeight += 170
					}
					if(showTurnover == true)
					{
						graphHeight += 170
					}
					if(showNumberTrades == true)
					{
						graphHeight += 170
					}
					var attributes = "scrolling:yes;status:no;dialogWidth:750px;dialogHeight:"+graphHeight+"px"
					var win_attributes = 'width=750, height='+graphHeight
					
					if(navigator.appName == "Microsoft Internet Explorer")
					{
						showModelessDialog(URL,window,attributes);
						//window.open(URL,'',win_attributes)
					}
					else
						window.open(URL,'',win_attributes)
				}
			}
		}
	}
	else
	{
		var jsStartDate = new Date()
		var jsEndDate = new Date()
		
		var default_start_day
		var default_start_month
		var default_start_year
		
		if(default_time == "1_week")
		{
			var myDate = new Date()
			myDate.setDate(myDate.getDate() - 7) 

			default_start_day = myDate.getDate()
			default_start_month = myDate.getMonth() + 1
			default_start_year = myDate.getFullYear()
		}
		else if(default_time == "1_month")
		{
			lastMonthDate = new Date()
			lastMonthDate.setMonth(lastMonthDate.getMonth() - 1)
			
			default_start_day = lastMonthDate.getDate()
			default_start_month = lastMonthDate.getMonth() + 1
			default_start_year = lastMonthDate.getFullYear()
		}
		else if(default_time == "3_month")
		{
			lastMonthDate = new Date()
			lastMonthDate.setMonth(lastMonthDate.getMonth() - 3)
			
			default_start_day = lastMonthDate.getDate()
			default_start_month = lastMonthDate.getMonth() + 1
			default_start_year = lastMonthDate.getFullYear()
		}
		else if(default_time == "1_year")
		{
			default_start_day = jsStartDate.getDate()
			default_start_month = jsStartDate.getMonth() + 1
			default_start_year = jsStartDate.getFullYear() - 1
		}
		

		var default_end_day = jsEndDate.getDate()
		var default_end_month = jsEndDate.getMonth() + 1
		var default_end_year = jsEndDate.getFullYear()
		
		var eToGraph = document.equityGraphForm.eToGraph.value
		var eToCompare = document.equityGraphForm.eToCompare.value
		var cwToCompare = document.equityGraphForm.cwToCompare.value
		var indexToCompare = document.equityGraphForm.indexToCompare.value
		var etfToCompare = document.equityGraphForm.etfToCompare.value
		
		var URL = GraphURL+"/app/equityGenerateGraphTemp.asp?start_day="+default_end_day+"&start_month="+default_end_month+"&start_year="+default_end_year+"&end_day="+default_start_day+"&end_month="+default_start_month+"&end_year="+default_start_year
		URL += "&eToGraph="+eToGraph+"&eToCompare="+eToCompare+"&etfToCompare="+etfToCompare+"&cwToCompare="+cwToCompare+"&indexToCompare="+indexToCompare+"&showHL="+showHL+"&showVolume="+showVolume+"&showMarkcap="+showMarkcap+"&showTurnover="+showTurnover+"&showNumberTrades="+showNumberTrades+"&showBids="+showBids+"&showOffers="+showOffers
		
		var graphHeight = 430

		// in this case bids and offers are shown on a separate graph
		// so add additional 170 pixels
		if( (eToCompare != "" || indexToCompare != "" || showHL)
		    &&
		  (showBids || showOffers)
		)
		{
			graphHeight += 170
		}

		if(showVolume == true)
		{
			graphHeight += 170
		}
		if(showMarkcap == true)
		{
			graphHeight += 170
		}
		if(showTurnover == true)
		{
			graphHeight += 170
		}
		if(showNumberTrades == true)
		{
			graphHeight += 170
		}
		
		var attributes = "scrolling:yes;status:no;dialogWidth:750px;dialogHeight:"+graphHeight+"px"
		var win_attributes = 'width=750, height='+graphHeight
		
		if(navigator.appName == "Microsoft Internet Explorer")
		{
			//alert(URL)
			showModelessDialog(URL,window,attributes);
			//window.open(URL,'',win_attributes)
		}
		else
		{
			//alert(URL)
			window.open(URL,'',win_attributes)
		}
	}
}



function generateEtfGraph(isUserLogged)
{ 
	var start_day = document.equityGraphForm.start_day.value
	var start_month = document.equityGraphForm.start_month.value
	var start_year = document.equityGraphForm.start_year.value

	var end_day = document.equityGraphForm.end_day.value
	var end_month = document.equityGraphForm.end_month.value
	var end_year = document.equityGraphForm.end_year.value

	var default_time = document.equityGraphForm.default_time.value

	// fix values if default_time is specified
	if(default_time != "")
	{
		var Now = new Date()
		var StartDate = new Date()
       		if(default_time == "1_week")
		{
			StartDate.setDate(StartDate.getDate() - 7) 
		}
		else if(default_time == "1_month")
		{
			StartDate.setMonth(StartDate.getMonth() - 1)
		}
		else if(default_time == "3_month")
		{
			StartDate.setMonth(StartDate.getMonth() - 3)
		}
		else // default if(default_time == "1_year")
		{
			StartDate.setFullYear(StartDate.getFullYear() - 1)
		}
		end_day = StartDate.getDate()
		end_month = StartDate.getMonth() + 1
		end_year = StartDate.getFullYear()
		start_day = Now.getDate()
		start_month = Now.getMonth() + 1
		start_year = Now.getFullYear()
		
	}

	if(isUserLogged)
	{
		var showHL = document.equityGraphForm.showHL.checked
		var showVolume = document.equityGraphForm.showVolume.checked 
		var showMarkcap = document.equityGraphForm.showMarkcap.checked
		var showTurnover = document.equityGraphForm.showTurnover.checked
		var showNumberTrades = document.equityGraphForm.showNumberTrades.checked
		var showBids = document.equityGraphForm.showBids.checked
		var showOffers = document.equityGraphForm.showOffers.checked
	}
	else
	{
		var showHL = ""
		var showVolume = ""
		var showMarkcap = ""
		var showTurnover = ""
		var showNumberTrades = ""
		var showBids = ""
		var showOffers = ""
	}
	
	if(end_day == -1 || end_month == -1 || end_year == -1)
	{
		alert("You have not selected a valid start date")
	}
	else if(start_day == -1 || start_month == -1 || start_year == -1)
	{
		alert("You have not selected a valid end date")
	}
	else
	{
		var jsStartDate = new Date(start_year, start_month -1, start_day)
		var jsEndDate = new Date(end_year, end_month -1, end_day)
		
		if(jsStartDate > new Date())
		{
			alert("The end date should not be later than todays date")
		}
		else
		{
			if(jsEndDate >= jsStartDate)
			{
				alert("The end date should be later than the start date")
			}
			else
			{
				var eToGraph = document.equityGraphForm.eToGraph.value
				var eToCompare = document.equityGraphForm.eToCompare.value
				var cwToCompare = document.equityGraphForm.cwToCompare.value
				var indexToCompare = document.equityGraphForm.indexToCompare.value
		
				var URL = GraphURL+"/app/etfGenerateGraphTemp.asp?start_day="+start_day+"&start_month="+start_month+"&start_year="+start_year+"&end_day="+end_day+"&end_month="+end_month+"&end_year="+end_year
				URL += "&eToGraph="+eToGraph+"&eToCompare="+eToCompare+"&cwToCompare="+cwToCompare+"&indexToCompare="+indexToCompare+"&showHL="+showHL+"&showVolume="+showVolume+"&showMarkcap="+showMarkcap+"&showTurnover="+showTurnover
				URL += "&showNumberTrades="+showNumberTrades+"&showBids="+showBids+"&showOffers="+showOffers
				var graphHeight = 430
				if( (eToCompare != "" || indexToCompare != "")
				    &&
				    (showBids || showOffers)
				  )
				{
					graphHeight += 170		
				}

				if(showVolume == true)
				{
					graphHeight += 170
				}
				if(showMarkcap == true)
				{
					graphHeight += 170
				}
				if(showTurnover == true)
				{
					graphHeight += 170
				}
				if(showNumberTrades == true)
				{
					graphHeight += 170
				}
				var attributes = "status:no;dialogWidth:750px;dialogHeight:"+graphHeight+"px"
				var win_attributes = 'width=750, height='+graphHeight
				// alert(URL)
				//alert(attributes)
				if(navigator.appName == "Microsoft Internet Explorer")
					showModelessDialog(URL,window,attributes);
				else
					window.open(URL,'',win_attributes)
			}
		}
	}
}

function generateCWGraph(isUserLogged)
{
	var start_day = document.cwGenerateGraph.start_day.value
	var start_month = document.cwGenerateGraph.start_month.value
	var start_year = document.cwGenerateGraph.start_year.value

	var end_day = document.cwGenerateGraph.end_day.value
	var end_month = document.cwGenerateGraph.end_month.value
	var end_year = document.cwGenerateGraph.end_year.value
	
	if(isUserLogged)
	{
		var showHL = document.cwGenerateGraph.showHL.checked
		var showVolume = document.cwGenerateGraph.showVolume.checked 
		//var showMarkcap = document.all.showMarkcap.checked
		var showMarkcap = ""
		var showTurnover = document.cwGenerateGraph.showTurnover.checked
	}
	else
	{
		var showHL = ""
		var showVolume = ""
		var showMarkcap = ""
		var showTurnover = ""
	}
	
	
	var cwToGraph = document.cwGenerateGraph.cwToGraph.value
	var eToCompare = document.cwGenerateGraph.eToCompare.value
	var cwToCompare = document.cwGenerateGraph.cwToCompare.value
	var indexToCompare = document.cwGenerateGraph.indexToCompare.value
	
	if(end_day == -1 || end_month == -1 || end_year == -1)
	{
		alert("You have not selected a valid start date")
	}
	else if(start_day == -1 || start_month == -1 || start_year == -1)
	{
		alert("You have not selected a valid end date")
	}
	else
	{
		var jsStartDate = new Date(start_year, start_month -1, start_day)
		var jsEndDate = new Date(end_year, end_month -1, end_day)
		if(jsStartDate > new Date())
		{
			alert("The end date should not be later than todays date")
		}
		else
		{
			if(jsEndDate >= jsStartDate)
			{
				alert("The end date should be later than the start date")
			}
			else
			{
				//var URL = "cwGenerateGraph.asp?start_day="+start_day+"&start_month="+start_month+"&start_year="+start_year+"&end_day="+end_day+"&end_month="+end_month+"&end_year="+end_year
				//URL += "&cwToGraph="+cwToGraph+"&eToCompare="+eToCompare+"&cwToCompare="+cwToCompare+"&indexToCompare="+indexToCompare
				var URL = GraphURL+"/app/cwGenerateGraphTemp.asp?start_day="+start_day+"&start_month="+start_month+"&start_year="+start_year+"&end_day="+end_day+"&end_month="+end_month+"&end_year="+end_year
				URL += "&cwToGraph="+cwToGraph+"&eToCompare="+eToCompare+"&cwToCompare="+cwToCompare+"&indexToCompare="+indexToCompare+"&showHL="+showHL+"&showVolume="+showVolume+"&showMarkcap="+showMarkcap+"&showTurnover="+showTurnover
				var graphHeight = 450
				if(showVolume == true)
				{
					graphHeight += 120
				}
				if(showMarkcap == true)
				{
					graphHeight += 120
				}
				if(showTurnover == true)
				{
					graphHeight += 120
				}
				var attributes = "status:no;dialogWidth:750px;dialogHeight:"+graphHeight+"px"
				var win_attributes = 'width=750, height='+graphHeight
				//alert(attributes)
				if(navigator.appName == "Microsoft Internet Explorer")
					showModelessDialog(URL,window,attributes);
				else
					window.open(URL, '', win_attributes)
				
				//showModelessDialog(URL,window,"status:no;dialogWidth:620px;dialogHeight:450px");
				//window.open(URL)
			}
		}
	}

}

function generateBondGraph()
{ 
	var start_day = document.equityGraphForm.start_day.value
	var start_month = document.equityGraphForm.start_month.value
	var start_year = document.equityGraphForm.start_year.value

	var end_day = document.equityGraphForm.end_day.value
	var end_month = document.equityGraphForm.end_month.value
	var end_year = document.equityGraphForm.end_year.value
	
	var bToGraph = document.equityGraphForm.bToGraph.value
	var bToCompare = document.equityGraphForm.bToCompare.value

	var default_time = document.equityGraphForm.default_time.value

	// fix values if default_time is specified
	if(default_time != "")
	{
		var Now = new Date()
		var StartDate = new Date()
       		if(default_time == "1_week")
		{
			StartDate.setDate(StartDate.getDate() - 7) 
		}
		else if(default_time == "1_month")
		{
			StartDate.setMonth(StartDate.getMonth() - 1)
		}
		else if(default_time == "3_month")
		{
			StartDate.setMonth(StartDate.getMonth() - 3)
		}
		else // default if(default_time == "1_year")
		{
			StartDate.setFullYear(StartDate.getFullYear() - 1)
		}
		end_day = StartDate.getDate()
		end_month = StartDate.getMonth() + 1
		end_year = StartDate.getFullYear()
		start_day = Now.getDate()
		start_month = Now.getMonth() + 1
		start_year = Now.getFullYear()
		
	}

	
	if(end_day == -1 || end_month == -1 || end_year == -1)
	{
		alert("You have not selected a valid start date")
	}
	else if(start_day == -1 || start_month == -1 || start_year == -1)
	{
		alert("You have not selected a valid end date")
	}
	else
	{
		var jsStartDate = new Date(start_year, start_month -1, start_day)
		var jsEndDate = new Date(end_year, end_month -1, end_day)
		if(jsStartDate > new Date())
		{
			alert("The end date should not be later than todays date")
		}
		else
		{
			if(jsEndDate >= jsStartDate)
			{
				alert("The end date should be later than the start date")
			}
			else
			{
				//var URL = "bondGenerateGraph.asp?start_day="+start_day+"&start_month="+start_month+"&start_year="+start_year+"&end_day="+end_day+"&end_month="+end_month+"&end_year="+end_year
				//URL += "&bToGraph="+bToGraph+"&bToCompare="+bToCompare
				var URL = GraphURL+"/app/bondGenerateGraphTemp.asp?start_day="+start_day+"&start_month="+start_month+"&start_year="+start_year+"&end_day="+end_day+"&end_month="+end_month+"&end_year="+end_year
				URL += "&bToGraph="+bToGraph+"&bToCompare="+bToCompare
				if(navigator.appName == "Microsoft Internet Explorer")
					showModelessDialog(URL,window,"status:no;dialogWidth:650px;dialogHeight:410px");
				else	
					window.open(URL,'','height=410, width=650')
			}
		}
	}

}

function generateIndexGraph()
{
	var start_day = document.indexGraphForm.start_day.value
	var start_month = document.indexGraphForm.start_month.value
	var start_year = document.indexGraphForm.start_year.value

	var end_day = document.indexGraphForm.end_day.value
	var end_month = document.indexGraphForm.end_month.value
	var end_year = document.indexGraphForm.end_year.value

	var default_time = document.indexGraphForm.default_time.value

	// fix values if default_time is specified
	if(default_time != "")
	{
		var Now = new Date()
		var StartDate = new Date()
       		if(default_time == "1_week")
		{
			StartDate.setDate(StartDate.getDate() - 7) 
		}
		else if(default_time == "1_month")
		{
			StartDate.setMonth(StartDate.getMonth() - 1)
		}
		else if(default_time == "3_month")
		{
			StartDate.setMonth(StartDate.getMonth() - 3)
		}
		else // default if(default_time == "1_year")
		{
			StartDate.setFullYear(StartDate.getFullYear() - 1)
		}
		end_day = StartDate.getDate()
		end_month = StartDate.getMonth() + 1
		end_year = StartDate.getFullYear()
		start_day = Now.getDate()
		start_month = Now.getMonth() + 1
		start_year = Now.getFullYear()
		
	}
	
	var INDEX1 = document.indexGraphForm.INDEX1.value
	var r = new Array();
	for (var i = 0; i< document.indexGraphForm.INDEX2.options.length; i++)
	{
		if (document.indexGraphForm.INDEX2.options[i].selected)
		{
			r[r.length] = document.indexGraphForm.INDEX2.options[i].value;
		}
	}
	
	var INDEX2 = r.join(", ")
	
	var r2 = new Array();
	for (var i = 0; i< document.indexGraphForm.INDEX3.options.length; i++)
	{
		if (document.indexGraphForm.INDEX3.options[i].selected)
		{
			r2[r2.length] = document.indexGraphForm.INDEX3.options[i].value;
		}
	}
	
	var INDEX3 = r2.join(", ")
	
	var equity = document.indexGraphForm.equity.value
	var bond = document.indexGraphForm.bond.value
	var cw = document.indexGraphForm.cw.value
	var isReturn = document.indexGraphForm.isReturn.checked
	var etf = document.indexGraphForm.etf.value
	
	if(end_day == -1 || end_month == -1 || end_year == -1)
	{
		alert("You have not selected a valid start date")
	}
	else if(start_day == -1 || start_month == -1 || start_year == -1)
	{
		alert("You have not selected a valid end date")
	}
	else
	{
		var jsStartDate = new Date(start_year, start_month -1, start_day)
		var jsEndDate = new Date(end_year, end_month -1, end_day)
		if(jsStartDate > new Date())
		{
			alert("The end date should not be later than todays date")
		}
		else
		{
			if(jsEndDate >= jsStartDate)
			{
				alert("The end date should be later than the start date")
			}
			else
			{
				if(INDEX1 == "")
				{
					alert("Please select an index to graph")
				}
				else
				{
					var URL = GraphURL+"/app/indexHGGenerateTemp.asp?start_day="+start_day+"&start_month="+start_month+"&start_year="+start_year+"&end_day="+end_day+"&end_month="+end_month+"&end_year="+end_year
					URL += "&INDEX1="+INDEX1+"&INDEX2="+INDEX2+"&INDEX3="+INDEX3+"&equity="+equity+"&cw="+cw+"&etf="+etf+"&isReturn="+isReturn+"&bond="+bond
					//if(navigator.appName == "Microsoft Internet Explorer")
					//	showModelessDialog(URL,window,"status:no;dialogWidth:640px;dialogHeight:410px");
					//else
						window.open(URL,'', 'height=410, width=640')
						//window.open(URL)
				}
			}
		}
	}
}

function 
generateBondIndexGraph()
{ 
	var start_day = document.bondIndexGraphForm.start_day.value
	var start_month = document.bondIndexGraphForm.start_month.value
	var start_year = document.bondIndexGraphForm.start_year.value

	var end_day = document.bondIndexGraphForm.end_day.value
	var end_month = document.bondIndexGraphForm.end_month.value
	var end_year = document.bondIndexGraphForm.end_year.value
	
	var default_time = document.bondIndexGraphForm.default_time.value

	// fix values if default_time is specified
	if(default_time != "")
	{
		var Now = new Date()
		var StartDate = new Date()
       		if(default_time == "1_week")
		{
			StartDate.setDate(StartDate.getDate() - 7) 
		}
		else if(default_time == "1_month")
		{
			StartDate.setMonth(StartDate.getMonth() - 1)
		}
		else if(default_time == "3_month")
		{
			StartDate.setMonth(StartDate.getMonth() - 3)
		}
		else // default if(default_time == "1_year")
		{
			StartDate.setFullYear(StartDate.getFullYear() - 1)
		}
		end_day = StartDate.getDate()
		end_month = StartDate.getMonth() + 1
		end_year = StartDate.getFullYear()
		start_day = Now.getDate()
		start_month = Now.getMonth() + 1
		start_year = Now.getFullYear()
		
	}


	//alert("start_day="+start_day+"&start_month="+start_month+"&start_year="+start_year+"&end_day="+end_day+"&end_month="+end_month+"&end_year="+end_year)
	
	var INDEX1 = document.bondIndexGraphForm.INDEX1.value
	var r = new Array();
	for (var i = 0; i< document.bondIndexGraphForm.INDEX2.options.length; i++)
	{
		if (document.bondIndexGraphForm.INDEX2.options[i].selected)
		{
			r[r.length] = document.bondIndexGraphForm.INDEX2.options[i].value;
		}
	}
	
	var INDEX2 = r.join(", ")
	
	var r2 = new Array();
	for (var i = 0; i< document.bondIndexGraphForm.INDEX3.options.length; i++)
	{
		if (document.bondIndexGraphForm.INDEX3.options[i].selected)
		{
			r2[r2.length] = document.bondIndexGraphForm.INDEX3.options[i].value;
		}
	}
	
	var INDEX3 = r2.join(", ")
	
	var equity = document.bondIndexGraphForm.equity.value
	var bond = document.bondIndexGraphForm.bond.value
	//var cw = document.indexGraphForm.cw.value
	var isReturn = document.bondIndexGraphForm.isReturn.checked
	//var etf = document.indexGraphForm.etf.value
	
	if(end_day == -1 || end_month == -1 || end_year == -1)
	{
		alert("You have not selected a valid start date")
	}
	else if(end_day < 3 && end_month <= 3 && end_year == 2003)
	{
		alert("Start date must be after 3 March 2003")
	}
	else if(start_day == -1 || start_month == -1 || start_year == -1)
	{
		alert("You have not selected a valid end date")
	}
	else
	{
		var jsStartDate = new Date(start_year, start_month -1, start_day)
		var jsEndDate = new Date(end_year, end_month -1, end_day)
		if(jsStartDate > new Date())
		{
			alert("The end date should not be later than todays date")
		}
		else
		{
			if(jsEndDate >= jsStartDate)
			{
				alert("The end date should be later than the start date")
			}
			else
			{
				if(INDEX1 == "")
				{
					alert("Please select an index to graph")
				}
				else
				{
				    var URL = GraphURL + "/app/bondIndexHGGenerateTemp.asp?start_day=" + start_day + "&start_month=" + start_month + "&start_year=" + start_year + "&end_day=" + end_day + "&end_month=" + end_month + "&end_year=" + end_year
					URL += "&INDEX1="+INDEX1+"&INDEX2="+INDEX2+"&INDEX3="+INDEX3+"&bond="+bond+"&isReturn="+isReturn+"&equity="+equity
					
					//if(navigator.appName == "Microsoft Internet Explorer")
					//	showModelessDialog(URL,window,"status:no;dialogWidth:640px;dialogHeight:410px");
					//else
						window.open(URL,'', 'height=410, width=640')
						//window.open(URL)
				}
			}
		}
	}
}

function generateClassGraph()
{
	var start_day = document.History.start_day.value
	var start_month = document.History.start_month.value
	var start_year = document.History.start_year.value

	var end_day = document.History.end_day.value
	var end_month = document.History.end_month.value
	var end_year = document.History.end_year.value
	
	var SEDOL = document.History.SEDOL.value
	var CLASS_ID = document.History.CLASS_ID.value
	var REF_NO = document.History.REF_NO.value
	
	if(end_day == -1 || end_month == -1 || end_year == -1)
	{
		alert("You have not selected a valid start date")
	}
	else if(start_day == -1 || start_month == -1 || start_year == -1)
	{
		alert("You have not selected a valid end date")
	}
	else
	{
		var jsStartDate = new Date(start_year, start_month -1, start_day)
		var jsEndDate = new Date(end_year, end_month -1, end_day)
		if(jsStartDate > new Date())
		{
			alert("The end date should not be later than todays date")
		}
		else
		{
			if(jsEndDate >= jsStartDate)
			{
				alert("The end date should be later than the start date")
			}
			else
			{
			    var URL = GraphURL + "/app/classGenerateGraphTemp.asp?start_day=" + start_day + "&start_month=" + start_month + "&start_year=" + start_year + "&end_day=" + end_day + "&end_month=" + end_month + "&end_year=" + end_year
				URL += "&SEDOL="+SEDOL+"&REF_NO="+REF_NO+"&CLASS_ID="+CLASS_ID
				if(navigator.appName == "Microsoft Internet Explorer")
					showModelessDialog(URL,window,"status:no;dialogWidth:640px;dialogHeight:480px");
				else
					window.open(URL,'', 'height=480, width=640')
			}
		}
	}
}


function generateEquityDGraph(instrumentID, start_day, start_month, start_year)
{
    var URL = GraphURL+"/app/equitydailygtemp.asp?start_day=" + start_day + "&start_month=" + start_month + "&start_year=" + start_year + "&INSTRUMENT_ID=" + instrumentID
	if(navigator.appName == "Microsoft Internet Explorer")
		showModelessDialog(URL,window,"status:no;dialogWidth:440px;dialogHeight:550px");
	else
		window.open(URL,'','height=500,width=440') 
}

function generateEtfDGraph(instrumentID, start_day, start_month, start_year)
{
    var URL = GraphURL + "/app/etfDailyGTemp.asp?start_day=" + start_day + "&start_month=" + start_month + "&start_year=" + start_year + "&INSTRUMENT_ID=" + instrumentID
	//alert(URL)
	if(navigator.appName == "Microsoft Internet Explorer")
		showModelessDialog(URL,window,"status:no;dialogWidth:440px;dialogHeight:500px");
	else
		window.open(URL,'','height=500,width=440')
}

function generateCWDGraph(cwID, start_day, start_month, start_year)
{
	//var URL = "cwGenerateDGraph.asp?start_day="+start_day+"&start_month="+start_month+"&start_year="+start_year+"&INSTRUMENT_ID="+cwID
    var URL = GraphURL + "/app/cwGenerateDGraphTemp.asp?start_day=" + start_day + "&start_month=" + start_month + "&start_year=" + start_year + "&INSTRUMENT_ID=" + cwID
	if(navigator.appName == "Microsoft Internet Explorer")
		showModelessDialog(URL,window,"status:no;dialogWidth:440px;dialogHeight:505px");
	else
		window.open(URL,'','height=505,width=440')
}

function loadDailyIndexGraph(indexType)
{ 
	document.dailyGraph.src=GraphURL+"/app/indexDailyGraph.asp?INDEX_TYPE="+indexType
	var funcToCall = "loadDailyIndexGraph('" + indexType + "') ;"
	var the_timeout = setTimeout(funcToCall,300000); 
}

function loadDailyEtfNavIndexGraph() 
{
	
	document.dailyEtfGraph.src=GraphURL+"/app/indexEtfNavDailyGraph.asp"
	
	var funcToCall = "loadDailyEtfNavIndexGraph() ;"
	var the_timeout = setTimeout(funcToCall,300000);

}

// 4 functions for each XSL file that uses them because of different form names.
// cw_ functions are for CoveredWarrant graph
// without _ in function name are for equity graph

function cwSelectChanged()
{
	if(document.equityGraphForm.cwToCompare.options[document.equityGraphForm.cwToCompare.selectedIndex.text] != "")
	{
			document.equityGraphForm.showHL.checked = false
			document.equityGraphForm.showHL.disabled = true
			document.equityGraphForm.showVolume.checked = false
			document.equityGraphForm.showVolume.disabled = true
			document.equityGraphForm.showMarkcap.checked = false
			document.equityGraphForm.showMarkcap.disabled = true
			document.equityGraphForm.showTurnover.checked = false
			document.equityGraphForm.showTurnover.disabled = true
	}
	else
	{
		if(document.equityGraphForm.eToCompare.options[document.equityGraphForm.eToCompare.selectedIndex.text] == "" && document.equityGraphForm.indexToCompare.options[document.equityGraphForm.indexToCompare.selectedIndex.text] == "")
		{
			document.equityGraphForm.showHL.disabled = false
			document.equityGraphForm.showVolume.disabled = false
			document.equityGraphForm.showMarkcap.disabled = false
			document.equityGraphForm.showTurnover.disabled = false
		}	
	}
}

function cw_cwSelectChanged()
{
	if(document.cwGenerateGraph.cwToCompare.options[document.cwGenerateGraph.cwToCompare.selectedIndex.text] != "")
	{
			document.cwGenerateGraph.showHL.checked = false
			document.cwGenerateGraph.showHL.disabled = true
			document.cwGenerateGraph.showVolume.checked = false
			document.cwGenerateGraph.showVolume.disabled = true
			document.cwGenerateGraph.showMarkcap.checked = false
			document.cwGenerateGraph.showMarkcap.disabled = true
			document.cwGenerateGraph.showTurnover.checked = false
			document.cwGenerateGraph.showTurnover.disabled = true
	}
	else
	{
		if(document.cwGenerateGraph.eToCompare.options[document.cwGenerateGraph.eToCompare.selectedIndex.text] == "" && document.cwGenerateGraph.indexToCompare.options[document.cwGenerateGraph.indexToCompare.selectedIndex.text] == "")
		{
			document.cwGenerateGraph.showHL.disabled = false
			document.cwGenerateGraph.showVolume.disabled = false
			document.cwGenerateGraph.showMarkcap.disabled = false
			document.cwGenerateGraph.showTurnover.disabled = false
		}	
	}
}

function indexSelectChanged()
{
	if(document.equityGraphForm.indexToCompare.selectedIndex != 0
	  || document.equityGraphForm.eToCompare.selectedIndex != 0)
     	{
			document.equityGraphForm.showHL.checked = false
			document.equityGraphForm.showHL.disabled = true
			document.equityGraphForm.showVolume.checked = false
			document.equityGraphForm.showVolume.disabled = true
			document.equityGraphForm.showMarkcap.checked = false
			document.equityGraphForm.showMarkcap.disabled = true
			document.equityGraphForm.showTurnover.checked = false
			document.equityGraphForm.showTurnover.disabled = true
			document.equityGraphForm.showNumberTrades.checked = false
			document.equityGraphForm.showNumberTrades.disabled = true
			document.equityGraphForm.showBids.checked = false
			document.equityGraphForm.showBids.disabled = true
			document.equityGraphForm.showOffers.checked = false
			document.equityGraphForm.showOffers.disabled = true
	}
	else
	{
			document.equityGraphForm.showHL.disabled = false
			document.equityGraphForm.showVolume.disabled = false
			document.equityGraphForm.showMarkcap.disabled = false
			document.equityGraphForm.showTurnover.disabled = false
			document.equityGraphForm.showNumberTrades.disabled = false
			document.equityGraphForm.showBids.disabled = false
			document.equityGraphForm.showOffers.disabled = false

	}
}

function cw_indexSelectChanged()
{
	if(document.cwGenerateGraph.indexToCompare.options[document.cwGenerateGraph.indexToCompare.selectedIndex.text] != "")
	{
			document.cwGenerateGraph.showHL.checked = false
			document.cwGenerateGraph.showHL.disabled = true
			document.cwGenerateGraph.showVolume.checked = false
			document.cwGenerateGraph.showVolume.disabled = true
			document.cwGenerateGraph.showMarkcap.checked = false
			document.cwGenerateGraph.showMarkcap.disabled = true
			document.cwGenerateGraph.showTurnover.checked = false
			document.cwGenerateGraph.showTurnover.disabled = true
	}
	else
	{
		if(document.cwGenerateGraph.eToCompare.options[document.cwGenerateGraph.eToCompare.selectedIndex.text] == "" && document.cwGenerateGraph.cwToCompare.options[document.cwGenerateGraph.indexToCompare.selectedIndex.text] == "")
		{
			document.cwGenerateGraph.showHL.disabled = false
			document.cwGenerateGraph.showVolume.disabled = false
			document.cwGenerateGraph.showMarkcap.disabled = false
			document.cwGenerateGraph.showTurnover.disabled = false
		}	
	}
}

function equitySelectChanged()
{
	if(document.equityGraphForm.eToCompare.selectedIndex != 0
	   || document.equityGraphForm.indexToCompare.selectedIndex != 0
          )

	{
			document.equityGraphForm.showHL.checked = false
			document.equityGraphForm.showHL.disabled = true
			document.equityGraphForm.showVolume.checked = false
			document.equityGraphForm.showVolume.disabled = true
			document.equityGraphForm.showMarkcap.checked = false
			document.equityGraphForm.showMarkcap.disabled = true
			document.equityGraphForm.showTurnover.checked = false
			document.equityGraphForm.showTurnover.disabled = true
			document.equityGraphForm.showNumberTrades.checked = false
			document.equityGraphForm.showNumberTrades.disabled = true
			document.equityGraphForm.showBids.checked = false
			document.equityGraphForm.showBids.disabled = true
			document.equityGraphForm.showOffers.checked = false
			document.equityGraphForm.showOffers.disabled = true 
	}
	else
	{
			document.equityGraphForm.showHL.disabled = false
			document.equityGraphForm.showVolume.disabled = false
			document.equityGraphForm.showMarkcap.disabled = false
			document.equityGraphForm.showTurnover.disabled = false
			document.equityGraphForm.showNumberTrades.disabled = false
			document.equityGraphForm.showBids.disabled = false
			document.equityGraphForm.showOffers.disabled = false
	}
}

function cw_equitySelectChanged()
{
	if(document.cwGenerateGraph.eToCompare.options[document.cwGenerateGraph.eToCompare.selectedIndex.text] != "")
	{
			document.cwGenerateGraph.showHL.checked = false
			document.cwGenerateGraph.showHL.disabled = true
			document.cwGenerateGraph.showVolume.checked = false
			document.cwGenerateGraph.showVolume.disabled = true
			document.cwGenerateGraph.showMarkcap.checked = false
			document.cwGenerateGraph.showMarkcap.disabled = true
			document.cwGenerateGraph.showTurnover.checked = false
			document.cwGenerateGraph.showTurnover.disabled = true
			document.equityGraphForm.showBids.checked = false
			document.equityGraphForm.showBids.disabled = true
			document.equityGraphForm.showOffers.checked = false
			document.equityGraphForm.showOffers.disabled = true

	}
	else
	{
		if(document.cwGenerateGraph.indexToCompare.options[document.cwGenerateGraph.indexToCompare.selectedIndex.text] == "" && document.cwGenerateGraph.cwToCompare.options[document.cwGenerateGraph.indexToCompare.selectedIndex].text == "")
		{
			document.cwGenerateGraph.showHL.disabled = false
			document.cwGenerateGraph.showVolume.disabled = false
			document.cwGenerateGraph.showMarkcap.disabled = false
			document.cwGenerateGraph.showTurnover.disabled = false
			document.equityGraphForm.showNumberTrades.disabled = false
			document.equityGraphForm.showBids.disabled = false
			document.equityGraphForm.showOffers.disabled = false
		}	
	}
}

function showHLChanged()
{
	commonEquityFormChangeHandler()
}

function cw_showHLChanged()
{
	if(document.cwGenerateGraph.showHL.checked)
	{
		document.cwGenerateGraph.indexToCompare.selectedIndex = 0
		document.cwGenerateGraph.indexToCompare.disabled = true
		document.cwGenerateGraph.eToCompare.selectedIndex = 0
		document.cwGenerateGraph.eToCompare.disabled = true
		document.cwGenerateGraph.cwToCompare.selectedIndex = 0
		document.cwGenerateGraph.cwToCompare.disabled = true
	}
	else
	{
		if(!document.cwGenerateGraph.showVolume.checked && !document.cwGenerateGraph.showMarkcap.checked && !document.cwGenerateGraph.showTurnover.checked)
		{
			document.cwGenerateGraph.indexToCompare.disabled = false
			document.cwGenerateGraph.eToCompare.disabled = false
			document.cwGenerateGraph.cwToCompare.disabled = false
		}	
	}
	
}

function showTurnoverChanged()
{
	commonEquityFormChangeHandler()
}

function showNumberTradesChanged()
{
	commonEquityFormChangeHandler()
}

function showBidsChanged() 
{
	commonEquityFormChangeHandler()
}

function showOffersChanged()
{
	commonEquityFormChangeHandler()
}

function commonEquityFormChangeHandler()
{
	if( document.equityGraphForm.showHL.checked
	 || document.equityGraphForm.showVolume.checked
	 || document.equityGraphForm.showMarkcap.checked
	 || document.equityGraphForm.showTurnover.checked
	 || document.equityGraphForm.showNumberTrades.checked
	 || document.equityGraphForm.showBids.checked
	 || document.equityGraphForm.showOffers.checked
          ) // then disable index/equity
	{
		document.equityGraphForm.indexToCompare.selectedIndex = 0
		document.equityGraphForm.indexToCompare.disabled = true
		document.equityGraphForm.eToCompare.selectedIndex = 0
		document.equityGraphForm.eToCompare.disabled = true
		document.equityGraphForm.cwToCompare.selectedIndex = 0
		document.equityGraphForm.cwToCompare.disabled = true
	}
	else
	{
		document.equityGraphForm.indexToCompare.disabled = false
		document.equityGraphForm.eToCompare.disabled = false
		document.equityGraphForm.cwToCompare.disabled = false
	}
}

function cw_showTurnoverChanged()
{
	if(document.cwGenerateGraph.showTurnover.checked)
	{
		document.cwGenerateGraph.indexToCompare.selectedIndex = 0
		document.cwGenerateGraph.indexToCompare.disabled = true
		document.cwGenerateGraph.eToCompare.selectedIndex = 0
		document.cwGenerateGraph.eToCompare.disabled = true
		document.cwGenerateGraph.cwToCompare.selectedIndex = 0
		document.cwGenerateGraph.cwToCompare.disabled = true
	}
	else
	{
		if(!document.cwGenerateGraph.showVolume.checked && !document.cwGenerateGraph.showMarkcap.checked && !document.cwGenerateGraph.showHL.checked)
		{
			document.cwGenerateGraph.indexToCompare.disabled = false
			document.cwGenerateGraph.eToCompare.disabled = false
			document.cwGenerateGraph.cwToCompare.disabled = false
		}	
	}
	
}

function showVolumeChanged()
{
	commonEquityFormChangeHandler()
}

function cw_showVolumeChanged()
{
	if(document.cwGenerateGraph.showVolume.checked)
	{
		document.cwGenerateGraph.indexToCompare.selectedIndex = 0
		document.cwGenerateGraph.indexToCompare.disabled = true
		document.cwGenerateGraph.eToCompare.selectedIndex = 0
		document.cwGenerateGraph.eToCompare.disabled = true
		document.cwGenerateGraph.cwToCompare.selectedIndex = 0
		document.cwGenerateGraph.cwToCompare.disabled = true
	}
	else
	{
		if(!document.cwGenerateGraph.showHL.checked && !document.cwGenerateGraph.showMarkcap.checked && !document.cwGenerateGraph.showTurnover.checked)
		{
			document.cwGenerateGraph.indexToCompare.disabled = false
			document.cwGenerateGraph.eToCompare.disabled = false
			document.cwGenerateGraph.cwToCompare.disabled = false
		}	
	}
	
}

function showMarkcapChanged()
{
	commonEquityFormChangeHandler()
}

function cw_showMarkcapChanged()
{
	if(document.cwGenerateGraph.showMarkcap.checked)
	{
		document.cwGenerateGraph.indexToCompare.selectedIndex = 0
		document.cwGenerateGraph.indexToCompare.disabled = true
		document.cwGenerateGraph.eToCompare.selectedIndex = 0
		document.cwGenerateGraph.eToCompare.disabled = true
		document.cwGenerateGraph.cwToCompare.selectedIndex = 0
		document.cwGenerateGraph.cwToCompare.disabled = true
	}
	else
	{
		if(!document.cwGenerateGraph.showVolume.checked && !document.cwGenerateGraph.showHL.checked && !document.cwGenerateGraph.showTurnover.checked)
		{
			document.cwGenerateGraph.indexToCompare.disabled = false
			document.cwGenerateGraph.eToCompare.disabled = false
			document.cwGenerateGraph.cwToCompare.disabled = false
		}	
	}
	
}

function printGraph()
{
	window.print();
}

function timeFrameChanged()
{
	if(document.equityGraphForm.default_time.selectedIndex != 0)
	{
		document.equityGraphForm.end_day.selectedIndex = 0
		document.equityGraphForm.end_month.selectedIndex = 0
		document.equityGraphForm.end_year.selectedIndex = 0
		document.equityGraphForm.start_day.selectedIndex = 0
		document.equityGraphForm.start_month.selectedIndex = 0
		document.equityGraphForm.start_year.selectedIndex = 0
	}
}

function dateChanged()
{
	if(  document.equityGraphForm.end_day.selectedIndex != 0
	  || document.equityGraphForm.end_month.selectedIndex != 0
	  || document.equityGraphForm.end_year.selectedIndex != 0
	  || document.equityGraphForm.start_day.selectedIndex != 0
	  || document.equityGraphForm.start_month.selectedIndex != 0
	  || document.equityGraphForm.start_year.selectedIndex != 0
          )
	{ // set timeFrame to default value
		document.equityGraphForm.default_time.selectedIndex = 0
	}

}

function timeFrameIndexChanged()
{
	if(document.indexGraphForm.default_time.selectedIndex != 0)
	{
		document.indexGraphForm.end_day.selectedIndex = 0
		document.indexGraphForm.end_month.selectedIndex = 0
		document.indexGraphForm.end_year.selectedIndex = 0
		document.indexGraphForm.start_day.selectedIndex = 0
		document.indexGraphForm.start_month.selectedIndex = 0
		document.indexGraphForm.start_year.selectedIndex = 0
	}
}

function dateIndexChanged()
{
	if(  document.indexGraphForm.end_day.selectedIndex != 0
	  || document.indexGraphForm.end_month.selectedIndex != 0
	  || document.indexGraphForm.end_year.selectedIndex != 0
	  || document.indexGraphForm.start_day.selectedIndex != 0
	  || document.indexGraphForm.start_month.selectedIndex != 0
	  || document.indexGraphForm.start_year.selectedIndex != 0
          )
	{ // set timeFrame to default value
		document.indexGraphForm.default_time.selectedIndex = 0
	}

}

function timeFrameBondChanged()
{
	if(document.bondIndexGraphForm.default_time.selectedIndex != 0)
	{
		document.bondIndexGraphForm.end_day.selectedIndex = 0
		document.bondIndexGraphForm.end_month.selectedIndex = 0
		document.bondIndexGraphForm.end_year.selectedIndex = 0
		document.bondIndexGraphForm.start_day.selectedIndex = 0
		document.bondIndexGraphForm.start_month.selectedIndex = 0
		document.bondIndexGraphForm.start_year.selectedIndex = 0
	}
}

function dateBondChanged()
{
	if(  document.bondIndexGraphForm.end_day.selectedIndex != 0
	  || document.bondIndexGraphForm.end_month.selectedIndex != 0
	  || document.bondIndexGraphForm.end_year.selectedIndex != 0
	  || document.bondIndexGraphForm.start_day.selectedIndex != 0
	  || document.bondIndexGraphForm.start_month.selectedIndex != 0
	  || document.bondIndexGraphForm.start_year.selectedIndex != 0
          )
	{ // set timeFrame to default value
		document.bondIndexGraphForm.default_time.selectedIndex = 0
	}

}

function timeFrameBondMarketChanged()
{
	if(document.equityGraphForm.default_time.selectedIndex != 0)
	{
		document.equityGraphForm.end_day.selectedIndex = 0
		document.equityGraphForm.end_month.selectedIndex = 0
		document.equityGraphForm.end_year.selectedIndex = 0
		document.equityGraphForm.start_day.selectedIndex = 0
		document.equityGraphForm.start_month.selectedIndex = 0
		document.equityGraphForm.start_year.selectedIndex = 0
	}
}

function dateBondMarketChanged()
{
	if(  document.equityGraphForm.end_day.selectedIndex != 0
	  || document.equityGraphForm.end_month.selectedIndex != 0
	  || document.equityGraphForm.end_year.selectedIndex != 0
	  || document.equityGraphForm.start_day.selectedIndex != 0
	  || document.equityGraphForm.start_month.selectedIndex != 0
	  || document.equityGraphForm.start_year.selectedIndex != 0
          )
	{ // set timeFrame to default value
		document.equityGraphForm.default_time.selectedIndex = 0
	}

}

function timeFrameETFInstrumentChanged()
{
	if(document.equityGraphForm.default_time.selectedIndex != 0)
	{
		document.equityGraphForm.end_day.selectedIndex = 0
		document.equityGraphForm.end_month.selectedIndex = 0
		document.equityGraphForm.end_year.selectedIndex = 0
		document.equityGraphForm.start_day.selectedIndex = 0
		document.equityGraphForm.start_month.selectedIndex = 0
		document.equityGraphForm.start_year.selectedIndex = 0
	}
}

function dateETFInstrumentChanged()
{
	if(  document.equityGraphForm.end_day.selectedIndex != 0
	  || document.equityGraphForm.end_month.selectedIndex != 0
	  || document.equityGraphForm.end_year.selectedIndex != 0
	  || document.equityGraphForm.start_day.selectedIndex != 0
	  || document.equityGraphForm.start_month.selectedIndex != 0
	  || document.equityGraphForm.start_year.selectedIndex != 0
          )
	{ // set timeFrame to default value
		document.equityGraphForm.default_time.selectedIndex = 0
	}

}

