// JScript 文件
   function getXMLHTTP(){
            var xmlhttp=false;
            try{
                xmlhttp=new XMLHttpRequest();
            }catch(e){
                try{
                    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }catch(e){
                    alert("你的浏览器不支持Ajax");
                }
            }
            return xmlhttp;
        }
        
        
        
function GET_ClassROOM(){
            var xmlhttp=getXMLHTTP();
            var count=10;
            xmlhttp.open("Get","Ashx/GET_ClassRoom.ashx",true);
           //  document.getElementById ("message").style.display="block";
            xmlhttp.onreadystatechange=function(){              
            if(xmlhttp.readyState==4){  
                  if(xmlhttp.status==200){
                   //   document.getElementById ("message").style.display="none";
                       if(xmlhttp.responseText!=""){  
                  document.getElementById ("classroom").innerHTML=xmlhttp.responseText;
                              }             
               }
            }
         }
         xmlhttp.send(null);       
}

//------------------
function get_zuowei(p)
{
  var xmlhttp=getXMLHTTP();
            var count=10;
            xmlhttp.open("Get","Ashx/GET_zuowei.ashx?claid="+p,true);
           //  document.getElementById ("message").style.display="block";
            xmlhttp.onreadystatechange=function(){              
            if(xmlhttp.readyState==4){  
                  if(xmlhttp.status==200){
                   //   document.getElementById ("message").style.display="none";
                       if(xmlhttp.responseText!=""){  
                  document.getElementById ("zuowei").innerHTML=xmlhttp.responseText;
                    var div= document.getElementById ("classroom").getElementsByTagName ("li");
                      for(var i = 0; i < div.length; i++) 
        { 
   
        if (div[i].id=="li_"+p )
        {
         div[i].style.background="red";
        
        }
        else 
        {
          div[i].style.background="";
        }
      
        
    
      }
              
                 }             
               }
            }
         }
         xmlhttp.send(null);       
}
//-------------

function Get_Course(){
            var xmlhttp=getXMLHTTP();
            var count=10;
            xmlhttp.open("Get","Ashx/Get_Course.ashx",true);
           //  document.getElementById ("message").style.display="block";
            xmlhttp.onreadystatechange=function(){              
            if(xmlhttp.readyState==4){  
                  if(xmlhttp.status==200){
                   //   document.getElementById ("message").style.display="none";
                       if(xmlhttp.responseText!=""){  
                  document.getElementById ("course").innerHTML=xmlhttp.responseText+"</br>";
                              }             
               }
            }
         }
         xmlhttp.send(null);       
}
//-----------------------
function Get_nianji(){
            var xmlhttp=getXMLHTTP();
            var count=10;
            xmlhttp.open("Get","Ashx/Get_nianji.ashx",true);
           //  document.getElementById ("message").style.display="block";
            xmlhttp.onreadystatechange=function(){              
            if(xmlhttp.readyState==4){  
                  if(xmlhttp.status==200){
                   //   document.getElementById ("message").style.display="none";
                       if(xmlhttp.responseText!=""){  
                  document.getElementById ("nianji").innerHTML=xmlhttp.responseText;
                              }             
               }
            }
         }
         xmlhttp.send(null);       
}
//----------------------


//美萍

function GET_time(){
            var xmlhttp=getXMLHTTP();
            var count=10;
         
     
            xmlhttp.open("Get","Ashx/Get_time.ashx",true);
           //  document.getElementById ("message").style.display="block";
            xmlhttp.onreadystatechange=function(){              
            if(xmlhttp.readyState==4){  
                  if(xmlhttp.status==200){
                   //   document.getElementById ("message").style.display="none";
                       if(xmlhttp.responseText!=""){  
                
               
                  document.getElementById("show_time").innerHTML=xmlhttp.responseText+"</br>";
                              }             
               }
            }
         }
         xmlhttp.send(null);       
}
//----------------------------
function GET_xq(){
            var xmlhttp=getXMLHTTP();
            var count=10;
         
     
            xmlhttp.open("Get","Ashx/Get_xiaoqu.ashx",true);
           //  document.getElementById ("message").style.display="block";
            xmlhttp.onreadystatechange=function(){              
            if(xmlhttp.readyState==4){  
                  if(xmlhttp.status==200){
                   //   document.getElementById ("message").style.display="none";
                       if(xmlhttp.responseText!=""){  
                
               
                  document.getElementById("kkk").innerHTML=xmlhttp.responseText;
                              }             
               }
            }
         }
         xmlhttp.send(null);       
}
//-------------------------

