﻿/**
 * 客户端配置类
 */
function KConfig(){	}
//KConfig.Url="http://42.0.191.27/";	//地图服务器网址
KConfig.Url="";	//地图服务器网址
KConfig.MapPath=KConfig.Url + "maps/";					//地图存放目录
KConfig.MapCmd=KConfig.Url + "Cmd.aspx";				//地图操作响应文件
KConfig.CurPath=KConfig.Url + "cur/";					//图标存放目录
KConfig.ToolImagePath=KConfig.Url + "images/";			//工具栏存放目录

KConfig.MoveScale=1;									//移动比率
KConfig.MapMinLevel=3;									//地图缩放最小级别

KConfig.MapMaxLevel=23;									//地图缩放最大级别


KConfig.HistoryBack=10;									//地图后退几步(数据不超过30)

KConfig.ProgressImage=KConfig.ToolImagePath + "loading.gif"		//进度条图片

KConfig.ThemeLegendImage="themes/";						//专题图图片存放目录

KConfig.MapScale=3600*100;								//地图比例系数
//[3600是固定，100根据图层不同而不同，如厦门是100，亚洲为1500]

//JD业务属性 START START ADDED BY QQM 20070319
KConfig.G_OpenPage="searchCondition.jsp";
KConfig.G_Para="center:1;resizable:0;scroll:0;status:1;edge:raised;unadorned:0;help:0;dialogWidth:455px;dialogHeight:340px";
KConfig.G_bOpen=true;
//JD业务属性 END

//鹰眼图参数

KConfig.NavigateMap=KConfig.ToolImagePath + "navigate.gif";		//鹰眼图图片

KConfig.NavigateLeft=43630000;//42423631;							//鹰眼图左上角X直角坐标
KConfig.NavigateTop=275650000;//275834403;							//鹰眼图左上角Y直角坐标
KConfig.NavigateRight=49510000;//50614019;							//鹰眼图右下角X直角坐标
KConfig.NavigateBottom=269850000;//270158273;							//鹰眼图右下角Y直角坐标


KConfig.NavigateWidth=120;								//鹰眼图宽
KConfig.NavigateHeight=123;								//鹰眼图高

KConfig.Session=5;										//服务器session设置数据[查看Web.config中sessionState的timeout参数],单位为分钟
KConfig.LinkPath=KConfig.Url + "Link.aspx";				//刷新页面(保证IE在线时session不会丢失)


/**
* 点选范围参数设置
*/
KConfig.left=8;
KConfig.top=8;
KConfig.right=8; 
KConfig.bottom=8;

/**	  
 * 定义一个函数为类

 */
KConfig.defineClass = function(className,fun)
{
	window[className] = fun;
}

/**
 * 定义一个函数为类的静态方法

 */
KConfig.defineStaticFunction = function(oClass, funName, fun)
{
    oClass[funName] = fun;
}

/**
 * 定义一个函数为类的方法
 */
KConfig.defineFunction = function(oClass, funName, fun)
{
    oClass.prototype[funName] = fun;
} 



//=================================VML 统计图[START]=================================
KConfig.all=new Array();
/*
 * 画饼状图
 * centerX--饼图中心点X坐标
 * centerY--饼图中心点Y坐标
 * R--饼图半径
 * Angle--扇形的角度(360圆/180半圆)gradient
 */
