//忽略脚本错误
	window.onerror = function() {
			//return true;
		}
	
	var const_themes = "drakblue";
	
	document.write('<link href="../themes/'+ const_themes +'.css" rel="stylesheet" type="text/css" charset="UTF-8"/>');
	
	var isIE=((document.all&&document.getElementById&&!window.opera)?true:false); 
	var isMozilla=((!document.all&&document.getElementById&&!window.opera)?true:false); 
	var isOpera=((window.opera)?true:false);
	var isNS4 = ((document.layers)?true:false);
	
//取得元素
function getRef(id) {		
		if (isIE) return document.getElementById(id);
		if (isNS4) return document.layers[id];
		if (isMozilla) return document.getElementById(id);		
		if (isOpera) return document.getElementById(id);
		return document.getElementById(id);
}

function chkEmpty(fld,title)
{
	var o=getRef(fld);
	if(o != null)
	{
		if(o.value.length == 0)	
		{
			alert("[" + title + "] 是必填项")
			o.focus();
			return false;
		}
	}
	return true;
}

function chkNumber(fld,title)
{
	var o=getRef(fld);
	if(o != null)
	{
		if(o.value.length = 0 || isNaN(o.value))	
		{
			alert("[" + title + "] 不是一个有效的数字")
			o.focus();
			return false;
		}
	}
	return true;
}

function ReturnToList(url) {
		if(top.location==parent.location) {
			document.location = url;
		}else{
			window.parent.location = url;
		}
}


function sel(obj,clsName)
	{
		if (obj != null)
		{	
			var o;
				if (obj.checked == true)
				{
					o = getRef("tr" + obj.value)
					if(o!=null) o.className = "selBgcolor";
				}
				else
				{
					o =getRef("tr" + obj.value)
					if(o!=null) o.className = clsName;	
				}	
			
		}
	}
function checkAll(obj)
{
   var a = document.getElementsByTagName("input");
   if(obj.checked==false){
	   for (var i=0; i<a.length; i++)
		{
		  if (a[i].type == "checkbox") a[i].checked = false;
		  tmpObj = getRef("tr" + a[i].value)
		  if ((i+1) % 2 == 1)
		  {
		  	if (tmpObj != null) tmpObj.className = "bgcolor-1";
		  }
		  else
		  {
			if (tmpObj != null) tmpObj.className = "bgcolor-2";
		  }
		}
   }
   else
   {
	   for (var i=0; i<a.length; i++)
		{
			if (a[i].type == "checkbox") 
			{
					tmpObj = getRef("tr" + a[i].value)
					a[i].checked = true;
					if (tmpObj != null) tmpObj.className = "selBgcolor";
			}
		}
   }
}

function checkAllMenu(obj)
{
   var a = document.getElementsByTagName("input");
   if(obj.checked==false){
	   for (var i=0; i<a.length; i++)
		{
		  if (a[i].type == "checkbox" && a[i].name == "id") a[i].checked = false;
	}
   }
   else
   {
	   for (var i=0; i<a.length; i++)
		{
			if (a[i].type == "checkbox"  && a[i].name == "id") a[i].checked = true;
		}
   }
}

function checkSubmit(chkName)
{
   var a = document.getElementsByTagName("input");
	   for (var i=0; i<a.length; i++)
		{
		  if (a[i].type == "checkbox" && a[i].name == chkName)
		  {
		  	if(a[i].checked == true) return true;
		  }
		}
		alert('您最少需要选择一个处理选项!在前面的选择复选框打勾哦');
		return false;
}

function doSubmit(frm,action) {
	var obj = getRef(frm);
	if (obj != null && checkSubmit("id")) {
		obj.action = action;
		obj.submit();
	}
}


function isChecked(val)
{
	var isChked = false;
	var ids = document.getElementsByTagName("input");
	for (i=0;i<ids.length;i++)
	{
		if(ids[i].type == "checkbox" )
		{
			if(ids[i].checked == true && ids[i].value == val) isChked = true;	
		}
	}
	return isChked;
	
}

function setClsName(id,clsName)
{
	var tmpObj = getRef("tr" + id);
	if (isChecked(id)) {
			tmpObj.className = "selBgcolor";	
		}
		else
		{
			tmpObj.className = clsName;		
		}
}

function setCls(clsName,obj)
{
	if (obj != null) {
			obj.className = clsName;		
		}
}

function setDisplay(tdID,imgID)
{
	var tmpTdObj = getRef(tdID);
	var tmpImgObj = getRef(imgID);
	if (tmpTdObj.className == "dBlock") {
			tmpTdObj.className = "dNone";	
			tmpImgObj.src = "images/ico.gif"
		}
		else
		{
			for (i=1;i<=12;i++)
			{	
				theNum = i;
				if (i < 10)  theNum = "0" + "" + i;
				tempTdObj = getRef("menuList" + theNum);
				tempImgObj = getRef("arr" + theNum);
				if(tempTdObj != null) tempTdObj.className = "dNone";	
				if(tempImgObj != null) tempImgObj.src = "images/ico.gif"
			}
			tmpTdObj.className = "dBlock";	
			tmpImgObj.src = "images/ico02.gif"
		}
}

function setChecked(val)
{
	var ids = document.getElementsByTagName("input");
	for (i=0;i<ids.length;i++)
	{
		if(ids[i].type == "checkbox" )
		{
			if(ids[i].value == val)
			{	
				if (ids[i].checked == false) 
				{
					ids[i].checked = true;				
				}
				else
				{
					ids[i].checked = false;		
				}
			}
		}
	}	
}


