﻿

    function addToFav(){
        var url = "http://www.cpyxh.com";
        var title = "操盘英雄汇";
            
        if (window.sidebar) { // Mozilla Firefox Bookmark
            window.sidebar.addPanel(title, url,"");
        } else if( window.external ) { // IE Favorite
            window.external.AddFavorite( url, title);
        } else if(window.opera) { // Opera 7+
            return false; // do nothing
        } else {
             alert('您的浏览器不支持此操作,请复制地栏的地址,进行添加。');
        }
    }

    //获得Cookie解码后的值
    function GetCookieVal(offset)
    {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
    endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
    }
    //设定Cookie值
    function SetCookie(name, value)
    {
        var expdate = new Date();
        var argv = SetCookie.arguments;
        var argc = SetCookie.arguments.length;
        var expires = (argc > 2) ? argv[2] : null;
        var path = (argc > 3) ? argv[3] : null;
        path="/";
        var domain = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
        if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
        document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))
        +((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
        +((secure == true) ? "; secure" : "");
        return 1;
    }
    //删除Cookie
    function DelCookie(name)
    {
        var exp = new Date();
        exp.setTime (exp.getTime() - 1);
        var cval = GetCookie (name);
        document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
    }
    function GetCookie(name)
    //获得Cookie的原始值
    {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen)
        {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
        return GetCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
        }
        return null;
    }

//获取url参数var IP=GetUrlPara("IP") 
 function GetUrlPara()
 { 
     var Url=top.window.location.href; 
     var u,g,StrBack=''; 
     if(arguments[arguments.length-1]=="#") 
     {
       u=Url.split("#"); 
     }
     else 
     {
           u=Url.split("?"); 
           if (u.length==1) 
           {
               g='';
           }
           else
           {
                 g=u[1]; 
                 if(g!='')
                 { 
                   gg=g.split("&"); 
                 }
                 var MaxI=gg.length; 
                 str = arguments[0]+"="; 
                 for(i=0;i<MaxI;i++)
                 { 
                    if(gg[i].indexOf(str)==0)
                     { 
                       StrBack=gg[i].replace(str,""); 
                       break; 
                     } 
                  } 
            }
       } 
        return StrBack; 
  } 

