//var Openfree = new Class.create();
//Openfree.prototype = {
//    Version: '0.0.0.1',

//    initialize: function () {

//    },
//    
//    Alert: function(message)
//    {
//        alert(message);
//    },

//    MoveSelectListItem: function (source, target) {
//        var i;
//        for (i = 0; i < source.length; i++) {
//            if (source.options[i].selected) {
//                var objOption = document.createElement("OPTION");
//                objOption.text = source.options[i].text;
//                objOption.value = source.options[i].value;
//                target.options.add(objOption);
//                source.options.remove(i);
//                break;
//            }
//        }

//        if (i - 1 >= 0) {
//            source.selectedIndex = i - 1;
//        }
//    },


//    Sleep: function (delay) {
//        var now = new Date();
//        var exitTime = now.getTime() + delay;
//        while (true) {
//            now = new Date();
//            if (now.getTime() > exitTime)
//                return;
//        }
//    },

//    AnimationFadeOut: function (obj, delay) {
//        setTimeout(function () {
//            $create(AjaxControlToolkit.Animation.AnimationBehavior,
//                { "OnLoad": "{\"AnimationName\":\"Sequence\",\"AnimationChildren\":[{\"AnimationName\":\"Parallel\",\"AnimationTarget\":\"" + obj + "\",\"Duration\":\".5\",\"Fps\":\"50\",\"AnimationChildren\":[{\"AnimationName\":\"FadeOut\",\"AnimationChildren\":[]},{\"AnimationName\":\"Resize\",\"Height\":\"0\",\"AnimationChildren\":[]}]}]}" }, null, null, $get(obj));
//        }, delay);
//    },


//    //tbPhone.Attributes.Add("onkeypress", "Openfree.prototype.EnterSubmit(" + tbPhone.ClientID + ",event);");
//    EnterSubmit: function (obj, event) {
//        var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
//        if (keyCode == 13) {
//            WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(obj, "", true, "EnterSubmitQuery", "", false, true));
//            return false;
//        }
//    }
//}






/*

gridIndenture.Columns[0].HeaderText = "<input id=\"cbSelectAll\" type=\"checkbox\" onclick='checkAll(this, "+this.Form.ClientID+");'> 选择";

*/

function AnimationFadeOut(obj, delay) {
        setTimeout(function () {
            $create(AjaxControlToolkit.Animation.AnimationBehavior,
                { "OnLoad": "{\"AnimationName\":\"Sequence\",\"AnimationChildren\":[{\"AnimationName\":\"Parallel\",\"AnimationTarget\":\"" + obj + "\",\"Duration\":\".5\",\"Fps\":\"50\",\"AnimationChildren\":[{\"AnimationName\":\"FadeOut\",\"AnimationChildren\":[]},{\"AnimationName\":\"Resize\",\"Height\":\"0\",\"AnimationChildren\":[]}]}]}" }, null, null, $get(obj));
        }, delay);
    }


function checkAll(sender, form)
{	
    var object;
    for(var i = form.elements.length-1; i>=0; --i)
    {
        object = form.elements[i];
        if (sender.name != object.name && object.type == 'checkbox')
        {
            object.checked = sender.checked;
        }
    }
}

/*

validateCheckOne('checkbox1');

*/
function validateCheckOne(control)
{	
    var object = document.getElementsByName(control);
    var count = 0;
    for(var i =0; i< object.length; i++)
    {        
        if(count>1)
        {
            alert("请选择一条记录");
            return false;
        }
        if(object[i].checked) count ++;
    }    
    return true;
}


/*

gridIndenture.Columns[0].HeaderText = "<input id=\"cbSelectAll\" type=\"checkbox\" onclick='checkAll(this, "+this.Form.ClientID+");'> 选择";






if(document.getElementById(name).checked==true)
    {
        var index = name;
        index = index.replace("treeProjectn","")
        index = index.replace("CheckBox","")
        
        
        //SelectOne(name, index);
        for(i=0; i<<%=TreeNodeCount%>; i++)
        {
            try
            {
                var temp = window.document.getElementById("treeProjectn"+i+"CheckBox");
                if(temp!=null && temp.checked == true) temp.click();
            }
            catch(e)
            {
            }                    
        }
        
        temp=document.getElementById(selected);
        temp.click();
    }
*/
function checkOne(clickID, serverID, count)
{
    //if(clickID.checked==true)
    //{
        //var index = clickID;
        //index = index.replace(serverID+"_","")
        //index = index.replace("CheckBox","")
        
        //SelectOne(name, index);
        for(i=0; i<count; i++)
        {
            try
            {
                //var obj = window.document.getElementById(serverID + "n" + i + "CheckBox");
                var obj = window.document.getElementById(clickID + "_" + i);
                if(obj!=null && obj.checked == true) 
                {
                    obj.click();
                }
            }
            catch(e)
            {}                    
        }
        
        //obj=document.getElementById(selected);
        //obj.click();
    //}
}

