var ajaxTimeOut = 90; 
var defaultPage = ''	//XP系统测试时设为dn.asp或index.asp若为2003系统，或服务器系统请清空
function externallinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i < anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank";
	}
}

window.onload = externallinks;
function HistoryUrl() {
	var url= location.href.toLowerCase();var urlarr= url.split('?url=');var tempurl = urlarr[urlarr.length - 1];
	if(url.indexOf("/login.shtml")!=-1){location.href='/login.shtml';}else{location.href='/Login.shtml?url='+ tempurl;}
}
function LoadJsCssFile(filename, filetype){
	if (filetype == 0){
		var fileref = document.createElement('script');
		fileref.setAttribute("type","text/javascript");
		fileref.setAttribute("src",filename);
	}
	else if (filetype == 1){
		var fileref = document.createElement("link");
		fileref.setAttribute("rel", "stylesheet");
		fileref.setAttribute("type", "text/css");
		fileref.setAttribute("href",filename);
	}
	else if (filetype == 2){
		var fileref = document.createElement("link");
		fileref.setAttribute("rel", "shortcut icon");
		fileref.setAttribute("type", "image/ico");
		fileref.setAttribute("href",filename);
	}
	if (typeof fileref != "undefined") document.getElementsByTagName("head")[0].appendChild(fileref)
}
///sys类ajax引用，分离出来方便以后改AJAX框架时更改
function sysAjax(loadTxt,postUrl,dataStr,tag){
	model.AjaxComon(loadTxt,postUrl,dataStr,tag);
}

function getOs() {
	var sAgent = navigator.userAgent.toLowerCase();
	if (sAgent.indexOf("msie") >= 0) return 'IE';
	if (sAgent.indexOf("firefox") >= 0) return 'Firefox';
	if (sAgent.indexOf("safari") >= 0) return 'Safari';
	if (sAgent.indexOf("opera") >= 0) return 'Opera';
	if (sAgent.indexOf("netscape") >= 0) return 'NetScape';
	if (sAgent.indexOf("camino") >= 0) return 'Camino';
	if (sAgent.indexOf("gecko/") >= 0) return 'Gecko';
	return 'unknown';
}

function addFavorite(url,name){
	switch(getOs()){
		case 'IE' :
			window.external.addFavorite(url,name);
			break;
		default :
			window.sidebar.addPanel(name,url,"");
			break;
	}
}

function setHomepage(url){
	switch(getOs()){
		case 'IE' :
			document.body.style.behavior = 'url(#default#homepage)';
			document.body.setHomePage(url);
			break;
		default :
			if (window.sidebar){
				if(window.netscape){
					try {
						netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
					}
					catch (e) {
						alert('SeaGull CMS 提醒：\n\n设置首页的操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config\n然后将项 signed.applets.codebase_principal_support 值该为true');
					}
				}
				var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
				prefs.setCharPref('browser.startup.homepage',url);
			}
			break;
	}
}

function SetCookie(name,value,days) {
	var exp = new Date(); //new Date("December 31, 9998");
	exp.setTime(exp.getTime() + days * 24 * 60 * 60 * 1000);
	document.cookie = name +'='+ escape(value) + ';expires='+ exp.toGMTString();
}

function getCookie(name) {
	var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	if(arr != null) return unescape(arr[2]); return null;
}

function ReturnMultipleValue(tag) {
	if (document.getElementById(tag)){
		var result = '';
		for (var i = 0; i < document.getElementById(tag).options.length; i ++) {
			if (document.getElementById(tag).options[i].selected) {
				if (result == '') result = document.getElementById(tag).options[i].value;
				else result = result +','+ document.getElementById(tag).options[i].value;
			}
		}
		return result;
	}
}

function selectAllCheckBox(objName,selfObjName){
	var coll = document.getElementsByTagName('input')
	if(!coll) return;
	if(coll.length){
		for(var i = 0;i < coll.length;i++){
			if (coll.item(i).name == objName) coll.item(i).checked = document.getElementById(selfObjName).checked;
		}
	}
	else coll.checked = document.getElementById(selfObjName).checked;
}

function getValueList(tagName,tagId){
	var result = "";
	var coll = document.getElementsByTagName(tagName)
	if(!coll) return result;
	if(coll.length){
		for(var i = 0;i<coll.length;i++){
			if(coll.item(i).checked) {
				if (coll.item(i).id == tagId) result += (result == "")?coll.item(i).value:("," + coll.item(i).value);
			}
		}
	}else{
		if(coll.checked) result = coll.value;
	}
	return result;
}

