﻿/* used in => '/investment-research/investment-companies/investment-companies-results.aspx?search=recs'  */
function LoadFactsheetww2(invcode)
{
    var url = "http://ww2.bestinvest.co.uk";
    //var urlpath = "fmpro?-db=webprices.fp5&-lay=allfields&-format=fundfacts_popup.htm&-script=setglobalbenchmark&investment_codename==" + invcode + "&-find";
    var urlpath = "fmpro?-db=webprices.fp5&-lay=allfields&-format=factsheet.htm&investment_codename==" + invcode + "&-find";
    window.open(url + "/funds/" + urlpath, "Window","height=700,width=800,resizable=yes,scrollbars=yes");
}

/*function LoadZeroFactsheet(invcode)
{
    var url = "http://ww2.bestinvest.co.uk";
    var urlpath = "fmpro?-db=webprices.fp5&-lay=zerodetail&-format=zero_detail.asp&-script=zeroset&investment_codename==" + invcode + "&-find";
    window.open(url + "/zeros/" + urlpath, "Window","height=700,width=800,resizable=yes,scrollbars=yes");
}*/

/* ? => /investment-research/fund-research/search/performance.aspx */
function LoadChart(mexCode)
{
    var urlpath= 'https://ww2.bestinvest.co.uk/charting/fmpro?-db=webchartdata.fp5&-format=result.htm&-lay=web&mex==' + mexCode + '&-script=multidraw_initial&-find';
    window.open(urlpath,"Window","height=600,width=470,resizable=yes,scrollbars=yes");
}

/* used => investment-research/investment-companies/investment-companies-results.aspx?search=recs */
function LoadPerformanceChart(mexCode)
{
    var urlpath= 'https://ww2.bestinvest.co.uk/charting/fmpro?-db=webchartdata.fp5&-format=result.htm&-lay=web&mex==' + mexCode + '&-script=multidraw_initial&-find';
    window.open(urlpath,"Window","height=600,width=470,resizable=yes,scrollbars=yes");
}

// function to show the different content areas
/*function flipContent(strArea, iHeight, nContent) {

    //then flip the relevant section
    if (document.all) {
        //IE version
        if (document.all[strArea].style.display == "inline") {
            document.all["arrow_" + strArea].src = "/img/buttons/btn_tell_me_more.gif";
            document.all[strArea].style.height = "1px";
            document.all[strArea].style.display = "none";
        } else {
        document.all["arrow_" + strArea].src = "/img/buttons/btn_tell_me_more.gif";
            document.all[strArea].style.height = "100%";
            document.all[strArea].style.display = "inline";
        }
    } else {
        //mozilla version
        divArea = document.getElementById(strArea);
        plusName = document.getElementById("arrow_" + strArea);
        if (divArea.style.display == "inline") {
            plusName.src = "/img/buttons/btn_tell_me_more.gif";
            divArea.style.height = "1px";
            divArea.style.display = "none";
        } else {
            plusName.src = "/img/buttons/btn_tell_me_more.gif";
            divArea.style.height = "1px";
            divArea.style.display = "inline";
        }
    }

    //then make sure all the others are shut except the one you opened
    for (i = 1; i < nContent; i++) {
        if ("how" + i != strArea) {
            //IE version
            if (document.all) {
                document.all["how" + i].style.height = "1px";
                document.all["how" + i].style.display = "none";
                document.all["arrow_how" + i].src = "/img/buttons/btn_tell_me_more.gif";
            } else {
                //mozilla version
                divAreaToClose = document.getElementById("how" + i);
                plusNameToClose = document.getElementById("arrow_how" + i);
                divAreaToClose.style.height = "1px"
                divAreaToClose.style.display = "none"
                plusNameToClose.src = "/img/buttons/btn_tell_me_more.gif"
            }
        }
    }
}*/

