﻿function Asc(strChar) {
	var strTmp=new String(strChar);
	return(strTmp.charCodeAt(0));
}

function Chr(intCode) {
	return(String.fromCharCode(intCode));
}

function Mid(strSource,intStart,intCount) {
	return(strSource.substr(intStart-1,intCount));
}

function Left(strSource,intCount) {
	return(strSource.substr(0,intCount));
}

function Right(strSource,intCount) {
	return(source.substr(source.length-count,count));
}

function isEmail(email) {
	var endvalue,allowstrlist;
	endvalue=true;
	allowstrlist="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-.@";
	if (email.lastIndexOf("@")==-1 || email.lastIndexOf(".")==-1) {
		endvalue=false;
	} else if (email.indexOf("@",email.indexOf("@")+1)!=-1 || email.indexOf(".",email.indexOf("@"))==-1) {
		endvalue=false;
	} else if (email.substr(0,1)=="@" || email.substr(0,1)=="." || email.substr(email.length-1,1)=="@" || email.substr(email.length-1,1)==".") {
		endvalue=false;
	}
	for (var i=0;i<email.length;i++) {
		if (allowstrlist.indexOf(email.substr(i,1))==-1) {
			endvalue=false;
			break;
		}
	}

	return(endvalue);
}

function isCount(count)
{
	var re;
	re=new RegExp("[^0-9]","g");
	if(re.test(count) || count=="0" || count.substring(0,1)=="0")
		return false;
	else
		return true;
}

function Replace(strSource,strFind,strToStr) {
	strSource=new String(strSource);
	strFind=new String(strFind);
    var strEndValue,intFindStart,intFindEnd,strTmpFront,strTmpEnd;
    strEndValue=strSource;
    intFindEnd=0;
	
    while (strEndValue != ""){
		intFindStart = strEndValue.indexOf(strFind,0);
		if (intFindStart!=-1) {
			intFindEnd=intFindStart+strFind.length;
			strTmpFront=strEndValue.substr(0,intFindStart);
			strTmpEnd=strEndValue.substr(intFindEnd);
			strEndValue=strTmpFront+strToStr+strTmpEnd;
		} else {
			break;
		}
	}
    return(strEndValue);
}

function lTrim(strSource) {
	return(strSource.replace(/^\s*/,""));
}

function rTrim(strSource) {
	return(strSource.replace(/\s*$/,""));
}

function Trim(strSource) {
	return(strSource.replace(/\s*$/,""));
}

function lCase(strSource) {
	strSource=new String(strSource);
	strSource=strSource.toLowerCase(strSource);
	return(strSource);
}

function uCase(strSource) {
	strSource=new String(strSource);
	strSource=strSource.toUpperCase(strSource);
	return(strSource);
}

function Random(intLow,intUp) {
	var intTmp;
	if (intUp<intLow) {
		intTmp=intUp;
		intUp=intLow;
		intLow=intTmp;
	}
	return(parseInt(parseInt(intUp-intLow+1)*Math.random()+intLow));
}

function preloadImagesList() {
	var d=document;
	if(d.images) {
		if(!d.MM_p) {
			d.MM_p=new Array();
		}
		var i,j=d.MM_p.length,a=preloadimageslist.arguments;
		for(i=0; i<a.length; i++) {
			if (a[i].indexOf("#")!=0) {
				d.MM_p[j]=new Image;
				d.MM_p[j++].src=a[i];
			}
		}
	}
}

function getQueryValue(strName) {
	var reg=new RegExp("(^|&)"+ strName +"=([^&]*)(&|$)");
	var r=window.location.search.substr(1).match(reg);
	if (r!=null) return unescape(r[2]);
	return "";
}

function openUrlInNewWindowWithPara(strUrl,intWidth,intHeight,strShowScroll) {
	if (bolShowScroll==null) {
		bolShowScroll="yes";
	}
	newwin=window.open("","","width="+intWidth+",height="+intHeigh+",top=20,left=20,scrollbars="+strShowScroll);
	newwin.location.href=strUrl;
}

/*************************************************************
名称：isnumeric
功能：判断传入的变量值是否为合法的数字
参数：numberstr，源字符串；
返回：True或False，是否是数字
说明：01062988442或1.860
*************************************************************/
function isnumeric(numberstr) {
	if (numberstr==null) return false;
	var number=new Number(numberstr);
	if (isNaN(number)) {
		return false;
	}
	return true;
}