function getItemValue(tagName,val) {
	if (val == '***') document.getElementById(tagName).value = '';
	else {
		if (document.getElementById(tagName).value == '') document.getElementById(tagName).value = val;
		else document.getElementById(tagName).value = document.getElementById(tagName).value +','+ val;
	}
}
function getItemOption(tagName,val) {
	if (val == '***') {document.getElementById(tagName).value = '';}
	else {
	document.getElementById(tagName).value = val;
		
	}
}
function checkDisabled(tagName,objNull) {
	var coll = document.getElementsByTagName('input')
	var temp = false;
	if (objNull == '') temp = true;
	if (!coll) return;
	if (coll.length){
		for(var i = 0;i < coll.length;i++){
			if (coll.item(i).name == tagName)  coll.item(i).disabled = temp;
		}
	}
	else coll.disabled = temp;
}

function windowOpen(url,item,val,target) {
	var a = item.split("|")
	var b = val.split("|")
	if (target == 'open') {
		if (item == '') window.open(url);
		else {
			for (var i = 0;i < a.length ;i ++ ){
				if (i == 0) url = url +'?'+ a[i] +'='+ escape(b[i]);
				else  url = url +'&'+ a[i] +'='+ escape(b[i]);
			}
			window.open(url);
		}
	}
	else {
		if (item == '') location.href = url;
		else {
			for (var i = 0;i < a.length ;i ++ ){
				if (i == 0) url = url +'?'+ a[i] +'='+ escape(b[i]);
				else  url = url +'&'+ a[i] +'='+ escape(b[i]);
			}
			location.href = url;
		}
	}
}


function menuStyle(objName,nTag){
	if (nTag=='top'){
		$('.navigationtable div').each(function(){
			var classname=$(this).attr('id')==objName?"navigationtd_select":"navigationtd";
			$(this).attr('class',classname);
		});
	}else if (nTag=='menu'){
		$('#leftmenu span').each(function(){
		var classname=$(this).attr('id')==objName?"clickedmenu":"menu";
		$(this).attr('class',classname);
	});
		
	}
}

function randomChar(l,t){
	if (t == 1) var x = "0123456789poiuytrewqasdfghjklmnbvcxzQWERTYUIOPLKJHGFDSAZXCVBNM";
	else var x = "0123456789ABCDEF";
	var tmp = "";
	for(var i = 0;i < l;i ++) {
		tmp += x.charAt(Math.ceil(Math.random()*100000000)%x.length);
	}
	return tmp;
}

function changeClassName(stype,num,count,selfClass,tagClass) {
	if (document.getElementById(stype +'_'+ num)) document.getElementById(stype +'_'+ num).className = tagClass;
	for (var i = 0; i <= count; i ++) {
		if (i != num) {
			if (document.getElementById(stype +'_'+ i)) document.getElementById(stype +'_'+ i).className = selfClass;
		}
	}
}

function setIntervalchangeClassName(stype,count,step,showType) {
	var j = 0;
	for (var i = 0; i < count; i ++) {
		if (document.getElementById(stype +'_'+ i) && document.getElementById(stype +'_'+ i).style.display != 'none') {
			j = i;
			break;
		}
	}
	var k = j + 1;
	if (k >= count) k = 0;
	document.getElementById(stype +'_'+ j).style.display = 'none';
	if (showType) showBlock(stype +'_'+ k,step);
	else document.getElementById(stype +'_'+ k).style.display = 'block';
}

function showTr(id) {
	if (document.getElementById(id).style.display == 'none'){
		document.getElementById(id).style.display = ''
	}
	else document.getElementById(id).style.display = 'none'
}

function showBlocks(pre,num,count,step) {
	if (document.getElementById(pre +'_'+ num)) showBlock(pre +'_'+ num,step);
	for (var i = 0; i < count; i ++) {
		if (i != num) {
			if (document.getElementById(pre +'_'+ i)) hiddenBlock(pre +'_'+ i,step);
//			if (document.getElementById(pre +'_'+ i)) document.getElementById(pre +'_'+ i).style.display = 'none';
		}
	}
}

