/**
* 复选框全（不）选
* 
* author: GuoLei
* date: 2008-11-19
*/
function checkAll(allId,itemName)
{
	var items = document.getElementsByName(itemName);
	for(var i=0;i<items.length;i++) items[i].checked = $(allId).checked;
}
/**
* 选择一个复选框
* 
* author: GuoLei
* date: 2008-11-19
*/
function checkOne(allId,itemName)
{
	var items = document.getElementsByName(itemName);
	for(var i=0;i<items.length;i++) if(!items[i].checked) break;
	$(allId).checked = items[i]?items[i].checked:true;
}
/**
* 选择一个复选框
* 
* author: GuoLei
* date: 2008-11-19
*/
function fillSelect(obj,data)
{
	try {
		$(obj).options.length = 0;
		if(typeof data == 'string' && data.indexOf('^')>-1) {
			var data = data.split('@');
			for(var i=0;i<data.length;i++) {
				$(obj).options[i] = document.createElement("OPTION");
				$(obj).options[i].value = data[i].split('^')[0];
				$(obj).options[i].text = data[i].split('^')[1]; 
			}
		}
		else if(typeof data == 'string' && data.indexOf('{')>-1) {
			eval("var data="+data);
			var i=0;
			for(var prop in data) {
				$(obj).options[i] = document.createElement("OPTION"); 
				$(obj).options[i].text = data[prop]; 
				$(obj).options[i].value = prop;
			}
			i++;
		}
	}catch(e) { return false; }
}

/**
* 确定选择
*
* author: GuoLei
* date: 2008-11-19
*/
function doActions(formId,url)
{
	//检查是否有选项
	var flag = false;
	for(var i=0;i<cks.length;i++)
		flag = flag || cks[i].checked;
	if(!flag) {
		window.alert("请至少选择一个记录");
		return;
	}
	if(!window.confirm("您确定要执行操作吗？")) return;
	form = document.forms[formId];
	form.action = url;
	form.submit();
}

/**
* 选中文本框，提示文字自动隐藏
* 
* author: GuoLei
* date: 2008-09-11
*/
function focusInput(obj,text)
{
	obj.value = "";
	obj.style.color = "#000000";
}

/**
* 不选文本框，提示文字自动显示
* 
* author: GuoLei
* date: 2008-09-11
*/
function blurInput(obj,text)
{
	if(obj.value === "") {
		obj.value = text?text:"请输入内容";
		obj.style.color = "#cccccc";
	}
}

/**
* 将地址复制到剪贴板 （当前只适用于IE）
* 
* author: GuoLei
* date: 2008-09-11
*/
function copyToClipBoard(href)
{
	try {
		var clipBoardContent="";
		//clipBoardContent+=document.title;
		clipBoardContent+="";
		if(typeof href == "undefined")
			clipBoardContent+=this.location.href;
		else
			clipBoardContent+=href;
		window.clipboardData.setData("Text",clipBoardContent);
		alert("复制成功，请粘贴到你的QQ/MSN上推荐给你的好友");
	}catch(e) {
		alert("您的浏览器不支持“复制到剪贴板功能”，请使用键盘快捷键(Ctrl+C)来完成");
	}
}

