﻿
    var xmlplay;
    var List1st;
    
    List1st = new Array();

    List1st[0] = new Array();
    List1st[0][0] = '0';
    List1st[0][1] = '請選擇電影　　　　　　　　';

    function sendLink(){
    
        var id;
        var url;
        var root;
        
        if( document.cinemaseek.module.value == '0') root = '';
        
        else root = '.';        
        
        url = root + './movie/index.aspx';

        if( document.cinemaseek.play1st.value != '0'){

            id = document.cinemaseek.play1st.value;
            url = root + './movie/playtime.aspx?id=' + id;
            
        } 

        else if( document.cinemaseek.cinema.value != '0'){

            id = document.cinemaseek.cinema.value;
            url = root + './movie/cinema_playtime.aspx?id=' + id;
            
        } 
        
        location.assign( url);
        
    }
   
    function getPlayList(){

        var i;
        var root;
        
        if( document.cinemaseek.module.value == '0') root = '';
        
        else root = '.';        

        if( List1st.length == 1){
    
            var url = root + './xml/xml_movie_list.aspx?play=1';
    
            if( window.XMLHttpRequest) xmlplay = new XMLHttpRequest();
            else if( window.ActiveXObject) xmlplay = new ActiveXObject('Microsoft.XMLHTTP');

            xmlplay.open( 'GET', url, false);

            if( navigator.appName == 'Netscape'){
    
                xmlplay.send( null);
                setPlayList();
            
            }
            
            else{
    
                xmlplay.onreadystatechange = setPlayList;
                xmlplay.send( null);
                
            }
        
        }
        
        else{

            document.cinemaseek.play1st.options[0] = new Option( List1st[0][1], List1st[0][0]);

            for( i = 1; i < List1st.length; i ++){
            
                document.cinemaseek.play1st.options[i] = new Option( List1st[i][1], List1st[i][0]);
                
            }
        
        }

    }
    
    function setPlayList(){

        var i;
        var total;
        var xmlroot;
        var id, chinesename;
        var n;

        if( xmlplay.readyState == 4 && xmlplay.status == 200){ 
            
            xmlroot = xmlplay.responseXML.documentElement;
            
            total = parseInt( xmlroot.selectNodes('./result/single').length);
            
            if( total > 0){

                document.cinemaseek.play1st.disabled = true;
                document.cinemaseek.play1st.options[0] = new Option( List1st[0][1], List1st[0][0]);
              
                for( i = 0; i < total; i ++){

                    id = xmlroot.selectNodes('./result/single/id')[i].firstChild.nodeValue;
                    chinesename = xmlroot.selectNodes('./result/single/chinesename')[i].firstChild.nodeValue;

                    if( chinesename.length > 13) chinesename = chinesename.substring( 0, 12) + '...';

                    n = i + 1;

                    document.cinemaseek.play1st.options[n] = new Option( chinesename, id);

                    List1st[n] = new Array();
                    List1st[n][0] = id;
                    List1st[n][1] = chinesename;

                }
 
                document.cinemaseek.play1st.disabled = false;
                
            }

        }

    }

