<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN xmlns="http://www.w3.org/1999/xhtml">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script type="text/javascript" src="jquery.min.js"></script>
<style>
#main{
margin:0px auto 0px auto;
width:500px;
height:600px;
background-color:#aa9456;
padding-left:0px;
}
#crab{
padding-left:0px;
}
#content1{
background-color:#789fff;
height:100px;
text-align:center;
}
#bottom{
padding-top:15px;
background:#445674;
height:60px;
text-align:center;
}
#money{
color:f2f2f2;
}
#StartMoney{
background-color:#f4f4f4;
color:red;
padding-left:55px;
margin-top:5px;
}
#btn{
margin-top:20px;
text-align:center;
}
</style>
<script>
var a=0,b=0,c=0,d=0;
var time;
$(function(){
var reg=/[1-9]\d*/g;
$("#moneys").blur(function(){
var money=(parseInt(this.value));
var startmoneys=parseInt($("#startmoneys").val());
if(money>startmoneys){
document.getElementById("StartBtn").disabled=true;
alert("你输入钱大于你的余额");
return;
}
else if(!reg.test(this.value)){
document.getElementById("StartBtn").disabled=true;
alert("你输入的数字有误");
return;
}
else{
document.getElementById("StartBtn").disabled=false;
}
}).focus(function(){
$("#moneys").select();
})
})
function sum(){
a=0,b=0,c=0,d=0;
var j=parseInt(document.getElementById("moneys").value);
var i=parseInt(document.getElementById("startmoneys").value);
document.getElementById("startmoneys").value=i+j;
}
function sum2(){
a=0,b=0,c=0,d=0;
var j=parseInt(document.getElementById("moneys").value);
var i=parseInt(document.getElementById("startmoneys").value);
document.getElementById("startmoneys").value=i-j;
}
function readgo(){
document.getElementById("StartBtn").disabled=true;
var rad=document.getElementById("bottom").getElementsByTagName("input");
meth();
a+=Math.round(Math.random()*5+1);
b+=Math.round(Math.random()*5+1);
c+=Math.round(Math.random()*5+1);
d+=Math.round(Math.random()*5+1);
time=setTimeout(readgo,10);
if(a>=469||b>=469||c>=469||d>=469)
{
document.getElementById("StartBtn").disabled=false;
clearTimeout(time);
if((a>=467&&rad[0].checked==true)||(b>=467&&rad[1].checked==true)||(c>=467&&rad[2].checked==true)||(d>=467&&rad[3].checked==true)){
alert("你赢了");
sum();
meth();
return;
}
else{
alert("你输了 !")
sum2();
meth();
return;
}
}
function meth(){
document.getElementById("crab1").style.paddingLeft=a;
document.getElementById("crab2").style.paddingLeft=b;
document.getElementById("crab3").style.paddingLeft=c;
document.getElementById("crab4").style.paddingLeft=d;
}
}
</script>
</HEAD>
<BODY>
<div id="main">
<div id="crab">
<div id="crab1"><img src="1.jpg"></div><br>
<div id="crab2"><img src="2.jpg"></div><br>
<div id="crab3"><img src="3.jpg"></div><br>
<div id="crab4"><img src="4.jpg"></div><br>
</div>
<div id="content">
<div id="content1">
<img src="3.gif"/> <img src="pic/5.gif"> <img src="3.gif"/>
</div>
</div>
<div id="bottom">
<img src="1.jpg"><input type="radio" name="crab" checked="true">
<img src="2.jpg"><input type="radio" name="crab">
<img src="3.jpg"><input type="radio" name="crab">
<img src="4.jpg"><input type="radio" name="crab">
</div>
<div id="money">
<img src="pic/1.gif">押<input type="text" name="money" id="moneys" size="28">元<img src="pic/7.gif">
<div id="StartMoney">你的余额为:<input type="text" name="money3" id="startmoneys" size="28" value="8888" readonly="true">元</div>
<div id="btn"><input type="button" value="开始" id="StartBtn" disabled="true" onclick="readgo()"></div>
</div>
</div>
</BODY>
</HTML>