﻿// JScript File
	
	var intRB = 0;

    function bookingSystem(lang){
    if(lang == "en"){
        swf = "http://www.ghticket.com/epayment/mini/epayment_hk_small_eng.swf";
    }else{
        swf = "http://www.ghticket.com/epayment/mini/epayment_hk_small_chi.swf";
    }
    
    swfObj = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="380" id="epayment_hk_small_eng" align="middle">';
    swfObj += '<param name="allowScriptAccess" value="always" />';
	swfObj += '<param name="movie" value="'+ swf +'" /><param name="quality" value="high" /><param name="bgcolor" value="#cccccc" />';
	swfObj += '<embed src="'+swf+'" quality="high" bgcolor="#cccccc" width="380" name="epayment_hk_small_eng" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	swfObj += '</object>';
    
    document.getElementById("div_booking").innerHTML = swfObj;
    }
	
	function scroll() {    
        var div_board = document.getElementById("board");
        var div_rollboard = document.getElementById("rollboard");
        var nHeight = div_board.offsetHeight * -1;
        var oneStep = 2;
        //div_board.style.top = 0;
        //alert(div_board.offsetTop + "xx");
        //alert(div_board.offsetHeight + "|" + div_board.style.top);
        t = div_board.offsetTop;
        t = parseInt(t,10);
        if(isNaN(t)){
           t = 0; 
        }        
        if(t - oneStep <= nHeight){
            div_board.style.top  = (div_rollboard.offsetHeight - oneStep) + "px";
        }else{
            div_board.style.top  = (t - oneStep) + "px";
        }
        
        
        //var height = myDiv.style.height;
        //height = height.split("px")[0];
        
       /*
        if(parseInt(div_board.style.top) > -350) {
            div_board.style.top = parseInt(div_board.style.top) - 2
        } else {
            div_board.style.top = parseInt(div_board.style.top) + 670
        }
        */
    }
    
 function getHttp(){  
	    var xmlHttp;
	    try
	    {    // Firefox, Opera 8.0+, Safari    
		    xmlHttp=new XMLHttpRequest();    
	    }
	    catch (e)
	    {    // Internet Explorer    
		    try
		    {      
			    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		    }
		    catch (e)
		    {      
			    try
			    {
			            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
			    }
			    catch (e)
			    {
			            alert("Your browser does not support AJAX!");   
			            return false; 
			    }      
		    }
	    }  
        return xmlHttp;    
    }    

