//create by duncan
/*
 * cookies类
 */
var Cookies=new Object();

/**
 * 通过名称取cookie值
 * cookieName    cookie名
 */
Cookies.getCookie=function(/*String*/ cookieName){
  document.cookie= "history='' path=/; domain=www.netfilm.cn; expires="+new Date((new Date()).getTime() - 10000) ;
  var cookies = document.cookie;
  var finder = cookies.indexOf(cookieName + '=');
  if (finder == -1) // 找不到
    return null;
  finder += cookieName.length + 1;
  var end = cookies.indexOf(';', finder);
  if (end == -1) return unescape(cookies.substring(finder));
  var value = unescape(cookies.substring(finder, end));
 
  if(!value){
  	value = '';
  }
  return unescape(value);
	
};
/**
 * 向cookie写入数据
 * @param cookieName  cookie名
 * @param value    cookie值
 * @param time    保存时间 如果为null 则保存一年
 */
Cookies.addCookie=function(/*String*/ cookieName,/*String*/ value,/*String*/ time){
	var expires = null;
	if(time!=null){
		expires = time;
	}else{
		expires = new Date((new Date()).getTime() + 1*56*24*60* 60000);//设置cookis保存的时间为一年
	}
	document.cookie= cookieName + "="+escape(value)+ "; expires=" + expires.toGMTString() + "; path=/; domain=www.netfilm.cn;" ;
};

/**
 * @param cookieName    cookie名
 */
Cookies.deleteCookie=function(/*String*/ cookieName){
	var value = Cookies.getCookie(cookieName);
	var expires = new Date();
	expires.setTime  (expires.getTime()  -  1);
	Cookies.addCookie(cookieName,value,expires);
};
//要屏蔽哪些电影，写在这里即可
var arrmovie=["1"];


//如果踩中地雷弹出下面的语句
var tipyuju="该影片为黄金VIP用户方可观看，请发送6到1066077068成为黄金VIP用户";
window.dhtmlHistory = {
    initialize: function() {
      if (this.isInternetExplorer() == false) {
         return;
      }

      if (historyStorage.hasKey("DhtmlHistory_pageLoaded") == false) {
         this.fireOnNewListener = false;
         this.firstLoad = true;
         historyStorage.put("DhtmlHistory_pageLoaded", true);
      }
      else {
         this.fireOnNewListener = true;
         this.firstLoad = false;   
      }
   },
             
   addListener: function(callback) {
      this.listener = callback;
      if (this.fireOnNewListener == true) {
         this.fireHistoryEvent(this.currentLocation);
         this.fireOnNewListener = false;
      }
   },
   
    add: function(newLocation, historyData) {
      var self = this;
      var addImpl = function() {
         if (self.currentWaitTime > 0)
            self.currentWaitTime = self.currentWaitTime - self.WAIT_TIME;
         newLocation = self.removeHash(newLocation);
         var idCheck = document.getElementById(newLocation);
         if (idCheck != undefined || idCheck != null) {
            var message = 
               "Exception: History locations can not have "
               + "the same value as _any_ id's "
               + "that might be in the document, "
               + "due to a bug in Internet "
               + "Explorer; please ask the "
               + "developer to choose a history "
               + "location that does not match "
               + "any HTML id's in this "
               + "document. The following ID "
               + "is already taken and can not "
               + "be a location: " 
               + newLocation;
               
            throw message; 
         }
         historyStorage.put(newLocation, historyData);
         self.ignoreLocationChange = true;
         this.ieAtomicLocationChange = true;
         self.currentLocation = newLocation;
         window.location.hash = newLocation;
         if (self.isInternetExplorer())
            self.iframe.src = "blank.html?" + newLocation;
         this.ieAtomicLocationChange = false;
      };
      window.setTimeout(addImpl, this.currentWaitTime);
      this.currentWaitTime = this.currentWaitTime + this.WAIT_TIME;
   },
   
   isFirstLoad: function() {
      if (this.firstLoad == true) {
         return true;
      }
      else {
         return false;
      }
   },
   
   isInternational: function() {
      return false;
   },
   
   getVersion: function() {
      return "0.05";
   },
   
   getCurrentLocation: function() {
      var currentLocation = this.removeHash(window.location.hash);
      
      return currentLocation;
   },
   currentLocation: null,
   
   listener: null,
   
   iframe: null,
   
   ignoreLocationChange: null,
 
   WAIT_TIME: 200,

   currentWaitTime: 0,
   
   fireOnNewListener: null,
   
   firstLoad: null,
   
   ieAtomicLocationChange: null,          
   
   create: function() {
      var initialHash = this.getCurrentLocation();
      this.currentLocation = initialHash;
      if (this.isInternetExplorer()) {
         document.write("<iframe style='border: 0px; width: 1px; "
                               + "height: 1px; position: absolute; bottom: 0px; "
                               + "right: 0px; visibility: visible;' "
                               + "name='DhtmlHistoryFrame' id='DhtmlHistoryFrame' "
                               + "src='blank.html?" + initialHash + "'>"
                               + "</iframe>");
         this.WAIT_TIME = 400;
      }

      var self = this;
      window.onunload = function() {
         self.firstLoad = null;
      };
      if (this.isInternetExplorer() == false) {
         if (historyStorage.hasKey("DhtmlHistory_pageLoaded") == false) {
            this.ignoreLocationChange = true;
            this.firstLoad = true;
            historyStorage.put("DhtmlHistory_pageLoaded", true);
         }
         else {
            this.ignoreLocationChange = false;
            this.fireOnNewListener = true;
         }
      }
      else {
         this.ignoreLocationChange = true;
      }
      
      if (this.isInternetExplorer()) {
            this.iframe = document.getElementById("DhtmlHistoryFrame");
      }                                                              
      var self = this;
      var locationHandler = function() {
         self.checkLocation();
      };
      setInterval(locationHandler, 100);
   },
   
   /** Notify the listener of new history changes. */
   /** private */ fireHistoryEvent: function(newHash) {
      // extract the value from our history storage for
      // this hash
      var historyData = historyStorage.get(newHash);

      // call our listener      
      this.listener.call(null, newHash, historyData);
   },
   
   checkLocation: function() {
      // ignore any location changes that we made ourselves
      // for browsers other than Internet Explorer
      if (this.isInternetExplorer() == false
         && this.ignoreLocationChange == true) {
         this.ignoreLocationChange = false;
         return;
      }
      if (this.isInternetExplorer() == false
          && this.ieAtomicLocationChange == true) {
         return;
      }
      
      // get hash location
      var hash = this.getCurrentLocation();
      
      // see if there has been a change
      if (hash == this.currentLocation)
         return;
      this.ieAtomicLocationChange = true;
      
      if (this.isInternetExplorer()
          && this.getIFrameHash() != hash) {
         this.iframe.src = "blank.html?" + hash;
      }
      else if (this.isInternetExplorer()) {
         // the iframe is unchanged
         return;
      }
         
      // save this new location
      this.currentLocation = hash;
      
      this.ieAtomicLocationChange = false;
      
      // notify listeners of the change
      this.fireHistoryEvent(hash);
   },  

   /** Gets the current location of the hidden IFrames
       that is stored as history. For Internet Explorer. */
   /** private */ getIFrameHash: function() {
      // get the new location
      var historyFrame = document.getElementById("DhtmlHistoryFrame");
      var doc = historyFrame.contentWindow.document;
      var hash = new String(doc.location.search);

      if (hash.length == 1 && hash.charAt(0) == "?")
         hash = "";
      else if (hash.length >= 2 && hash.charAt(0) == "?")
         hash = hash.substring(1); 
    
    
      return hash;
   },          
   
   /** Removes any leading hash that might be on a location. */
   /** private */ removeHash: function(hashValue) {
      if (hashValue == null || hashValue == undefined)
         return null;
      else if (hashValue == "")
         return "";
      else if (hashValue.length == 1 && hashValue.charAt(0) == "#")
         return "";
      else if (hashValue.length > 1 && hashValue.charAt(0) == "#")
         return hashValue.substring(1);
      else
         return hashValue;     
   },          
   
   /** For IE, says when the hidden iframe has finished loading. */
   /** private */ iframeLoaded: function(newLocation) {
      // ignore any location changes that we made ourselves
      if (this.ignoreLocationChange == true) {
         this.ignoreLocationChange = false;
         return;
      }
      
      // get the new location
      var hash = new String(newLocation.search);
      if (hash.length == 1 && hash.charAt(0) == "?")
         hash = "";
      else if (hash.length >= 2 && hash.charAt(0) == "?")
         hash = hash.substring(1);
      
      // move to this location in the browser location bar
      // if we are not dealing with a page load event
      if (this.pageLoadEvent != true) {
         window.location.hash = hash;
      }

      // notify listeners of the change
      this.fireHistoryEvent(hash);
   },
   
   /** Determines if this is Internet Explorer. */
   /** private */ isInternetExplorer: function() {
      var userAgent = navigator.userAgent.toLowerCase();
      if (document.all && userAgent.indexOf('msie')!=-1) {
         return true;
      }
      else {
         return false;
      }
   }
};
window.historyStorage = {
   /** If true, we are debugging and show the storage textfield. */
   /** public */ debugging: false,
   
   /** Our hash of key name/values. */
   /** private */ storageHash: new Object(),
   
   /** If true, we have loaded our hash table out of the storage form. */
   /** private */ hashLoaded: false, 
   
   /** public */ put: function(key, value) {
       this.assertValidKey(key);
       
       // if we already have a value for this,
       // remove the value before adding the
       // new one
       if (this.hasKey(key)) {
         this.remove(key);
       }
       
       // store this new key
       this.storageHash[key] = value;
       
       // save and serialize the hashtable into the form
       this.saveHashTable(); 
   },
   
   /** public */ get: function(key) {
      this.assertValidKey(key);
      
      // make sure the hash table has been loaded
      // from the form
      this.loadHashTable();
      
      var value = this.storageHash[key];

      if (value == undefined)
         return null;
      else
         return value; 
   },
   
   /** public */ remove: function(key) {
      this.assertValidKey(key);
      
      // make sure the hash table has been loaded
      // from the form
      this.loadHashTable();
      
      // delete the value
      delete this.storageHash[key];
      
      // serialize and save the hash table into the 
      // form
      this.saveHashTable();
   },
   
   /** Clears out all saved data. */
   /** public */ reset: function() {
      this.storageField.value = "";
      this.storageHash = new Object();
   },
   
   /** public */ hasKey: function(key) {
      this.assertValidKey(key);
      
      // make sure the hash table has been loaded
      // from the form
      this.loadHashTable();
      
      if (typeof this.storageHash[key] == "undefined")
         return false;
      else
         return true;
   },
   
   /** Determines whether the key given is valid;
       keys can only have letters, numbers, the dash,
       underscore, spaces, or one of the 
       following characters:
       !@#$%^&*()+=:;,./?|\~{}[] */
   /** public */ isValidKey: function(key) {
      // allow all strings, since we don't use XML serialization
      // format anymore
      return (typeof key == "string");
      
      /*
      if (typeof key != "string")
         key = key.toString();
      
      
      var matcher = 
         /^[a-zA-Z0-9_ \!\@\#\$\%\^\&\*\(\)\+\=\:\;\,\.\/\?\|\\\~\{\}\[\]]*$/;
                     
      return matcher.test(key);*/
   },
   
   
   
   
   /** A reference to our textarea field. */
   /** private */ storageField: null,
   
   /** private */ init: function() {
      // write a hidden form into the page
      var styleValue = "position: absolute; top: -1000px; left: -1000px;";
      if (this.debugging == true) {
         styleValue = "width: 30em; height: 30em;";
      }   
      
      var newContent =
         "<form id='historyStorageForm' " 
               + "method='GET' "
               + "style='" + styleValue + "'>"
            + "<textarea id='historyStorageField' "
                      + "style='" + styleValue + "'"
                              + "left: -1000px;' "
                      + "name='historyStorageField'></textarea>"
         + "</form>";
      document.write(newContent);
      
      this.storageField = document.getElementById("historyStorageField");
   },
   
   /** Asserts that a key is valid, throwing
       an exception if it is not. */
   /** private */ assertValidKey: function(key) {
      if (this.isValidKey(key) == false) {
         throw "Please provide a valid key for "
               + "window.historyStorage, key= "
               + key;
       }
   },
   
   /** Loads the hash table up from the form. */
   /** private */ loadHashTable: function() {
      if (this.hashLoaded == false) {
         // get the hash table as a serialized
         // string
         var serializedHashTable = this.storageField.value;
         
         if (serializedHashTable != "" &&
             serializedHashTable != null) {
            // destringify the content back into a 
            // real JavaScript object
            this.storageHash = eval('(' + serializedHashTable + ')');  
         }
         
         this.hashLoaded = true;
      }
   },
   
   /** Saves the hash table into the form. */
   /** private */ saveHashTable: function() {
      this.loadHashTable();
      
      // serialized the hash table
      var serializedHashTable = JSON.stringify(this.storageHash);
      
      // save this value
      this.storageField.value = serializedHashTable;
   }   
};










