//对空格 的处理

// 去左空格;
function ltrim(s) {
	return s.replace(/^\s*/, "");
}
// 去右空格;
function rtrim(s) {
	return s.replace(/\s*$/, "");
}
// 去左右空格;
function trim(s) {
	return rtrim(ltrim(s));
}

/*只能输入数字*/
function onlyNum(txt) {
	txt.value = txt.value.replace(/[^\d]/g, '');
}

//过滤掉特殊字符  
function strangecode(s) {
	return s.replace(/<|>|'|;|&|#|"|'/, "");
}

/*复制粘贴给好友*/
function copyToClipBoard() {
	var clipBoardContent = "";
	clipBoardContent += document.title;
	clipBoardContent += "";
	clipBoardContent += this.location.href;
	window.clipboardData.setData("Text", clipBoardContent);
	alert("复制成功，请粘贴到您的QQ/MSN上推荐给您的好友");
}

/* 复制的时候，调用的方法*/
// onbeforepaste="shuru1(this);"
function shuru1(txt) {
	clipboardData.setData('text', clipboardData.getData('text').replace(
			/[^\d]/g, ''));
}

//邮件格式验证
function isEmail(strEmail) {
	if (ltrim(strEmail) != "") {
		if (strEmail
				.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
			//document.getElementById("err_altID").innerHTML = '';
			return true;
		} else {
			alert("邮件格式错误,请重新输入!");
			//document.getElementById("err_altID").innerHTML = '<font color = "red">邮件格式错误,请重新输入!</font>';
			//document.getElementById("err_altID").focus();
		}
	} else {
		//alert("请输入您的邮件!");
		//document.getElementById("err_altID").innerHTML = '<font color = "red">请输入您的邮件!</font>';
		//document.getElementById("err_altID").focus();
	}
}

/**
 * 对输入字符长度的判断
 * which 对象
 * maxchar 允许输入的最大值
 */
function checkLength(which, maxchar) {
	var oTextCount = document.getElementById("char");
	//iCount = which.value.replace(/[^\u0000-\u00ff]/g,"aa").length;
	iCount = which.value.replace(/[\uff00-\uffff]/g, "aa").length;

	if (iCount <= maxchar) {
		if (document.getElementById("charNumID").style.display == "none") {
			document.getElementById("charNumID").style.display = "block";
			document.getElementById("re_countid").innerHTML = "";
			document.getElementById("re_countid").style.display == "none"
		}

		oTextCount.innerHTML = "<font color=#DC0000>" + iCount + "</font>";
		which.style.border = '1px dotted #7f9db9';
		which.size = iCount + 1;
		which.value = which.value.substr(0, maxchar);
		document.getElementById("re_altID").innerHTML = '';
	} else {
		which.value = which.value.substr(0, maxchar);
		document.getElementById("re_altID").innerHTML = '&nbsp;&nbsp;<font color=#DC0000>最大输入' + maxchar + '字</font>';
		;
	}
}

/**
 * 失焦时评论内容边框变实现
 * which 对象
 * @param which 
 * @return
 */
function checkBorderStyle() {
	document.getElementById("re_count").style.border = '1px solid #7f9db9';
	
}

//定位地图
function sh_showMap(x, y, tit, info) {
	//alert(x);alert(y);alert(tit);alert(info);
	var sul = "./locateByLatLng.html?lng=" + x + "&lat=" + y
			+ "&w=360&h=350&title=" + tit + "&info=" + info;
	document.all.sh_mapIframe1.src = sul;
}

//弹出"地图显示层"
function open_MapDiv(s_x, s_y, t_name, t_add) {
	document.getElementById('oLayer').innerHTML = '';
	document.getElementById('oLayer').innerHTML = '<div align = "right" style=""><font color="green" size="2"><a onclick="mapDiv_closes()" style="cursor: hand;">关闭</a></font>&nbsp;</div><div><iframe id="sh_mapIframe1" name="sh_mapIframe1" scrolling="no" frameborder="0" width="100%" height="360px" src="./locateByLatLng.html?lng='
			+ s_x
			+ '&lat='
			+ s_y
			+ '&w=380&h=355&title='
			+ t_name
			+ '&info='
			+ t_add + '"></iframe><div>';
	document.frames('sh_mapIframe1').location.reload();
}

//关闭"地图显示层"
function mapDiv_closes() {
	document.all.sh_mapIframe1.src = '';
	document.getElementById('oLayer').innerHTML = '';
	document.getElementById("divTest").style.visibility = "hidden";
}

function changBusQueryBG(obj, ContainerID) {
	var As = document.getElementById(ContainerID).getElementsByTagName("a");
	if (obj == null) {
		for ( var i = 0; i < As.length; i++) {
			As[i].parentNode.style.background = "#fff";
		}
		
	} else {
		for ( var i = 0; i < As.length; i++) {
			As[i].parentNode.style.background = "url('./images/index/underline_bg.jpg')";
		}
		obj.parentNode.style.background = "url('./images/index/busQuery_bg.jpg')";
	}

}
/*>>>>>>>>>>>>>>>>>>>信息窗口执行，有背景变化>>>>>>>>>>>>>>>>>>>>*/
//点击”从这里出发“，显示输入框
function displayGoHere(id, id2, id3, id4, operate) {
	//alert(operate);
	if (document.getElementById(id).style.display == 'none') {
		document.getElementById(id).style.display = "block";
		document.getElementById(id4).focus();
		document.getElementById(id2).style.display = 'none';
		document.getElementById(id3).style.display = 'none';
		changBusQueryBG(operate,"busQueryAContainer");
	} else {
		document.getElementById(id).style.display = 'none';
		changBusQueryBG(null,"busQueryAContainer");
	}
}

