﻿/*
    右下方空置項按鈕物件
*/
AreaButton = function(plugIn,areaObj,areaProp) 
{

    this.plugIn = plugIn;
    this.areaObj = areaObj;
    this.areaProp = areaProp;
    
    var txtTitleObj = areaObj.findName("txtTitle");
    var txtTitleShadowObj = areaObj.findName("txtTitleShadow");
    var imgReflectObj = areaObj.findName("imgReflect");
    var imgPictureObj = areaObj.findName("imgPicture");
    
    var leftBase = 10;
          
    //修改屬性
    imgPictureObj["Source"] = areaProp.img; 
    imgReflectObj["Source"] = areaProp.img;
    
    areaObj.cursor = "Hand";
    areaObj["Canvas.Left"] = areaProp.left;
    areaObj["Canvas.Top"] = areaProp.top;

    txtTitleObj["Canvas.Left"] = txtTitleObj["Canvas.Left"] + (leftBase * (4-areaProp.name.length));
    txtTitleObj["Text"] = areaProp.name;

    txtTitleShadowObj["Canvas.Left"] = txtTitleShadowObj["Canvas.Left"] + (leftBase * (4-areaProp.name.length));
    txtTitleShadowObj["Text"] = areaProp.name;

    //將文字物件存進陣列
    txtObject[txtObject.length] = txtTitleObj;
    txtObject[txtObject.length] = txtTitleShadowObj;
    
    //新增事件
    areaObj.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleAreaBlockMouseEnter));
    areaObj.addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleAreaBlockMouseLeave)); 
    areaObj.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleAreaBlockMouseLeftButtonDown));       
}
//Area Control MouseEnter 滑鼠事件
AreaButton.prototype.handleAreaBlockMouseEnter = function(sender,eventArgs) {
    sender.findname("tlnBtnZoomIn").begin();
}   
//Area Control MouseLeave 滑鼠事件
AreaButton.prototype.handleAreaBlockMouseLeave = function(sender,eventArgs) {
    sender.findname("tlnBtnZoomOut").begin();
}   
//Area Control MouseLeftButtonDown 滑鼠事件
AreaButton.prototype.handleAreaBlockMouseLeftButtonDown = function(sender,eventArgs) {
    if(this.areaProp.code=="Oceania"){
        sender.getHost().content.findname("tlneOceaniaZoomIn").begin();
    } else if(this.areaProp.code=="Europe"){
		sender.getHost().content.findname("tlneEuropeZoomIn").begin();
	} else if(this.areaProp.code=="NorthAmerica"){
	    sender.getHost().content.findname("tlneNorthAmericaZoomIn").begin();
    } else if(this.areaProp.code=="China"){
	    sender.getHost().content.findname("tlneChinaZoomIn").begin();
    } else if(this.areaProp.code=="NorthAsia"){
	    sender.getHost().content.findname("tlneNorthAsiaZoomIn").begin();
    } else if(this.areaProp.code=="SouthAsia"){
	    sender.getHost().content.findname("tlneSouthAsiaZoomIn").begin();
    } else if(this.areaProp.code=="Home"){
        location.href = "index.aspx";
    } else if(this.areaProp.code=="BackPage2"){
        //移置第二頁
        document.getElementById("hdnTripcode").value = "";
        document.getElementById("form1").submit();
	} else if(this.areaProp.code=="Buy"){
        eval("winNa = window.open('http://dp.china-airlines.com/PRO/index/SELL.htm',null,'menubar=no,status=yes,toolbar=no,scrollbars=yes,resizable=yes,width="+(screen.width-100)+",height="+(screen.height-100)+",top=0,left=0')");
    } else if(this.areaProp.code=="Club"){
        eval("winNa = window.open('http://dp.china-airlines.com/index.html',null,'menubar=no,status=yes,toolbar=no,scrollbars=yes,resizable=yes,width="+(screen.width-100)+",height="+(screen.height-100)+",top=0,left=0')");
    } else if(this.areaProp.code=="Note"){
        eval("winNa = window.open('http://dp.china-airlines.com/PRO/index/note.htm',null,'menubar=no,status=yes,toolbar=no,scrollbars=yes,resizable=yes,width="+(screen.width-100)+",height="+(screen.height-100)+",top=0,left=0')");
    } else if(this.areaProp.code=="Query"){
        
        //confirmPanel.setContent(document.getElementById("queryPanel").innerHTML);
        confirmPanel.setContent(document.getElementById("queryPanel").innerHTML);
        confirmPanel.open();
    }
}