/*

gridIndenture.Columns[0].HeaderText = "<input id=\"cbSelectAll\" type=\"checkbox\" onclick='checkControlAll(this, "+this.Form.ClientID+", \"cbSelec\");'> 选择";

control 要处理的组件特征字符串

*/
function checkControlAll(sender, form, control)
{	
    var object;
    for(var i = form.elements.length-1; i>=0; --i)
    {
        object = form.elements[i];
        if (sender.name != object.name && object.type == 'checkbox')
        {
            //过滤服务器端组件
            if (object.name.indexOf(control) > -1)
            {
               object.checked = sender.checked;
            }
        }
    }
}

function showHideDiv(object, isShow)
{
    if(isShow)
    {
        document.getElementById(object).style.display ="";
    }
    else
    {
        document.getElementById(object).style.display ="none";
    }
}



/*

全部参数为对象，第一个参数会被隐藏，第二个对象开始至最后的的对象全部显示

*/
function ObjectListHide()
{
	var i,args = ObjectListHide.arguments;
	for (i=2; i<(args.length); i++)
		if (document.getElementById(args[i]).style.display =="") {
			document.getElementById(args[i]).style.display = "none";
		}else{
			document.getElementById(args[i]).style.display = "";
	}
	document.getElementById(args[0]).style.display = "none";
	document.getElementById(args[1]).style.display = "";
}

function ObjectListShow()
{
	var i,args = ObjectListShow.arguments;
	for (i=2; i<(args.length); i++)
		if (document.getElementById(args[i]).style.display =="") {
			document.getElementById(args[i]).style.display = "none";
		}else{
			document.getElementById(args[i]).style.display = "";
	}
	document.getElementById(args[1]).style.display = "none";
	document.getElementById(args[0]).style.display = "";
}

/*

textBox.Attributes.Add("onkeydown", MultiTextBoxMaxLength(textBox.ClientID,1500));
textBox.Attributes.Add("onkeyup", MultiTextBoxMaxLength(textBox.ClientID, 1500));

*/
function multiTextBoxMaxLengh(object, maxLength)
{
    if (object.value.length > maxLength)
    {
        object.value = object.value.substring(0, maxLength);
    }
}

function multiTextBoxMaxLengh_(objectID, maxLength)
{
    var obj = document.getElementById(objectID)
    if (obj != null && obj.value.length > maxLength)
    {
        obj.value = obj.value.substring(0, maxLength);
    }
}

/*
var listAll = findListBoxByName("ListBoxAllFields");
	var listVisible = findListBoxByName("ListBoxVisibleFields");
	var str = ";";
	var i;
	for(i=0;i<listVisible.length;i++)
	{
		str += listVisible.options[i].value + ";";
	}
	for(i=0;i<listAll.length;i++)
	{
		if(listAll.options[i].selected)
		{
			if(str.indexOf(";" + listAll.options[i].value + ";") == -1)
			{
				var oOption = document.createElement("OPTION");
				listVisible.options.add(oOption);
				oOption.innerText = listAll.options[i].text;
				oOption.value = listAll.options[i].value;
			}
		}
	}
	for(i=0;i<listAll.length;i++)
	{
		listAll.options[i].selected = false;
	}
	updateVisibleFieldsInHidden(listVisible);
	
	*/


/*

    取得浏览器类型

*/
function getBrowser(){
   if(navigator.userAgent.toLowerCase().indexOf("msie")>0)
   {
        return "msie";
   }
   if(navigator.userAgent.toLowerCase().indexOf("firefox")>0)
   {
        return "firefox";
   }
   if(navigator.userAgent.toLowerCase().indexOf("safari")>0)
   {
        return "safari";
   }
   if(navigator.userAgent.toLowerCase().indexOf("camino")>0)
   {
        return "camino";
   }
   if(navigator.userAgent.toLowerCase().indexOf("gecko")>0)
   {
        return "gecko";
   }
}


/*

    读写Cookie 
    var expires = new Date();
	expires.setTime(expires.getTime() + 3600000 * 24 * 30);
    _setCookie("loginName", "openfree", expires);

*/
function _setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + escape(path) : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");

	document.cookie = curCookie;
}
function _getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);

	if (begin == -1) {
		begin = dc.indexOf(prefix);

		if (begin != 0)
			return "";
	} else
		begin += 2;

	var end = document.cookie.indexOf(";", begin);

	if (end == -1)
		end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}