//点击”到达这里“，显示输入框
function displayThere(id1, id, id3, id4, operate) {
	//alert();
	if (document.getElementById(id).style.display == 'none') {
		document.getElementById(id).style.display = "block";
		document.getElementById(id4).focus();
		document.getElementById(id1).style.display = 'none';
		document.getElementById(id3).style.display = 'none';
		changBusQueryBG(operate,"busQueryAContainer");
	} else {
		document.getElementById(id).style.display = 'none';
		changBusQueryBG(null,"busQueryAContainer");
	}
}
//点击”周边查询“，显示输入框
function displayAround(id1, id2, id, operate) {
	//alert();
	if (document.getElementById(id).style.display == 'none') {
		document.getElementById(id).style.display = "block";
		document.getElementById(id1).style.display = 'none';
		document.getElementById(id2).style.display = 'none';
		changBusQueryBG(operate,"busQueryAContainer");
	} else {
		document.getElementById(id).style.display = 'none';
		changBusQueryBG(null,"busQueryAContainer");
	}
}
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/

/*>>>>>>>>>>>>>>>>>>>左边信息栏执行，无背景变化>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
//点击”从这里出发“，显示输入框
function displayGoHere2(id, id2, id3, id4) {
	//alert();
	if (document.getElementById(id).style.display == 'none') {
		document.getElementById(id).style.display = "block";
		document.getElementById(id4).focus();
		document.getElementById(id2).style.display = 'none';
		document.getElementById(id3).style.display = 'none';
	} else {
		document.getElementById(id).style.display = 'none';
	}
}

//点击”到达这里“，显示输入框
function displayThere2(id1, id, id3, id4) {
	//alert();
	if (document.getElementById(id).style.display == 'none') {
		document.getElementById(id).style.display = "block";
		document.getElementById(id4).focus();
		document.getElementById(id1).style.display = 'none';
		document.getElementById(id3).style.display = 'none';
	} else {
		document.getElementById(id).style.display = 'none';
	}
}
//点击”周边查询“，显示输入框
function displayAround2(id1, id2, id) {
	//alert();
	if (document.getElementById(id).style.display == 'none') {
		document.getElementById(id).style.display = "block";
		document.getElementById(id1).style.display = 'none';
		document.getElementById(id2).style.display = 'none';
	} else {
		document.getElementById(id).style.display = 'none';
	}
}
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/




/*<<<<<<<<<<<<<<输入框特殊字符处理开始<<<<<<<<<<<<<<<<<<<*/
function dealSymbol(dealStr, currentElementID) {
	var dealStrTemp = trim(dealStr);
	
	var dealReg = /[\\\^\+\-\=\~\!\@\#\%\&\*\_\|\$]/g;
	for ( var i=0; i<dealStrTemp.length; i++ ) {
		dealStrTemp = dealStrTemp.replace( dealReg, "" );
	}
	document.getElementById(currentElementID).focus();
	if (dealStrTemp.length == 0) {
		document.getElementById(currentElementID).value = "";
		alert("输入非法字符，请重输！");
		return;
	} else {
		if ( typeof(dealStrTemp) == "undefined" ) {
			dealStrTemp = "";
		}
		document.getElementById(currentElementID).value = dealStrTemp;
	}
	return dealStrTemp;
	
}


/*<<<<<<<<<<<<<<输入框特殊字符处理结束<<<<<<<<<<<<<<<<<<<*/




/*<<<<<<<<<<<<<<设置光标函数开始<<<<<<<<<<<<<<<<<<<*/
//设置光标函数
function setCaret ( id, position ) {
	var textBox = document.getElementById(id);
	var range = textBox.createTextRange();
	range.collapse(true);
	range.moveStart('character', position);
	range.select();
}

/*<<<<<<<<<<<<<<设置光标函数结束<<<<<<<<<<<<<<<<<<<*/



/*<<<<<<<<<<<<<<图片按比例缩放结束<<<<<<<<<<<<<<<<<<<*/
//图片按比例缩放
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;
        }
        ImgD.alt=image.width+"×"+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;
        }
        ImgD.alt=image.width+"×"+image.height;
        }
    }
} 
/*<<<<<<<<<<<<<<图片按比例缩放结束<<<<<<<<<<<<<<<<<<<*/



/*<<<<<<<<<<<<<<人气点击数更新结束<<<<<<<<<<<<<<<<<<<*/
function updateClick () {
	
	
}
var updateClickReq;
function updateClick(clickBigTypeID,clickInfoID) {
	
	updateClickReq = createAjaxObj();
	if (updateClickReq.readyState == 4 || updateClickReq.readyState == 0) {
		updateClickReq.open("POST", './ajaxUpdateClick?&infoID=' + clickInfoID +'&bigTypeID=' + clickBigTypeID, true);
		updateClickReq.setRequestHeader("Content-Type",
				"application/x-www-form-urlencoded");//alert(classID);
		updateClickReq.onreadystatechange = updateClickFilish;
		updateClickReq.send(null);
	}
}
function updateClickFilish(){
	if (updateClickReq.readyState == 4 || updateClickReq.readyState == 0) {
		if (updateClickReq.responseXML != null) {
			//alert('updateClickFilish');
		}
	}
}

/*<<<<<<<<<<<<<<人气点击数更新结束<<<<<<<<<<<<<<<<<<<*/


