function showBlock(tag,step){
	if (document.getElementById(tag).style.display == 'none') {
		var h = 0;
		var anim = function(){
			document.getElementById(tag).style.display = 'block';
			document.getElementById(tag).style.overflow = 'hidden';
			var max_h = document.getElementById(tag).scrollHeight;
			h += step;
			if(h >= max_h){
				if (navigator.userAgent.toLowerCase().indexOf("msie 6.0") >= 0) {
					document.getElementById(tag).style.height = max_h +'px';
					document.getElementById(tag).style.overflow = 'auto';
				}
				else document.getElementById(tag).style.height = 'auto';
				if(tt) window.clearInterval(tt);
			}
			else{
				document.getElementById(tag).style.height = h +'px';
			}
		}
		var tt = window.setInterval(anim,2);
	}
}

function hiddenBlock(tag,step){
	if (document.getElementById(tag).style.display == 'block') {
		var h = document.getElementById(tag).scrollHeight;
		if (navigator.userAgent.toLowerCase().indexOf("msie 6.0") >= 0) document.getElementById(tag).style.overflow = 'hidden';
		var anim = function(){
			h -= step;
			if(h <= 10){
				document.getElementById(tag).style.display = 'none';
				if(tt) window.clearInterval(tt);
			}
			else{
				document.getElementById(tag).style.height = h +'px';
			}
		}
		var tt = window.setInterval(anim,10);
	}
}

function changePic(pic1,pic2,id) {
	if (document.getElementById(id).title == '点击展开') {
		document.getElementById(id).src = pic2;
		document.getElementById(id).title = '点击合起';
	}
	else {
		document.getElementById(id).src = pic1;
		document.getElementById(id).title = '点击展开';
	}
}

function openSelWin(url,winWidth,winHeight) {
	var regWin = window.open(url,'selWin_'+ randomChar(10,1),'modal=yes,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no,width='+ winWidth +',height='+ winHeight);
	if (regWin) {
		regWin.moveTo((screen.availWidth - winWidth) / 2,(screen.availHeight - winHeight - 12) / 2);
		regWin.focus();
	}
	return true;
}


function GetServerData(resultType,virtualRoot,act,val1,val2,val3,val4,tagObj) {
	xmlHttpPost(resultType,'',virtualRoot +'/Lib/Xml/SysFlag/'+defaultPage+'?action=getserverdata','obj='+ act +'&val1='+ val1 +'&val2='+ val2 +'&val3='+ val3 +'&val4='+ val4,0,0,tagObj);
}



function CheckReadGroup(virtualRoot,readscore,infoId,pageNo) {
	var userRead = xmlHttpPost(false,'',virtualRoot +'/Lib/Xml/SysFlag/'+defaultPage+'?action=getUserReadGroup','id='+ infoId +'&readscore='+ readscore,0,2,'');
	if (userRead == 'True') xmlHttpPost(true,'',virtualRoot +'/Lib/Xml/SysFlag/','action=checkReadGroup&id='+ infoId +'&pageNo='+ pageNo,0,0,'Info_'+ infoId);
}



function GetUserLoginForm(virtualRoot,tempId,formId) {
	xmlHttpPost(false,'',virtualRoot +'/Lib/Xml/SysFlag/'+defaultPage+'?action=checkUser','tempid='+ tempId +'&id='+ formId,0,0,'LoginForm_'+ formId);
}

function ChkUserLogin(virtualRoot,action,formId) {
	var tempid = document.getElementById('tempId').value;
	var usn = document.getElementById('usn').value;
	var psw = document.getElementById('psw').value;
	var code = document.getElementById('code').value;
	var saveCookie = document.getElementById('savecookie').checked;
	if (saveCookie) saveCookie = 1;
	xmlHttpPost(true,'身份验证中，请稍后...',virtualRoot +'/Lib/Xml/SysFlag/'+defaultPage+'?action='+ action,'tempid='+ tempid +'&usn='+ usn +'&psw='+ psw +'&code='+ code +'&savecookie='+ saveCookie +'&id='+ formId,0,0,'LoginForm_'+ formId);
}


function GetActionFlagCont(virtualRoot,resultType,flagID,pageNo) {
	var ajaxType = true;
	if (resultType == 3) ajaxType = false;
	xmlHttpPost(ajaxType,'Loading...',virtualRoot +'/Lib/Xml/SysFlag/'+defaultPage+'?action=changePage','id='+ flagID +'&page='+ pageNo,0,0,'P_'+ flagID)
}