/** The JSON class is copyright 2005 JSON.org. */
Array.prototype.______array = '______array';

var JSON = {
    org: 'http://www.JSON.org',
    copyright: '(c)2005 JSON.org',
    license: 'http://www.crockford.com/JSON/license.html',

    stringify: function (arg) {
        var c, i, l, s = '', v;

        switch (typeof arg) {
        case 'object':
            if (arg) {
                if (arg.______array == '______array') {
                    for (i = 0; i < arg.length; ++i) {
                        v = this.stringify(arg[i]);
                        if (s) {
                            s += ',';
                        }
                        s += v;
                    }
                    return '[' + s + ']';
                } else if (typeof arg.toString != 'undefined') {
                    for (i in arg) {
                        v = arg[i];
                        if (typeof v != 'undefined' && typeof v != 'function') {
                            v = this.stringify(v);
                            if (s) {
                                s += ',';
                            }
                            s += this.stringify(i) + ':' + v;
                        }
                    }
                    return '{' + s + '}';
                }
            }
            return 'null';
        case 'number':
            return isFinite(arg) ? String(arg) : 'null';
        case 'string':
            l = arg.length;
            s = '"';
            for (i = 0; i < l; i += 1) {
                c = arg.charAt(i);
                if (c >= ' ') {
                    if (c == '\\' || c == '"') {
                        s += '\\';
                    }
                    s += c;
                } else {
                    switch (c) {
                        case '\b':
                            s += '\\b';
                            break;
                        case '\f':
                            s += '\\f';
                            break;
                        case '\n':
                            s += '\\n';
                            break;
                        case '\r':
                            s += '\\r';
                            break;
                        case '\t':
                            s += '\\t';
                            break;
                        default:
                            c = c.charCodeAt();
                            s += '\\u00' + Math.floor(c / 16).toString(16) +
                                (c % 16).toString(16);
                    }
                }
            }
            return s + '"';
        case 'boolean':
            return String(arg);
        default:
            return 'null';
        }
    },
    parse: function (text) {
        var at = 0;
        var ch = ' ';

        function error(m) {
            throw {
                name: 'JSONError',
                message: m,
                at: at - 1,
                text: text
            };
        }

        function next() {
            ch = text.charAt(at);
            at += 1;
            return ch;
        }

        function white() {
            while (ch != '' && ch <= ' ') {
                next();
            }
        }

        function str() {
            var i, s = '', t, u;

            if (ch == '"') {
outer:          while (next()) {
                    if (ch == '"') {
                        next();
                        return s;
                    } else if (ch == '\\') {
                        switch (next()) {
                        case 'b':
                            s += '\b';
                            break;
                        case 'f':
                            s += '\f';
                            break;
                        case 'n':
                            s += '\n';
                            break;
                        case 'r':
                            s += '\r';
                            break;
                        case 't':
                            s += '\t';
                            break;
                        case 'u':
                            u = 0;
                            for (i = 0; i < 4; i += 1) {
                                t = parseInt(next(), 16);
                                if (!isFinite(t)) {
                                    break outer;
                                }
                                u = u * 16 + t;
                            }
                            s += String.fromCharCode(u);
                            break;
                        default:
                            s += ch;
                        }
                    } else {
                        s += ch;
                    }
                }
            }
            error("Bad string");
        }

        function arr() {
            var a = [];

            if (ch == '[') {
                next();
                white();
                if (ch == ']') {
                    next();
                    return a;
                }
                while (ch) {
                    a.push(val());
                    white();
                    if (ch == ']') {
                        next();
                        return a;
                    } else if (ch != ',') {
                        break;
                    }
                    next();
                    white();
                }
            }
            error("Bad array");
        }

        function obj() {
            var k, o = {};

            if (ch == '{') {
                next();
                white();
                if (ch == '}') {
                    next();
                    return o;
                }
                while (ch) {
                    k = str();
                    white();
                    if (ch != ':') {
                        break;
                    }
                    next();
                    o[k] = val();
                    white();
                    if (ch == '}') {
                        next();
                        return o;
                    } else if (ch != ',') {
                        break;
                    }
                    next();
                    white();
                }
            }
            error("Bad object");
        }

        function num() {
            var n = '', v;
            if (ch == '-') {
                n = '-';
                next();
            }
            while (ch >= '0' && ch <= '9') {
                n += ch;
                next();
            }
            if (ch == '.') {
                n += '.';
                while (next() && ch >= '0' && ch <= '9') {
                    n += ch;
                }
            }
            if (ch == 'e' || ch == 'E') {
                n += 'e';
                next();
                if (ch == '-' || ch == '+') {
                    n += ch;
                    next();
                }
                while (ch >= '0' && ch <= '9') {
                    n += ch;
                    next();
                }
            }
            v = +n;
            if (!isFinite(v)) {
                error("Bad number");
            } else {
                return v;
            }
        }

        function word() {
            switch (ch) {
                case 't':
                    if (next() == 'r' && next() == 'u' && next() == 'e') {
                        next();
                        return true;
                    }
                    break;
                case 'f':
                    if (next() == 'a' && next() == 'l' && next() == 's' &&
                            next() == 'e') {
                        next();
                        return false;
                    }
                    break;
                case 'n':
                    if (next() == 'u' && next() == 'l' && next() == 'l') {
                        next();
                        return null;
                    }
                    break;
            }
            error("Syntax error");
        }

        function val() {
            white();
            switch (ch) {
                case '{':
                    return obj();
                case '[':
                    return arr();
                case '"':
                    return str();
                case '-':
                    return num();
                default:
                    return ch >= '0' && ch <= '9' ? num() : word();
            }
        }

        return val();
    }
};



