
/* start */ 
var has_shown = false;
function close_div(placeBoxId,iframeId){
	$('#' + placeBoxId).hide();
	$('#' + iframeId).hide();
	has_shown = false;
}
function changePlaceDiv(placeBoxId,iframeId){
	if (has_shown) {
		return '';
	}
	$("#" + iframeId).show();
	$("#" + placeBoxId).show();
	has_shown = true;
}
/* end */ 

function changeRemark(){
	if(document.getElementById("order_bz").value =='（不超过500字）'){
		document.getElementById("order_bz").value = ''; 
	}
}    
function checkLen(obj) 
{
var maxChars = 500;//最多字符数
if (obj.value.length > maxChars)
obj.value = obj.value.substring(0,maxChars);
var curr = maxChars - obj.value.length;
document.getElementById("count").innerHTML = curr.toString();
}
			function IFrameAutoFit()
			{
				try
				{
					if(window!=parent)
					{
						var a = parent.document.getElementsByTagName("IFRAME");
						for(var i=0; i<a.length; i++)
						{
							if(a[i].contentWindow == window)
							{
								var h1=0, h2=0,w1,w2;
								a[i].parentNode.style.height = a[i].offsetHeight +"px";
								a[i].parentNode.style.width  = a[i].offsetWidth +"px";
								a[i].style.height = "10px";
								if(document.documentElement && document.documentElement.scrollHeight)
								{
									h1 = document.documentElement.scrollHeight;
								}
								if(document.body)
								{
									h2=document.body.scrollHeight;
								}
								var h = Math.max(h1, h2);
								if(document.all) 
								{
									h += 4;
								}
								if(window.opera) 
								{
									h += 1;
								}
								
								if(document.documentElement && document.documentElement.scrollWidth)
								{
									w1 = document.documentElement.scrollWidth;
								}
								if(document.body)
								{
									w2=document.body.scrollWidth;
								}
								var w = Math.max(w1, w2);
								a[i].style.height = a[i].parentNode.style.height = h +"px";
								a[i].style.width=a[i].parentNode.style.width=w+"px";
							}
						}
					}
				}
				catch (ex)
				{
				}
			}
			if(window.attachEvent)
			{
				window.attachEvent("onload",  IFrameAutoFit);
			}
			else if(window.addEventListener)
			{
				window.addEventListener('load',  IFrameAutoFit,  false);
			}    



function bookcheack(){	
	if (document.getElementById("KS_name").value.search(/[\u4e00-\u9fa5]/g)==-1){
		    alert("姓名只能输入中文");
			document.getElementById("KS_name").focus();
			document.getElementById("KS_name").select();
			return false;
			//msg=msg+"姓名,";
			//sum++;
		}
			if(document.getElementById("KS_name").value.length>8 || document.getElementById("KS_name").value.length<2){
			alert("您填写的真实姓名不正确!");
			document.getElementById("KS_name").focus();
			document.getElementById("KS_name").select();
			return false;
		}
		
	if (document.getElementById("KS_name").value.replace(/ /g,"")==""){
		alert("姓名不能为空,请填写你的姓名");
		document.getElementById("KS_name").focus();
		return false;
		}
		
		if (document.getElementById("order_bz").value.replace(/ /g,"")==""){
		alert("咨询内容不能为空");
		document.getElementById("order_bz").focus();
		return false;
		}
		else if (document.getElementById("order_bz").value.replace(/ /g,"").length < 2){
		alert("咨询内容字数太少了！\n\n请重新输入。");
		document.getElementById("order_bz").focus();
		return false;
		}
		else if (document.getElementById("order_bz").value.replace(/ /g,"").length > 500){
		alert("咨询内容字数太多，请重新输入，或直接拨打电话400-678-8683进行咨询！");
		document.getElementById("order_bz").focus();
		return false;
		}
		
		String.prototype.Trim = function() {  
  var m = this.match(/^\s*(\S+(\s+\S+)*)\s*$/);  
  return (m == null) ? "" : m[1];  
}

String.prototype.isMobile = function() {
	return (/^0{0,1}(13[0-9]?|15[0-9]?|18[0-9])[0-9]{8}$/.test(this.Trim()));  
  //return (/^(?:13\d|15[89])-?\d{5}(\d{3}|\*{3})$/.test(this.Trim()));  
} 

String.prototype.isTel = function()
{
    //"兼容格式: 国家代码(2到3位)-区号(2到3位)-电话号码(7到8位)-分机号(3位)"
    //return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/.test(this.Trim()));
    return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/.test(this.Trim()));
}
		if (document.getElementById("KS_tel").value.isMobile()||document.getElementById("KS_tel").value.isTel())  {            
            return true;  
        } 
        else {  
            alert("请输入正确的手机号码或电话号码\n\n例如:135********或0571-86830306"); 
            document.getElementById("KS_tel").focus();
			 document.getElementById("KS_tel").select();
            return false;        
        }
return true;				
}