/*
    首頁各站點物件
*/
STN = function(plugIn,stnObj,stnProp) 
{
    this.plugIn = plugIn;
    this.stnObj = stnObj;
    this.stnProp = stnProp;
    
    var pthLineObj = stnObj.findName("pthLine");
    var imgPointToObj = stnObj.findName("imgPointTo");
    var imgPointFromObj = stnObj.findName("imgPointFrom");
    var imgPointEndObj = stnObj.findName("imgPointEnd");
    var txtCitynameObj = stnObj.findName("txtCityname");
    //var txtCitynameShadowObj = stnObj.findName("txtCitynameShadow");
    
    //修改屬性    
    txtCitynameObj["Text"] = stnProp.name;
        
    //txtCitynameShadowObj["Text"] = stnProp.name;

    //將文字物件存進陣列
    txtObject[txtObject.length] = txtCitynameObj;
    //txtObject[txtObject.length] = txtCitynameShadowObj;
    
    if(stnProp.isRight=="Y") {
        imgPointToObj["Canvas.Left"] = 0;
        imgPointFromObj["Canvas.Left"] = 0;
        imgPointEndObj["Canvas.Left"] = 0;
        
        txtCitynameObj["Canvas.Left"] = 6 + stnProp.txtLeft;
        //txtCitynameShadowObj["Canvas.Left"] = 6 + 0.3 + stnProp.txtLeft;
        
        txtCitynameObj["Canvas.Top"] = txtCitynameObj["Canvas.Top"] + stnProp.txtTop;
        //txtCitynameShadowObj["Canvas.Top"] = txtCitynameShadowObj["Canvas.Top"] + stnProp.txtTop;
        
        pthLineObj["Height"] = stnProp.lineHeight;
        pthLineObj["Width"] = stnProp.lineWidth;
    
        stnObj["Canvas.Left"] = stnProp.left;
        stnObj["Canvas.Top"] = stnProp.top;
        
        stnActualWidth = imgPointToObj["Width"] + txtCitynameObj["ActualWidth"];
    } else {
        txtCitynameObj["Canvas.Left"] = 0;
        //txtCitynameShadowObj["Canvas.Left"] = 0 + 0.3;
        
        imgPointToObj["Canvas.Left"] = txtCitynameObj.actualWidth +5 + stnProp.txtLeft;
        imgPointFromObj["Canvas.Left"] = txtCitynameObj.actualWidth +5 + stnProp.txtLeft;
        imgPointEndObj["Canvas.Left"] = txtCitynameObj.actualWidth +5 + stnProp.txtLeft;
        pthLineObj["Canvas.Left"] = txtCitynameObj.actualWidth +5 + stnProp.txtLeft;
        
        txtCitynameObj["Canvas.Top"] = txtCitynameObj["Canvas.Top"] + stnProp.txtTop;
        //txtCitynameShadowObj["Canvas.Top"] = txtCitynameShadowObj["Canvas.Top"] + stnProp.txtTop;
        
        pthLineObj["Height"] = stnProp.lineHeight;
        pthLineObj["Width"] = stnProp.lineWidth;
        
        stnObj["Canvas.Left"] = stnProp.left - imgPointToObj["Canvas.Left"];
        stnObj["Canvas.Top"] = stnProp.top;
        
    }
    
    if(this.stnProp.disabled){
        imgPointEndObj["Visibility"] = "Visible";
    } else {
        imgPointEndObj["Visibility"] = "Collapsed";
        stnObj.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleSTNBlockMouseEnter));
        stnObj.addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleSTNBlockMouseLeave));    
    }
    
    stnObj.cursor = "Hand";
    //txtCitynameObj["Visibility"] = "Collapsed";
    
    //新增事件
    stnObj.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleSTNBlockMouseLeftButtonDown));
}
//STN Control MouseEnter 滑鼠事件
STN.prototype.handleSTNBlockMouseEnter = function (sender,eventArgs)
{

        sender.findname("tlnBallMouseOver").begin();
        
        stnPanelBlock["Canvas.Top"] = eventArgs.GetPosition(null).Y-15;
        stnPanelBlock["Canvas.Left"] = eventArgs.GetPosition(null).X + 10;
        
        var chkP = 1;
        stnPanelBlock.findname("cnvPart1")["Visibility"] = "Collapsed";
        stnPanelBlock.findname("cnvPart2")["Visibility"] = "Collapsed";
        stnPanelBlock.findname("cnvPart3")["Visibility"] = "Collapsed";
        stnPanelBlock.findname("pthLine1")["Visibility"] = "Collapsed";
        stnPanelBlock.findname("pthLine2")["Visibility"] = "Collapsed";
        
        
        if(this.stnProp.depttpe){
            var part = stnPanelBlock.findname("cnvPart" + chkP);
            var title = part.findname("txtTitle" + chkP);
            var timeTitle = part.findname("txtTimeTitle" + chkP);
            var time = part.findname("txtTime" + chkP);
            
            title["Text"] = "台北 - " + this.stnProp.name;
            time["Text"] = this.stnProp.tpetime;

            updateSingleObjFontObject(fontSource,title);
            updateSingleObjFontObject(fontSource,timeTitle);
            updateSingleObjFontObject(fontSource,time);
            
            part["Visibility"] = "Visible";

            chkP = chkP +1;
        }
        if(this.stnProp.depttxg){
            var part = stnPanelBlock.findname("cnvPart" + chkP);
            var title = part.findname("txtTitle" + chkP);
            var timeTitle = part.findname("txtTimeTitle" + chkP);
            var time = part.findname("txtTime" + chkP);
            if(this.stnProp.code=="HNL"){ //HNL有經東京接駁
                title["Text"] = "台北出發(經東京)";
            } else {
                title["Text"] = "台中 - " + this.stnProp.name;
            }
            time["Text"] = this.stnProp.txgtime;
            
            updateSingleObjFontObject(fontSource,title);
            updateSingleObjFontObject(fontSource,timeTitle);
            updateSingleObjFontObject(fontSource,time);
            
            part["Visibility"] = "Visible";
                    
            chkP = chkP +1;
        }
        if(this.stnProp.deptkhh){
            var part = stnPanelBlock.findname("cnvPart" + chkP);
            var title = part.findname("txtTitle" + chkP);
            var timeTitle = part.findname("txtTimeTitle" + chkP);
            var time = part.findname("txtTime" + chkP);
            
            title["Text"] = "高雄 - " + this.stnProp.name;
            time["Text"] = this.stnProp.khhtime;
            
            updateSingleObjFontObject(fontSource,title);
            updateSingleObjFontObject(fontSource,timeTitle);
            updateSingleObjFontObject(fontSource,time);
            
            part["Visibility"] = "Visible";
                    
            chkP = chkP +1;
        }
        
        if(chkP==3){
            stnPanelBlock.findname("pthLine1")["Visibility"] = "Visible";
        } else if(chkP==4){
            stnPanelBlock.findname("pthLine1")["Visibility"] = "Visible";
            stnPanelBlock.findname("pthLine2")["Visibility"] = "Visible";
        }
        
        stnPanelBlock.findname("tlnSTNPanelShow").begin();
}
//STN Control MouseLeave 滑鼠事件
STN.prototype.handleSTNBlockMouseLeave = function (sender,eventArgs)
{
        sender.findname("tlnBallMouseOut").begin();
        stnPanelBlock.findname("tlnSTNPanelHide").begin();
}
//STN Control MouseLeftButtonDown 滑鼠事件
STN.prototype.handleSTNBlockMouseLeftButtonDown = function (sender,eventArgs)
{
    if(this.stnProp.code=="TWN"){//若選擇台灣時
        var confirmValue = confirm("想來台灣走走嗎?");
        if(confirmValue!=null && confirmValue){
            location.href = "http://dp.china-airlines.com/inbound/ENG/html/index.html";
        }
    } else if(this.stnProp.disabled){
        alert('尚未開放!');
    } else {
        document.getElementById("hdnCitycode").value = this.stnProp.code;
        document.getElementById("form1").submit();
    }
    
}