// function to show the different content areas
/*function flipContent2(strArea, iHeight, nContent) {

    //then flip the relevant section
    if (document.all) {
        //IE version
        if (document.all[strArea].style.display == "block") {
            document.all[strArea].style.height = "1px";
            document.all[strArea].style.display = "none";
        } else {
            document.all[strArea].style.height = "100%";
            document.all[strArea].style.display = "block";
        }
    } else {
        //mozilla version
        divArea = document.getElementById(strArea);
        if (divArea.style.display == "inline") {
            plusName.src = "../img/info.gif";
            divArea.style.height = "1px";
            divArea.style.display = "none";
        } else {
            divArea.style.height = "1px";
            divArea.style.display = "inline";
        }
    }

    //then make sure all the others are shut except the one you opened
    for (i = 1; i < nContent; i++) {
        if ("how" + i != strArea) {
            //IE version
            if (document.all) {
                document.all["how" + i].style.height = "1px";
                document.all["how" + i].style.display = "none";
            } else {
                //mozilla version
                divAreaToClose = document.getElementById("how" + i);
                divAreaToClose.style.height = "1px"
                divAreaToClose.style.display = "none"
            }
        }
    }
}*/

function LoadManager(code) {
    //var url = "";
    //var urlpath = "fundmanagerfact.aspx?id=" + code;
	//window.open("/insight/investments/factsheets/" + urlpath, "Window", "height=700,width=800,resizable=yes,scrollbars=yes, menubar=yes");
    window.open("http://ww2.bestinvest.co.uk/fundmanagers/fmpro?-db=fman.fp5&-lay=web_info&-format=fund_managernew.htm&codenamesector==" + code + "&-find", "Window", "height=700,width=800,resizable=yes,scrollbars=yes, menubar=yes");
}

/*function onPicker1Change(picker) {
    Calendar1.SetSelectedDate(picker.GetSelectedDate());
}*/

/*function onCalendar1Change(calendar) {
    Picker1.SetSelectedDate(calendar.GetSelectedDate());
}*/


/*function onPicker2Change(picker) {
    Calendar2.SetSelectedDate(picker.GetSelectedDate());
}*/

/*function onCalendar2Change(calendar) {
    Picker2.SetSelectedDate(calendar.GetSelectedDate());
}*/


/*function dateWaterMark(id, msg){
	var $id = $(id);

	
	if($id.val().toString().length == 0){
	
		$id.val(msg);
		$id.css("color", "#666");
	
		$id.focus(function(){
			if($id.val() == msg){
				$id.css('color', '#000');
			}
		});
		
		$id.blur(function(){
			if($id.val() == ""){
				$id.val(msg);
				$id.css('color', '#000');
			}
		});
	}
}*/

function watermark(idx, watermark, btnid, error_msg, override) {
	
	if (override == null)
		override = false;
	
	$(idx).val(watermark);
	$(idx).css("color", "#666666");
	
	$(idx).focus(function(event){
		if ( ($(idx).val() == watermark)  ) {
			$(idx).css("color", "#000000");
			$(idx).val("");
			b = true;
		}
	});
	
	$(idx).blur(function(event){
		if ($(idx).val() == "") {
			$(idx).val(watermark);
			$(idx).css("color", "#666666");	
		}
		if ($(idx).val() != watermark){
			$(idx).css("color", "#000000");
		}
	});
	
	if(error_msg !== null){
		$(btnid).click(function(event){
			if ($(idx).val() == watermark) {
				if (override == false) {
					alert(error_msg);
					return false;
				}else {
					$(idx).val('');
				}
			}
		});
	}
};


/* ? */
function LoadCofundsLegal(type) {
    window.open("cofundslegal" + type + ".htm", 'Cofundslegal', 'width=550,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}


/*function factsheet_win2(fundcode)
{
	 recpage = "http://ww2.bestinvest.co.uk/vcts/fmpro?-db=webprices.fp5&-lay=allfields&-format=vct_detail1.htm&investment_codename==" + fundcode + "&-find";
	 fundcode = window.open(recpage,'factsheet','width=720,height=600,left=0,top=0,toolbar=no,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,copyhistory=no,resizable=yes');
}*/