function changePage(virtualRoot,resultType,action,pCount,pButton,pPlace,pType,tagObj,condition) {
	this.blur();
	var pNo = '';
	var ajaxType = true;
	if (resultType == 3) ajaxType = false;
	if (pButton == 'First') pNo = 1;
	else if (pButton == 'Previous'){
		if (document.getElementById('P_'+ tagObj +'_No0')) pNo = Number(document.getElementById('P_'+ tagObj +'_No0').innerHTML) - 1;
		if (document.getElementById('P_'+ tagObj +'_No1')) pNo = Number(document.getElementById('P_'+ tagObj +'_No1').innerHTML) - 1;
		if (pNo < 1) pNo = 1;
	}
	else if (pButton == 'Next'){
		if (document.getElementById('P_'+ tagObj +'_No0')) pNo = Number(document.getElementById('P_'+ tagObj +'_No0').innerHTML) + 1;
		if (document.getElementById('P_'+ tagObj +'_No1')) pNo = Number(document.getElementById('P_'+ tagObj +'_No1').innerHTML) + 1;
		if (pNo > pCount) pNo = pCount;
	}
	else if (pButton == 'Last') pNo = pCount;
	else pNo = Number(pButton);
	if (pType == 0){
		for (var i = 1;i <= pCount;i ++ ){
			if (i == pNo) {
				if (document.getElementById('P_'+ tagObj +'_'+ i)) document.getElementById('P_'+ tagObj +'_'+ i).style.display = 'block';
			}
			else {
				if (document.getElementById('P_'+ tagObj +'_'+ i)) document.getElementById('P_'+ tagObj +'_'+ i).style.display = 'none';
			}
		}
	}
	else xmlHttpPost(ajaxType,'Loading...',virtualRoot +'/Lib/Xml/SysFlag/'+defaultPage+'?action='+ action,'id='+ tagObj +'&page='+ pNo +'&condition='+ unescape(condition).replace(" ","%20"),0,0,'P_'+ tagObj)
	if (document.getElementById('P_'+ tagObj +'_No0')) document.getElementById('P_'+ tagObj +'_No0').innerHTML = pNo;
	if (document.getElementById('P_'+ tagObj +'_No1')) document.getElementById('P_'+ tagObj +'_No1').innerHTML = pNo;
}

function publicInfo(wid,aTag) {
	location.href = '#'+ aTag;
	if (parent.document.getElementById('progress')) parent.document.getElementById('progress').style.width = wid;
	if (document.getElementById('progress')) document.getElementById('progress').style.width = wid;
}


function xmlHttpPost(tf,loadImg,url,valueStr,postType,oprateType,id){
	loadImg = '<img style="border:0px;" align="absmiddle" src="/Lib/Images/Loading.gif" alt="Loading..." /> <span style="color:#999999">'+ loadImg +'</span>';
	var postStr = 'POST';
	if (postType == 1) postStr = 'GET';
	var xmlhttp = creatAjaxObject();
	var timeOut;
	xmlhttp.open(postStr,url,tf);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	if (tf == false) {
		xmlhttp.send('now='+ new Date().getTime() +'&'+ valueStr);
		timeOut = setTimeout(function () {if (xmlhttp) xmlhttp.abort();},ajaxTimeOut * 1000);
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			val = unescape(xmlhttp.responseText);
			if (timeOut) clearTimeout(timeOut);
			if (oprateType == 2) return val
			else returnAjaxResult(oprateType,id,val);
		}
	}
	else {
		xmlhttp.onreadystatechange = function() {
			var val = '';
			switch(xmlhttp.readyState){
				case 4 :
					if (xmlhttp.status == 200) val = unescape(xmlhttp.responseText);
					else val = '<span style="color:#ff0000">Err:'+ xmlhttp.status +'</span>';
					if (xmlhttp.status == 0) val = '<span style="color:#ff0000">请求超时</span>';
					break;
				default :
					var a = id.split(',');
					for (i = 0;i < a.length ;i ++ ){
						if (val == '') val = loadImg;
						else val = val +'<!--AjaxSplit-->'+ loadImg;
					}
					break;
			}
			if (timeOut) clearTimeout(timeOut);
			if (oprateType == 2) return val
			else returnAjaxResult(oprateType,id,val);
		}
	}
	if (tf) {
		xmlhttp.send(valueStr);
		timeOut = setTimeout(function () {if (xmlhttp) xmlhttp.abort();},ajaxTimeOut * 1000);
	}
}


