<!--

function LTrim(str)
{ //去掉字符串 的头空格
	var i;
	for(i=0; i<=str.length-1; i++)
	{	
		if(str.charAt(i) != " " && str.charAt(i) != " ") break;
	}
	str = str.substring(i,str.length);
	return str;
}

function RTrim(str)
{
	var i;
	for(i = str.length-1; i>=0; i--)
	{
		if(str.charAt(i) != " " && str.charAt(i) != " ") break;
	}
	str = str.substring(0,i+1);
	return str;
}

function Trim(str)
{
	return LTrim(RTrim(str));
}
function $(id)
{
	return document.getElementById(id);
}
function go(url)
{
	window.location = url;
}

function makeBlockMoveable(block, controlArea)
{
	var isMouseDown = false;
	var x = 0;
	var y = 0;
	var moveElementX = 0;
	var moveElementY = 0;
	var cursor = "default";
	elementAddEventHandle(controlArea, 
						'mousedown', 
						function(e)
						{
							e = (e) ? e : window.event;
							isMouseDown = true;
							cursor = controlArea.style.cursor;
							controlArea.style.cursor = "move";
							x = e.screenX;
							y = e.screenY;
							moveElementX = parseInt(block.offsetLeft);
							moveElementY = parseInt(block.offsetTop);
						})
	elementAddEventHandle(document.body, 
						'mousemove', 
						function(e)
						{
							if(! isMouseDown) return ;
							e = (e) ? e : window.event;
							block.style.left = (moveElementX + e.screenX - x) + 'px';
							block.style.top = (moveElementY + e.screenY - y) + 'px';
						})
	elementAddEventHandle(document.body, 
						'mouseup', 
						function(e)
						{
							if(! isMouseDown) return ;
							e = (e) ? e : window.event;
							isMouseDown = false;
							controlArea.style.cursor = cursor;
							x = 0;
							y = 0;
							moveElementX = 0;
							moveElementY = 0;
						})
}
function elementAddEventHandle(element, eventName, funcHandle)
{
    if(element.addEventListener)
    	element.addEventListener(eventName, funcHandle, false);
    else
    	element.attachEvent('on' + eventName, funcHandle);
}


/////////////////下面是老网站的公共函数 吴发东,2011-10-24
function OpenWindow(url,width,height,style)
{
	if (!width || width<=0) width = 640;
	if (!width || height<=0) height = 450;
	if (!style) style = "status=no,directories=no,scrollbars=yes,Resizable=yes";
	
	return window.open(url
			,"","width=" + width +", height="+ height +",left=" + (screen.availWidth - width -10) + 
			",top=0," + style)
}

function display(obj)
{
	if (obj && obj.style)
	{
		obj.style.display = (obj.style.display=='none')?'':'none';
	}
}

function EncodeURL(str)
{
	if (str==null)
	{
		return ""
	}
	var m="",sp="";
	for(var i=0;i<str.length;i++){
		if(sp.indexOf(str.charAt(i))!=-1){
			m+=str.charAt(i)	
		}else{
			var n=str.charCodeAt(i)
			var t="0"+n.toString(8)
			if(n>0x7ff)
			{	
				m += escape(str.charAt(i))
			}
			else 
				m += encodeURIComponent(str.charAt(i));
/*				if(n>0x7f)
				m+=("%"+(192+parseInt(t.slice(-4,-2),8)).toString(16)+"%"+(128+parseInt(t.slice(-2),8)).toString(16)).toUpperCase()
			else if(n>0x0f)
				m+=("%"+(n.toString(16)).slice(-2)).toUpperCase()
			else
				m+=("%0"+(n.toString(16)).slice(-2)).toUpperCase()
*/
		}
	}
	return m;
}