function ajax_make(cid,no){
            var xmlhttp=getXMLHTTP();
            var count=10;
         
     
            xmlhttp.open("Get","Ashx/ajax_make.ashx?cid="+cid+"&no="+no,true);
           //  document.getElementById ("message").style.display="block";
            xmlhttp.onreadystatechange=function(){              
            if(xmlhttp.readyState==4){  
                  if(xmlhttp.status==200){
                   //   document.getElementById ("message").style.display="none";
                       if(xmlhttp.responseText!=""){  
                
              
               alert(xmlhttp.responseText)
                
                              }             
               }
            }
         }
         xmlhttp.send(null);       
}

//---------------------------------------
function sub_meit(xiaoqu,xingming,sex,tel,gread,ss,begin,end){
            var xmlhttp=getXMLHTTP();
            var count=10;
            xmlhttp.open("Get","Ashx/sub_meit.ashx?xq="+xiaoqu+"&xm="+xingming+"&sex="+sex+"&tel="+tel+"&gread="+gread+"&ss="+ss+"&begin="+begin+"&end="+end,true);
           //  document.getElementById ("message").style.display="block";
            xmlhttp.onreadystatechange=function(){              
            if(xmlhttp.readyState==4){  
                  if(xmlhttp.status==200){
                   //   document.getElementById ("message").style.display="none";
                       if(xmlhttp.responseText!=""){  
               if (xmlhttp.responseText=="1")
               {
                // window.location.reload();
               alert("报名成功!!");
                window.location.href="index_detail.html?user="+encodeURIComponent(xingming);
             
               
            
                }
                
                              }             
               }
            }
         }
         xmlhttp.send(null);       
}
//------------------------------


function choose_corese(){
            var xmlhttp=getXMLHTTP();
           
 var couser_select=document.getElementById("course_select").value; 
 var zuowei_value=document.getElementById("zuowei_value").value; 
var time_select=document.getElementById("time_select").value; 
var c_value=document.getElementById ("c_value");
var begin=document.getElementById ("begin").value;
var end=document.getElementById ("end").value;
var erro="";
var price=0;
            xmlhttp.open("Get","Ashx/choose_corese.ashx?codid="+couser_select+"&time="+time_select+"&begin="+escape(begin)+"&end="+escape(end),true);
           //  document.getElementById ("message").style.display="block";
            xmlhttp.onreadystatechange=function(){              
            if(xmlhttp.readyState==4){  
                  if(xmlhttp.status==200){
                   //   document.getElementById ("message").style.display="none";
                       if(xmlhttp.responseText!=""){  
                       
               //alert(xmlhttp.responseText)
                price=parseFloat(xmlhttp.responseText);
                              }     
                                      
               }
            }
         }
         xmlhttp.send(null);  
         
           if (zuowei_value=="")
{
//alert("请选择教室和座位号!!");
erro+="请选择教室和座位号!!\n";
}
if (begin=="" || end=="")
{
erro+="请选择上课日期!!\n";
}
else
{
var d1 = new Date(begin.replace("-","/"));   
var d2 = new Date(end.replace("-","/"));   

 if( Date.parse(d1) - Date.parse(d2)>0)   
{ 
   erro+="开始日期应小于结束日期!!\n";
}
//erro+="开始日期应小于结束日期!!\n";
}

//if (begin=="" && end==""  )
//{
//errom+="请选择上课时间段!!";
//}
if (erro=="")
{


document.getElementById("count").value=parseInt(document.getElementById("count").value)+1; 
//alert("课程"+couser_select+"座位"+zuowei_value+"时间"+time_select)
c_value.value+=couser_select+"|"+zuowei_value+"|"+time_select+"|"+"^";
//alert(c_value.value );
Get_Course();
GET_ClassROOM();
document.getElementById("zuowei").innerHTML=""; 
GET_time();
//alert(document.getElementById("count").value)


document.getElementById("ccc").innerHTML+="<div style='padding-top:10px;padding-bottom:10px' id='div_"+parseInt(document.getElementById("count").value)+"' >课程名 "+ document.getElementById("course_select").options[document.getElementById("course_select").selectedIndex].text+" 教室 "+document.getElementById ("room").value+" 座位号 "+zuowei_value.split(',')[1]+ " 上课时间 "+document.getElementById("time_select").options[document.getElementById("time_select").selectedIndex].text+" 上课日期 "+begin+"至" + end +" 学费 "+price+"<input class='button_r' type='button'value='删除'onclick=dell_course("+couser_select+",'"+escape(zuowei_value) +"',"+time_select+","+parseInt(document.getElementById("count").value)  +","+price +") />  </div>";

document.getElementById("total").value=parseFloat(document.getElementById("total").value)+price;
document.getElementById ("show_price").innerHTML="总费用:"+document.getElementById ("total").value;
$('#div_win').dialog('close');

}
else
{
alert(erro)

}
            
}
//----------------