/*
    第二頁行程查詢結果
*/
TRIPCARD = function(plugIn,cardObj,cardProp) 
{
    this.plugIn = plugIn;
    this.cardObj = cardObj;
    this.cardProp = cardProp;
    
    var txtTripnamcObj = cardObj.findName("txtTripnamc");
    var txtTripcodeObj = cardObj.findName("txtTripcode");
    var txtPriceObj = cardObj.findName("txtPrice");
    var imgTrippicObj = cardObj.findName("imgTrippic");
    var imgMedalObj = cardObj.findName("imgMedal");
    var txtShowDayObj = cardObj.findName("txtShowDay");
    var txtShowNightObj = cardObj.findName("txtShowNight");
    var txtDayObj = cardObj.findName("txtDay");
    var txtNightObj = cardObj.findName("txtNight");
    
    //修改屬性
    cardObj.cursor = "Hand";
    imgTrippicObj["Source"] = (cardProp.Imageurl==null||cardProp.Imageurl==""?"images/noimage.png":cardProp.Imageurl); 
    txtTripnamcObj["Text"] = splitLine(cardProp.Tripnamc,"\n",9,2);    
    txtPriceObj["Text"] = "$ " + cardProp.Mina2bn + " 元 起";
    txtShowDayObj["Text"] = cardProp.Tripdays;
    txtShowNightObj["Text"] = cardProp.Tripnght;
    txtTripcodeObj["Text"] = cardProp.Tripcode;

    if(cardProp.Iselite!="0"){
        imgMedalObj["Visibility"] = "Visible";
        imgMedalObj["Source"] = "images/moneysale02.png";
    } else if(cardProp.Perdtype!="Y"){
        imgMedalObj["Visibility"] = "Visible";
        imgMedalObj["Source"] = "images/moneysale01.png";
    } else {
        imgMedalObj["Visibility"] = "Collapsed";
    }
    
    //將文字物件存進陣列
    txtObject[txtObject.length] = txtTripnamcObj;
    txtObject[txtObject.length] = txtPriceObj;
    txtObject[txtObject.length] = txtShowDayObj;
    txtObject[txtObject.length] = txtShowNightObj;
    txtObject[txtObject.length] = txtDayObj;
    txtObject[txtObject.length] = txtNightObj;
                        
    //新增事件
    cardObj.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleCardBlockMouseLeftButtonDown));
}