function creatAjaxObject() {
	var xmlhttp = false;
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
		if (xmlhttp.overrideMimeType) xmlhttp.overrideMimeType('text/xml');
	}
	else if (window.ActiveXObject) {
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
			}
		}
	}
	if (!xmlhttp) {
		alert('Can not init XMLHttpRequest!');
		return false;
	}
	return xmlhttp
}

function returnAjaxResult(oprateType,id,val) {
	switch(oprateType){
		case 0 :
			if (document.getElementById(id)) document.getElementById(id).innerHTML = val;
			break;
		case 1 :
			if (document.getElementById(id)) document.getElementById(id).value = val;
			break;
		case 2 :
			return val;
			break;
		case 3 :
			alert(val);
			break;
		case 4 :
			document.body.innerHTML = val;
			break;
		case 5 :
			document.write(val);
		case 6 :
			location.href = val;
			break;
		case 7 :
			eval(val);
			break;
		default :
			break;
	}
}


function setCaret(textObj){
	if (textObj.createTextRange) textObj.caretPos = document.selection.createRange().duplicate();
}

function insertAtCaret(textObj,textFeildValue) {
	if(document.all) {
		if (textObj.createTextRange && textObj.caretPos) {
			var caretPos = textObj.caretPos;
			caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ''?textFeildValue + '' : textFeildValue;
		}
		else textObj.value = textFeildValue;
	}
	else{
		if(textObj.setSelectionRange){
			var rangeStart = textObj.selectionStart;
			var rangeEnd = textObj.selectionEnd;
			var tempStr1 = textObj.value.substring(0,rangeStart);
			var tempStr2 = textObj.value.substring(rangeEnd);
			textObj.value = tempStr1 + textFeildValue + tempStr2;
		}
		else alert("This version of Mozilla based browser does not support setSelectionRange");
	}
}


function GetLength(obj){
	var iLength ;
	if (getOs() == 'Opera') {
		iLength = document.getElementById(obj).value.replace(/[^\x00-\xff]/g,"**").length;
	}
	else {
		var oEditor = FCKeditorAPI.GetInstance(obj) ;
		var oDOM = oEditor.EditorDocument ;
		if ( document.all ) iLength = oDOM.body.innerText.length ;
		else{
			var r = oDOM.createRange() ;
			r.selectNodeContents( oDOM.body ) ;
			iLength = r.toString().length ;
		}
	}
	return iLength;
}


function createReviewEditor(virtualRoot,toolBarSet,wid,hei,tagObj,showType) {
	
	//checkLoadEditor();
	if(toolBarSet==undefined||toolBarSet==''){toolBarSet='Basic';}
	if(wid==undefined||wid==''){wid='98%'}
	if(hei==undefined||hei==''){hei=100;}
	if (showType == 0){ oFCKeditor.Create() ;
		CKEDITOR.appendTo( 'reviewCont_'+tagObj, {customConfig : virtualRoot +'/lib/ckeditor/user_config.js',toolbar:toolBarSet,width:wid,height:hei}, '' );
	}else{
		CKEDITOR.replace('reviewCont_'+tagObj,{customConfig : virtualRoot +'/lib/ckeditor/user_config.js',toolbar:toolBarSet,width:wid,height:hei} ); }
}
function createEditor(virtualRoot,toolBarSet,wid,hei,tagObj,showType) {
	//checkLoadEditor();
	if(toolBarSet==undefined||toolBarSet==''){toolBarSet='Basic';}
	if(wid==undefined||wid==''){wid='98%'}
	if(hei==undefined||hei==''){hei=100;}

	if (showType == 0){ oFCKeditor.Create() ;
		CKEDITOR.appendTo(tagObj, {customConfig : virtualRoot +'/lib/ckeditor/user_config.js',toolbar:toolBarSet,width:wid,height:hei}, '' );
	}else{
		CKEDITOR.replace(tagObj,{customConfig : virtualRoot +'/lib/ckeditor/user_config.js',toolbar:toolBarSet,width:wid,height:hei} ); }
}