/** Initialize all of our objects now. */
window.historyStorage.init();
window.dhtmlHistory.create();
//create by duncan
function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    if (arguments.length == 1)
      return element;
    elements.push(element);
  }
  return elements;
};
//通用类
var Common = function(){
	this.targetDiv="";//切换的目标DIV	
	this.message="";//提示信息
	this.type="html";
	this.sync=true;
	/**
	 * 切换DIV内容
	 * @param {Object} targetDiv 目标层
	 * @param {Object} url 请求URL
	 */
	this.switchToContentHTML=function(targetDiv,url,message,sync){
		this.targetDiv=targetDiv;
		this.message=message;		
		var contentLoader=new ContentLoader(url,'',this,"returnRequest");
		if(sync==false){//同步请求
		    this.sync=sync;		
		}
		contentLoader.sync=this.sync;
	    contentLoader.sendRequest();//发送请求
	};
	this.returnRequest=function(http_request){
	   var divContent=http_request.responseText;//获取返回内容
	   if(divContent!=""){
	   	  if(this.type=="html"){
		  	$(this.targetDiv).innerHTML=divContent;//显示DIV内容
		  }else{
		  	$(this.targetDiv).innerText=divContent;//显示DIV内容
		  }	      
	   }       
	   
       if(this.message.length>0){
	   	  alert(this.message);
		  this.message="";
	   }	   
	};	
	
};

//create by duncan
/**
 * XMLHttpRequest数据传输类
 * @param url @type String  要请求的URL
 * @param poststr  @type String|Object  请求参数，如果是对象会自动生成对应的字符串
 * @param component  @type Object  回调响应对象
 * @param method  @typ  Object   回调方法，默认为ajaxUpdate
 */
ContentLoader = function(url,poststr,component,method){
	var urlq = url;
	try{
		var urlSign = "";
		if(url){
			if(url.indexOf("?")!=-1){
				urlSign = "&";
			}else{
				urlSign = "?";
			}
		}
		urlq = url + urlSign + "clearAjaxCache="+ new Date().getTime();
	}catch(e){
	}
	
	this.url = urlq;    //请求URL	
	this.poststr=poststr;     //请求参数	
	this.component = component;    //回调对象
	this.http_request = null;    //存放XMLHttpRequest对象
	this.method=method!=null?method:'ajaxUpdate';         //AJAX的回调方法,默认为ajaxUpdate
	this.sync=true;
};
ContentLoader.prototype = {
	/**
	 * 从获取浏览器获取HttpRequest请求
	 * @return httprequest
	 * private
	 */
	getHttpRequest : function(){
		var http_request;
		if(window.XMLHttpRequest) { 
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) {
				http_request.overrideMimeType('text/xml');
			}
		}
		else if (window.ActiveXObject) {
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		return http_request;
	},	
	/**
	 * 发送请求
	 * public
	 */
	sendRequest : function(){		
		this.http_request = this.getHttpRequest();		
		var oThis  = this;
		oThis.http_request.onreadystatechange = function(){
			oThis.handleAjaxREsponse(oThis.http_request)
		};	
		oThis.http_request.open('post', oThis.url, this.sync);
		oThis.http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");		
		oThis.http_request.send(this.poststr+'&time='+new Date().getTime());
	},	
	/**
	 * 响应服务器信息
	 * private
	 */
	handleAjaxREsponse : function(http_request){
			if (http_request.readyState == 4) { 
	            if (http_request.status == 200) {//连接正常	                   	   	
					if(this.component!=null){
					    this.component[this.method](http_request);	//执行回调函数
					}
	            }		      
	        }
	}	
};
//create by duncan
//相关影片类
var RelateMovie=new Object();
/**
 * 填写相关影片类的DIV内容
 */
RelateMovie.writer=function(){
	var url="/relateMovieAction.do?movieId="+MovieInfo.movieId;
	new Common().switchToContentHTML("relateUL",url,"");	
};




//create by duncan
//电影类
var Movie=function(){
	this.movieId="";//影片ID
	this.name="";//名称
	this.poster="";//小海报路径
}
//最近看过的节目类
var RecentView=new Object();
RecentView.movie=new Movie();//当前影片
//添加看过的节目
RecentView.addMovie=function(){
	var movieList=Cookies.getCookie("movieList");
	var movieStr=this.movie.movieId+"|"+this.movie.name+"|"+this.movie.poster;
	if(movieList==null){		
		Cookies.addCookie("movieList",movieStr);
	}else{
		var movies=movieList.split("#");
		for(var i=0;i<movies.length;i++){
			var movieStrs=movies[i].split("|");
			if(this.movie.movieId==movieStrs[0]){//已存在Cookie中		    
				if(i==1){
					movieList=movieStr+"#"+movies[0];
					if(movies.length>=3){
						movieList=movieList+"#"+movies[2];
					}					
					Cookies.addCookie("movieList",movieList);
				}
				if(i==2){
					movieList=movieStr+"#"+movies[0]+"#"+movies[1];
					Cookies.addCookie("movieList",movieList);
				}
				return;
			}				
		}		
		if(movies.length>=3){
		    movieList=movies[0]+"#"+movies[1];
		}
		movieList=movieStr+"#"+movieList;
		Cookies.addCookie("movieList",movieList);
	}	
};
//获取最近看过的影片
RecentView.getMovies=function(){
    var movies=new Array();
	var movieList=Cookies.getCookie("movieList");
	if(movieList==null){
		return null;
	}
	var movieStrs=movieList.split("#");
	for(var i=0;i<movieStrs.length;i++){
		var movie=new Movie();
		var movieStr=movieStrs[i].split("|");
		movie.movieId=movieStr[0];
		movie.name=movieStr[1];
		movie.poster=movieStr[2];
		movies[i]=movie;
	}
	return movies;
};

//将最近看过的3部电影写到页面
RecentView.writerMovie=function(){
	var movies=RecentView.getMovies();
	if(movies!=null){
		for(var i=0;i<movies.length;i++){
			var movie=movies[i];
			var name=movie.name;
			if(name.length>5){
				name=name.substring(0,5);
			}
			document.write('<li><a target="_blank" href="/MovieDetail.do?movie='+movie.movieId+'"><img src="http://imgc.netfilm.cn/'+movie.poster+'" alt="'+movie.name+'" style="width:60px; height:80px; border:1px solid #999; padding:2px;" border="0" />'+name+'</a></li>');
		}
	}	
	//添加当前的详细页面的影片到最近看过的节目
	RecentView.movie.name=MovieInfo.name;
	RecentView.movie.movieId=MovieInfo.movieId;
	RecentView.movie.poster=MovieInfo.littlePoster;
	RecentView.addMovie();
};





//create by duncan
//投票类
var Vote=new Object();

/**
 * 投票
 * @param {Object} movieId 影片ID
 */
Vote.vote=function(){
	var isVote=Cookies.getCookie("vote"+MovieInfo.movieId);
	if(isVote=="yes"){
		alert("你已经投过票了,不能再投票了!");
		return;
	}
	var score=$('score').value;//获取评分
	var url="/voteAction.do?movieId="+MovieInfo.movieId+"&score="+score;
	new Common().switchToContentHTML("voteDiv",url,"谢谢您参与投票！");
	Cookies.addCookie("vote"+MovieInfo.movieId,"yes");//添加到Cookies表示已对该影片投票
};
/**
 * 写投票情况方法
 * @param {Object} movieId
 */