// handleCardBlockMouseLeftButtonDown
TRIPCARD.prototype.handleCardBlockMouseLeftButtonDown = function (sender,eventArgs)
{
        //移置第三頁
        document.getElementById("hdnTripcode").value = this.cardProp.Tripcode;
        document.getElementById("form1").submit();
}

/*
    第二頁行程查詢結果
*/
DROPDOWNMENU = function(plugIn,menuObj,menuProp,top,left,name) 
{
    this.DEFAULT_ITEMCODE = "NONE"; //若選取後的背景顏色
    this.SELECTED_BGCOLOR = "#4CFF9C00"; //若選取後的背景顏色
    this.selectedItemCode = this.DEFAULT_ITEMCODE; //目前選擇的項目
    
    this.name = name;
    this.plugIn = plugIn;
    this.menuObj = menuObj;
    this.menuProp = menuProp;
    this.top = top;
    this.left = left;
    
    if(menuProp!=null && menuProp.length>0){
    
        //設定高度及主選單項目
        menuObj["Height"] = 25 * (menuProp.length+1);
        menuObj["Canvas.Top"] = this.top;
        menuObj["Canvas.Left"] = this.left;
        this.menuObj["Visibility"] = "Collapsed"; //選單初始隱藏
    
        //設定內部選項及ITEM            
        for(var i=1;i<12;i++){
        
            var cnvOptObj = menuObj.findName("cnvOpt" + i);
            var imgOptObj = menuObj.findName("imgOpt" + i);
            var txtOptObj = menuObj.findName("txtOpt" + i);        
            var txtOptHObj = menuObj.findName("txtOptH" + i);        
            
            if( i<= (menuProp.length+1)){
                //設定屬性
                if(i==1){
                    txtOptHObj["Text"] = this.DEFAULT_ITEMCODE;
                    txtOptObj["Text"] = "不設定篩選範圍";
                } else {
                    txtOptHObj["Text"] = menuProp[i-2][0];
                    txtOptObj["Text"] = menuProp[i-2][1];
                }
                
                //加入事件
                cnvOptObj.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleMenuItemMouseLeftButtonDown ));
                cnvOptObj.addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMenuItemMouseLeave ));
                cnvOptObj.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMenuItemMouseEnter ));
                
                //將文字物件存進陣列
                txtObject[txtObject.length] = txtOptObj;
                
            } else {
                //不顯示項目隱藏
                cnvOptObj["Visibility"] = "Collapsed";
            }
        }
        
    }//if(menuProp!=null && menuProp.length>0){
                        
    //新增事件
    this.menuObj.addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMenuBlockMouseLeave));
    this.menuObj.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMenuBlockMouseEnter));
    
    this.initMenuSelectedItem();
}