function checkLoadEditor(){
	if ( window.CKEDITOR ){
		(function(){
			var showCompatibilityMsg = function(){
				var env = CKEDITOR.env;
				var html = '<p><strong>Your browser is not compatible with CKEditor.</strong>';
				var browsers = {
					gecko : 'Firefox 2.0',
					ie : 'Internet Explorer 6.0',
					opera : 'Opera 9.5',
					webkit : 'Safari 3.0'
				};
				var alsoBrowsers = '';
				for ( var key in env ){
					if ( browsers[ key ] ){
						if ( env[key] )
							html += ' CKEditor is compatible with ' + browsers[ key ] + ' or higher.';
						else
							alsoBrowsers += browsers[ key ] + '+, ';
					}
				}
				alsoBrowsers = alsoBrowsers.replace( /\+,([^,]+), $/, '+ and $1' );
				html += ' It is also compatible with ' + alsoBrowsers + '.';
				html += '</p><p>With non compatible browsers, you should still be able to see and edit the contents (HTML) in a plain text field.</p>';
				var alertsEl = document.getElementById( 'alerts' );
				alertsEl && ( alertsEl.innerHTML = html );
			};
			var onload = function()	{
				// Show a friendly compatibility message as soon as the page is loaded,
				// for those browsers that are not compatible with CKEditor.
				if ( !CKEDITOR.env.isCompatible )
					showCompatibilityMsg();
			};
			// Register the onload listener.
			if ( window.addEventListener )
				window.addEventListener( 'load', onload, false );
			else if ( window.attachEvent )
				window.attachEvent( 'onload', onload );
		})();
	}
}
function InsertLocalFileToEditer(virtualRoot,filename,extname,filepath,filesize,tag) {
	if (typeof(FCKeditorAPI) == 'undefined') {
		alert('您尚未载入编辑器');
	}
	else {
		switch(extname){
		case 'jpg': case 'gif': case 'jpeg': case 'bmp': case 'png':
			InsertHTML(tag,'<img alt="'+ filename +'" title="'+ filename +'" src="'+ filepath +'" />');
			break;
		default :
			InsertHTML(tag,'<img src="'+ virtualRoot +'/Lib/Images/File/'+ extname +'.gif" style="border:0px; vertical-align:middle;" alt="" /> <a href="'+ unescape(filepath) +'" rel="external">'+ unescape(filename) +'.'+ extname +'</a> ['+ filesize +']');
			break;
		}
	}
}

//    if (CKEDITOR.env.ie) {  
//        sel = this.pe.getSelection().getNative().createRange().text;  
//    }  
//    else {  
//        sel = this.pe.getSelection().getNative();  
//    }  


function InsertHTML(obj,str){
	var oEditor	= CKEDITOR.instances[obj];
	//if (!oEditor){alert('编辑器载入失败,请重刷')}
	if (oEditor.mode == 'wysiwyg'){
		oEditor.insertHtml( str );
	}
	else
		alert( 'You must be in WYSIWYG mode!' );
}

function InsertText(obj,str){
	var oEditor	= CKEDITOR.instances[obj];
	//if (!oEditor){alert('编辑器载入失败,请重刷')}
	if ( oEditor.mode == 'wysiwyg' ){
		oEditor.insertText( str );
	}
	else
		alert( 'You must be in WYSIWYG mode!' );
}

function SetContents(obj,str){
	//if (!oEditor){alert('编辑器载入失败,请重刷')}
	var oEditor	= CKEDITOR.instances[obj];
	oEditor.setData(str);
}

function GetContents(obj){
	//if (!oEditor){alert('编辑器载入失败,请重刷')}
	var oEditor	= CKEDITOR.instances[obj];
	return oEditor.getData();
}
function ExecuteCommand(obj,commandName ){
	var oEditor	= CKEDITOR.instances[obj];
	if ( oEditor.mode == 'wysiwyg' ){
		oEditor.execCommand( commandName );
	}
	else
		alert( 'You must be in WYSIWYG mode!' );
}