Vote.writer=function(){
	var url="/voteAction.do?movieId="+MovieInfo.movieId+"&score=0";
	new Common().switchToContentHTML("voteDiv",url,'');
};
//create by duncan
//影评类
var MovieComment=new Object();
/**
 * 向页面写影评内容
 * @param {Object} name 影片名称
 */
MovieComment.writer=function(){
	var url="/movieCommentAction.do?movieId="+MovieInfo.movieId+"&name="+MovieInfo.name;	
	new Common().switchToContentHTML("movieCommentDiv",url,'');	
};
/**
 * 弹出层DIV对象
 * author duncan
 */
var Div=new Object();
/**
 *  创建层
 * @param {Object} width  层的宽度
 * @param {Object} height 层的高度
 * @param {Object} title  层的标题
 * @param {Object} divId  层的ID
 */
Div.createDiv=function(width,height,title,divId,shadowDivId){
	
	var arrayPageSize=this.getWindowSize();
	var windowWidth=arrayPageSize[2];
	var windowHeight=arrayPageSize[3];
	var shadowDIV=document.createElement("div");
	shadowDIV.setAttribute("id",shadowDivId);
	shadowDIV.style.position="absolute";
	shadowDIV.style.top="0";
	shadowDIV.style.background="#CCC";
	shadowDIV.style.filter="alpha(opacity=70)";
    shadowDIV.style.MozOpacity = "166%";
    shadowDIV.style.left="0";

    //获取pageWindth
    shadowDIV.style.width= arrayPageSize[0]+ "px";
    //获取pageHeight
    shadowDIV.style.height= arrayPageSize[1] + "px";
    shadowDIV.style.zIndex = "0";
    //将创建的阴影div加入到body对象中
	document.body.appendChild(shadowDIV);
	
	
	//由于浏览器差别,获取scroll值不同

	var scrollPos; 
	if (typeof window.pageYOffset != 'undefined') { 
	   scrollPos = window.pageYOffset; 
	} 
	else if (typeof document.compatMode != 'undefined' && 
	     document.compatMode != 'BackCompat') { 
	     scrollPos = document.documentElement.scrollTop; 
	} 
	else if (typeof document.body != 'undefined') { 
	   scrollPos = document.body.scrollTop; 
	}  
	

    var borderDiv = document.createElement("div");

    borderDiv.setAttribute("id" ,"borderDiv");
    borderDiv.style.top=((windowHeight/2)-(height/2)+scrollPos) +"px";
    borderDiv.style.position="absolute";    
    borderDiv.style.left=(windowWidth/2)-(width/2)+"px";
    borderDiv.style.width = width + "px";
    borderDiv.style.height = height + "px";
    borderDiv.style.zIndex = "1000";  
    document.body.appendChild(borderDiv);
	


    /**
     *  创建弹出窗口的中间层此层用
     * 窗口的总宽度减去左、右两边的图片宽度等于中意层的宽度
     */
    var titleCenterDiv = document.createElement("div");
    titleCenterDiv.style.cssText = "float:left";
    titleCenterDiv.style.width = document.getElementById('borderDiv').style.width;
   //titleCenterDiv.style.height = "20px";
   
	//titleCenterDiv.style.fontSize="17px";
	//titleCenterDiv.style.fontWeight = "bold";
	//titleCenterDiv.innerText=title;
    borderDiv.appendChild(titleCenterDiv);



    /**
     * 创建弹出窗口的关闭窗口的按扭层
     */
    var closeDiv = document.createElement("div");
    closeDiv.setAttribute("id" ,"closeDiv");
    closeDiv.style.cssText = "float:right";
	closeDiv.style.left=(width+75)+"px";
	closeDiv.style.position="absolute";
	closeDiv.style.top=titleCenterDiv.style.top+2;
    closeDiv.style.width = "20px";
    closeDiv.style.height = "20px";
    closeDiv.style.backgroundImage = "url('/movie_detail/img/btn_close_on.png')";
    closeDiv.style.backgroundRepeat = "no-repeat";
    closeDiv.style.cursor = "pointer";
    closeDiv.attachEvent("onclick" ,function(){Div.closeDiv(shadowDivId)});

    titleCenterDiv.appendChild(closeDiv);

    /**	  
     * 创建弹出窗口的窗体，用来在此窗口中显示不同的信息
     * 总窗体的宽度减去窗体边的宽度等于实际窗体的宽度
     * 
     */

    var bodyDiv = document.createElement("div");
    bodyDiv.setAttribute("id" ,divId)
    bodyDiv.style.width = (width-6) + "px";
    bodyDiv.style.height = "100%";
    bodyDiv.style.textAlign="center";
    bodyDiv.style.backgroundColor="#FFF";
    bodyDiv.style.border = "3px #EBEBE9 solid";
    borderDiv.appendChild(bodyDiv);	
};
Div.closeDiv=function(shadowDivId){
	
	document.getElementById('borderDiv').style.display = "none";
    document.getElementById('borderDiv').removeNode(true);
	if(shadowDivId!=""){
		document.getElementById(shadowDivId).style.display = "none";
        document.getElementById(shadowDivId).removeNode(true);
	}	
	if($('scoreSelectDiv')!=null){
		$('scoreSelectDiv').style.visibility="visible";//隐藏投票下拉列表
	}	
};

/**
     *  获取屏幕的大小
     * 并返回
     * pageWidth－－页面宽度
     * pageHeight－－页面高度
     * windowWidth－－窗口宽度
     * windowHeigh－－窗口高度
     *
     */