// 選取狀態顯示
DROPDOWNMENU.prototype.initMenuSelectedItem = function ()
{
    //移置第三頁
    for(var i=1;i<12;i++){
        
        var cnvOptObj = this.menuObj.findName("cnvOpt" + i);
        var imgOptObj = this.menuObj.findName("imgOpt" + i);
        var txtOptObj = this.menuObj.findName("txtOpt" + i);        
        var txtOptHObj = this.menuObj.findName("txtOptH" + i);        
        
        if( this.selectedItemCode == txtOptHObj.text ){
            imgOptObj["Source"] = "images/apply.png";
            cnvOptObj["Background"] = this.SELECTED_BGCOLOR;
        } else {
            imgOptObj["Source"] = "images/unapply.png";
            cnvOptObj["Background"] = null;
        }
        
    }
}
// Item 選取後事件
DROPDOWNMENU.prototype.getSelectedItemCode = function ()
{
    return this.selectedItemCode;
}
DROPDOWNMENU.prototype.getMenuInstance = function ()
{
    return this.menuObj;
}
DROPDOWNMENU.prototype.setSelectedItemCode = function (itemCode)
{
    this.selectedItemCode = itemCode;
}
DROPDOWNMENU.prototype.resetItemCode = function ()
{
    this.selectedItemCode = this.DEFAULT_ITEMCODE;
}
//離開選單
DROPDOWNMENU.prototype.handleMenuBlockMouseLeave = function (sender,eventArgs)
{
    this.menuObj["Visibility"] = "Collapsed";
    eval(this.name + "MenuGetFocus = false;");
}
//進入選單
DROPDOWNMENU.prototype.handleMenuBlockMouseEnter = function (sender,eventArgs)
{
    eval(this.name + "MenuGetFocus = true;");
}
// Item 選取後事件
DROPDOWNMENU.prototype.handleMenuItemMouseLeftButtonDown = function (sender,eventArgs)
{
    this.selectedItemCode = sender.findName("txtOptH" + sender.name.substring(sender.name.length-1,sender.name.length)).text;
    this.menuObj["Visibility"] = "Collapsed";
    this.initMenuSelectedItem();
    
    //重新排列卡片
    isCardInited = false;
    loadCards();
}
DROPDOWNMENU.prototype.handleMenuItemMouseEnter = function (sender,eventArgs)
{
    var currentItemCode = sender.findName("txtOptH" + sender.name.substring(sender.name.length-1,sender.name.length)).text;
    if(currentItemCode != this.selectedItemCode){
        sender["Background"] = this.SELECTED_BGCOLOR;
    }

 
}
DROPDOWNMENU.prototype.handleMenuItemMouseLeave = function (sender,eventArgs)
{
    var currentItemCode = sender.findName("txtOptH" + sender.name.substring(sender.name.length-1,sender.name.length)).text;
    if(currentItemCode != this.selectedItemCode){
        sender["Background"] = null;
    }

 
}