function getFormatText(responseText)
{
	var s = responseText;
	if (s.indexOf('Microsoft')>=0)
	{
		s = Unicode2Asc(s.stripScripts().stripTags());
		s = s.replace(/ /g,"");
		s = s.replace(/\t/g,"");
		s = s.replace(/\n/g,"");
		s = s.replace(/&nbsp;/g," ");
		s = s.replace(/&quot;/g,'"');
		s = s.replace(/&amp;/g,'&');
		s = s.replace(/\r\r/g,"\r");
		s = s.replace(/\r\r/g,"\r");
		s = s.replace(/\r\r/g,"\r");
		s = s.replace(/\r\r/g,"\r");
		s = s.replace(/^.+技术信息(.+)网页：.+(时间：.+)$/, '$1$2');
	}
//	document.all.memo.value = s;
	return s;
}

function Unicode2Asc(value)
{
	var code= value.split('&#');
	var result = new Array;
	for (var i=0; i<code.length; i++)
	{
		var n= code[i].indexOf(';');
		var s='';
		if (n>0)
			s = code[i].substr(0,n);
		if (!isNaN(parseInt(s)))
		{
			result.push(String.fromCharCode(parseInt(s)));
			result.push(code[i].substr(n+1));
		}
		else
			result.push(code[i]);
	}
	return result.join('');
}


function savereply(TableName, id)
{
	var s;
	s = $F('text_' + TableName + id);
	if (s=='')
	{
		alert('请输入评论内容');
		return;
	}
	var url ='/register/XMLSaveReply.asp?tablename=' + TableName + 
		'&id=' + id + 
		'&title=' + '' + 
		'&content=' + EncodeURL(s);
	var aj = new Ajax.Request(url, {method:'post', asynchronous:false});

	s = getFormatText(aj.transport.responseText);
	if (!isNaN(parseInt(s)))
	{
		if ($('span_replycount' + id))	$('span_replycount' + id).innerText = s;
		alert('保存成功');
		$('text_' + TableName + id).value = '';
	}
}

function getAbsolutPosition(obj,type)
{
	try
	{
		var x=0;
		var y=0;
		while(obj!=null && obj.tagName.toUpperCase()!="BODY") {
			x+=obj.offsetLeft;
			y+=obj.offsetTop;
			obj=obj.offsetParent;
		}
		if (type==1) return x; else return y;
	}
	catch(e){}
}

function getZoomSize(obj,maxWidth)
{
	var n =obj.style.zoom;
	try
	{
		var x = obj.clientWidth;
		var n = maxWidth/x;
		n = (n>1) ? 1 : n;
		return n;
	}
	catch(e){return 1;}
}

function max(a,b)
{
	return (a>b)?a:b;
}
function min(a,b)
{
	return (a>b)?b:a;
}

function getSmallImageName(s)
{
	return s.substr(0,s.length-4) + '_small' + s.substr(s.length-4,4);
}

function doupload()
{
	if ($('uploadframe') && document.frames('uploadframe'))
	with (document.frames('uploadframe'))
	try
	{
		document.all['divProcessing'].style.display="";
		formupload.submit();
	}
	catch (e) {alert(e.description)}
}

function dopreview(fieldname)
{
	if ($(fieldname))
	try
	{
		OpenWindow($F(fieldname));
		if ($('imagepreview'))
		{
			var s = $('imagepreview').src;
			var t = getSmallImageName($F(fieldname));
			if (s!=t)
			{
				$('imagepreview').src = t;
			}
		}
	}
	catch (e) {alert(e.description)}
}

	function login()
	{
		if ($F('UserCode')=='' || $F('Password')=='')
		{
			alert('请输入帐号和密码');
			return;
		}
		var url="/register/XMLLogin.asp?UserCode=" + $F('UserCode') + "&Password=" + $F('Password') + "&AdvanceCode=" + $F('AdvanceCode');
		var aj = new Ajax.Request(url, {method:'post', asynchronous:false});
		var s = getFormatText(aj.transport.responseText);
		if (s=='登录成功')
		{
			location.href=location.href;
		}
		else
		{
			alert(s);
			$('AdvanceCode').value='';
			$('advanceimg').src='/advancecode.asp'
		}
	}
	function quit()
	{
		var url="/register/XMLLogin.asp?quit=1";
		var aj = new Ajax.Request(url, {method:'post', asynchronous:false});
		location.href=location.href;
	}

	function $Array(name)
	{
		if (document.all[name] && document.all[name].length == undefined)
		{
			return new Array($(name));
		}
		else 
			return $A(document.all[name]);
	}

	function ChangeState(obj)
	{
		//使控件隐藏、可见
		if (!obj)
			return

		if (obj.length!=undefined)
		for (var i=0; i<obj.length; i++)
		{
			if (obj[i].style)
				obj[i].style.display = obj[i].style.display=="none" ? "block" : "none";
		}
		else
		{
			if (obj.style)
				obj.style.display = obj.style.display=="none" ? "block" : "none";
		}
	}