Div.getWindowSize = function()
	{
	//定义window的x和y的坐标点
	var xScroll, yScroll,pageWidth,pageHeight,arrayPageSize;	
	if( window.innerHeight && window.scrollMaxY )	{
	    xScroll = document.body.scrollWidth;
	    yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if( document.body.scrollHeight > document.body.offsetHeight )	{ // all but Explorer Mac
	    xScroll = document.body.scrollWidth;
	    yScroll = document.body.scrollHeight;
	}
	else{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
	    xScroll = document.body.offsetWidth;
	    yScroll = document.body.offsetHeight;
	}
	//－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－
	//定义window的宽度和高度
	var windowWidth, windowHeight;
	if( self.innerHeight ){    // all except Explorer
	    windowWidth = self.innerWidth;
	    windowHeight = self.innerHeight;
	}
	else if( document.documentElement && document.documentElement.clientHeight ){ // Explorer 6 Strict Mode
	    windowWidth = document.documentElement.clientWidth;
	    windowHeight = document.documentElement.clientHeight;
	}
	else if( document.body ){ // other Explorers
	    windowWidth = document.body.clientWidth;
	    windowHeight = document.body.clientHeight;
	}
	//如果yScroll小于windowHeight那么页面的高度pageHeight=windowHeingt,否则等于yScroll
	if( yScroll < windowHeight ){
	    pageHeight = windowHeight;
	}
	else{
	    pageHeight = yScroll;
	}	
	//如果xScroll小于windowHeight那么页面的宽度pageWidth = windowWidth,否则等于xScroll
	if( xScroll < windowWidth )	{
	    pageWidth = windowWidth;
	}else{
	    pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth ,pageHeight ,windowWidth ,windowHeight);	
	return arrayPageSize;
};
//create by duncan
/**
 * 登陆对象
 */
var Login=new Object();
var UserStatus=1;//是0就是普通用户，其他就是无所谓了
Login.operator="";//操作,登陆成功后调用此操作
var myusername=0;
Login.checkLogin=function(operator){
	this.operator=operator;
	var url="/detailCheckLogin.do?time="+new Date().getTime();//刷新登陆条
	var contentLoader=new ContentLoader(url,'',this,"checkLoginReturn");
	contentLoader.sendRequest();//发送请求
};
/**
 * 判断是否登陆返回函数
 */
Login.checkLoginReturn=function(http_request){
	var tempstatus=http_request.responseText;//获取返回内容
	var temparr = tempstatus.split("|");
	var status = temparr[0];
	UserStatus = temparr[1];
	myusername = temparr[2];
	//alert(myusername+"asdasdasdasd");
	if(status=="success"){//已登陆
		eval(this.operator);
	}else{//未登陆,弹出登陆层
	    if($('scoreSelectDiv')!=null){
			$('scoreSelectDiv').style.visibility="hidden";//隐藏投票下拉列表
		}	    
		Div.createDiv(400,240, "用户登陆","loginDiv","loginShowdowDiv");	
		new Common().switchToContentHTML("loginDiv","/movie_detail/login.jsp","",false);	
		$('username1').focus();//
	}
};
/**
 * 详细页登陆
 */
Login.login=function(){
	var username=$('username1').value;
	if(username.length==0){
		$('messageDiv').style.visibility="visible";
		$('messageDiv').innerHTML="请输入用户名！";
		return;
	}
	var password=$('password1').value;
	if(password.length==0){
		$('messageDiv').style.visibility="visible";
		$('messageDiv').innerHTML="请输入登陆密码！";
		return;
	}
	var url="/detailLogin.do?username="+username+"&password="+password;
	var contentLoader=new ContentLoader(url,'',this,"loginReturn");
	contentLoader.sendRequest();//发送请求
};
/**
 * 登陆回调函数
 */
Login.loginReturn=function(http_request){
	var status=http_request.responseText;//获取返回内容
	if(status=="success"){//登陆成功
	    Div.closeDiv('loginShowdowDiv');//关闭登陆层	  
	    try{
			window.frames["checkLoginIframe"].location.reload();
		}catch(e){
		}  
		try{
			window.frames["headFrame"]["checkLoginIframe"].location.reload(); 
		}catch(e){
		}
		//eval(this.operator);
		//headFrame.document.getElementById('checkLoginIframe').src="/checkLogin.do?time="+new Date().getTime();//刷新登陆条
	}else{//未登陆,弹出登陆层
	    $('messageDiv').style.visibility="visible";
		$('messageDiv').innerHTML="用户名或密码错误!";
	}
};
//create by duncan
//收藏类
var Collect=new Object();
Collect.collect=function(){
	var url="/collectAction.do?movieId="+MovieInfo.movieId;
	var contentLoader=new ContentLoader(url,'',this,"collectReturn");
	contentLoader.sendRequest();//发送请求
};
/**
 * 收藏返回接口
 */
Collect.collectReturn=function(http_request){
	var status=http_request.responseText;//获取返回内容
	if(status=="success"){//
		alert("收藏成功,已将此影片添加到用户中心!");
	}else{
		alert("系统繁忙,请稍后再试!");
	}
};
function doPlayMovie(p){
	var play_url = '/client_info.jsp?movie='+p;
	var win =window.open(play_url,"","left=350,top=150,height=510,width=500");
	win.focus();
};

function showSubList() {
  var subList=document.getElementById('openSubListDiv');
  subList.style.position="absolute";  
  subList.style.top = $('subDiv').offsetTop+787+"px";   
  subList.style.left = $('subDiv').offsetLeft+155+"px";
  subList.style.display="block";
};
function showSubList1() {
  var subList=document.getElementById('openSubListDiv');
  subList.style.position="absolute";  
  subList.style.top =722+"px";   
  subList.style.left =147+"px";
  subList.style.display="block";
};
function closeSubListDiv(){
	document.getElementById('openSubListDiv').style.display='none';
};


/*
  *  javascript泛型类库.
*/
var Hash = function(h){    
    this._data = new Object();
}
    function Hash$clear(){
        delete this._data;
        this._data = new Object();    
    }        
    function Hash$add(key,value){
        if(!key || typeof(value) === 'undefined') return false;                
        this._data[key] = {key: key,value: value};
        return true;
    }
    function Hash$addRange(h){
        for(var key in h._data){
            var item = h._data[key];
            if(typeof(item) !== 'undefined'){
                this.add(item.key,item.value);
            }
        }
    }
    function Hash$remove(key){
        if(!key) return undefined;
        var item = this._data[key];    
        delete this._data[key];
        return item;
    }
    function Hash$removeAt(index){
        if(isNaN(index)) return undefined;
        var i = 0;        
        for(var key in this._data){
            if(i == index){
                return this.remove(key);
            }
            i++;
        }
        return undefined;
    }
    function Hash$removeRange(startIndex,endIndex){
        if(isNaN(startIndex) || isNaN(endIndex)) return undefined;
        var i = 0;
        var h = new Hash();
        for(var key in this._data){
            if(i >= startIndex && i<= endIndex){
                h.add(key,this.remove(key).value);
            }
            i++;
        }
        return h;
    }    
    function Hash$getCount(){
        var i = 0;
        for(var key in this._data) i++;       
        return i;
    }
    function Hash$forEach(method,instance){
        var i = 0;
        for(var key in this._data){
            var item = this._data[key];
            if(typeof(item) !== 'undefined'){
                method.call(instance, item, i, this);
                i++;
            }else{
                delete this._data[key];
            }
        }
    }
    function Hash$getKeys(){
        var arr = new Array();
        for (var key in this._data){
            var item = this._data[key];
            arr.push(item.key);
        }
        return arr;
    }
    function Hash$getValues(){
        var arr = new Array();
        for (var key in this._data){
            var item = this._data[key];
            arr.push(item.value);
        }
        return arr;        
    }
    function Hash$getItem(key){
        if(!key) return undefined;
        var item = this._data[key];
        if (typeof(item) !== 'undefined'){
            return item.value;                        
        }else{
            delete this._data[key];
            return undefined;
        }        
    }
    function Hash$containsKey(key){        
        if(typeof(this.getItem(key)) !== 'undefined'){
            return true;
        }
        return false;
    }
    function Hash$containsValue(value){
        for(var key in this._data){        
            if(value === this._data[key].value){
                return true;
            }
        }
        return false;    
    }
Hash.prototype = {
    _data : null,
    _keys : null,
    clear : Hash$clear,
    add : Hash$add,
    addRange : Hash$addRange,
    remove : Hash$remove,
    removeAt : Hash$removeAt,
    removeRange : Hash$removeRange,
    getCount : Hash$getCount,
    forEach : Hash$forEach,
    getKeys : Hash$getKeys,
    getValues : Hash$getValues,
    getItem: Hash$getItem,
    containsKey: Hash$containsKey, 
    containsValue: Hash$containsValue
}
Hash.__typeName = 'Hash';
Hash.__class = true;
//create by duncan
/**
 * js压缩图片
 */
var DrawImage=new Object();

DrawImage.draw=function(ImgD,iwidth,iheight){
	//参数(图片,允许的宽度,允许的高度) 
	var flag=false; 
    var image=new Image(); 
    image.src=ImgD.src; 
    if(image.width>0 && image.height>0){ 
    flag=true; 
    if(image.width/image.height>= iwidth/iheight){ 
        if(image.width>iwidth){   
        ImgD.width=iwidth; 
        ImgD.height=(image.height*iwidth)/image.width; 
        }else{ 
        ImgD.width=image.width;   
        ImgD.height=image.height; 
        } 
        } 
    else{ 
        if(image.height>iheight){   
        ImgD.height=iheight; 
        ImgD.width=(image.width*iheight)/image.height;         
        }else{ 
        ImgD.width=image.width;   
        ImgD.height=image.height; 
        }         
        } 
    } 
	
};
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
};

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
};

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
};

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//create by duncan
/**
 * 扩展查看影片详细信息
 */
var ExtendRead=new Object();
ExtendRead.readDivId="extendReadDiv";//扩展信息的DIV的ID
ExtendRead.content="";//扩展信息
/**
 * 打开
 */
ExtendRead.openRead=function(){
	if(this.content.length>0){
		$(this.readDivId).innerHTML=this.content;
		$('extendTitle').innerHTML='<a href="javascript:ExtendRead.closeRead()"><strong>[关闭展开]</strong></a>&nbsp;&nbsp;&nbsp;&nbsp';
		return;
	}
	var url="extendRead.do?movieId="+MovieInfo.movieId;
	var common=new Common();
	common.type="text";
	common.switchToContentHTML(this.readDivId,url,'',false);
	$('extendTitle').innerHTML='<a href="javascript:ExtendRead.closeRead()"><strong>[关闭展开]</strong></a>&nbsp;&nbsp;&nbsp;&nbsp';	
};
/**
 * 关闭
 */
ExtendRead.closeRead=function(){
	
	$('extendTitle').innerHTML='<a href="javascript:ExtendRead.openRead()"><strong>[展开全部]</strong></a>&nbsp;&nbsp;&nbsp;&nbsp';
	this.content=$(this.readDivId).innerHTML;
	$(this.readDivId).innerHTML="";
};
var MovieInfo=function(){
	this.movieId="";//影片ID
	this.name="";//影片名称
	this.bigPoster="";//大海报
	this.littlePoster="";//小海报
	this.directorClass=5;//导演评分,
    this.sprightlyClass=5;//演技评分
    this.dubClass=5;//原音评分
    this.sceneClass=5;//镜头评分
    this.shearClass=5;//剪切评分
    this.dramaClass=5;//编剧评分
    this.amusementClass=5;//娱乐评分
    this.stuntClass=5;//特技评分
    this.integrateClass=5;//综合评分
    this.suitablePerson="";//适合人群
    this.clickCount;//点播次数
    this.collectCount;//收藏次数
    this.commentCount;//影评数
    this.type;//0为电影,1为电视剧,2为TVB电视剧
    this.channel;//导航条
};












//create by duncan
/**
 * 查看影片版权信息对象
 */