var KConfig_DrawPie = function(centerX,centerY,R,Angle,sType,sValue,sScore,sColor,sOpacity)
{
	
	try
    {
		//统计项
		var Type=sType.split(',');
		var Value=sValue.split(',');
		var Score=sScore.split(',');
		var Color=sColor.split(',');	
		var Opacity=sOpacity;
    
        if(parseInt(Angle) > 360)
        {
            Angle = parseInt(Angle - parseInt(Angle / 360) *360);
            if(Angle == 0)
                Angle = 360;
        }
        var mx = Math.pow(2,16) * parseInt(Angle);
        var vTotal = 0;
        var startAngle = 0;
        var endAngle = 0;
        var pieAngle = 0;
        var prePieAngle = 0;
        var strHtml = "";
        for(i = 0;i < Type.length;i++)
        {
            vTotal += parseInt(Value[i]);
        }
        strHtml += "<v:group id='group1' style='position:absolute;left:"+parseInt(centerX-1.5*R)+"px;top:"+parseInt(centerY-R)+"px;z-index:100000;width:"+eval(2*R)+";height:"+eval(2*R)+"' coordsize='21600,21600'>";
        for(i = 0;i < Type.length; i++)
        { 
            pieAngle = Value[i] / vTotal;
            startAngle += prePieAngle;
            prePieAngle = pieAngle;
            endAngle = pieAngle;         
            //顺序的划出各个饼图
            
            strHtml += "<v:shape title='" + Type[i] + "\n" + Value[i]  + "'";
            strHtml += "style='LEFT:0px;WIDTH:15000px;TOP:0px;HEIGHT:14000px'";
            strHtml += "coordsize='1500,1400' strokecolor='"+Color[i]+"'";
            strHtml += "path='M 750 700 AE 750 700 750 700 " + parseInt(mx * startAngle) + " " + parseInt(mx * endAngle) + " xe'";
            strHtml += "fillcolor='"+ Color[i] +"'>";
            strHtml += "<v:fill rotate='t' opacity='" + Opacity + "' type='' focus='100%' strokecolor='black' angle='" + parseInt( parseInt(Angle) * (startAngle + endAngle /2)) +"'>";
            strHtml += "</v:fill>";
            strHtml += "</v:shape>";    
        }
        strHtml += "</v:group>";
        return strHtml;
    }
    catch(e)
    {
        return "";
    } 
}
/*
 * 画柱状图
 * left--柱状图左下角顶点X坐标
 * top--柱状图左下角定点Y坐标
 * width--单个柱状图的宽度
 */
var KConfig_DrawHistogram=function(left,top,width,sType,sValue,sScore,sColor)
{
    try
    {
		//统计项
		var Type=sType.split(',');
		var Value=sValue.split(',');
		var Score=sScore.split(',');
		var Color=sColor.split(',');
		
			
        var strHtml="";
        strHtml+="<v:group id='group1' style='position:absolute;left:"+eval(left-width-6)+"px;top:"+eval(top+3)+"px;z-index:10000;width:100;height:100' coordsize='100,100'>";
        for(i=0;i<Type.length;i++)
        {   
            strHtml+="<v:rect title='" + Type[i] + "\n" + Value[i] + "'";
            strHtml+="style='POSITION:absolute;Z-INDEX:1;LEFT:"+parseInt(i * width)+"px;TOP:" + parseInt(-10*Score[i]) +"px;width:"+width+";height:" + parseInt(10 * Score[i]) + ";'";
            strHtml+="fillcolor='" + Color[i] + "' stroked='f'/>";
        }
        strHtml+="</v:group>";
        return strHtml;
    }
    catch(e)
    {
        return "";
    }    
}
/*
 * 产生随机色
 */
function RandColor()
{
    return "rgb("+ parseInt( Math.random() * 255) +"," +parseInt( Math.random() * 255) +"," +parseInt( Math.random() * 255)+")";
}
/*
 * 添加统计项
 * sType--统计项
 * sValue--统计值
 * sColor--颜色(RGB)
 */
var KConfig_Add=function(sType,sValue,sScore,sColor)
{
	try
	{
		sType=sType.split(",");
		sValue=sValue.split(",");
		sColor=sColor.split(",");
		sScore=sScore.split(",");
		var oData=new Object();
		for(i=0;i<sType.length;i++)
		{
			oData.Type=sType[i];			
			oData.Value=parseFloat(sValue[i]);
			oData.Score=parseFloat(sScore[i]*3);
			oData.Color=sColor[i];
			var count=KConfig.all.length;
			KConfig.all[count]=oData;
		}
	}
	catch(e)
	{
		return("初始化统计数据错误!");
	}	
}
/*
 * 清除统计数据
 */
var KConfig_ClearAll=function()
{
    KConfig.all.length=0;
}

var KConfig_DrawCircle=function(left,top,width,height,sColor,type,value)
{
	try
	{
		var para=type+"\n"+value;
		var strHtml="<v:oval title='"+para+"'; style='POSITION:absolute;CUSRSOR:HAND;Z-INDEX:1000;LEFT:"+eval(left-width-5)+"px;TOP:"+eval(top-height/2)+"px;width:"+width+";height:"+height+";' fillcolor='"+sColor+"' stroked='f'/>";
		return strHtml;	
	}
	catch(e)
	{
		return "";
	}
}

KConfig.defineStaticFunction(KConfig, "DrawPie", KConfig_DrawPie);
KConfig.defineStaticFunction(KConfig, "Add", KConfig_Add);
KConfig.defineStaticFunction(KConfig, "ClearAll", KConfig_ClearAll);
KConfig.defineStaticFunction(KConfig, "DrawHistogram", KConfig_DrawHistogram);
KConfig.defineStaticFunction(KConfig, "DrawCircle", KConfig_DrawCircle);
//=================================VML 统计图[START]=================================