DROPDOWNMENU.prototype.handleMenuItemMouseLeftButtonDown = function (sender,eventArgs)
{
    this.selectedItemCode = sender.findName("txtOptH" + sender.name.substring(sender.name.length-1,sender.name.length)).text;
    this.menuObj["Visibility"] = "Collapsed";
    this.initMenuSelectedItem();
    
    //重新排列卡片
    isCardInited = false;
    loadCards();
}

/*
    City Image
*/
CITYIMAGE = function(plugIn,imgObj,imgBg,imgProp,idx) 
{
    this.isMovie = true;
    this.isPlay=false;
    this.plugIn = plugIn;
    this.imgObj = imgObj;
    this.imgBg = imgBg;
    this.imgProp = imgProp;
    this.imgFirmObj = this.plugIn.content.findname("imgFirm" + idx);
    
    if(imgProp!=null){
        
        //判斷是影片或是圖片
        if(imgProp.Isvideo=="N"){
            this.imgFirmObj["Visibility"] = "Collapsed";
            this.isMovie = false;
        }
        
        imgObj["Source"] = imgProp.Smlimage;
        
        //新增事件
        this.imgObj.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleCityImageMouseLeftButtonDown ));
        this.imgObj.addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleCityImageBlockMouseLeave));
        this.imgObj.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleCityImageBlockMouseEnter));    
    } else {
        this.imgObj["Visibility"] = "Collapsed";
        this.imgBg["Visibility"] = "Collapsed";
        this.imgFirmObj["Visibility"] = "Collapsed";
    }
    
}

CITYIMAGE.prototype.handleCityImageMouseLeftButtonDown = function (sender,eventArgs)
{
    
    if(this.isMovie){
        document.getElementById("movieFrame").src=mvurl + this.imgProp.Midimage + '/iframe.html';
        document.getElementById("moviePanel").style.display='block';
        
        this.plugIn.content.findname("imgScenery")["Visibility"] = "Collapsed";
        this.plugIn.content.findname("cnvVedio")["Visibility"] = "Visible";
    } else {
        
        document.getElementById("movieFrame").src='movie3.htm';
        document.getElementById("moviePanel").style.display='none';
        
        this.plugIn.content.findname("imgScenery")["Source"] = this.imgProp.Midimage;
        this.plugIn.content.findname("imgScenery")["Visibility"] = "Visible";
        this.plugIn.content.findname("cnvVedio")["Visibility"] = "Collapsed";
    }
    this.plugIn.content.findname("txtCityImageTitle")["Text"] = this.imgProp.Descript;
    this.plugIn.content.findname("rtgCityImageBG")["Width"] = this.plugIn.content.findname("txtCityImageTitle")["ActualWidth"] +10;
    txtObject[txtObject.length] = this.plugIn.content.findname("txtCityImageTitle");
}

CITYIMAGE.prototype.handleCityImageBlockMouseLeave = function (sender,eventArgs)
{
    this.imgObj["Opacity"] = 0.7;
}

CITYIMAGE.prototype.handleCityImageBlockMouseEnter = function (sender,eventArgs)
{
    this.imgObj["Opacity"] = 1;
}

CITYIMAGE.prototype.setMidImage = function ()
{
    this.plugIn.content.findname("txtCityImageTitle")["Text"] = this.imgProp.Descript;
    this.plugIn.content.findname("rtgCityImageBG")["Width"] = this.plugIn.content.findname("txtCityImageTitle")["ActualWidth"] +20;
    txtObject[txtObject.length] = this.plugIn.content.findname("txtCityImageTitle");
    this.plugIn.content.findname("imgScenery")["Source"] = this.imgProp.Midimage;
}