var ViewVersion=new Object();
ViewVersion.isClose=false;
ViewVersion.download=false;//是否已下载
ViewVersion.view=function(){
	if(this.download){
		$('versionDiv').style.display="block";
		this.isClose=false;
		return;
	}
	var url="viewVersion.do?movieId="+MovieInfo.movieId;
	var contentLoader=new ContentLoader(url,'',this,"returnVersion");
    contentLoader.sendRequest();//发送请求
};
ViewVersion.close=function(){
	$('versionDiv').style.display="none";
	ViewVersion.isClose=true;
};
ViewVersion.returnVersion=function(http_request){
	var viewText=http_request.responseText;//获取返回结果
	var versionDiv = document.createElement("div");
	versionDiv.setAttribute("id" ,"versionDiv");
    versionDiv.style.position="absolute";  
    versionDiv.style.top = 440+"px";   
    versionDiv.style.left =560+"px";
	versionDiv.innerHTML=viewText;
	versionDiv.style.display="block";
    document.body.appendChild(versionDiv);
	document.onmousedown=ViewVersion.close;
	this.isClose=false;
	this.download=true;
};


//create by duncan
//页面箱子类,用于装载分页后的页面
var PageBox=function(){
	this.pages=new Hash();
	/**
	 * 添加访问过的页面到箱中
	 * @param url 为页面请求的URL地址
	 * @param page type String 页面字符串
	 * 
	 */
	this.addPage=function(url,page){
		this.pages.add(url,page);//添加页面
	};
	/**
	 * 
	 *通过请求url从页面箱中获取相应的页面
	 *@param url 请求分页的URL
	 */
	 this.getPage=function(url){
	 	return this.pages.getItem(url);
	 };
	/**
	 * 删除对应URL的页面
	 * @param url 请求URL
	 */
	this.deletePage=function(url){
		this.pages.remove(url);
	};
	/**
	 * 清空页面箱中所有的职位
	 */
	this.clearPage=function(){
		this.pages.clear();
	};
	/**
	 * 获取所有页面箱中的所有的页面,以数组方式返回
	 */
	this.getAllPages=function(){
		return this.pages.getValues();
	};
	/**
	 * 获取所有页面箱中的所有的请求URL列表,以数组方式返回
	 */
	this.getAllPageNo=function(){
		return this.pages.getKeys();
	};
	/**
	 * 获取页面箱中的保存的页面总数
	 */
	this.getSize=function(){
	   return this.pages.getCount();
    };
};
//create by duncan
//列表分页支持类
var Page =new Object();
Page.replaceDiv="centerContentDiv";//替换层DIV的ID
Page.pageBox=new PageBox();//页面箱,用于保存已请求的页面
Page.url="";//请求URL
Page.pageNo=1;//当前页
Page.totalPage=1;//总页数
Page.viewType="0";//显示方式,0为标准显示方式(默认),1为列表方式显示
Page.isExist=false;//控制同步请求
/**
 * 初始化请求URL
 */
Page.send=function(){ 
	if($('totalPage')!=null){
		this.totalPage=$('totalPage').value;
	}
	if(this.pageNo<1||this.pageNo>this.totalPage){
          return false; 
    }
	this.createURL();//初始URL	
	if(this.pageBox.getPage(this.url)!=null){//此分页页面已访问过,直接从页面箱中获取显示
		$(this.replaceDiv).innerHTML=this.pageBox.getPage(this.url);
		return false;
	}	
	var contentLoader=new ContentLoader(this.url,'',this,"pageReturn");
    contentLoader.sendRequest();//发送请求
};
/**
 * 
 */
Page.createURL=function(){
    var movieId=MovieInfo.movieId;	
	if(this.viewType=="0")
	{
		this.url="/LinkIntro.do?movieId="+movieId+"&pageNo="+this.pageNo;
	}
	else if(this.viewType=="1")
	{
		this.url="/LinkDetail.do?movieId="+movieId+"&pageNo="+this.pageNo;
	}
};
/**
 * 跳到下一页
 */
Page.goToNextPage=function(){
	this.pageNo=parseInt($('pageNo').value)+1;
	this.send();	
};
/**
 * 跳到上一页
 */
Page.goToUpPage=function(){
	this.pageNo=parseInt($('pageNo').value)-1;
	this.send();
};

Page.changeViewType=function(viewType){  
  if(this.isExist==true){
  	 return;
  }
  this.viewType=viewType;
  this.isExist=true;
  this.send();
};
/**
 * 跳到某一页
 */
Page.goToPage=function(pageNo){
	this.pageNo=parseInt(pageNo);
	this.send();
};
/**
 *跳到首页
 */
Page.gotoIndexPage=function(){
	this.pageNo=1;
	this.send();
};
/**
 * 跳到未页
 */
Page.gotoEndPage=function(){
	this.pageNo=$('totalPage').value;
	this.send();
};
Page.pageReturn=function(http_request){
	var page=http_request.responseText;//获取返回列表
    $(this.replaceDiv).innerHTML=page;//替换分页内容
    this.pageBox.addPage(this.url,page);//添加page到Page箱
    this.isExist=false;
};
//相关片花
var Videos=new Object();
Videos.replaceDiv="centerContentDiv";//替换层DIV的ID
Videos.pageBox=new PageBox();//页面箱,用于保存已请求的页面
Videos.url="";//请求URL
/**
 * 初始化请求URL
 */
 Videos.send=function()
 {
   this.createURL();//初始URL	
   if(this.pageBox.getPage(this.url)!=null){//此分页页面已访问过,直接从页面箱中获取显示
		$(this.replaceDiv).innerHTML=this.pageBox.getPage(this.url);
		return false;
   }	
   var contentLoader=new ContentLoader(this.url,'',this,"videosReturn");
   contentLoader.sendRequest();//发送请求
 };
 /**
 * 
 */
Videos.createURL=function(){
	this.url="/LinkVideos.do?movieId="+MovieInfo.movieId;
};
Videos.videosReturn=function(http_request){
	var page=http_request.responseText;//获取返回列表
	//page=page.replace("#MovieInfo.name#",MovieInfo.name);
	
    $(this.replaceDiv).innerHTML=page;//替换页面内容
    this.pageBox.addPage(this.url,page);//添加page到Page箱
};
/**
 *跳到首页
 */
Videos.gotoIndexPage=function(){
	this.send();
};
function mobileSubmit(){
   var mobile=$('mobile').value;
	if (mobile==""||mobile=="输入您的手机号码"){			
			alert("请填写移动号码、联通号码或者小灵通号码");
			$('mobile').focus();
			return false;
		}
	if (mobile.length !=11){			
			alert("请填写正确的手机号码或者小灵通号码");
			$('mobile').focus();
			return false;
	}
	return true;
};

function checkFocuskMobile(){
   var mobile=$('mobile').value;
   if(mobile=="输入您的手机号码"){
       $('mobile').value="";       
   }
};
function checkOnblurMobile(){
   var mobile=$('mobile').value;
   if(mobile==""){
       $('mobile').value="输入您的手机号码";       
   }
};
function doTestSpeed(){
	var play_url = "/test_speed2.jsp";
	var s=OW('_test',480,230,200,80,false,false,false,false,false,play_url,'modalIframe','');
};
function OW(strName,iW,iH,TOP,LEFT,R,S,SC,T,TB,URL,TYPE,dArg)
{
if (TYPE=="modal" || TYPE=="modalIframe")
{
var sF="";
var _rv;
sF+=T?'unadorned:'+T+';':'';
sF+=TB?'help:'+TB+';':'';
sF+=S?'status:'+S+';':'';
sF+=SC?'scroll:'+SC+';':'';
sF+=R?'resizable:'+R+';':'';
sF+=iW?'dialogWidth:'+iW+'px;':'';
sF+=iH?'dialogHeight:'+(parseInt(iH)+(S?42:0))+'px;':'';
sF+=TOP?'dialogTop:'+TOP+'px;':'';
sF+=LEFT?'dialogLeft:'+LEFT+'px;':'';
if (TYPE=="modal"){
	if(URL.indexOf('?')!=-1)
		URL = URL+"&r="+Math.round(Math.random()*1000000);
_rv=window.showModalDialog(URL,dArg?dArg:"",sF);
}
else
{
var da=new Object()
da.w=iW;
da.h=iH;
da.url=URL;
_rv=window.showModalDialog("/ModalIframe.jsp?r="+Math.round(Math.random()*1000000),da,sF);
}
if ("undefined" != typeof(_rv) )
return _rv;
}
else
{
var sF="";
sF+=iW?'width='+iW+',':'';
sF+=iH?'height='+iH+',':'';
sF+=R?'resizable='+R+',':'';
sF+=S?'status='+S+',':'';
sF+=SC?'scrollbars='+SC+',':'';
sF+=T?'titlebar='+T+',':'';
sF+=TB?'toolbar='+TB+',':'';
sF+=TB?'menubar='+TB+',':'';
sF+=TOP?'top='+TOP+',':'';
sF+=LEFT?'left='+LEFT+',':'';
var var_win = window.open(URL?URL:'about:blank',strName?strName:'',sF);
if(var_win){var_win.focus();}
return var_win;
}
};




