﻿var strDiv;
var smInterval;
var iErrTime=3;
var strURLFirst;
//document.domain="51yey.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;
            //document.getElementById("dlogin").style.paddingTop="20px";
            return;
            }
            tableTag=content.getElementsByTagName("Table");
            var userHTML = '<div class="inload">';
            userHTML += '<div class="intable_Div" style="float:left; width:100px; padding-left:50px;  ">欢迎您 ' + getTagValue(content,"REALNAME")+'</div>';
            userHTML += '<div class="inloadman" style="padding-left:20px; float:left;width:100px; "><a href="' + strURL+getTagValue(tableTag[0],"STRURL") + '" target="_blank" >>>'+getTagValue(tableTag[0],"STRVLAUE")+'</a></div>'
             userHTML +='<div class="inloadman" style="float:left;width:100px; "><a href="javascript:btnCancle_Click()" style="text-decoration:none;font-size:12px">>>注销</a></div>';
             
             
            var ninStrl = "";                   
            if( getTagValue(content,"GROUPID") != "4")
            {
                //ninStrl = '<div class="shuoming"  style="float:left; "><span class="spanR">*</span>您可以通过进入小管家里面登陆<span class="spanG">我的博客</span>和<span class="spanG">班级圈子</span></div>';
            }          
            else
            {
                //ninStrl = '<div class="shuoming" style="float:left; width:400px; padding:0px; margin:0px;"><span class="spanR">*</span>您可以通过进入<span class="spanG">网站管理</span>来管理您的幼儿园</div>';
            }
            if(iClassID==2)
            {
                ninStrl = '<div style="height:15px; line-hieght:15px; font-size:12px; text-align:center;"><span class="spanR">*</span>这是您第一次登陆！</div>';
                strURLFirst=strURL+getTagValue(tableTag[0],"STRURL");
            }
            userHTML += ninStrl;
            userHTML += '</div>';
            document.getElementById("dlogin").innerHTML = userHTML;
            
        } else if (iClassID == 0){
            var strHTML='<div style="text-align:left;">';
            strHTML+='用户名或密码错误！<br>';
            strHTML+='&nbsp;&nbsp;<span style="width:15px;color:red" id="sTime">3</span>&nbsp;&nbsp;秒之后返回！</div>';
            document.getElementById("dlogin").innerHTML =strHTML;
            //document.getElementById("dlogin").style.paddingLeft="20px";
            smInterval = window.setInterval(gotoError, 1000);
        } 
        
    }else{
        alert("网络传输中发生错误，请稍候再试！");
        document.getElementById("dlogin").innerHTML = strDiv;
    }
}
function gotoError(){
if(iErrTime<=0){
clearInterval(smInterval);
document.getElementById("dlogin").innerHTML = strDiv;
//document.getElementById("dlogin").style.paddingTop="20px";
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;
            //document.getElementById("dlogin").style.paddingTop="20px";
    }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");
		      if(pageBot){
		     pageBot.innerHTML=strHtml;
		     }
		     //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();
}
