//JS时间（日期）和星期显示
function showDate_and_Week(){
	try{
		var d = new Date();
		var showStr = d.getFullYear()+'年'+(d.getMonth()+1)+'月'+d.getDate()+'日 星期'+['日','一','二','三','四','五','六'][d.getDay()];
		document.write(showStr);
		//return showStr;
	}
	catch(e){
		document.write('时间调用出错');
	}
}

//for empty?
function isEmpty(theValue, strMsg){
if(theValue==""){
alert(strMsg+"不能为空!");
return true;
}
return false;
}


// check chinese NOT GOOD
function isChinese(str){
var badChar ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
badChar += "abcdefghijklmnopqrstuvwxyz";
badChar += "0123456789";
badChar += " "+"　";//半角与全角空格
badChar += "`~!@#$%^&()-_=+]\\\\|:;\\\\\'<,>?/";//不包含*或.的英文符号
if(""==str){
return false;
}
for(var i=0;i<str.length;i++){
var c = str.charAt(i);//字符串str中的字符
if(badChar.indexOf(c)<0){
return false;
}
}
return true;
}

// number checker
function isNumber(str)
{
	if(str=="")
	{return false;}
	if(str*1+""=="NaN")
	{return false;}
	return true;
}

// useless
function isNumber_Ex(str,len){
if(""==str){
return false;
}

if(str.length!=len){
return false;
}

if(!isNumber(str)){
return false;
}
return true;
}

//img zoom
var flag=false;
function DrawImage(ImgD,width,height){
    var image=new Image();
    var iwidth =width;
    var iheight =height;
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= iwidth/iheight){
        if(image.width>iwidth){
        ImgD.width=iwidth;
        ImgD.height=(image.height*iwidth)/image.width;
        }else{
        ImgD.width=image.width;
        ImgD.height=image.height;
        }
        }
    else{
        if(image.height>iheight){
        ImgD.height=iheight;
        ImgD.width=(image.width*iheight)/image.height;
        }else{
        ImgD.width=image.width;
        ImgD.height=image.height;
        }
        }
    }
}

function markKey(themark){
	document.myform(themark+'M').value = document.myform(themark).value;
}
/*

/*General Function Section*/

// Trim() , Ltrim() , RTrim()
//***************************************************
String.prototype.Trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.LTrim = function()
{
return this.replace(/(^\s*)/g, "");
}

String.prototype.RTrim = function()
{
return this.replace(/(\s*$)/g, "");
}
//***************************************************


/*regExpress function - check fittable by Clark*/
function checkstring(intstring,regstring)
{
	if (intstring.Trim()==""){
		return false;
	}
	var re=new RegExp(regstring);
	re.ignoreCase=true;
	re.global=true;
	var input=intstring;
	if (input.search(re)!=-1){
		return true;
	}
	else{
		return false;
	}
}

//compare datetime
function bettertime(strDateStart,strDateEnd){

	var strSeparator = "-"; //日期分隔符

	var strDateArrayStart;

	var strDateArrayEnd;

	var intDay;

	strDateArrayStart = strDateStart.split(strSeparator);

	strDateArrayEnd = strDateEnd.split(strSeparator);

	var strDateS = new Date(strDateArrayStart[0] + "/" + strDateArrayStart[1] + "/" + strDateArrayStart[2]);

	var strDateE = new Date(strDateArrayEnd[0] + "/" + strDateArrayEnd[1] + "/" + strDateArrayEnd[2]);

	intDay = (strDateS-strDateE)/(1000*3600*24)

	return intDay

}

//Highlight function by Clark
void function highlight(keyword)
{
	var keyarray=null;
	var key=keyword;
	var elements=document.all;
	var keyString="";
	var keyArray=null;
	if (keyword.indexOf(" ")){
		keyString=key.replace(/\s/ig,"|");
	}
	else{
		keyString=key;
	}
	keyString=keyString.replace(/\(/ig,"\\(").replace(/\)/ig,"\\)");
	keyarray=keyString.split("|");
	for (var kindex=0;kindex<keyarray.length;kindex++){
		var keyitem=keyarray[kindex];
		for (var i=0;i<elements.length;i++){
			var element=elements[i];
			if (element.id.search(/item[0-9]+/)!=-1){
				var itemhtml=element.innerHTML;
				var citemhtml=itemhtml.replace(eval("/(>.*)(" + keyitem + ")(.*<)/ig"),"$1<font style='color:red;text-decoration:underline;'>$2</font>$3");
				element.innerHTML=citemhtml;
			}
		}
	}
}

//配合我的数字导航做的
void function turnpage(num,maxnum,pagestring)
{
	var pagenum=num.match(/[0-9]+/i);
	if (pagenum==null){
		pagenum=1;
	}
	if (pagenum>maxnum){
		pagenum=maxnum;
	}
	var jumpstring=pagestring.replace("{PAGE}",pagenum);
	location.href=jumpstring;
}

//复制函数
function CopyText(strCopyed)
{
	if (strCopyed.Trim()==""){
		return false;
	}
	clipboardData.setData("Text",strCopyed);
	return true;
}