//create by duncan
/**
 * 详细页面框架类
 * 用于控制详细页面的各个子模板
 */
var framework=new Object();
framework.templates=new Hash();//用于保存已访问的各个子模板页面
framework.historyData=new Hash();//保存操作历史记录,用于点击"后退"按钮记录
/**
 *当前模板,0为影片概括,1为海报剧照,2为相关片花,3为相关影评,4为相关新闻,
 *5为关联影片,6为本片排行,7为本片评测,8为本片留言,9为本片CLUB 
 */
framework.frame="0"; //当前模板
framework.leftFrame="";//是否已下载模板左边的内容
//切换各个模块
framework.switchTemplate=function(frame){
	if(this.isDownloadLeftFrame==false){
		this.init();
	}
	var frameHTML=$('contentDiv').innerHTML;
	this.templates.add("frame"+this.frame,frameHTML);//保存上一个模块内容
	$('contentDiv').innerHTML="";
	var lastFrameHTML=this.templates.getItem("frame"+frame);
	if(lastFrameHTML==null){//为空则请求该模块
		if(this.leftFrame==""){//页面左边模板还没下载,请求下载,在此使用同步操作
		    var url="/movie_detail/leftFrame.jsp?bigPoster="+MovieInfo.bigPoster;
			url+="&clickCount="+MovieInfo.clickCount+"&collectCount="+MovieInfo.collectCount+"&commentCount="+MovieInfo.commentCount+"&type="+MovieInfo.type;
			new Common().switchToContentHTML("contentDiv",url,"",false);	
			this.leftFrame=$('contentDiv').innerHTML;//设置已下载			
		}else{
			$('contentDiv').innerHTML=this.leftFrame;
		}
		if(frame==1){//海报剧照
		    var url="/photoAction.do?movieId="+MovieInfo.movieId;
			new Common().switchToContentHTML("centerContentDiv",url,"",false);
		}else if(frame==2){//关联电影,下载首页相关片花
			Videos.gotoIndexPage();
		}else if(frame==3){//相关影评
			var url="/movieCommentAction.do?movieId="+MovieInfo.movieId+"&type=1&name="+MovieInfo.name;
			new Common().switchToContentHTML("centerContentDiv",url,"",false);	
		}else if(frame==4){//相关新闻
			$('centerContentDiv').innerHTML='  <div style="float:left;width:515px;margin:0 0 0 2px;background:url(http://imgc.netfilm.cn/movie_detail/img/mid01_02.gif) repeat-y left top;"><div style="width:515px;margin:0px;padding:0px;"><img src="http://imgc.netfilm.cn/movie_detail/img/mid01_01.gif" border="0" /></div><div style="width:500px;margin-left:5px;"><iframe src="http://ent.vv8.com/interface--logic---netfilm_aboutnews----pagenum---1.html" frameborder="0" scrolling="no" width="500" height="500"></iframe></div><div style="width:515px; margin:0px; padding:0px;"><img src="http://imgc.netfilm.cn/movie_detail/img/mid01_03.gif" border="0" /></div></div>';
        }
		else if(frame==5){//关联电影,下载首页关联电影
			Page.gotoIndexPage();
		}else if(frame==7){
			var url="/movie_detail/classComment.jsp?directorClass="+MovieInfo.directorClass+"&sprightlyClass="+MovieInfo.sprightlyClass+"&dubClass="+MovieInfo.dubClass+"&sceneClass="+MovieInfo.sceneClass;
			url+="&shearClass="+MovieInfo.shearClass+"&dramaClass="+MovieInfo.dramaClass+"&amusementClass="+MovieInfo.amusementClass+"&stuntClass="+MovieInfo.stuntClass+"&integrateClass="+MovieInfo.integrateClass+"&suitablePerson="+MovieInfo.suitablePerson;
			new Common().switchToContentHTML("centerContentDiv",url,"",false);	
		}
		
	}else{//不为空,取出上次访问此页面的内容显示
		$('contentDiv').innerHTML=lastFrameHTML;
	}
	this.storeHistory();//添加后退功能
	framework.updateNavigate(frame);
	this.frame=frame;//切换当前模块
};
/**
 * 更新导航条
 */
framework.updateNavigate=function(frame){
	var title=$('frame'+this.frame).innerText;
	$('frame'+this.frame).className="";
	$('frame'+this.frame).innerHTML="<a href=\"javascript:framework.switchTemplate('"+this.frame+"')\">"+title+"</a>";
	title=$('frame'+frame).innerText;
	$('frame'+frame).className="s";//《片名》影片概括 - 相关频道名 - 中国网络院线
	$('frame'+frame).innerHTML=title;
	var titleValue="《"+MovieInfo.name+"》"+title;	
	if(MovieInfo.type==0){
		 titleValue+=" - 电影频道 - 中国网络院线";
	}else if(MovieInfo.type==1){
		 titleValue+=" - 电视剧频道 - 中国网络院线";
	}else if(MovieInfo.type==2){
		 titleValue+=" - TVB频道 - 中国网络院线";
	}		
	document.title=titleValue;
};
/**
 * 初始化后退历史事件记录
 */
framework.init=function(){
	dhtmlHistory.addListener(this.historyChange);
	dhtmlHistory.framework=this;
	this.storeHistory();	
};
/**
 * 保存历史数据
 * @param {Object} content 历史数据
 */
framework.storeHistory=function(){
	var content=$('totalDiv').innerHTML;
	//取系统时间做为锚点
	var time=new Date().getTime();
	dhtmlHistory.add('netfilm:'+time,time);//添加后退锚点
	this.historyData.add(time,content);//记录历史
};
/**
 * 点击"后退"按钮调用此方法
 */
framework.historyChange=function(newLocation,historyData){
	if(historyData==null||historyData.length==0){
		return;
	}
	var content=this.framework.historyData.getItem(historyData);//获取最近操作的HTML代码
	$('totalDiv').innerHTML=content;//设置后退内容
};
/**
 * 更新导航条
 */
framework.updateChannel=function(){
   headFrame.document.getElementById('channelspan').innerHTML=MovieInfo.channel;
};
//create by duncan 2007-10-18
var Player=new Object();//播放对象
Player.playPage="";//播放页面
Player.isMove=false;//是否移动播放窗口
Player.playURL="";//播放地址
Player.playLog=new Hash();//播放日志记录，key为影片ID，value为播放URL,目的为了防止重复请求播放接口
Player.movieId="";//当前播放的影片ID
Player.timer;//定时自动关闭窗口的定时器
Player.count=1;//进度条控制
/**
 * 播放影片
 * @param {Object} movieId 影片ID
 */
 
Player.playByReal = function (){
	location.href=this.playURL     //播放器播放
	$('showPlayMessage').innerHTML="本窗口将会 10 秒后自动关闭！如果您的RealPlayer没有成功打开，请点击<a href='javascript:Player.playOnline()'>&nbsp;</a>" ;		
	clearTimeout(this.timer);//取消上一次的定时自动关闭窗口
	this.timer=setTimeout("Player.close()", 10000);			
}
Player.play=function(movieId){
	//以下初始化参数
	this.movieId=movieId;	
	this.isMove=false;
	this.count=1;
	
	
	var bbhave = new Array();
	//检索这部影片的id是否在禁猎范围内
	for(var q=0;q<arrmovie.length;q++){
			if(movieId==arrmovie[q])
			{
				bbhave[bbhave.length] = arrmovie[q];
			}
		}
	if(bbhave.length>0&&UserStatus==0){
		//不可以观看
		//alert(myusername+"这是realplayer的");
		//try{
		var myck = getCookie(myusername);
		//alert(myck);
		if(myck==1){
			//联盟
			//alert(1);
			twoshowDivlms(myusername);
		}else if(myck==2){
			//钱不够
			//alert(2);
			twoshowDivpays(myusername);
		}else if(myck==4)
			//钱够
			//alert(4);
			twoshowDivs(myusername);
		//}catch(e){
		//alert(e)
		//}
	}else{
		//可以观看
					if(this.playLog.getItem(movieId)!=null&&this.playPage!=""){//重复请求播放，从日志箱中取上一次的播放地址进行播放
					
					this.openPlayerPage();		
					this.playURL=this.playLog.getItem(movieId);		
					var mycookie;
					try{
						mycookie = getCookie('play_zx');
						if(mycookie==0){ 
							this.playOnline();			//在线播放 			
				 		}else {
				 			this.playByReal();
						}
						return;
					}catch(e){
						this.playByReal();
						return;
					}
				}
				
				
				this.openPlayerPage();
				var realPlayer=$("realPlayer");//获取realPlayer插件对象
				if(realPlayer==null){//没有安装realPlayer
				    $('showPlayMessage').innerHTML="您看到当前的文字信息，表明您的系统中没有安装RealPlayer播放软件或者需要升级。<a  href='http://imgc.netfilm.cn/dw/RealPlayer10-cn.exe'>点击下载RealPlayer</a>" ;
				    alert("您的系统中没有安装RealPlayer播放软件，请先安装realPlayer再播放。");
					location.href="http://imgc.netfilm.cn/dw/RealPlayer10-cn.exe";		
					return false;
				}else{//已安装realPlayer
				    var params ="";
					try{
						params=realPlayer.getDRMInfo("RNBA");
					}catch(e){}
				    if(params == ""){
						params="&clientPubKey=sss";
				    }else{
						params="&"+params;
					}
					var url="/getPlayURL.do?movie="+movieId+params;
					//  alert(url + "=url");
					var contentLoader = new ContentLoader(url,'',this,'playResturn');  
					contentLoader.sendRequest(); 
				}
	}
	
	
}
/**
 * 请求播放地址返回接口
 */