/* IE 7 激活Falsh控件*/
function writeflashhtml(arg)
{
	var parm = []
	var _default_version = "6,0,29,0";
	var _default_quality = "high";
	var _default_align = "middle";
	var _default_menu = "false";

	for(i = 0; i < arguments.length; i ++)
	{
		parm[i] = arguments[i].split(' ').join('').split('=')
		for (var j = parm[i].length-1; j > 1; j --)
		{
			parm[i][j-1]+="="+parm[i].pop();
		}
		switch (parm[i][0])
		{
			case '_version' : var _version = parm[i][1] ; break ; 
			case '_swf' : var _swf = parm[i][1] ; break ; 
			case '_base' : var _base = parm[i][1] ; break ; 
			case '_quality' : var _quality = parm[i][1] ; break ; 
			case '_loop' : var _loop = parm[i][1] ; break ; 
			case '_bgcolor' : var _bgcolor = parm[i][1] ; break ; 
			case '_wmode' : var _wmode = parm[i][1] ; break ; 
			case '_play' : var _play = parm[i][1] ; break ; 
			case '_menu' : var _menu = parm[i][1] ; break ; 
			case '_scale' : var _scale = parm[i][1] ; break ; 
			case '_salign' : var _salign = parm[i][1] ; break ; 
			case '_height' : var _height = parm[i][1] ; break ; 
			case '_width' : var _width = parm[i][1] ; break ; 
			case '_hspace' : var _hspace = parm[i][1] ; break ; 
			case '_vspace' : var _vspace = parm[i][1] ; break ; 
			case '_align' : var _align = parm[i][1] ; break ; 
			case '_class' : var _class = parm[i][1] ; break ; 
			case '_id' : var _id = parm[i][1] ; break ; 
			case '_name' : var _name = parm[i][1] ; break ; 
			case '_style' : var _style = parm[i][1] ; break ; 
			case '_declare' : var _declare = parm[i][1] ; break ; 
			case '_flashvars' : var _flashvars = parm[i][1] ; break ; 
			default :;
		}
	}

	var thtml = ""
	thtml += "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + ((_version)?_version:_default_version) + "'"
	if(_width) thtml += " width='" + _width + "'"
	if(_height) thtml += " height='" + _height + "'"
	if(_hspace) thtml += " hspace='" + _hspace + "'"
	if(_vspace) thtml += " vspace='" + _vspace + "'"
	if(_align) thtml += " align='" + _align + "'"
	else thtml += " align='" + _default_align + "'"
	if(_class) thtml += " class='" + _class + "'"
	if(_id) thtml += " id='" + _id + "'"
	if(_name) thtml += " name='" + _name + "'"
	if(_style) thtml += " style='" + _style + "'"
	if(_declare) thtml += " " + _declare
	thtml += ">"
	if(_swf) thtml += "<param name='movie' value='" + _swf + "'>"
	if(_quality) thtml += "<param name='quality' value='" + _quality + "'>" 
	else thtml += "<param name='quality' value ='" + _default_quality + "'>"
	if(_loop) thtml += "<param name='loop' value='" + _loop + "'>"
	if(_bgcolor) thtml += "<param name='bgcolor' value='" + _bgcolor + "'>"
	if(_play) thtml += "<param name='play' value='" + _play + "'>"
	if(_menu) thtml += "<param name='menu' value='" + _menu + "'>"
	else thtml += "<param name='menu' value='" + _default_menu + "'>"
	if(_scale) thtml += "<param name='scale' value='" + _scale + "'>"
	if(_salign) thtml += "<param name='salign' value='" + _salign + "'>"
	if(_wmode) thtml += "<param name='wmode' value='" + _wmode + "'>"
	if(_base) thtml += "<param name='base' value='" + _base + "'>"
	if(_flashvars) thtml += "<param name='flashvars' value='" + _flashvars + "'>"
	thtml += "<embed pluginspage='http://www.macromedia.com/go/getflashplayer'"
	if(_width) thtml += " width='" + _width + "'"
	if(_height) thtml += " height='" + _height + "'"
	if(_hspace) thtml += " hspace='" + _hspace + "'"
	if(_vspace) thtml += " vspace='" + _vspace + "'"
	if(_align) thtml += " align='" + _align + "'"
	else thtml += " align='" + _default_align + "'"
	if(_class) thtml += " class='" + _class + "'"
	if(_id) thtml += " id='" + _id + "'"
	if(_name) thtml += " name='" + _name + "'"
	if(_style) thtml += " style='" + _style + "'"
	thtml += " type='application/x-shockwave-flash'"
	if(_declare) thtml += " " + _declare 
	if(_swf) thtml += " src='" + _swf + "'"
	if(_quality) thtml += " quality='" + _quality + "'"
	else thtml += " quality='" + _default_quality + "'"
	if(_loop) thtml += " loop='" + _loop + "'"
	if(_bgcolor) thtml += " bgcolor='" + _bgcolor + "'"
	if(_play) thtml += " play='" + _play + "'"
	if(_menu) thtml += " menu='" + _menu + "'"
	else thtml += " menu='" + _default_menu + "'"
	if(_scale) thtml += " scale='" + _scale + "'"
	if(_salign) thtml += " salign='" + _salign + "'"
	if(_wmode) thtml += " wmode='" + _wmode + "'"
	if(_base) thtml += " base='" + _base + "'"
	if(_flashvars) thtml += " flashvars='" + _flashvars + "'"
	thtml += "></embed>"
	thtml += "</object>"
	document.write(thtml)
}