/// <reference path="jquery.min.js" />
var isIE = !!window.ActiveXObject;
var isIE6 = isIE && !window.XMLHttpRequest;
var isIE8 = isIE && !!document.documentMode;
var isIE7 = isIE && !isIE6 && !isIE8;
function confirmurl(url, message) {
	//url = url+'&pc_hash='+pc_hash;
	if(confirm(message)) redirect(url);
}
function redirect(url) {
	location.href = url;
}
//滚动条
$(function(){
	$(":text").addClass('input-text');
})

/**
 * 全选checkbox,注意：标识checkbox id固定为为check_box
 * @param string name 列表check名称,如 uid[]
 */
function selectall(name) {
	if ($("#check_box").attr("checked")==false) {
		$("input[name='"+name+"']").each(function() {
			this.checked=false;
		});
	} else {
		$("input[name='"+name+"']").each(function() {
			this.checked=true;
		});
	}
}
function openwinx(url,name,w,h) {
	if(!w) w=screen.width-4;
	if(!h) h=screen.height-95;
	url = url+'&pc_hash='+pc_hash;
    window.open(url,name,"top=100,left=400,width=" + w + ",height=" + h + ",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no");
}
//弹出对话框
function omnipotent(id,linkurl,title,close_type,w,h) {
	if(!w) w=700;
	if(!h) h=500;
	art.dialog({id:id,iframe:linkurl, title:title, width:w, height:h, lock:true},
	function(){
		if(close_type==1) {
			art.dialog({id:id}).close()
		} else {
			var d = art.dialog({id:id}).data.iframe;
			var form = d.document.getElementById('dosubmit');form.click();
		}
		return false;
	},
	function(){
			art.dialog({id:id}).close()
	});void(0);
}
function AllSet() {
    var crate = $("#Channel_rate").val();
    var gate = $("#GateID").val();
    var state = $("#Cstate").attr("checked");
    $('input[name="Channelid"]:checked').each(function () {
        var chennelID = $(this).val();
        if (crate != 0) {
            $("#ChannelRate_" + chennelID).val(crate);
        }
        if (gate != "0") {
            $("#GateID_" + chennelID).val(gate);
        }
        if (state == true) {
            $("#Cstate_" + chennelID).attr("checked", "true");
        } else {
            $("#Cstate_" + chennelID).removeAttr("checked");
        }
    });
}
function showRow(id) {
    if (isIE7 || isIE6) {
        if ($("#append_" + id).css("display") == "block") {
            $("#append_" + id).css("display", "none");
        }
        else {
            $("#append_" + id).css("display", "block");
        }
    }
    else {
        if ($("#append_" + id).css("display") == "table-row") {
            $("#append_" + id).css("display", "none");
        }
        else {
            $("#append_" + id).css("display", "table-row");
        }
    }
}
function copyToClipboard(maintext) {
    if (window.clipboardData) {
        window.clipboardData.setData("Text", maintext);
    } else if (window.netscape) {
        try {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        } catch (e) {
            alert("该浏览器不支持一键复制！n请手工复制文本框链接地址～");
        }

        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if (!clip) return;
        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        if (!trans) return;
        trans.addDataFlavor('text/unicode');
        var str = new Object();
        var len = new Object();
        var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
        var copytext = maintext;
        str.data = copytext;
        trans.setTransferData("text/unicode", str, copytext.length * 2);
        var clipid = Components.interfaces.nsIClipboard;
        if (!clip) return false;
        clip.setData(trans, null, clipid.kGlobalClipboard);
    }
    alert("复制到剪贴板成功");
}