function openPopupWindow(strURL, intW, intH) {
	window.open(strURL, 'popupWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=Yes,scrollbars=yes,resizable=yes,width=' + intW + ',height=' + intH + '');
}

function openFundPage(strURL, strLang, strError) 
{ 
  if (strURL != null)
  {
		var fundIdObj = document.getElementById('RoburFramework_SaveFundInformation_ddlFundList_myDropDownBox');
		var fundId = fundIdObj.options[fundIdObj.selectedIndex].value;
		
		var fromYearObj = document.getElementById('RoburFramework_SaveFundInformation_fromDate_YearDownList');
		var fromYear = fromYearObj.options[fromYearObj.selectedIndex].value;
		var toYearObj = document.getElementById('RoburFramework_SaveFundInformation_toDate_YearDownList');
		var toYear = toYearObj.options[toYearObj.selectedIndex].value;

		var fromMonthObj = document.getElementById('RoburFramework_SaveFundInformation_fromDate_MonthDownList');
		var fromMonth = fromMonthObj.options[fromMonthObj.selectedIndex].value;
		var toMonthObj = document.getElementById('RoburFramework_SaveFundInformation_toDate_MonthDownList');
		var toMonth = toMonthObj.options[toMonthObj.selectedIndex].value;
		
		var fromDayObj = document.getElementById('RoburFramework_SaveFundInformation_fromDate_DayDownList');
		var fromDay = fromDayObj.options[fromDayObj.selectedIndex].value;
		var toDayObj = document.getElementById('RoburFramework_SaveFundInformation_toDate_DayDownList');
		var toDay = toDayObj.options[toDayObj.selectedIndex].value;

		var fromDate = null;
		var toDate = null;
		//intial value-check
		if(fundId.length > 1 && fromYear >= 1968 && toYear >= 1968 && fromMonth > 0 && toMonth > 0 && fromDay > 0 && toDay > 0) 
		{
			fromDate = fromYear + "-" + fromMonth + "-" + fromDay;
			toDate = toYear + "-" + toMonth + "-" + toDay;
			//fromDate has to be equal or lower than toDate
			if (fromDate <= toDate)
			{
				var url = strURL + "?fundId=" + fundId + "&fromDate=" + fromDate + "&toDate=" + toDate + "&epsLanguage=" + strLang;
				document.location.href = url;
				return true;
			}
			alert(strError);
			return false;
		}
		else 
		{
			alert(strError);
			return false;
		} 
	}
}

//changes the number of options in the selectbox
function changeOptions(yearControl, monthControl, controlName)
{
	var i;
	var currentYear;
	var currentMonth;
	var currentMonthControl;
	var leapYear = false;
	var daysInMonth = new Array (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	var op;
	var oldDate; //the previous date in the day drop down list
	var oldDateSet = false;

	controlObj = window.document.all[controlName];
	oldDate = controlObj[controlObj.selectedIndex].value;
	controlObj.options.length = 0;
	currentYear = window.document.all[yearControl].value;
	currentMonthControl = window.document.all[monthControl];
	currentMonth = currentMonthControl.value;

	//check if it's a leap year
	if ((currentYear % 4 == 0) && (currentYear % 100 != 0 || currentYear % 400 == 0))
	{
		leapYear = true;
	}
	
	if (leapYear)
	{
		daysInMonth[1] = 29;
	}

	for (i=0; i<daysInMonth[currentMonth-1]; i++)
	{
		op = new Option;
		if (i<9)
		{
			op.text = "0" + (i+1);
			op.value = "0" + (i+1);
		}
		else	
		{
			op.text = (i+1);
			op.value = (i+1);
		}
		controlObj.options[controlObj.options.length] = op;
		if (controlObj.options[controlObj.options.length-1].value == oldDate)
		{
			controlObj.options[controlObj.options.length-1].selected = true;
			oldDateSet = true;
		}
	}
	
	if (!oldDateSet)
	{
		controlObj.options[controlObj.options.length-1].selected = true;
	}
}

function ShowRestDoc(divId)
	{
	
		if(document.getElementById("restDocument"+divId) != null)
		{
			if(document.getElementById("restDocument"+divId).className == 'showDiv' )
			document.getElementById("restDocument"+divId).className = 'hideDiv';
		else
			document.getElementById("restDocument"+divId).className = 'showDiv';
		}
	}
	
	function ShowIngress(divId)
	{
		if(document.getElementById(divId) != null)
		{
			if(document.getElementById(divId).className == 'showDiv' )
			{
				document.getElementById(divId).className = 'hideDiv';
				document.getElementById("a"+divId).className = '';
			}	
			else
			{
				document.getElementById(divId).className = 'showDiv';
				document.getElementById("a"+divId).className = 'boldHeader';
			}
		ShowRestDoc(divId);
	}
}