function CreateFlash(obj,idad, swfurl, wad, had, vs){
	var FlashPic = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
	if (wad) FlashPic += 'width="' + wad + '" ';
	if (had) FlashPic += 'height="' + had + '" ';
	FlashPic += 'id="'+ idad +'" align="middle">';
	FlashPic += '<param name="allowScriptAccess" value="always" />';
	FlashPic += '<param name="quality" value="high" />';
	FlashPic += '<param name="menu" value="false" />';
	FlashPic += '<param name="movie" value="'+ swfurl +'" />';
	FlashPic += '<param name="wmode" value="transparent" />';
	FlashPic += '<param name="flashvars" value="'+ vs +'" />';
	FlashPic += '<embed src="'+ swfurl +'" flashvars="'+ vs +'" wmode="transparent" quality="high" ';
	if (wad) FlashPic += 'width="'+ wad +'" ';
	if (had) FlashPic += 'height="'+ had +'" ';
	FlashPic += 'name="'+ idad +'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
	FlashPic += "</object>";
	document.getElementById(obj).innerHTML = FlashPic;
}
function LoadFlash(wmode,url,width,Height)
{ 
document.write('<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,2,0 width=' + width + ' height=' + Height + ' align="middle">');
document.write('<param name="movie" value="' + url + '">');
document.write(' <param name="quality" value="high">');
document.write('  <param name="wmode" value="' + wmode +'">');
document.write(' <embed src="' + url + '" width="' + width + '" height="' + Height + '" align="middle" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent">');
document.write('<param name="menu" value="false"/>');
document.write('</embed>');		
document.write(' </object>');		
}

function CheckChineseName(str){
	var str = str.substr(0,1);
	var surname = "赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄和穆萧尹姚邵堪汪祁毛禹狄米贝明臧计伏成戴谈宋茅庞熊纪舒屈项祝董粱杜阮蓝闵席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田樊胡凌霍虞万支柯咎管卢莫经房裘缪干解应宗宣丁贲邓郁单杭洪包诸左石崔吉钮龚程嵇邢滑裴陆荣翁荀羊於惠甄魏加封芮羿储靳汲邴糜松井段富巫乌焦巴弓牧隗山谷车侯宓蓬全郗班仰秋仲伊宫宁仇栾暴甘钭厉戎祖武符刘姜詹束龙叶幸司韶郜黎蓟薄印宿白怀蒲台从鄂索咸籍赖卓蔺屠蒙池乔阴郁胥能苍双闻莘党翟谭贡劳逄姬申扶堵冉宰郦雍郤璩桑桂濮牛寿通边扈燕冀郏浦尚农温别庄晏柴瞿阎充慕连茹习宦艾鱼容向古易慎戈廖庚终暨居衡步都耿满弘匡国文寇广禄阙东殴殳沃利蔚越夔隆师巩厍聂晁勾敖融冷訾辛阚那简饶空曾毋沙乜养鞠须丰巢关蒯相查后江红游竺权逯盖益桓公万俟司马上官欧阳夏侯诸葛闻人东方赫连皇甫尉迟公羊澹台公冶宗政濮阳淳于仲孙太叔申屠公孙乐正轩辕令狐钟离闾丘长孙慕容鲜于宇文司徒司空亓官司寇仉督子车颛孙端木巫马公西漆雕乐正壤驷公良拓拔夹谷宰父谷粱晋楚闫法汝鄢涂钦段干百里东郭南门呼延妫海羊舌微生岳帅缑亢况後有琴梁丘左丘东门西门商牟佘佴伯赏南宫墨哈谯笪年爱阳佟第五言福";
	r = surname.search(str);
	if(r == -1) return false
	else return true
}
function hiddenSelect(showType) {
	var coll = document.getElementsByTagName('select')
	if (!coll) return;
	if (coll.length){
		for(var i = 0;i < coll.length;i++){
			if (showType == 'hidden') {
				if (coll.item(i).style.display != 'none' ) coll.item(i).style.display = 'none';
			}
			else {
				if (coll.item(i).style.display == 'none' ) coll.item(i).style.display = '';
			}
		}
	}
}

function closeFullDiv() {
	hiddenSelect('show');
	document.getElementById('FullScreenDiv').style.display = 'none';
	document.getElementById('FullScreenContDiv').style.display = 'none';
}

