﻿var strDiv;
var smInterval;
var iErrTime=3;
var strURLFirst;
//document.domain="5156bb.com";
//alert(document.cookie);


function imgLogin_onclick(){
    //用户名检查f
    var username = document.getElementById("username").value;
    var password = document.getElementById("password").value;
    
    if (username=="") {
        alert("请输入用户名！");
        document.getElementById("username").focus();
        return false;
    }
    if (password == "") {
        alert("请输入密码！");
        document.getElementById("password").focus();
        return false;
    }
    //记住密码
    var autologin = 0;
    if (document.getElementById("autologin").checked == true) {
        autologin = 1;
    }
    //var Ajax = new oAjax("http://www.5156bb.com/gardenweb/login/gardenLogin.aspx","loginCheck",loginCheck,false);
    var Ajax = new oAjax("../../login/gardenLogin.aspx","loginCheck",loginCheck,false);
    Ajax.Get("schoolid="+$F("hSchoolID")+"&username=" + username + "&password=" + password + "&chkSaveFlag=" + autologin);
    //Ajax.loading("dlogin",null,"登陆中......");
    strDiv=document.getElementById("dlogin").innerHTML;
    document.getElementById("dlogin").innerHTML='<img id="ajaxLoadImg" src="../../ajax/loader3.gif" style=" height:16px; width:16px;"/>登陆中......';
    return false;
}

function loginCheck(content) {
    var isSuccess = getTagValue(content,"Success");
    
    //alert(isSuccess);
    //var strURL="http://www.5156bb.com/";
    var strURL="../../";
    if(isSuccess && isSuccess =="True"){
        var iClassID=getTagValue(content,"RowCount");
        
        if ( iClassID>= 1) {
            if (iClassID == "1"){
            document.getElementById("dlogin").innerHTML =strDiv;
            
            return;
            }
            tableTag=content.getElementsByTagName("Table");
            var userHTML = '';
            userHTML += '<table cellpadding="0" cellspacing="0">';
            userHTML += '<tr>';
            userHTML += '<td align="center" style="font-size:12px;color:#2C6202;padding-top:0px" colspan="3">';
            userHTML += getTagValue(content,"REALNAME") + '<br />欢迎您来到幼儿园';
            userHTML += '</td></tr>';
            
            if(iClassID==2){
            userHTML += '<tr><td> </td><td align="center" style="height: 20px;font-size:12px">';
             userHTML += '这是您第一次登陆！';
             userHTML += '</td><td> </td></tr>';
             strURLFirst=strURL+getTagValue(tableTag[0],"STRURL");
            }
            for(i=0;i<tableTag.length;i++){
                userHTML += '<tr><td></td><td align="right" style="width:120px;">';
                userHTML += '<a href="'+strURL+getTagValue(tableTag[i],"STRURL")+'" style="text-decoration:none;font-size:12px" target="'+(iClassID==2?"_self":"_blank")+'">进入'
                            +getTagValue(tableTag[i],"STRVLAUE")+'>></a>';
                userHTML += '</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>';
            }
            if(tableTag.length<3){
            userHTML +='<tr><td> </td><td align="right">';
            userHTML +='<a href="javascript:btnCancle_Click()" style="text-decoration:none;font-size:12px">注销>></a>';
            userHTML +='</td><td> </td></tr>';
            }
            userHTML += '</table><br/>';
            //userHTML=userHTML.substring(0,userHTML.length-1);

            document.getElementById("dlogin").innerHTML = userHTML;
            
            //if(iClassID>1){
            //document.getElementById("aClass").href = "garden/class/class.aspx?classid="+iClassID;
            //document.getElementById("hClassID").value =iClassID;
            //}
            
            
        } else if (iClassID == 0){
            var strHTML='<div style="border:0px solid red;padding:5px 0px 5px 10px">';
            strHTML+='<div> 用户名或密码错误！</div>';
            strHTML+='<div> <span id="sTime">3</span>秒之后返回！</div></div>';
            document.getElementById("dlogin").innerHTML =strHTML;
            smInterval = window.setInterval(gotoError, 1000);
        } 
        
    }else{
        alert("网络传输中发生错误，请稍候再试！");
        document.getElementById("dlogin").innerHTML = strDiv;
    }
}
function gotoError(){
if(iErrTime<=0){
clearInterval(smInterval);
document.getElementById("dlogin").innerHTML = strDiv;
iErrTime=3;
return;}
iErrTime--;
document.all.sTime.innerHTML=iErrTime;
}
function login_first(){
//var Ajax = new oAjax("http://192.168.1.2/gardenweb/login/gardenLogin.aspx","loginCheck",loginCheck);
//Ajax.loading("dlogin",null,"登陆中......");
//    var Ajax = new oAjax("Default.aspx","initData",initData,false);
//    Ajax.Get();
    
    //Ajax = new oAjax("http://www.5156bb.com/gardenweb/login/gardenLogin.aspx","loginCheck",loginCheck,false);
    Ajax = new oAjax("../../login/gardenLogin.aspx","loginCheck",loginCheck,false);
    Ajax.Get("schoolid="+document.all.hSchoolId.value);
    //Ajax.loading("dlogin",null,"登陆中......");
    strDiv=document.getElementById("dlogin").innerHTML;
    document.getElementById("dlogin").innerHTML='<img id="ajaxLoadImg" src="../../ajax/loader3.gif" style=" height:16px; width:16px;"/>登陆中......';
}