/*
    Map Image
*/
var currentMapZoomToken = null;
var currentImgMapZoomToken = null;
var currentTxtMapZoomToken = null;
MAPIMAGE = function(plugIn,imgObj,imgProp,idx) 
{
    this.plugIn = plugIn;
    this.imgProp = imgProp;
    
    this.imgObj = imgObj;
    this.imgMapPicObj = this.imgObj.findname("imgMap" + idx);
    this.txtMapObj = this.imgObj.findname("txtMap" + idx);
    
    if(imgProp!=null){

        this.imgMapPicObj["Source"] = imgProp.Mapimage;
        this.txtMapObj["Text"] = imgProp.Maptitle;
        
        txtObject[txtObject.length] = this.txtMapObj;

        //新增事件
        this.imgObj.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleMapImageMouseLeftButtonDown ));
        this.imgObj.addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMapImageBlockMouseLeave));
        this.imgObj.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMapImageBlockMouseEnter));    
                
    } else {
        this.imgObj["Visibility"] = "Collapsed";
    }
    
}

MAPIMAGE.prototype.handleMapZoomMouseLeftButtonDown = function (sender,eventArgs)
{
    eval("winNa = window.open('" + this.imgProp.Mpbimage + "',null,'menubar=no,status=yes,toolbar=no,scrollbars=yes,resizable=yes,width="+(screen.width-100)+",height="+(screen.height-100)+",top=0,left=0')");
}

MAPIMAGE.prototype.handleMapImageMouseLeftButtonDown = function (sender,eventArgs)
{
    this.setMidImage();
}

MAPIMAGE.prototype.handleMapImageBlockMouseLeave = function (sender,eventArgs)
{
    this.imgMapPicObj["Opacity"] = 0.7;
}

MAPIMAGE.prototype.handleMapImageBlockMouseEnter = function (sender,eventArgs)
{
    this.imgMapPicObj["Opacity"] = 1;
}

MAPIMAGE.prototype.setMidImage = function ()
{
    this.plugIn.content.findname("imgMap")["Source"] = this.imgProp.Mpbimage;
    
    //圖片放大事件 1.移除 2.新增
    if(currentMapZoomToken!=null){
        this.plugIn.content.findname("imgMap").removeEventListener("MouseLeftButtonDown",currentMapZoomToken);
        this.plugIn.content.findname("imgMapZoom").removeEventListener("MouseLeftButtonDown",currentImgMapZoomToken);
        this.plugIn.content.findname("txtMapZoom").removeEventListener("MouseLeftButtonDown",currentTxtMapZoomToken);
    }
    currentMapZoomToken = this.plugIn.content.findname("imgMap").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleMapZoomMouseLeftButtonDown ));
    currentImgMapZoomToken = this.plugIn.content.findname("imgMapZoom").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleMapZoomMouseLeftButtonDown ));
    currentTxtMapZoomToken = this.plugIn.content.findname("txtMapZoom").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleMapZoomMouseLeftButtonDown ));
}

HOTELITEM = function(plugIn,htlObj,htlProp) 
{
    
    this.htlObj = htlObj;
    this.htlProp = htlProp;
    this.txtHotlcodeObj = htlObj.findName("txtHotlcode");
    this.txtHotlnameObj = htlObj.findName("txtHotlname");
    this.txtHotlnamcObj = htlObj.findName("txtHotlnamc");
    this.imgHotelObj = htlObj.findName("imgHotel");
           
    this.txtDescriptionObj = htlObj.findName("txtDescription");
    this.imgStarObj = htlObj.findName("imgStar");
    this.rtgBackgroundObj = htlObj.findName("rtgBackground");
     
    this.txtHotlcodeObj["Text"] = htlProp.Hotlcode;
    this.txtHotlnamcObj["Text"] = htlProp.Hotlnamc;
    this.txtHotlnameObj["Text"] = htlProp.Hotlname;
    this.imgHotelObj["Source"] = htlProp.Imagurl1; // 飯店小圖片顯示
    this.txtDescriptionObj["Text"] = splitLine(htlProp.Location,"\n",21,3);
    
    this.imgStarObj["Source"] = "images/Star" + htlProp.Star + ".png";
    
    this.htlObj["Opacity"] = 0.8;
    
    txtObject[txtObject.length] = this.txtHotlcodeObj;
    txtObject[txtObject.length] = this.txtHotlnameObj;
    txtObject[txtObject.length] = this.txtHotlnamcObj;
    txtObject[txtObject.length] = this.txtDescriptionObj;

    this.htlObj.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleHotelMouseLeftButtonDown ));
    this.htlObj.addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleHotelBlockMouseLeave));
    this.htlObj.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleHotelBlockMouseEnter));  
            
}

