﻿// JScript File

		function detectMouseCoordinates(dt,cht,e)
		{ 
		    try
            {
			var txtSelDate = $get("txtSelDate");
			var txtChartType = $get("txtChartType");
			var txtScrollX = $get("txtScrollX");
			var txtScrollY = $get("txtScrollY");
			var lbRemove = $get("lbRemove");
			var txt1 = $get("txt1");
			var txtX = $get("txtX");
			var txtY = $get("txtY");
			var posx,posy,scrollx,scrolly; 
			var offsetX,offsetY;
	        var txtShowSplit = $get("txtShowSplit");

			txtSelDate.value=dt;
			posx=0; 
			posy=0; 
			scrollx=0; 
			scrolly=0; 
			if(!e) var e=window.event; 

			if(e.pageX||e.pageY)
			{ 
		        posx=e.pageX; 
				posy=e.pageY; 
			} 
			else if(e.clientX||e.clientY)
			{ 
				posx = e.x + document.documentElement.scrollLeft; 
				posy = e.y + document.documentElement.scrollTop; 
		    } 
			scrollx = txtScrollX.value;
			scrolly = txtScrollY.value;
			posx = posx + parseInt(scrollx);
			posy = posy + parseInt(scrolly);
	        offsetX = -20;
	        offsetY = -120;
	        posx = posx + offsetX;
	        posy = posy + offsetY;
   			var SplitLinkButton = $get("SplitLinkButton");
	        if(checkDateIsSplit())
	        {
	            SplitLinkButton.innerHTML = "Join";
	        }
	        else
	        {
	   	        SplitLinkButton.innerHTML = "Split";
            }
            if(txtShowSplit.value == "true")
            {
                SplitLinkButton.style.display = "none";
            }
            else
            {
                 SplitLinkButton.style.display = "block";
            }
			Panel1.style.visibility = "visible";
			Panel1.style.top = posy + "px";
			Panel1.style.left = posx + "px";
			txtX.value = posx+ "px";
			txtY.value = posy+ "px";
			e.cancelBubble = true;
		    }
            catch(err)
            {
                alert(err.description + " detectMouseCoordinates");
            }
            return false;
} 

function UpdateChart()
{
    var updateButton = $get("updateButton");
    updateButton.click();
}
function hide()
{
	try
    {
    	Panel1.style.visibility = "Hidden";
	}
    catch(err)
    {
        alert(err.description + " hide");
    }
}
function Split(e)
{
    try
    {

        var txtSelDate = $get("txtSelDate");
        var txtSplit = $get("txtSplit");
        var lbSplit = $get("lbSplit");
        var str = txtSelDate.value;
        var bfound=false;
        for(i=lbSplit.options.length-1;i>=0;i--)
        {
            if(lbSplit.options[i].text == str) 
            {
                bfound = true;
                txtSplit.value = "r" + txtSelDate.value; 
            }
        } 
        if(!bfound)
        {   
            txtSplit.value = txtSelDate.value; 
        }
    
 //       UpdateChart();
        hide();
     }
     catch(err)
     {
          alert(err.description + " Split");
     }
}
function checkDateIsSplit()
{
    try
    {
        var txtSelDate = $get("txtSelDate");
        var txtSplit = $get("txtSplit");
        var lbSplit = $get("lbSplit");
        var str = txtSelDate.value;
        var bfound=false;
        for(i=lbSplit.options.length-1;i>=0;i--)
        {
            if(lbSplit.options[i].text == str) 
            {
                bfound = true;
            }
        }
    } 
    catch(err)
    {
          alert(err.description + " checkDateIsSplit");
    }
    return bfound;
}
		function openWindow(e)
		{
            try
            {
			    var txtSelDate = $get("txtSelDate");
			    var txtSelQry = $get("txtSelQry");
			    var TypeCht = $get("txtChart");
			    var st = $get("txtStart");
			    var end = $get("txtEnd");
		        var txtArea = $get("txtArea");
		        var txtPatch = $get("txtPatch");
                var txtFilt = $get("txtFilt");
                var txtFiltCiras = $get("txtFiltCiras");
                var widSize = "width=400,height=400,scrollbars=yes,resizable=yes"
				    window.open('Cases.aspx?Date='+txtSelDate.value ,'mywindow',widSize);
			}
            catch(err)
            {
                alert(err.description + " openWindow");
            }
}

function removePoint(e)
{
    try
    {

        var txtSelDate = $get("txtSelDate");
        var txtRemove = $get("txtRemove");
        var str = txtSelDate.value;
        var bfound=false;
        txtRemove.value = txtSelDate.value; 
    //    UpdateChart();
        hide();
     }
     catch(err)
     {
          alert(err.description + " Remove");
     }
}