﻿
function xmlLessonFlash(name,xmlFile){
	this.name         = name;      
	this.xmlFile      = xmlFile;     
}

/********************************************************************
 功能： 创建 document 对象
 类型： 
 参数：	 无
 返回值: 无
 创建人: zxw			更改时间：06/06/08 10:43
********************************************************************/
var newword_is_ie = true;
xmlLessonFlash.prototype.createXMLDOM = function(fileRoute){ //生成XMLDOM对象
	/*var xmldom;
	var agt = navigator.userAgent.toLowerCase();
        newword_is_ie = (agt.indexOf("msie")!=-1 && document.all);
        
	if (window.ActiveXObject){
		var xmldom = new ActiveXObject("Microsoft.XMLDOM");
	} else {
		if (document.implementation && document.implementation.createDocument) {
			var xmldom = document.implementation.createDocument("","doc",null);
		}
	}
	xmldom.async = false;
	xmldom.resolveExternals = false;
	xmldom.validateOnParse = false;
	xmldom.preserveWhiteSpace = true;
	return xmldom;  */
    var agt = navigator.userAgent.toLowerCase();
        newword_is_ie = (agt.indexOf("msie")!=-1 && document.all);
            
    xmlhttp=null;
    if (window.XMLHttpRequest)
    { // code for all new browsers
       xmlhttp=new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {// code for IE5 and IE6
       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (xmlhttp!=null)
    {
      //xmlhttp.onreadystatechange=state_Change;
      xmlhttp.open("GET",fileRoute,false);
      xmlhttp.send(null);
      xmlDoc = xmlhttp.responseXML;//.documentElement;
    }
    else
    {
      alert("Your browser does not support XMLHTTP.");
      xmlDoc = null;
    }  
    return xmlDoc;     
}

/********************************************************************
 功能： 创建生成HTML
 类型：  createCourse() 读取课程的xml文件并把它转换成html
 	getElementById(String elementId) 根据给定的id去找对应的元素
 参数：	 无
 返回值: 无
 创建人: zxw			更改时间：06/06/08 10:43
********************************************************************/
xmlLessonFlash.prototype.createHtml = function(){
	var xmldom = this.createXMLDOM(this.xmlFile);
	if (xmldom) {
		this.createFlash(xmldom);
	} else {
		this.html = 'Load XML Error';
	}
}
/*************************
功能：判断是否有Flash
**************************/
xmlLessonFlash.prototype.createIsHtml = function(){
	var xmldom = this.createXMLDOM(this.xmlFile);
	if (xmldom) {
		this.createIsFlash(xmldom);
	} else {
		this.html = 'Load XML Error';
	}
}

/********************************************************************
 功能： 课程内容的生成
 类型： 接口函数
 参数：	obj: 需要读取的xml文件的对象
        id： 判断传入的节点 id为null时为根节点        
        getElementsByTagName(String tagname) 返回标签名字为tagname的所有元素
        item(i)  按照给定的索引返回节点
 返回值: 无
 创建人: zxw			更改时间：06/06/08 10:43
********************************************************************/
xmlLessonFlash.prototype.createFlash = function(obj, id){
	//flash 显示
	  var unCorIdflashnum = "zxw";
	  var nodes = obj.getElementsByTagName('flash');
	  var nodesflashnum = nodes.length;
	  var outstr = "";
	  var flashshowlist ="<div class='greenbox'><h2><b></b>Other Flash of this Lesson</h2><ul>";		
	  for (var i=0; i < nodesflashnum; i++){
	  	xmle = nodes.item(i);
	  	flashfile = xmle.getAttribute("src").replace("\\","/");
	  	if(i == showi){
			outstr += "<object id='flashlesson' style='width:500px;height:490px' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0'>";
			outstr += "   <param name='movie' value='"+basepath+"flashplay.swf'>";
		        outstr += "   <param name='flashvars' value='vpath="+path+"/"+flashfile+"'>";
    
            		outstr += "<embed src='"+basepath+"flashplay.swf' flashvars='vpath="+path+"/"+flashfile+"' style='width:500px;height:490px' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed></object>";
	  	}
	        if(i == showi)
                   flashshowlist += "<li><img src='"+basepath+"_images/bullet_go.gif'>&nbsp;"+i+"、Flash</li>";
                else
                   flashshowlist += "<li>&nbsp;&nbsp;&nbsp;&nbsp;<a href='"+basepath+"index.php/Video/index/"+lessonid+"/"+lessontype_id+"/"+i+"'  title='flash'>  &nbsp;"+i+"、Flash</a></li>";
            
	  }
	 flashshowlist +="</ul><b class='xbottom'><b class='xb4'></b><b class='xb3'></b><b class='xb2'></b><b class='xb1'></b></b> </div>"; 

	 if (nodesflashnum > 1)
	  document.getElementById("flashlist").innerHTML = flashshowlist;
	 document.getElementById("videoflash").innerHTML = outstr;
}

/***************************
功能：判断是否有Flash
****************************/
var SYSnodesflashnum = 0;
xmlLessonFlash.prototype.createIsFlash = function(obj, id){
	//flash 显示
	  var nodes = obj.getElementsByTagName('flash');
	  SYSnodesflashnum = nodes.length;
}

/*************************
功能：判断是否有exer
**************************/
xmlLessonFlash.prototype.createIsExer = function(){
	var xmldom = this.createXMLDOM(this.xmlFile);
	if (xmldom) {
		this.createIsExernum(xmldom);
	} else {
		this.html = 'Load XML Error';
	}
}

var SYSnodesexernum = 0;
xmlLessonFlash.prototype.createIsExernum = function(obj, id){
	//flash 显示
	  var nodes = obj.getElementsByTagName('subject');
	  SYSnodesexernum = nodes.length;
}