HOTELITEM.prototype.handleHotelMouseLeftButtonDown = function (sender,eventArgs)
{
    var tmpURL = "http://dp.china-airlines.com/" + this.htlProp.Areacode + "/" + this.htlProp.Citycode + "/html/HTL" + this.htlProp.Hotlcode.replace("/","") + ((this.htlProp.Reptcode==null||this.htlProp.Reptcode=='')?"":this.htlProp.Reptcode) + ".htm";
    eval("winNa = window.open('" + tmpURL + "',null,'menubar=no,status=yes,toolbar=no,scrollbars=yes,resizable=yes,width=537,height=385,top=0,left=0')");
}

HOTELITEM.prototype.handleHotelBlockMouseLeave = function (sender,eventArgs)
{
    this.htlObj["Opacity"] = 0.8;
}

HOTELITEM.prototype.handleHotelBlockMouseEnter = function (sender,eventArgs)
{
    this.htlObj["Opacity"] = 1;
}

CONTENTITEM = function(plugIn,contentObj,contentProp) 
{
    
    this.contentObj = contentObj;
    this.contentProp = contentProp;
    
    this.imgPictureObj = contentObj.findName("imgPicture");
    this.txtTitleTextObj = contentObj.findName("txtTitleText");
    this.txtContentObj = contentObj.findName("txtContent");
    if(this.contentProp.Imgurl1_cnt!=null && this.contentProp.Imgurl1_cnt!=""){
        this.imgPictureObj["Source"] = this.contentProp.Imgurl1_cnt; //圖片顯示
    } else {
        this.imgPictureObj["Source"] = this.contentProp.Imageurl_sbj; //圖片顯示
    }
    
    if(this.contentProp.Title_cnt!=null && this.contentProp.Title_cnt!=""){
        this.txtTitleTextObj["Text"] = this.contentProp.Title_cnt;
    } else {
        this.txtTitleTextObj["Text"] = this.contentProp.Title_sbj;
    }
    
    if(this.contentProp.Content_cnt!=null && this.contentProp.Content_cnt!=""){
        this.txtContentObj["Text"] = splitLine(contentProp.Content_cnt,"\n",35,30);
    } else {
        this.txtContentObj["Text"] = splitLine(contentProp.Content_sbj,"\n",35,30);
    }
    
    
            
    txtObject[txtObject.length] = this.txtTitleTextObj;
    txtObject[txtObject.length] = this.txtContentObj;
                

    this.imgPictureObj.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleContentMouseLeftButtonDown ));
    
            
}

CONTENTITEM.prototype.handleContentMouseLeftButtonDown = function (sender,eventArgs)
{
    if(this.contentProp.Imgurl1_cnt!=null && this.contentProp.Imgurl1_cnt!=""){
        eval("winNa = window.open('" + this.contentProp.Imgurl1_cnt + "',null,'menubar=no,status=yes,toolbar=no,scrollbars=yes,resizable=yes,width=470,height=480,top=0,left=0')");
    } else {
        this.imgPictureObj["Source"] = this.contentProp.Imageurl_sbj; //圖片顯示
        eval("winNa = window.open('" + this.contentProp.Imageurl_sbj + "',null,'menubar=no,status=yes,toolbar=no,scrollbars=yes,resizable=yes,width=470,height=480,top=0,left=0')");
    }
    
}