//-----NAV Cinema List ------//    
    var cinemaListOver = false;
    var tobj;
    function showCinemalist(lang){
        //alert("welcome");
        var html = '';
        if(lang == "en"){            
            html += '<div class="cinemaMenuList1" style="width:120px; font-size: 12px;" onmouseover="setMouseOver()" onmouseout="setMouseOut()"><a href="/booking/cinema.aspx?cinema=grand_ocean&lang=en">GRAND OCEAN</a></div>';
            html += '<div class="cinemaMenuList2" style="width:120px; font-size: 12px;" onmouseover="setMouseOver()" onmouseout="setMouseOut()"><a href="/booking/cinema.aspx?cinema=gateway&lang=en">GOLDEN GATEWAY</a></div>';
            html += '<div class="cinemaMenuList1" style="width:120px; font-size: 12px;" onmouseover="setMouseOver()" onmouseout="setMouseOut()"><a href="/booking/cinema.aspx?cinema=gh_mk&lang=en">GH MONGKOK</a></div>';
            html += '<div class="cinemaMenuList2" style="width:120px; font-size: 12px;" onmouseover="setMouseOver()" onmouseout="setMouseOut()"><a href="/booking/cinema.aspx?cinema=gh_hw&lang=en">GH HOLLYWOOD</a></div>';
            html += '<div class="cinemaMenuList1" style="width:120px; font-size: 12px;" onmouseover="setMouseOver()" onmouseout="setMouseOut()"><a href="/booking/cinema.aspx?cinema=gh_ty&lang=en">GH TSING YI</a></div>';
			html += '<div class="cinemaMenuList2" style="width:120px; font-size: 12px;" onmouseover="setMouseOver()" onmouseout="setMouseOut()"><a href="/booking/cinema.aspx?cinema=gh_citywalk&lang=en">GH Citywalk</a></div>';
			html += '<div class="cinemaMenuList1" style="width:120px; font-size: 12px;" onmouseover="setMouseOver()" onmouseout="setMouseOut()"><a href="/booking/cinema.aspx?cinema=gh_whampoa&lang=en">GH Whampoa</a></div>';
        }else{
            html += '<div class="cinemaMenuList1" style="width:120px" onmouseover="setMouseOver()" onmouseout="setMouseOut()"><a href="/booking/cinema.aspx?cinema=grand_ocean&lang=tc">海運戲院</a></div>';
            html += '<div class="cinemaMenuList2" style="width:120px" onmouseover="setMouseOver()" onmouseout="setMouseOut()"><a href="/booking/cinema.aspx?cinema=gateway&lang=tc">嘉禾港威電影城</a></div>';
            html += '<div class="cinemaMenuList1" style="width:120px" onmouseover="setMouseOver()" onmouseout="setMouseOut()"><a href="/booking/cinema.aspx?cinema=gh_mk&lang=tc">嘉禾旺角電影城</a></div>';
            html += '<div class="cinemaMenuList2" style="width:120px" onmouseover="setMouseOver()" onmouseout="setMouseOut()"><a href="/booking/cinema.aspx?cinema=gh_hw&lang=tc">嘉禾荷里活電影城</a></div>';
            html += '<div class="cinemaMenuList1" style="width:120px" onmouseover="setMouseOver()" onmouseout="setMouseOut()"><a href="/booking/cinema.aspx?cinema=gh_ty&lang=tc">嘉禾青衣電影城</a></div>';
            html += '<div class="cinemaMenuList2" style="width:120px" onmouseover="setMouseOver()" onmouseout="setMouseOut()"><a href="/booking/cinema.aspx?cinema=gh_citywalk&lang=tc">嘉禾荃新天地</a></div>';
            html += '<div class="cinemaMenuList1" style="width:120px" onmouseover="setMouseOver()" onmouseout="setMouseOut()"><a href="/booking/cinema.aspx?cinema=gh_whampoa&lang=tc">嘉禾黃埔</a></div>';			
        }
        html += "";
        
        document.getElementById("cinemaMenu").innerHTML = html;        
        document.getElementById("cinemaMenu").style.display = "block";
        clearTimeout(tobj);
    
    }
    
    function hidelist(){
        if(!cinemaListOver){
            document.getElementById("cinemaMenu").style.display = "none";
        }
    }
    
    function hideCinemalist(){
        tobj = setTimeout('hidelist()',1000);
    }
    
    function setMouseOver(){
        cinemaListOver = true;
        clearTimeout(tobj);
    }
    
    function setMouseOut(){
        cinemaListOver = false;
        hideCinemalist();
    }

//-----End of NAV Cinema List ------//    