Player.playResturn=function(http_request){
	var content = http_request.responseText;
	if(content!=null&&content=="noMovie"){//请求的影片不存在
	    $('showPlayMessage').innerHTML="对不起哦！您点播的影片不存在！" ;
	    alert("对不起哦！您点播的影片不存在！");
		return false;
	}
	if(content!=null&&content=="noPermission"){//请求的影片没有权限播放
	    $('showPlayMessage').innerHTML="对不起哦！您点播的影片没有权限！" ;
	    alert("对不起哦！您点播的影片没有权限！");
		return false;
	}
	if(content!=null&&content=="maxLicense"){//请求影片超过最多license数
	    $('showPlayMessage').innerHTML="对不起哦！您在24小时请求该影片超过了5次，请稍后再点播放该影片！" ;
	    alert("对不起哦！您在24小时请求该影片超过了5次，请稍后再点播放该影片！"); 
		return false;
	}
	if(content!=null&&content=="pay"){//未定购服务
	     $('showPlayMessage').innerHTML="对不起哦！您还没有定购该影片的服务,请先定购服务。" ;
	     alert("您还没有定购该影片的服务,请先定购服务。");
	     var payLink=document.createElement("a");//创建<a href="/pay/selectProduct.jsp" target="_blank"></a>元素
		 //payLink.href="/ysclub";
		 payLink.target="_blank";
		 document.body.appendChild(payLink);
		 payLink.click();//跳转到定购服务页面
	     return;
	}
	if(content!=null&&content.indexOf("http://")!=-1){		
		this.playURL=content;
		this.playLog.add(this.movieId,content);//添加播放历史到日志箱
		var coocoo;
		try{
			coocoo=getCookie('play_zx');
			if(coocoo==0){ 			
				this.playOnline();     //在线播放
	 		}else {
	 			this.playByReal();
			}
		}catch(e){
			this.playByReal();
		} 
		
		
		
				
	}
}
/**
 * 打开播放窗口层
 */
Player.openPlayerPage=function(){
	/**if(this.playPage!=""){//已下载播放页面
	    if($('playerDiv')!=null){
			$('playerDiv').removeNode(true);
		}
		Player.createDIV();		
	}else{**/
	
	//请求下载播放页面
		var url="/openPlayerPage.do";
		var contentLoader=new ContentLoader(url,'',this,"openPlayerPageReturn");	
		contentLoader.sync=false;//同步请求
	    contentLoader.sendRequest();//发送请求
	//}
	
}
/**
 * 打开播放窗口返回接口
 */
Player.openPlayerPageReturn=function(http_request){
	var pageContent=http_request.responseText;//获取返回内容
	this.playPage=pageContent;	
	this.createDIV();	
}

Player.createDIV=function(){
	
	var arrayPageSize=Div.getWindowSize();
	var windowWidth=arrayPageSize[2];
	var windowHeight=arrayPageSize[3];		
	//由于浏览器差别,获取scroll值不同
    var scrollPos; 
	if (typeof window.pageYOffset != 'undefined') { 
	   scrollPos = window.pageYOffset; 
	} 
	else if (typeof document.compatMode != 'undefined' && 
	     document.compatMode != 'BackCompat') { 
	     scrollPos = document.documentElement.scrollTop; 
	} 
	else if (typeof document.body != 'undefined') { 
	   scrollPos = document.body.scrollTop; 
	} 
	var playerDiv = document.createElement("div");
    playerDiv.setAttribute("id" ,"playerDiv");
    playerDiv.style.top=((windowHeight/2)-(495/2)+scrollPos) +"px";
    playerDiv.style.position="absolute";    
    playerDiv.style.left=(windowWidth/2)-(704/2)+"px";
	playerDiv.style.width ="704px";
    playerDiv.style.height ="495px";
	playerDiv.innerHTML=this.playPage;
	document.body.appendChild(playerDiv);
	$("loading").style.width="1px";
	Player.showProcess();//显示进度条
}
/**
 * 显示进度条
 */

Player.showProcess=function(){
	if(this.count<182){
		if($("loading")!=null){
			this.count++;
		    setTimeout("Player.showProcess()",20);
		    $("loading").style.width = this.count/100*252;
		}		
	}
}
/**
 * 关闭播放窗口
 */
Player.close=function(){	
    if($('realPlayerPlugin')!=null){
		$('realPlayerPlugin').DoStop();//停止播放realPlayer
		$('realPlayerPlugin').removeNode(true);
	}
	$('playerDiv').removeNode(true);
	if($('scoreSelectDiv')!=null){
		$('scoreSelectDiv').style.visibility="visible";//显示投票下拉列表
	}
}

/**
 * 开始拖动播放窗口
 */
Player.startDrag=function(){
	if(event.button==1&&event.srcElement.tagName.toUpperCase()=="DIV"){
		$('bfchk_top').setCapture();
		this.isMove=true;
	} 
}
/**
 *拖动播放窗口
 */
Player.drag=function(){
	if(this.isMove){
		//由于浏览器差别,获取scroll值不同
	    var scrollPos; 
		if (typeof window.pageYOffset != 'undefined') { 
		   scrollPos = window.pageYOffset; 
		} 
		else if (typeof document.compatMode != 'undefined' && 
		     document.compatMode != 'BackCompat') { 
		     scrollPos = document.documentElement.scrollTop; 
		} 
		else if (typeof document.body != 'undefined') { 
		   scrollPos = document.body.scrollTop; 
		} 
	   $('playerDiv').style.left=event.clientX-277;
	   $('playerDiv').style.top=(event.clientY+scrollPos);
	 }
}

/**
 *拖动播放窗口
 */
Player.stopDrag=function(){	
    $('bfchk_top').releaseCapture();
    this.isMove=false;
}
/**
 * 
 * 在线播放
 * 
 */
Player.playOnline=function(){
	var url="/movie_detail/playOnWeb.jsp?playURL="+this.playURL;
	var contentLoader=new ContentLoader(url,'',this,"playOnlineReturn");	
	contentLoader.sync=false;//同步请求
	contentLoader.sendRequest();//发送请求
}
/**
 * 在线播放返回接口
 */
Player.playOnlineReturn=function(http_request){
	var content=http_request.responseText;//获取返回内容
	$('playOnLineDIV').innerHTML=content;
	clearTimeout(this.timer);//取消上一次的定时自动关闭窗口
}
/**
 * 全屏播放
 */
Player.fullScreen=function(){
	$('realPlayerPlugin').DoPlayPause();//先暂停播放
	$('realPlayerPlugin').SetFullScreen();//设置全屏
	$('realPlayerPlugin').DoPlay();//开始播放
}

//写cookies函数 作者：翟振凯
function SetCookie(name,value)//两个参数，一个是cookie的名子，一个是值
{
    var Days = 30; //此 cookie 将被保存 30 天
    var exp  = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
	if(value==0){
		alert("已经设为在线播放");
	}else{
		alert("已经设置为播放器播放");
	}
	
}
function getCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return null;

}
function delCookie(name)//删除cookie
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}


function shezhi()
{
	//设为1播放器
	SetCookie ('play_zx', '1');
	document.getElementById("formabc").style.display= "block";
}

function quxiao()
{
	//设为0在线,缺省在线
	SetCookie ('play_zx', '0');
	document.getElementById("formabc").style.display= "none";
}

function myone()
{
	if(getCookie('play_zx')==0){ 
 		//alert("在线播放");
 		shezhi();
 	}else {
		//alert("播放器播放");
		quxiao();
		
	}

}