function btnCancle_Click(){
 var Ajax = new oAjax('../../login/logout.aspx',"btnCancle",ajax_canclereturn,false);
	//Ajax.loading("loading",null);						
   Ajax.Get();
}

function ajax_canclereturn(content){

     var bb = getTagValue(content,"Success");
     if(bb && bb =="True"){
            //window.location.href="../login/login.aspx";
            document.getElementById("dlogin").innerHTML =strDiv;
            
    }else{ 
     //document.getElementById("save_ing").style.display="none";
     alert("消息取得失败! \n" + unescape(getTagValue(content,"ErrMsg")));
    }
          
}


function ajax_returnsave(content){
     var bb = getTagValue(content,"Success");
     if(bb && bb =="True"){
		        //document.getElementById("save_ing").style.display="none";
		        var strNum=getTagValue(content,"RowCount");
		        var strHtml="";
		        var j=0;
		         for(i=strNum.length;i<6;i++){
		        strHtml+='<img style="left:'+(20+i*20)+';top:12px" src="../../Stemp/t1/aboutus_res/0.gif" />';
		        }
		        j=i;
		        for(i=0;i<strNum.length;i++){
		        strHtml+='<img style="left:'+(20+j*20)+';top:12px" src="../../Stemp/t1/aboutus_res/'+(strNum.charCodeAt(i)-48)+'.gif" />';
		        j++;
		     }
		     var pageBot=document.getElementById("tdBottom");
		     pageBot.innerHTML=strHtml;
		     //pageBot.style.marginLeft="0px";
		     //pageBot.style.top="12px";

    }else{ 
     //document.getElementById("save_ing").style.display="none";
    alert("消息发送失败! \n" + unescape(getTagValue(content,"ErrMsg")));
    }
}
function getMusic()
{  
    var dpageBot=document.getElementById("dMusic");
    var  iW=0;
    var  iH=0;
    //a
    Exobud=document.getElementById("Exobud");
    //var  src=document.getElementById("hMusic").split('$')(0).split('&')(1);
     var strListA=$F("hMusic").split("$");
      if($F("hMusic")==""){ 
//     $("tdBottom").rows[0].cells[1].style.width='50';
//     $("tdBottom").rows[0].cells[5].style.width='120';
     return};
     for(i=0;i<strListA.length;i++){
     if(strListA[i]!=""){
     mkList(strListA[i].split("&")[1],strListA[i].split("&")[0],'','');
     }
     }
    dpageBot.innerHTML='<object id="Exobud" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" '+
  'type="application/x-oleobject" width="0" height="0" '+
  'style="position:relative;left:0px;top:0px;width:0px;height:0px;"> '+
  '<param name="autoStart" value="true"> '+
  '<param name="balance" value="0"> '+
  '<param name="currentPosition" value="0"> '+
  '<param name="currentMarker" value="0"> '+
  '<param name="enableContextMenu" value="false"> '+
  '<param name="enableErrorDialogs" value="false"> '+
  '<param name="enabled" value="true"> '+
  '<param name="fullScreen" value="false"> '+
  '<param name="invokeURLs" value="false"> '+
  '<param name="mute" value="false"> '+
  '<param name="playCount" value="1"> '+
  '<param name="rate" value="1"> '+
  '<param name="uiMode" value="none"> '+
  '<param name="volume" value="100"> '+
  '</object>';
 dpageBot.innerHTML+='<span class="time" id="disp2" value="" title="键盘控制：A：静音, ↓降音, ↑：增音, S/R：播放模式 , L：循环设定 , ←/Z：上一首 , X：暂停 , C：停止 , V/P：播放 , →/B下一首" '+
        'onClick="chgTimeFmt()" style="width:90;height:18;cursor:hand"></span> '+
        '&nbsp;<img name="scope" id="scope" src="/STemp/public/pubImg/scope_off.gif" width=17 height=16 '+
        'onClick="vizExobud()" style="cursor:help" title=""/> '+
        '&nbsp;<img src="/STemp/public/pubImg/list01.gif" class ="buttons" name="plist" value="List" title="播放列表" '+
        ' onClick="openPlist()" style="cursor:hand"/>';
  var str='<script language="JScript" for="Exobud" event="openStateChange(sf)">evtOSChg(sf);</script> '+
          '<script language="JScript" for="Exobud" event="playStateChange(ns)">evtPSChg(ns);</script> '+
          '<script language="JScript" for="Exobud" event="error()">evtWmpError();</script> '+
          '<script language="JScript" for="Exobud" event="Buffering(bf)">evtWmpBuff(bf);</script>';
  document.write(str);
  
       initExobud();
       startExobud();
}

