﻿function buyIt(type,id,name,memberPrice){var rn = Default.addShopCart(type,id,name,memberPrice).value;
if(rn == -1){alert('请先去登陆!');location.href ="/System/CheckLogin.aspx?url="+encodeURI(location.href);};
if(rn == 3){alert('放入购物车成功');var w1 = window.open('/Shopping/ShopCart.aspx','shopcart');w1.location.reload(true); };
if(rn == 2){alert('已存在购物车中');};
if(rn == 4){alert('放入购物车失败');};
if(rn == 5){alert('暂时无法购买,请刷新页面');};
    return false;}
function count(val){Default.addNum(val.toString()).value;}
function checkLogin(){
    var userid;var pwd;var code;
    var obj = document.getElementById("username");
    userid =obj.value.replace(/\s/g,"");if(userid.length == 0){alert("请输入用户名!");obj.focus();return false;}
    obj = document.getElementById("password");
    pwd = obj.value.replace(/\s/g,"");if(pwd.length == 0){alert("请输入密码!");obj.focus();return false;}
    obj = document.getElementById("code");
    code = obj.value.replace(/\s/g,"");
    if(code.length == 0){alert("请输入密码!");obj.focus();return false;}
    var rns = Default.checkLogin(userid,pwd,code).value;
    if(rns == "-2"){alert("验证码错误");return false;}else if(rns == "0"){alert("用户名或密码错误");return false;}
    else{//theForm.action="http://bbs.newedu365.com/login.aspx?reurl="+location.href;
location.href = location.href;return true;}}
function reLoadCode(val){val.src="../System/code.aspx?rand="+Math.random();return false;}
function changeCursor(val){val.style.cursor="pointer";}
function findPass(){window.open("/System/FindPassword.aspx","_blank");return false;}
var isReading = 0;
var curID;
function read(val)
{var voiceElement = document.getElementById("voice"); 
   if(isReading == 0)
  {  
        if(voiceElement != null)
        {
            voiceElement.stop();
            voiceElement.removeNode(true);
        } 
       voiceElement = document.createElement("<embed>");
       voiceElement.src="/news/voice/"+val+".wav";
       voiceElement.hidden = "true";
       voiceElement.id ="voice";
       voiceElement.autostart = "true"; 
       document.body.appendChild(voiceElement);
       curID = val;
       isReading = 1;
       return;
  } 
  if(isReading == 1)
  {
        if(curID == val){voiceElement.pause();isReading = 2;}
        else
       {
            voiceElement.stop(); isReading = 0; read(val);
       }  
       return;
  }
  if(isReading == 2)
  {
       if(curID == val){voiceElement.play();isReading = 1;}
       else
       {voiceElement.stop(); isReading = 0; read(val);} 
  }
}