var setGradient = (function(){ 

//private variables; 
var p_dCanvas = document.createElement('canvas'); 
var p_useCanvas = !!( typeof(p_dCanvas.getContext) == 'function'); 
var p_dCtx = p_useCanvas?p_dCanvas.getContext('2d'):null; 
var p_isIE = /*@cc_on!@*/false; 


//test if toDataURL() is supported by Canvas since Safari may not support it 

try{ p_dCtx.canvas.toDataURL() }catch(err){ 
p_useCanvas = false ; 
}; 

if(p_useCanvas){ 

return function (dEl , sColor1 , sColor2 , bRepeatY ){ 

if(typeof(dEl) == 'string') dEl = document.getElementById(dEl); 
if(!dEl) return false; 
var nW = dEl.offsetWidth; 
var nH = dEl.offsetHeight; 
p_dCanvas.width = nW; 
p_dCanvas.height = nH; 


var dGradient; 
var sRepeat; 
// Create gradients 
if(bRepeatY){ 
dGradient = p_dCtx.createLinearGradient(0,0,nW,0); 
sRepeat = 'repeat-y'; 
}else{ 
dGradient = p_dCtx.createLinearGradient(0,0,0,nH); 
sRepeat = 'repeat-x'; 
} 

dGradient.addColorStop(0,sColor1); 
dGradient.addColorStop(1,sColor2); 
p_dCtx.fillStyle = dGradient ; 
p_dCtx.fillRect(0,0,nW,nH); 
var sDataUrl = p_dCtx.canvas.toDataURL('image/png'); 

with(dEl.style){ 
backgroundRepeat = sRepeat; 
backgroundImage = 'url(' + sDataUrl + ')'; 
backgroundColor = sColor2; 
}; 
} 
}else if(p_isIE){ 

p_dCanvas = p_useCanvas = p_dCtx = null; 
return function (dEl , sColor1 , sColor2 , bRepeatY){ 
if(typeof(dEl) == 'string') dEl = document.getElementById(dEl); 
if(!dEl) return false; 
dEl.style.zoom = 1; 
var sF = dEl.currentStyle.filter; 
dEl.style.filter += ' ' + ['progid:DXImageTransform.Microsoft.gradient( GradientType=', +(!!bRepeatY ),',enabled=true,startColorstr=',sColor1,', endColorstr=',sColor2,')'].join(''); 

}; 

}else{ 

p_dCanvas = p_useCanvas = p_dCtx = null; 
return function(dEl , sColor1 , sColor2 ){ 

if(typeof(dEl) == 'string') dEl = document.getElementById(dEl); 
if(!dEl) return false; 
with(dEl.style){ 
backgroundColor = sColor2; 
}; 
//alert('your browser does not support gradient effet'); 
} 
}
})();







/*

showHideList.js

*/

function HideLi() {
    //第一个参数是隐藏+图标的ID,第二个是显示-图标的ID,第个三个至最后的参数是隐藏ID,可以写在一起
    var i, args = HideLi.arguments;
    for (i = 2; i < (args.length); i++)
        if (document.getElementById(args[i]).style.display == "") {
        document.getElementById(args[i]).style.display = "none";
    } else {
        document.getElementById(args[i]).style.display = "";
    }
    document.getElementById(args[0]).style.display = "none";
    document.getElementById(args[1]).style.display = "";
}
function ShowLi() {
    var i, args = ShowLi.arguments;
    for (i = 2; i < (args.length); i++)
        if (document.getElementById(args[i]).style.display == "") {
        document.getElementById(args[i]).style.display = "none";
    } else {
        document.getElementById(args[i]).style.display = "";
    }
    document.getElementById(args[1]).style.display = "none";
    document.getElementById(args[0]).style.display = "";
}











/*

// 说明 ：用 Javascript 实现锚点(Anchor)间平滑跳转
// 来源 ：ThickBox 2.1
// 整理 ：Yanfu Xie [xieyanfu@yahoo.com.cn]
// 日期 ：07.01.17 

调用方式：
scroller(el, duration)
el : 目标锚点 ID
duration : 持续时间，以毫秒为单位，越小越快
*/

// 转换为数字
function intval(v) {

    v = parseInt(v);

    return isNaN(v) ? 0 : v;

}

// 获取元素信息

function getPos(e) {

    var l = 0;

    var t = 0;

    var w = intval(e.style.width);

    var h = intval(e.style.height);

    var wb = e.offsetWidth;

    var hb = e.offsetHeight;

    while (e.offsetParent) {

        l += e.offsetLeft + (e.currentStyle ? intval(e.currentStyle.borderLeftWidth) : 0);

        t += e.offsetTop + (e.currentStyle ? intval(e.currentStyle.borderTopWidth) : 0);

        e = e.offsetParent;

    }

    l += e.offsetLeft + (e.currentStyle ? intval(e.currentStyle.borderLeftWidth) : 0);

    t += e.offsetTop + (e.currentStyle ? intval(e.currentStyle.borderTopWidth) : 0);

    return { x: l, y: t, w: w, h: h, wb: wb, hb: hb };

}



