﻿
			
function SaveButCheck()
{
	if(document.getElementById("txtUserName").value=="")
	{
		alert("访客名称不能为空!");
		document.getElementById("txtUserName").focus();return false;
	}
	if(document.getElementById("txtPhone").value=="")
	{
		alert("电话号码不能为空!");
		document.getElementById("txtPhone").focus();return false;
	}
	else
	{
		var re=/^((\(\d{3}\)|\d{3}-)?\d{8})|((\(\d{4}\)|\d{4}-)?\d{7})$/;
		if(!re.test(document.getElementById("txtPhone").value))
		{
			alert("电话号码格式错误!");
			document.getElementById("txtPhone").focus();return false;
		}
	}
	if(document.getElementById("txtCellPhone").value!="")
	{
		var re=/^1[3|5]\d{9}$/;
		if(!re.test(document.getElementById("txtCellPhone").value))
		{
			alert("手机号码格式错误!");
			document.getElementById("txtCellPhone").focus();return false;
		}
	}
	if(document.getElementById("txtTitle").value=="")
	{
		alert("题目不能为空!");
		document.getElementById("txtTitle").focus();return false;
	}
}
function LoginCheck()
{
	if(document.getElementById("txtName").value=="")
	{
		alert("用户名不能为空!");
		document.getElementById("txtName").focus();
		return false;
	}//txtPass
	if(document.getElementById("txtPass").value=="")
	{
		alert("密码不能为空!");
		document.getElementById("txtPass").focus();
		return false;
	}//txtPass
	if(document.getElementById("txtCCode").value=="")
	{
		alert("验证码不能为空!");
		document.getElementById("txtCCode").focus();
		return false;
	}//txtPass
}
function GetLocation()
{
	if(window.parent!=window.self)
	{
		alert('权限过期,请重新登录!');
		parent.location.href='Index.aspx';
	}
}
function load(ProvinceID)
{
	var drp2 = document.getElementById("City");
	for(var i=drp2.options.length-1;i>=0;i--)
	{
		drp2.remove(i);
	}
	var newOpt= document.createElement("OPTION");
　　newOpt.text="----";
　　newOpt.value="0";
　　drp2.options.add(newOpt);
	if(ProvinceID>0)
	{
　　	
		var oHttpReq = new ActiveXObject("MSXML2.XMLHTTP");    //发送请求Province
		var oDoc = new ActiveXObject("MSXML2.DOMDocument");    //响应结果
		oHttpReq.open("post","ManberTranceList.aspx?Province="+ProvinceID, false);
		oHttpReq.send("");
		result = oHttpReq.responseText;
		oDoc.loadXML(result);
		var items1 = oDoc.selectNodes("//NewDataSet/Table/DQMC");
　　	var itemsLength=items1.length;
　　	for(i=0;i<itemsLength;i++) 
　　	{
　　		var newOption = document.createElement("OPTION");
　　		newOption.text=items1[i].text;
　　		newOption.value=items1[i].text;
　　		drp2.options.add(newOption);
　　	}
　　}
}
function GetCityDetials()
{
	var txtsprice=document.getElementById("txtSPrice");
	var txteprice=document.getElementById("txtEPrice");
	if(isNaN(txtsprice.value))
	{
		alert("开始价格错误!");txtsprice.focus();txtsprice.select();return false;
	}
	if(isNaN(txteprice.value))
	{
		alert("结束价格错误!");txteprice.focus();txteprice.select();return false;
	}
	var ProCity="";
	var province=document.getElementById('Province');
　　var city=document.getElementById('City');
　　if(province.selectedIndex>0)
　　　　ProCity=province.options[province.selectedIndex].text;
　　if(city.selectedIndex>0)
　　　　ProCity+=","+city.options[city.selectedIndex].text;
　　document.getElementById('CityDetials').value=ProCity;
}
function GetType()
{
	return document.getElementById("HType").value;
}
function SelectPriceChanged()
{
	if(document.getElementById("ddlPrice").selectedIndex>-1)
	{
		if(document.getElementById("ddlPrice").selectedIndex==7)
		{
			document.getElementById("divPrice").style.display="block";
		}
		else
		{
			if(document.getElementById("divPrice").style.display=="block")
				document.getElementById("divPrice").style.display="none";
		}
	}
}
function Trim(str) 
{
	return str.replace(/(^\s*)|(\s*$)/g,"");
}
function LoginClick()
{
	var gk=event.keyCode;
	if (gk==13) {
	document.getElementById("btnLogin").click(); 
	}
}