//=========================================================================================
//  代码描述：打开一个新的没有状态栏、工具栏、菜单栏、定位栏，不能改变大小，且位置居中的新窗口 think           2005/04/11             创建
//=========================================================================================
function OpenWindow(pageURL, innerWidth, innerHeight,Type)
{	
	var ScreenWidth = screen.availWidth;
	var ScreenHeight = screen.availHeight;
	var StartX = (ScreenWidth - innerWidth) / 2;
	var StartY = (ScreenHeight - innerHeight) / 2;
	if(innerWidth==null&&innerHeight==null)
		window.open(pageURL)
	else if(Type==0)
	   window.open(pageURL, 'newwindow', 'left='+ StartX + ', top='+ StartY + ', Width=' + innerWidth +', height=' + innerHeight + ', resizable=no,unadorned:no,scrollbars=no, status=no, toolbar=no, menubar=no, location=no');
	else
	   window.open(pageURL, 'newwindow', 'left='+ StartX + ', top='+ StartY + ', Width=' + innerWidth +', height=' + innerHeight + ', resizable=yes,unadorned:no,scrollbars=yes, status=no, toolbar=no, menubar=no, location=no')
}
//==========================================================================================
// 代码描述：打开模式窗口函数，打开一个模式窗口不包含菜单、状态条、工具条、定位栏，不刷新父窗口           2006/10/26           创建
//==========================================================================================
function OpenModalWindow(pageURL, innerWidth, innerHeight)
{
	window.showModalDialog(pageURL, window, 'dialogWidth:' + innerWidth + 'px;dialogHeight:' + innerHeight + 'px;help:no;unadorned:no;resizable:no;status:no');
	return false;
}
function OpenModalWindowParentLoad(pageURL, innerWidth, innerHeight)
{
	//var sReturn;
	window.showModalDialog(pageURL, window, 'dialogWidth:' + innerWidth + 'px;dialogHeight:' + innerHeight + 'px;help:no;unadorned:no;resizable:no;status:no');
	return true;
}
function OpenPage(pageURL)
{
	window.location.href=pageURL;
}
function selectOneAndMore(type,selectcount)
{
	//alert(type);
	var len=document.form1.elements.length;
	var i;j=0
	for (i=0;i<len;i++)
	{
		if (document.form1.elements[i].type=="checkbox")
		{
			var sname=document.form1.elements[i].name;
			//alert(sname);
			var cutname=sname.substr(sname.lastIndexOf(":")+1);
			if(cutname=="cboxiID")
			{
				if(document.form1.elements[i].checked==true)
					j++;		
			}						
		}
	}
	if(j>0)
	{
		if(selectcount==-1)
		{
			if(type==null)
					return confirm('确定要做该操作吗?');
			return true;
		}
		else if(selectcount==null)
		{
			if(j>31)
			{
				alert("最多只能选择30项！");
				return false;
			}
			else
			{
				if(type==null||type=="")
					return confirm('确定要做该操作吗?');
			}
		}
		else
		{
			if(j>parseInt(selectcount,10))
			{
				alert("最多只能选择"+selectcount+"项！");
				return false;
			}
			else
			{
				if(type==null||type=="")
					return confirm('确定要做该操作吗?');
			}
		}
	}
	else
	{
		alert("请至少选择一项！");
		return false
	}		
}
function onclickCheckBox(itemID,obj,type,sText,sValue)
{  
	if(obj.checked)
	{
		document.all[itemID].style.backgroundColor="#999999";
		SelectItem(sText,sValue);
	}
	else
		document.all[itemID].style.backgroundColor="";	
}
function SelectItem(name,value)
{
	var retval = new Array();	
	retval[0] = name;
	retval[1] = value;	
	window.returnValue = retval;
	window.opener = null;
	window.close();
}
function setItemBackColor(itemID,obj)
{  
	if(obj.checked)
	{
		document.all[itemID].style.backgroundColor="#999999";
	}
	else
		document.all[itemID].style.backgroundColor="";	
}
function MouseOut(obj)   
{   
	if(obj.style.backgroundColor=="#999999")
		obj.style.backgroundColor="#999999";
	else
	{
		obj.style.backgroundColor=obj.getAttribute('BKC');
		obj.style.backgroundColor='';
	}
	
} 
function MouseOver(obj)   
{   
	if(obj.style.backgroundColor=="#999999")
		obj.setAttribute('BKC',"#999999");
	else
	{
		obj.setAttribute('BKC',obj.style.backgroundColor);
		obj.style.backgroundColor='#B0EDFF';
	}
	obj.style.cursor='hand';
}
function selectAll()
{
	var len=document.form1.elements.length;
	var i;
	for (i=0;i<len;i++)
	{
		if (document.form1.elements[i].type=="checkbox")
		{
			var sname=document.form1.elements[i].name;
			var ii=sname.lastIndexOf(":");
			if(ii==-1)
			{
			  ii=sname.lastIndexOf("$");
			}
			var cutname=sname.substr(ii+1);
			if(cutname=="cboxiID")
			{
				document.form1.elements[i].checked=true;
			}						
		}
	}
	//设置全选时所有行背景色变化

	var Curr_TR=document.all.tags("tr");   
	for(var i=1;i<Curr_TR.length;i++)   
	{   
		var itemid=Curr_TR[i].id;
		if(itemid.lastIndexOf("_")==-1&&itemid.substr(0,4)=="item")
			Curr_TR[i].style.backgroundColor="#999999";    
	}   	
}

function unSelectAll(){
	var len=document.form1.elements.length;
	var i;
	for (i=0;i<len;i++)
	{
		if (document.form1.elements[i].type=="checkbox")
		{
			var sname=document.form1.elements[i].name;
			//alert(sname);
			var ii=sname.lastIndexOf(":");
			if(ii==-1)
			{
			  ii=sname.lastIndexOf("$");
			}
			
			var cutname=sname.substr(ii+1);
			
			if(cutname=="cboxiID")
			{
			    if(document.form1.elements[i].checked==false)
			    document.form1.elements[i].checked=true;
			    else
				document.form1.elements[i].checked=false;
		    }
		}   
	} 
	//设置取消时所有行背景色变化

	var Curr_TR=document.all.tags("tr");   
	for(var i=1;i<Curr_TR.length;i++)   
	{   
		var itemid=Curr_TR[i].id;
		if(itemid.lastIndexOf("_")==-1&&itemid.substr(0,4)=="item")
			Curr_TR[i].style.backgroundColor="";    
	} 
}