﻿// General JS

function CheckPositiveInt(e) 
{	
    var keycode=e.keyCode? e.keyCode : e.charCode
    
	var bInValidChar = true;

	// Allow only numeric chars along with tab and full stop.
	if (keycode > 47 && keycode < 58 || keycode == 9 || keycode == 8 || keycode == 63275 || keycode == 46)
	{
	    bInValidChar = false;
	}
	
	if( bInValidChar == true )
	{	
	    if( window.event )
	    {
	        e.returnValue = false;
	    }
	    
	    if (typeof e.preventDefault != "undefined")
	    {
            e.preventDefault();
        }
	}
}

function CheckDateOnly(e) 
{
    var keycode = e.keyCode ? e.keyCode : e.charCode

	var bInValidChar = true;

	// Allow only numeric chars along with tab and full stop.
	// delete = 46 or 63275 in safari
	if (keycode > 45 && keycode < 58 || keycode == 9 || keycode == 8 || keycode == 63275)
	{
	    bInValidChar = false;
	}
	
	if( bInValidChar == true )
	{	
	    if( window.event )
	    {
	        e.returnValue = false;
	    }
	    
	    if (typeof e.preventDefault != "undefined")
	    {
            e.preventDefault();
        }
	}
}

function ConstructXAML( vColourSet, vDataSeries, vTitle, vWidth, vHeight, vYTitle )
{    
    var chartXmlString = ''
       +'<vc:Chart xmlns:vc="clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts" AnimationEnabled="False" BorderThickness="0" BorderBrush="#ADD1FF" CornerRadius="0" Width="' + vWidth + '" Height="' + vHeight + '"  Watermark="False" View3D="False">'
              
       +'<vc:Chart.Titles>'
            +'<vc:Title Text="' + vTitle + '" HorizontalAlignment="Left" />'
        +'</vc:Chart.Titles>'
        +'<vc:Chart.AxesY>'
        +'<vc:Axis Title="' + vYTitle + '" Prefix=""/>'
        +'</vc:Chart.AxesY>'
            
        +'<vc:Chart.Legends>'
        +'<vc:Legend Name="Legend1" FontSize="12"/>'
        +'</vc:Chart.Legends>'
        
        +'<vc:Chart.Series>'
            + vDataSeries
        +'</vc:Chart.Series>'
        +'</vc:Chart>';
        return chartXmlString;
}

function ValidateCountryDropDownList(CountryList)
{
    if(CountryList != null)
    {
        var strValue = new String(CountryList[CountryList.selectedIndex].value);
        return (strValue != "1");
    }
    else
    {
        return false;
    }
}

function ISIE6()
{
    var browser = navigator.appName;
    var version = navigator.appVersion;
    if ( browser== "Microsoft Internet Explorer" )
    {
        if(version.substring(22,25) == "6.0")
        {
            return true;
        }
    }
    return false;
}