function GetPingGuss()
{
	var sPrice=document.getElementById("Price").value;
	var sLiCheng=document.getElementById("LiCheng").value;
	var sNianXian=document.getElementById("NianXian").value;
	var sNianXianMonth=document.getElementById("NianXianMonth").value;
	if(isNaN(sPrice)||(sPrice==''))
	{
		alert("价格格式错误!");
		document.getElementById("Price").focus();
		return false;
	}
	if(isNaN(sLiCheng)||sLiCheng=='')
	{
		alert("里程格式错误！");
		document.getElementById("LiCheng").focus();
		return false;
	}
	if(isNaN(sNianXian))
	{
		alert("年限必须是数字！");
		document.getElementById("NianXian").focus();
		return false;
	}
	if(isNaN(sNianXianMonth))
	{
		alert("月份格式错误!");
		document.getElementById("NianXianMonth").focus();
		return false;
	}
	else
	{
		if(sNianXian==''&&sNianXianMonth=='')
		{
			alert("请填写使用年限!");return false;
		}
		if(sNianXian=='')sNianXian='0';
		if(sNianXianMonth=='')sNianXianMonth='0';
		if(sNianXianMonth!=''&&parseInt(sNianXianMonth)!=0)
		{
			sNianXian=parseInt(sNianXian)+parseInt(sNianXianMonth)/12;
			if(parseInt(document.getElementById("NianXianMonth").value)>12)
			{
				alert("月份不能大于12！");document.getElementById("NianXianMonth").focus();return false;
			}
		}
		var sZhuanKuan=document.getElementById("ZhuanKuan").selectedIndex;
		var sShiGu=document.getElementById("ShiGu").selectedIndex;
		var response=AjaxClass.GetPingGuResult(sPrice,sLiCheng,sNianXian,sZhuanKuan,sShiGu).value;
		if(response!=null)
		{
			if(response=='-1')
			{
				alert('使用年限不能为0');return;
			}
			if(response=='-3')
			{
				alert('超越系统设置使用年限');return;
			}
			if(response=='-2')
				alert('服务器故障');
			else
				window.showModalDialog('webs/PingGuResult.aspx?response='+response,null,"dialogWidth=250px;dialogHeight=200px");
		}
		else
			alert("请填写正确的参数!");
	}
}
function _InitScroll(_S1,_S2,_W,_H,_T){
	return "var marqueesHeight"+_S1+"="+_H+";var stopscroll"+_S1+"=false;var scrollElem"+_S1+"=document.getElementById('"+_S1+"');with(scrollElem"+_S1+"){style.width="+_W+";style.height=marqueesHeight"+_S1+";style.overflow='hidden';noWrap=true;}scrollElem"+_S1+".onmouseover=new Function('stopscroll"+_S1+"=true');scrollElem"+_S1+".onmouseout=new Function('stopscroll"+_S1+"=false');var preTop"+_S1+"=0; var currentTop"+_S1+"=0; var stoptime"+_S1+"=0;var leftElem"+_S2+"=document.getElementById('"+_S2+"');scrollElem"+_S1+".appendChild(leftElem"+_S2+".cloneNode(true));setTimeout('init_srolltext"+_S1+"()',"+_T+");function init_srolltext"+_S1+"(){scrollElem"+_S1+".scrollTop=0;setInterval('scrollUp"+_S1+"()',100);}function scrollUp"+_S1+"(){if(stopscroll"+_S1+"){return;}currentTop"+_S1+"+=5;if(currentTop"+_S1+"==(marqueesHeight"+_S1+"+5)) {stoptime"+_S1+"+=1;currentTop"+_S1+"-=5;if(stoptime"+_S1+"=="+_T/50+") {currentTop"+_S1+"=0;stoptime"+_S1+"=0;}}else{preTop"+_S1+"=scrollElem"+_S1+".scrollTop;scrollElem"+_S1+".scrollTop +=5;if(preTop"+_S1+"==scrollElem"+_S1+".scrollTop){scrollElem"+_S1+".scrollTop=0;scrollElem"+_S1+".scrollTop +=5;}}}";
}