function createDiv(e,id,style) {
	if (!document.getElementById(id)) {
		var cDiv = document.createElement("div");
		cDiv.id = id;
		cDiv.className = style;
		cDiv.style.position = 'absolute';
		cDiv.style.zIndex = 8880;
		document.body.appendChild(cDiv);
		if ((returnXY(e,'x') + document.getElementById(id).scrollWidth) > document.documentElement.scrollWidth) {
			cDiv.style.left = (document.documentElement.scrollWidth - document.getElementById(id).scrollWidth) - 20 +'px';
		}
		else {
			cDiv.style.left = returnXY(e,'x') +'px';
		}
		if ((returnXY(e,'y') + document.getElementById(id).scrollHeight) > document.documentElement.scrollHeight) {
			cDiv.style.top = (document.documentElement.scrollHeight - document.getElementById(id).scrollHeight) - 20 +'px';
		}
		else {
			cDiv.style.top = (returnXY(e,'y') + 6) +'px';
		}
	}
}

function createFullDiv(id) {
	hiddenSelect('hidden');
	if (!document.getElementById('FullScreenDiv')) {//判断FullScreenDiv是否存在
		var cDiv = document.createElement("div");
		cDiv.id = 'FullScreenDiv';
		cDiv.style.position = 'absolute';
		cDiv.style.zIndex = 8888;
		cDiv.style.left = '0px';
		cDiv.style.top = '0px';
		cDiv.style.width = '100%';
		cDiv.style.height = document.documentElement.scrollHeight + 100 +'px';
		cDiv.style.backgroundColor = '#eeeeee';
		cDiv.style.opacity = 0.90;
		cDiv.style.filter = 'Alpha(opacity=90)';
		document.body.appendChild(cDiv);
	}
	else {
		document.getElementById('FullScreenDiv').style.display = '';
		document.getElementById('FullScreenDiv').style.height = document.documentElement.scrollHeight + 100 +'px';
	}
	if (!document.getElementById(id)) {
		var cDiv = document.createElement("div");
		cDiv.id = id;
		cDiv.style.position = 'absolute';
		cDiv.style.zIndex = 9998;
		cDiv.style.width = '100%';
		cDiv.style.left = '0px';
		cDiv.style.top = '20px';
		document.body.appendChild(cDiv);
	}
	else {
		document.getElementById(id).style.display = '';
		document.getElementById(id).style.height = document.body.scrollHeight - 40 +'px';
	}
}

function returnXY(e,sType) {
	e = e || window.event;
	if (sType == 'x') return e.pageX ||(e.clientX?e.clientX + document.documentElement.scrollLeft:0);
	if (sType == 'y') return e.pageY ||(e.clientY?e.clientY + document.documentElement.scrollTop:0);
}

function setWeather(e,virtualRoot,id) {
	var coll = document.getElementsByTagName('div')
	if(!coll) return;
	if(coll.length){
		for(var i = 0;i < coll.length;i++){
			if (coll.item(i).className == 'setWeather'){
				coll.item(i).style.display = 'none';
			}
		}
	}
	if (!document.getElementById(id)) {
		createDiv(e,id,'setWeather');
		xmlHttpPost(true,'',virtualRoot +'/Lib/Xml/SysFlag/'+defaultPage+'?action=setweather','result=show&id='+ id,0,0,id);
	}
	else {
		document.getElementById(id).style.display = '';
		if ((returnXY(e,'x') + document.getElementById(id).scrollWidth) > document.documentElement.scrollWidth) {
			document.getElementById(id).style.left = (document.documentElement.scrollWidth - document.getElementById(id).scrollWidth) - 20 +'px';
		}
		else {
			document.getElementById(id).style.left = returnXY(e,'x') +'px';
		}
		if ((returnXY(e,'y') + document.getElementById(id).scrollHeight) > document.documentElement.scrollHeight) {
			document.getElementById(id).style.top = (document.documentElement.scrollHeight - document.getElementById(id).scrollHeight) - 20 +'px';
		}
		else {
			document.getElementById(id).style.top = (returnXY(e,'y') + 6) +'px';
		}
	}
}
function right(mainStr,lngLen) {
	if (mainStr.length - lngLen >= 0 && mainStr.length >= 0 && mainStr.length - lngLen <= mainStr.length) return mainStr.substring(mainStr.length - lngLen,mainStr.length)
	else return null
}


function setHomepage(){   
    if (document.all){   
    document.body.style.behavior='url(#default#homepage)';   
    document.body.setHomePage(document.URL);   
  }else if (window.sidebar){   
        if(window.netscape){   
       try{    
          netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");    
       }catch (e){    
                    alert( "该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" );    
       }   
        }    
    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);   
    prefs.setCharPref('browser.startup.homepage',document.URL);   
    }   
}