//----- Rotate Banner ---------//
    var films = new Array();
    var current_film = 0;
    
    var jetSos = new Array();
    var current_jetSo = 0;
    
    var vBanners = new Array();    
    var currentBanner = 0;
    
    function rotateFilm_add(img, id,desc){
        //alert("test");
        films[films.length] = '<a href="coming.aspx?movie_id=' + id + '">' + '<img src="' + img + '" border=0 height="105" style="padding:3px;float:left" align="left" />' + '</a>' + desc + ''
        //alert(films[films.length]-1);
    }
    
    //Add rotateBanner list for rotate banner in right hand side
    function rotateBanner_add(hstr){
        vBanners[vBanners.length] = hstr;
        //alert("add:" + hstr);
        
    }
    
    //Display a single , not rotate banner for header
    function rotateBanner_show(hstr){
        document.writeln(hstr);
    }
    
    //Rotate action for banner in right hand side
    function rotateBanner(){
        var p = currentBanner + 1;
        if(p >= vBanners.length){
            p=0;
        }
        document.getElementById('right_banner').innerHTML = vBanners[p];
        currentBanner = p;
    
    }
    function rotateFilm(){
        var p = current_film + 1;
        if(p >= films.length){
            p=0;
        }
        document.getElementById('div_filmlist').innerHTML = films[p];
        current_film = p;
    }

    function addJetSo(url,target,name,photo){        
        jetSos[jetSos.length] = "<div style='padding:4px'><a href=\"" + url + "\" target=\""+ target +"\">" + "<img src=\"" +photo + "\" border=\"0\" height=\"70px\" align='left' style='padding:3px' /><span style='font-weight:bold'>" + name + "</span></a></div>";

    }
    
    function rotateJetSo(){
        var p = current_jetSo + 1;
        if(p >= jetSos.length){
            p=0;
        }
        document.getElementById('div_jetso').innerHTML = jetSos[p];
        current_jetSo = p;
        
    }
    
    function rotateStart(){
        if(films.length > 0 && document.getElementById('div_filmlist')){
            document.getElementById('div_filmlist').innerHTML = films[0];        
            setInterval("rotateFilm()",3000);
        }
        if(jetSos.length > 0 &&  document.getElementById('div_jetso')){
            document.getElementById('div_jetso').innerHTML = jetSos[0];
            setInterval("rotateJetSo()",3000);
        }
        if(vBanners.length > 0 && document.getElementById('right_banner')){
            document.getElementById('right_banner').innerHTML = vBanners[0];
            setRotateBanner(true);
        }        
    }
	
	function setRotateBanner(isStart){
		if(isStart){
			if(intRB == 0){
				intRB = setInterval("rotateBanner()",3000);
			}
		}else{
			clearInterval(intRB);
			intRB = 0;
		}
	}
    
    function trailerAdd(trailerURL, trailerType){
        var FLVclassid ='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
        var FLVcodebase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0';
        var ASXclassid = 'CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6';
        var width = "280";
        var height = "240";
        var html = "";
        
        if(trailerType == 'flv'){
            html = '<object classid="' + FLVclassid + '" codebase="' + FLVcodebase +'" width="' + width + '" height="' + height + '" id="trailer" align="middle">';
            html += '    <param name="allowScriptAccess" value="sameDomain" />';
            html += '    <param name="movie" value="swf/trailer_innerpage.swf" />';
            html += '    <param name="quality" value="high" />';
            html += '    <param name="bgcolor" value="#ffffff" />';
            html += '    <param name="FlashVars" VALUE="url=' + trailerURL + '">';
            html += '    <embed src=swf/trailer_innerpage.swf flashVars="url=' + trailerURL + '" quality="high" bgcolor="#ffffff"'  +'" width="' + width + '" height="' + height + '" name="trailer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
            html += '</object>';
        }else if(trailerType == 'asx'){
            html = '<OBJECT id="VIDEO" CLASSID="" type="application/x-oleobject" width="' + width + '" height="' + height + '">  ';      	
	        html += '   <PARAM NAME="URL" value="' + trailerURL + '" />'; 	        
	        html += '   <PARAM NAME="AutoStart" VALUE="True"> ';     
	        html += '   <embed name="video" src="' + trailerURL + '" width="' + width + '" height="' + height + '"></embed> ';     
            html += '</OBJECT>';
        }
        
        document.getElementById('divTrailer').innerHTML = html;        
        //alert(html);
       
    }
    
    
 //-----End of Rotate Banner ---------//  
 
 //--VIP
  var numberOfFilm = 4;
    
    function buyTicket(film_id,cinema,lang){
        //alert("test");
        var list = document.getElementById("select_" + film_id);
        //alert(list);
        if(list)
            window.location.href = list.options[list.selectedIndex].value;
            //document.write(list.options[list.selectedIndex].value);

            
            
    } 
 
 //--end of VIP
 
 //----nowshowing
    function showTrailer(url){            
        if(url != ""){
            window.open("trailer.aspx?trailer=" + url,"trailer","width=280,height=240");
        }        
    }
    
    
//---- Cinema / Nowshowing

    function getOptionList(film_id,cinema_id,lang){
        var wsURL = "WebService.asmx/GetFilmOptionList?film_id=" + film_id + "&cinema=" + cinema_id + "&lang=" + lang;
        var wsHttp = getHttp();        
        if(wsHttp){
            wsHttp.onreadystatechange=function()
            {
            if(wsHttp.readyState==4)
              {          
              
              var xmlDoc=wsHttp.responseXML.documentElement;
              document.getElementById("list_" + film_id + "_" + cinema_id).innerHTML = xmlDoc.childNodes[0].nodeValue;
              }
            }
		    wsHttp.open("GET",wsURL,true);
		    wsHttp.send(null);
	    }          
    }
    
    function buyTicket(film_id,cinema,lang){
        //alert("test");
        var list = document.getElementById("select_" + film_id + "_" + cinema); //NEW 
	    //var list = document.getElementById("select_" + film_id);
        if(list){
           //alert("test");
          
           var listvalue = list.options[list.selectedIndex].value;
           if(listvalue != ""){
            window.location.href = listvalue;
           }
        }            
    }
    
    