var requestFields=null;
function showDlg(oUrl,fields,wd,ht,sl){
	var t="文件上传";
	if(oUrl.toLowerCase().indexOf("color") != -1) t="选择颜色"
	if(oUrl.toLowerCase().indexOf("selectfile") != -1) t="选择文件"
		requestFields=fields;
		newWin(t,oUrl,wd,ht);
}

function doSplit(fieldValues)
{	
	if(!requestFields) return;
	var fields = requestFields;
	var arrFields = fields.split("|");
	var arrFieldValues = fieldValues.split("|");
	var l=0;
	l=(arrFields.length <= arrFieldValues.length)?(arrFields.length):(arrFieldValues.length);
		for(i=0;i<l;i++)
		{
			tmpObj = getRef(arrFields[i]);
			if(tmpObj != null) tmpObj.value = arrFieldValues[i];
		}
	closeFocusWin();		
}

var acElement =null;
function goUrl(url,t){
	switch(t){
		case 0:
			document.location.href = url;
			break;
		case 1:
			window.document.location.reload();
			break;
		case 2:
			history.back();
			break;
		case 3:
			if (chkConfirm(1)) document.location.href=url;
			break;
		case 4:
			//document.execCommand("copy");
			alert("请用Ctrl+C组合键来实现复制功能!")
			break;
		case 5:
			if(acElement != null)
			{	
				acElement.focus();			
			var RPL=document.selection.createRange();				
				RPL.execCommand("paste");
			}
			//alert("请用Ctrl+V组合键来实现粘贴功能!")
			//alert(document.activeElement.tagName);
			break;
	}
}

function rtValue(val)
	{
		if(window.parent != null)
		{
			var pL = window.parent.document.location.href.toString();
				pL = pL.toLowerCase();
			if(pL.substr(pL.length-16) == "/admin/index.asp" || pL.substr(pL.length-7) == "/admin/" || pL.substr(pL.length-6) == "/admin")
			{
				window.clipboardData.setData('text',"../" + currentPath + "/" + val.split("|")[0]);
				openAlertDialog("文件路径已经复制到粘贴板",'');
			}
			else
			{
				var rtVal = "../" + currentPath + "/" + val;
				window.parent.openUploadSplitDialog("文件已选择,请不要修改文本框内地址<br>"+rtVal,rtVal);
				

			}
		}
		else
		{
			openAlertDialog("文件路径:" + val,'');
		}
	}
	
function reName(filename)
	{
		var f=filename;
		var w = 400;
		var h = 100;
		showMediaView(f,w,h,1);
	}
	
function deleteFile(title,url)
	{
		openConfirmDialogInfo("确认删除文件?",'请确认是否删除这个文件?',title,url);
	}
	
function fullView(filename,w,h)
	{	
		var f = filename;
		showMediaView(f,w,h,0);
	}

function setSelect(index,txt) {
		var t = getRef("categoryViewText");
		var s = getRef("searchBy");
		var ol = getRef("categoryViewList");
		var str,ch,j;
			str="";
			j=0;
			s.selectedIndex = parseInt(index);	
		for (var i=0;i<txt.length;i++) {
			if(j>=8) break;
			ch = txt.substr(i,1);
			if(found(ch)) {
				j = j + 1;	
			} else {
				j = j + 2;
			}
			str += ch;
		}
			t.innerHTML = str + "..";
			ol.style.display = "none";
			//showCategoryView(0)	
}
	
	function chgCls(obj) {
		var cls=obj.className.toString();
		if(cls.indexOf("_on") != -1) {
			obj.className=cls.replace("_on","");	
		} else {
			obj.className=cls + "_on";
		}
	}

var CurrentField="";

function RtValue(p1,p2)
{
	var o=getRef(CurrentField);	
	if(CurrentField == "n_key")
	{
		var obj = document.getElementById("n_key_lst");
		if(obj != null)
		{
			obj.options[obj.length] = new Option(p2,p2);
		}
	}
	else
	{
		o.value = p2;
		if(CurrentField.toLowerCase() == "p_pic")
		{
			var o2 = getRef("p_thumbs");
			if(o2 != null)
			{
				o2.value = p1;	
			}
		}		
	}
}

function showDlg(u,field,wd,ht,s)
{	
	var o = getRef("editor_jm");
		CurrentField = field;
	if(o != null)
	{
		document.frames[o.value + "___Frame"].OpenDialog(o.value);
	}
	else {
		window.open('upload/upload.asp?formname=frmCommon&editname=' + field + '','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')
	}
	
	
	//alert(document.frames["n_content___Frame"].GetContents("n_content"))
	//.FCKeditorAPI.GetInstance
	//FCK.ToolbarSet.CurrentInstance.Commands.GetCommand("Image").Execute();
	
	//window.open('upload/upload.asp?formname=frmCommon&editname=' + field + '','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')
}

function IsDigit(){
  return (((event.keyCode >= 48) && (event.keyCode <= 57)) || event.keyCode == 46);
}

function Review(s)
{
	var o = getRef("Preview");
	if(o) o.src = s;
}

/*
<input type="button" name="Submit2" class="go-wenbenkuang" value="上传图片" onClick="window.open('../upload.asp?formname=myform&editname=lj&uppath=shoppic&filelx=jpg','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')">
*/

