﻿/*
    当选择框子option的其中一项时,出现的大框子. 包含几个图片. 
*/
var CurrentPlayStatus="";
var FrameShowbox = Class.create();
FrameShowbox.prototype = {

    initialize : function(container)
    {
        this.container = $(container);
        
        this.container.className = 'frameshowbox_container';
        this.div_title = $C_DIV('','frameshowbox_title',this.container);
        this.div_bigpic = $C_DIV('','frameshowbox_bigpic',this.container);
        this.div_picbox = $C_DIV('','frameshowbox_picbox',this.container);
        this.div_price = $C_DIV('','frameshowbox_price',this.container);
        
        this.div_pic1 = $C_DIV('','frameshowbox_pic',this.div_picbox);
        this.div_pic2 = $C_DIV('','frameshowbox_pic',this.div_picbox);
        this.div_pic3 = $C_DIV('','frameshowbox_pic',this.div_picbox);      
    },
    
    show: function()
    {
        if(typeof(getSlide) != "undefined")
        {
            try
            {
                if(getSlide().slideState()=="play") 
                {
                    getSlide().setSlideState("stop");                
                    CurrentPlayStatus="play";
                }
            }catch(e){}
        }
        this.container.style.visibility = 'visible';    
    },
    
    hide: function()
    {
        if(typeof(getSlide) != "undefined")
        {
            try
            {
                if(CurrentPlayStatus=="play") 
                {
                    getSlide().setSlideState("play");
                    CurrentPlayStatus="";
                }
            }catch(e){}
        }
        this.container.style.visibility = 'hidden';
    },
    
    /*
        设置数据
        itemObject - ITEM数据
        foldername - 目录名称
    */
    setData : function( itemObject , foldername ,evt)
    {
        this.clearData();
        var data = itemObject;     
        this.div_title.innerHTML = data.LongDescription;
        this.div_price.innerHTML="Price:  $"+ data.Price;
        if(data.ItemCode == "gwo")
        {
            this.div_bigpic.innerHTML=data.Description;
            return ;
        }
        var imgurl = '/frameimage/' + foldername + '/' + data.OptionItemId + '/' + '1.jpg';
        this.div_bigpic.style.backgroundImage = 'url(' + imgurl + ')';
        
        imgurl = '/frameimage/' + foldername + '/' + data.OptionItemId + '/' + '2.jpg';
        this.div_pic1.innerHTML = "<img src='" + imgurl + "'></img>";
        imgurl = '/frameimage/' + foldername + '/' + data.OptionItemId + '/' + '3.jpg';
        this.div_pic2.innerHTML = "<img src='" + imgurl + "'></img>";
        imgurl = '/frameimage/' + foldername + '/' + data.OptionItemId + '/' + '4.jpg';
        this.div_pic3.innerHTML = "<img src='" + imgurl + "'></img>";
        var scrollPoint=getScroll();
        if (scrollPoint.top>=170)
        {
            this.container.style.top=scrollPoint.top+10+'px';
        }
        else
        {
            this.container.style.top = "170px";        
        }
        if(frameShowboxTipLeft)
        {           
            this.container.style.top = "70px"; 
            var ev = evt;
            if(window.event){
                ev = window.event;
            } 
            var tx = ev.clientX;
            if(tx > 340)
            {
                this.container.style.left = "-10px";
            }
            else
            {
                this.container.style.left = "330px";
            }
        }
    },
    clearData : function()
    {
        this.div_bigpic.style.marginTop="0px";
        this.div_bigpic.innerHTML="";
        this.div_bigpic.style.backgroundImage="";
        this.div_pic1.innerHTML ="";
        this.div_pic2.innerHTML ="";
        this.div_pic3.innerHTML ="";
    }    
}