function Get_ter(){
            var xmlhttp=getXMLHTTP();
            var count=10;
         
     
            xmlhttp.open("Get","Ashx/Get_ter.ashx",true);
           //  document.getElementById ("message").style.display="block";
            xmlhttp.onreadystatechange=function(){              
            if(xmlhttp.readyState==4){  
                  if(xmlhttp.status==200){
                   //   document.getElementById ("message").style.display="none";
                       if(xmlhttp.responseText!=""){  
                
               
                  document.getElementById("ter").innerHTML=xmlhttp.responseText;
                              }             
               }
            }
         }
         xmlhttp.send(null);       
}
//------------
function getArgs(strParame) {
         var args = new Object();
         var query = location.search.substring(1); // Get query string
         var pairs = query.split("&"); // Break at ampersand
         for (var i = 0; i < pairs.length; i++) {
             var pos = pairs[i].indexOf('='); // Look for "name=value"
             if (pos == -1) continue; // If not found, skip
             var argname = pairs[i].substring(0, pos); // Extract the name
             var value = pairs[i].substring(pos + 1); // Extract the value
             value = decodeURIComponent(value); // Decode it, if needed
             args[argname] = value; // Store as a property
         }
         return args[strParame]; // Return the object
     }
//===============
function get_stu_detail()
{
 var xmlhttp=getXMLHTTP();
            var count=10;
         
            
           // alert(getArgs("user"))
            xmlhttp.open("Get","Ashx/get_stu_detail.ashx?user="+getArgs("user"),true);
           //  document.getElementById ("message").style.display="block";
            xmlhttp.onreadystatechange=function(){              
            if(xmlhttp.readyState==4){  
                  if(xmlhttp.status==200){
                   //   document.getElementById ("message").style.display="none";
                       if(xmlhttp.responseText!=""){  
               
               
                  document.getElementById("show_detaile").innerHTML=xmlhttp.responseText;
                              }             
               }
            }
         }
         xmlhttp.send(null);       


}
//---------------------------
function denglu()
{
 var xmlhttp=getXMLHTTP();
            var count=10;
         var user=document.getElementById ("username").value;
         var pwd=document.getElementById ("password").value;
            
           
            xmlhttp.open("Get","Ashx/denglu.ashx?user="+escape(user)+"&pwd="+escape(pwd),true);
           //  document.getElementById ("message").style.display="block";
            xmlhttp.onreadystatechange=function(){              
            if(xmlhttp.readyState==4){  
                  if(xmlhttp.status==200){
                   //   document.getElementById ("message").style.display="none";
                       if(xmlhttp.responseText!=""){  
               
             if (xmlhttp.responseText=="1")
             {
               
                window.location.href="stu_index.aspx";
                }
                else 
                {
                  alert("用户名或密码错误!!!")
                              
                              document.getElementById ("username").value="";
                              document.getElementById ("password").value="";
                }
               //  document.getElementById("ww").innerHTML=xmlhttp.responseText;
                              }     
                                
               }
            }
         }
         xmlhttp.send(null);       


}


//-