// 获取滚动条信息

function getScroll() {

    var t, l, w, h;


    if (document.documentElement && document.documentElement.scrollTop) {

        t = document.documentElement.scrollTop;

        l = document.documentElement.scrollLeft;

        w = document.documentElement.scrollWidth;

        h = document.documentElement.scrollHeight;

    } else if (document.body) {

        t = document.body.scrollTop;

        l = document.body.scrollLeft;

        w = document.body.scrollWidth;

        h = document.body.scrollHeight;

    }

    return { t: t, l: l, w: w, h: h };

}



// 锚点(Anchor)间平滑跳转

function scroller(el, duration) {

    if (typeof el != 'object') { el = document.getElementById(el); }



    if (!el) return;



    var z = this;

    z.el = el;

    z.p = getPos(el);

    z.s = getScroll();

    z.clear = function () { window.clearInterval(z.timer); z.timer = null };

    z.t = (new Date).getTime();



    z.step = function () {

        var t = (new Date).getTime();

        var p = (t - z.t) / duration;

        if (t >= duration + z.t) {

            z.clear();

            window.setTimeout(function () { z.scroll(z.p.y, z.p.x) }, 13);

        } else {

            st = ((-Math.cos(p * Math.PI) / 2) + 0.5) * (z.p.y - z.s.t) + z.s.t;

            sl = ((-Math.cos(p * Math.PI) / 2) + 0.5) * (z.p.x - z.s.l) + z.s.l;

            z.scroll(st, sl);

        }

    };

    z.scroll = function (t, l) { window.scrollTo(l, t) };

    z.timer = window.setInterval(function () { z.step(); }, 13);

}



var _calendarextender;
function hideCalendar(cb) {
    _calendarextender = cb;
    setTimeout(delayHideCalendar, 200);
}
function delayHideCalendar() {
    _calendarextender.hide();
}
function calendarShown(sender, args) {
    sender._popupBehavior._element.style.zIndex = 1000005; 
}

/*--------------------------------------------------

多文档活动视图改变脚本，应该已经作废了，不使用

    
author			柴瑞
created			2006-01-17  18:10
updated			2006-01-17
updateCount     1

email			chairui1979@hotmail.com
website			http://chairui.openfree.net


--------------------------------------------------*/

var lastActiveViewIndex;

//
//  ActiveViewIndex：当前活动能的视图，MultiViewContentCount：全部视图的个数。
//
function ActiveViewChanged(ActiveViewIndex, MultiViewContentCount) {
    for (i = 0; i < MultiViewContentCount; i++) {
        if (i == ActiveViewIndex) {
            document.getElementById("MultiViewContent" + ActiveViewIndex).style.display = "";
            document.getElementById("MultiViewItem" + ActiveViewIndex).style.background = "#e6eef7";
            document.getElementById("ctl00_contentPlaceHolderID_tbSearchType").value = ActiveViewIndex;
        }
        else {
            document.getElementById("MultiViewContent" + i).style.display = "none";
            document.getElementById("MultiViewItem" + i).style.background = "#f2f7fb"; //"Transparent";
        }
    }
}





/*

打印相关

*/
function PageSetup(name, value) {
    try {
        var Wsh = new ActiveXObject("WScript.Shell");
        Wsh.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\" + name, value);
    }
    catch (e) {
        alert('需要运行运行Activex才能进行打印设置。');
    }
}
var oWin;
function Print() {
    try {
       

        if (oWin.window.document.readyState == "complete") {
            oWin.window.document.title = "打印窗口";
            //oWin.window.print();
            //oWin.window.document.all.WebBrowser.ExecWB(6, 6);
            //execScript(n = "vbPrintPage 6, 2, 3", "vbscript");
            oWin.window.doPrint();
            oWin.window.close();
        }
        else {
            setTimeout(Print, 1000);
        }
    }
    catch(e)
    {

    }
}
function PrintWindow(url, msg) {
    alert(msg);
    oWin = null;
    oWin = window.open("", "打印窗口", "height=50, width=50, top=0, left=0, menubar=no, location=no, scrollbars=no, resizable=no, status=no");
    //oWin = window.open("", "打印窗口");

    var myDate = new Date()
    oWin.location = url + "&Key=" + myDate.getTime(); 
    //oWin.location = window.location.href + "&Key=" + myDate.getTime(); 

    //oWin.document.open();
    //oWin.document.write(window.document.body.innerHTML);
    //oWin.document.close();
    //oWin.print();
    //oWin.close();
    setTimeout(Print, 2000);
}

　
