var flag=false;
function DrawImage(ImgD,iwidth,iheight){//参数(图片,允许的宽度,允许的高度)
	var image=new Image();
	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 checkform() {
	var strSearch=document.SearchForm.word;
	var strSearchdo=document.SearchForm.SearchKind;
	if (strSearch.value=="" || strSearch.value.indexOf("请输入您要查找的")!=-1 || strSearch.value.replace(/^\s+|\s+$/g,'')==""){
		alert("查询的关键字不能为空！\n\n请返回重新输入！");
		document.SearchForm.word.focus();
		return false;
	}
	if (strSearchdo.value=="" || strSearchdo.value=="0") {
		alert("查询关键字处理页面不能为空！\n\n请返回重新选择！");
		document.SearchForm.SearchKind.focus();
		return false;
	}
	var querystr=document.SearchForm.SearchKind[document.SearchForm.SearchKind.selectedIndex].value;
	document.SearchForm.action="/Search/"+querystr; 
}
//登录判断
function DoLogin() {
	var UsernameGet = Trim(document.LoginForm.UsernameGet.value);
	var PasswordGet = Trim(document.LoginForm.PasswordGet.value);
	var Verifycode = Trim(document.LoginForm.Verifycode.value);
	if(UsernameGet=="") {
		alert("请输入会员登录名！");
		document.LoginForm.UsernameGet.focus();
		return false;
	}
	if(PasswordGet == "") {
		alert("请输入密码！");
		document.LoginForm.PasswordGet.focus();
		return false;
	}
	if(Verifycode == "") {
		alert("请输入验证码！");
		document.LoginForm.Verifycode.focus();
		return false;
	}
}
//去掉空格
function Trim(inputString) {
	if (typeof inputString != "string") {
		return inputString;
	}
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ") { 
		//检查字符串开始部分的空格
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " ") {
	//检查字符串结束部分的空格
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
	}
	while (retValue.indexOf("  ") != -1) {
	//将文字中间多个相连的空格变为一个空格
		retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
	}
	return retValue;
}
//控frames高度
function TuneHeight() {
	var frm = document.getElementById("RightContent");
	var subWeb = document.frames ? document.frames["RightContent"].document:frm.contentDocument;
	if(frm != null && subWeb != null) {
		frm.height = subWeb.body.scrollHeight+40;
	}
}
//更改文字大小
function SetFontSize(size){
	document.getElementById("neirong").style.fontSize = size+'px';
}
//拷贝
function copyToClipBoard(){
	var clipBoardContent="";//初始清空
	var titleStr = window.document.title.split("-")[0];
	clipBoardContent+=titleStr;//写入Title
    clipBoardContent+='\r\n'+window.location.href;//换行，写入URL
	window.clipboardData.setData("Text",clipBoardContent);//写入ClipBoard
	alert("成功复制标题及链接,现在可以粘贴发给好友了!");//弹出提示，如不需要可删除或屏蔽此行
}

// Useage: HCmarquee(滚动对象id, 可见范围宽度, 可见范围高度, 滚动速度, 停留时间, 方向); 方向有left和up两种
function HCmarquee(id,mw,mh,mr,ms,pause,dr){
	//HCmarquee("b2b",280,80,10,20,60,"up")
	var obj=document.getElementById(id);
	obj.ss=false;
	obj.mr=mr;
	obj.mw=mw;
	obj.mh=mh;
	obj.ms=ms;
	obj.pause=pause;
	obj.pt=0; //pre top
	obj.st=0; //stop time
	obj.dr=dr; //direction

	with(obj){
		style.width=mw+"px";
		style.height=mh+"px";
		noWrap=false;
		onmouseover=stopm;
		onmouseout=startm;
		scrollTop=0+"px";
		scrollLeft=0+"px";
	}
	
	if(obj.mr!=1){
		switch(obj.dr){
			case("up"):
				obj.tt=mh*mr;
				obj.ct=mh;
				obj.innerHTML+=obj.innerHTML;
				setInterval(scrollUp,obj.ms);
				break;
		}
	}

	function scrollUp(){
		if(obj.ss==true) {
			return;
		}
		obj.ct+=1;
		if(obj.ct==obj.mh+1){
			obj.st+=1;
			obj.ct-=1;
			if(obj.st==obj.pause){
				obj.ct=0;
				obj.st=0;
			}
		} else {
			obj.pt=(++obj.scrollTop);
			if(obj.pt==obj.tt) {
				obj.scrollTop=0;
			}
		}
	}
	function stopm(){obj.ss=true;}
	function startm(){obj.ss=false;}
}