function getFlashHtml(src, width, height) {
    var ret = "";
    ret += "<embed src='" + src + "'";
    ret += " quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer'";
    ret += " type='application/x-shockwave-flash'";
    ret += " width='" + width + "'" + " height='" + height + "'";
    ret += " ></embed>";

    return ret;
}

function getTransparentFlashHtml(src, width, height) {
	var ret = "";
	ret += "<embed src='" + src + "'";
	ret += " quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer'";
	ret += " type='application/x-shockwave-flash'";
	ret += " wmode='transparent'";
	ret += " width='" + width + "'" + " height='" + height + "'";
	ret += " ></embed>";

	return ret;
}

function getImageAnchorHtml(href, target, src, width, height) {
    var imgHtml = "<img border='0' src='" + src + "'";
    imgHtml += " width='" + width + "'" + " height='" + height + "'>";

    var ret = imgHtml;

    if (href != "") {
        if (target == "") {
            target = "_slef";
        }
        ret = "<a href='" + href + "' target='" + target + "'>";
        ret += imgHtml;
        ret += "</a>";
    }

    return ret;
}

function switchTdADHtml(sn) {
	var tdADHtml = "";
	if (sn == 0) {
		tdADHtml = getTransparentFlashHtml("images/index_main.swf",  776, 180);
	}
	document.all.tdAD.innerHTML = tdADHtml;
}

//window.setTimeout("switchFlashToImg();", 3 * 1000);

// onLoad='window.setTimeout("switchFlashToImg();", 5 * 1000);'

//弹出窗口
/*ID=window.setTimeout("newWindow();",10);
function newWindow(){
	window.open('http://www.anltech.com/news/subject/05myd/open.htm','','width=480,height=269,resizable=no,scrollbars=no')
}
*/
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//function newWindow(){
//window.open('images05/KingdeeToMB.htm','StockToMB','left=10,top=0,width=780,height=600,resizable=yes,scrollbars=yes');
onLoad='window.setTimeout("newWindow();", 0 * 1000);'


function FormatDate(dt)
{
	var y,m,d,h,n,s
	y = dt.getFullYear();
	m = dt.getMonth() + 1;
	d = dt.getDate();
	h = dt.getHours();
	n = dt.getMinutes();
	s = dt.getSeconds();
	if (m<10) m = '0' + m;
	if (d<10) d = '0' + d;
	if (h<10) h = '0' + h;
	if (n<10) n = '0' + n;
	if (s<10) s = '0' + s;
	return y + '-' + m + '-' + d + ' ' + h + ':' + n + ':' + s;
}

	function openquestion()
	{
		OpenWindow('/question.asp', 800,500, "status=no,directories=no,scrollbars=no,Resizable=no");
	}

	function setdivblock(kind, kindname, kindlist)
	{
		var temp = kindlist.split(",");
		for (var i=0; i<temp.length; i++)
		{
			if ($('div_news_' + temp[i]))
				$('div_news_' + temp[i]).style.display = (temp[i]==kind) ? "" : "none";
			if ($('div_tabs_' + temp[i]))
			{
				$('div_tabs_' + temp[i]).style.color = (temp[i]==kind) ? "red" : "";
			}
			if ($('link_' + temp[0]))
			{
				$('link_' + temp[0]).href = "/webpage.asp?mainMenu=%u8D44%u8BAF&submenu=%2Fanl_news%2Fnewspage.asp&text=" + EncodeURL(kindname) + "&menuName=arMenu1&kindid=" + temp[i];
			}
		}
	}
-->
