var panelTimerId;
var curr_body_id=0;
function getQueryVariable(variable, dvalue) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
            return pair[1];
        }
    }
    return dvalue;
} 

function changeVideo(url, width, height, thumbnail) {

    if (thumbnail == null) {
        thumbnail = "/files/templates/pen/tc/images/overview/overview_tv.jpg";
    }

    if (url == '') {
        return;
    }
    if (width == null || isNaN(width) || width <= 0) {
        //width = 480;
        width = 624;
    }
    if (height == null || isNaN(height) || height <= 0) {
        //height = 270;
        height = 351;
    }
        
    var player_path = "/files/templates/pen/flash/mediaplayer.swf";
    
    var par = "file="+url+"&"
                    +"width="+width+"&"
                    +"heigh="+height+"&"
                    +"image="+thumbnail+"&"
                    +"showeq=false&"
                    +"searchbar=false&"
                    +"enablejs=false&"
                    +"autostart=false&"
                    +"showicons=true&"
                    +"showstop=false&"
                    +"showdigits=false&"
                    +"showdownload=false&"
                    +"usefullscreen=false&"
                    +"backcolor=0x000000&"
                    +"frontcolor=0xFFFFFF&"
                    +"lightcolor=0xFFFFFF&"
                    +"screencolor=0x000000";
                
    var player_html = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ' +
                            'WIDTH="'+width+'" HEIGHT="'+height+'" ID="charts" ALIGN="" VIEWASTEXT>' +
	                    '<PARAM NAME="movie" VALUE="'+player_path+'" />' +
	                    '<PARAM NAME="flashvars" Value="'+par+'" />' +	 
	                    '<PARAM NAME="quality" VALUE="high" />' +
	                    '<PARAM NAME="bgcolor" VALUE="#FFFFFF" />' +	                                       
	                    '<PARAM NAME="wmode" VALUE="transparent" /> ' +
	                    '<EMBED src="'+player_path+'" quality="high" ' +
	                        'flashvars="'+par+'" ' +
	                        'WIDTH="'+width+'" HEIGHT="'+height+'" NAME="charts" ALIGN="" swLiveConnect="true" bgcolor="#FFFFFF" wmode="transparent" ' +
	                        'TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>' +
                        '</OBJECT>';
                        
    $('mediaplayer').innerHTML = player_html;
                        
    /*
    if (swfobject.hasFlashPlayerVersion("9.0.0")) {
                var att = {
                    data: "/files/templates/pen/flash/mediaplayer.swf",
                    width: width,
                    height: height
                };


                var par = {
                    flashvars: "file="+url+"& "
                    +"width="+width+"&"
                    +"heigh="+height+"&"
                    +"image="+thumbnail+"&"
                    +"showeq=false&"
                    +"searchbar=false&"
                    +"enablejs=false&"
                    +"autostart=false&"
                    +"showicons=true&"
                    +"showstop=false&"
                    +"showdigits=false&"
                    +"showdownload=false&"
                    +"usefullscreen=false&"
                    +"backcolor=0x000000&"
                    +"frontcolor=0xFFFFFF&"
                    +"lightcolor=0xFFFFFF&"
                    +"screencolor=0x000000&"
                    +"overstretch=true"
                };

                var id = "mediaplayer";

                var mplayer = swfobject.createSWF(att, par, id);

        }
    */
}

var Body = new JS.Class({
    initialize: function(id,code, img_code, colors, title, summary, detail) {
        this.id=id;
        
        this.code = code;
        
        this.img_code = img_code;
        this.colors = colors;
        this.title = title;
        this.summary = summary;
        this.detail = detail;

        this.color = -1;
        this.items = new Array('', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
    },

    render: function(y, x) {
        var container;
        var panel;

        container = $('item-' + y + '-' + x);
        if (container == undefined)
            return;

        panel = panels[y][x]
        if (panel == null) {
            return;
        }

        var p;
        var html = '';
        var html1 = '';
        for (i = this.items.length - 1; i >= 0; i--) {
            if (this.items[i] == '') {
                if (html1.length > 0) {
                    html1 = "_" + html1;
                }
            } else {
                html1 = "_" + this.items[i] + html1;
            }
        }

        if (this.colors == null) {
            p = {
                imgcode: this.img_code,
                x: x,
                y: y,
                items: html1
            }
            html = templates.bodyImg.evaluate(p);

        } else {
            if (this.color == null || this.color < 0 || this.color >= this.colors.length) {
                this.color = 0;
            }
            if (this.colors[this.color][0] == '') {
                p = {
                    imgcode: this.img_code,
                    x: x,
                    y: y,
                    items: html1
                }
                html = templates.bodyColor.evaluate(p);
            }
            else {
                p = {
                    imgcode: this.img_code,
                    x: x,
                    y: y,
                    color: this.colors[this.color][0],
                    items: html1
                }
                html = templates.bodyColorImg.evaluate(p);
            }
        }
        container.update(html);

    },

    rendercolor: function(y, x) {
        var container;

        container = $('item-' + y + '-' + x);
        if (container == undefined)
            return;

        var html = '';
        var p;
        if (this.colors != null) {
            for (i = 0; i < this.colors.length; i++) {
                p = {
                    x: 'center',
                    y: 'top',
                    idx: i,
                    desc: this.colors[i][1],
                    icon: this.colors[i][3]
                }

                if (p.icon.length == 0) {
                    html += templates.bodyColorLITextOnly.evaluate(p);
                } else {
                    html += templates.bodyColorLI.evaluate(p);
                }

            }
            p = {
                li: html
            }
            html = templates.bodyColorUL.evaluate(p);
        }
        container.update(html);
    },


    changecolor: function(color) {
        this.color = color;
        this.render('top', 'center');
    },

    showpanel: function(y, x) {
        var panel = panels[y][x];
        if (panel == null)
            return;

        panel.show();
    },


    hidepanel: function(y, x, delay) {
        var panel = panels[y][x];
        if (panel == null)
            return;

        if (delay == null) {
            delay = 250;
        }
        panel.hide(delay);
    },


    showdetail: function(y, x) {
        this.hidepanel(y, x, 0);

        dlgdetail.setHeader(this.gettitle());
        dlgdetail.setBody(this.getdetail());
        /*dlgdetail.setFooter('<a href="#" onclick="dlgdetail.hide()">'
        + '<img src="/files/templates/pen/tc/images/product/btn_close.gif"/>'
        + '</a>');*/


        dlgdetail.render(document.body);
        dlgdetail.show();

    },

    gettitle: function() {
        var title = this.title;
        if (this.colors != null) {
            if (this.color >= 0 && this.color < this.colors.length) {
                title += this.colors[this.color][2];
            }
        }
        return title;
    },

    getsummary: function() {
        return this.summary;
    },

    getdetail: function() {
        return this.detail;
    },

    getlink: function(y, x) {
        var html;
        var p = {
            y: y,
            x: x,
            color: this.color

        }
        html = templates.bodyLink.evaluate(p);
        return html;
    },

    combine: function(item) {
        //alert(item.seq);
        this.items[item.seq] = item.img_code;
    },

    reset: function(y, x) {
        for (i = 0; i < this.items.length; i++) {
            this.items[i] = '';
        }

        drawall();

    }
});



var Accessory = new JS.Class({
    initialize: function(body_id,code, img_code, title, summary, detail, seq) {
        this.body_id = body_id;
        this.code = code;
        //alert(curr_body_id);
        this.img_code = img_code;
        this.title = title;
        this.summary = summary;
        this.detail = detail;
        if (seq >= 0 && seq < 15) {
            this.seq = seq;
        }
        else {
            this.seq = -1;
        }
    },

    render: function(y, x) {
        var container;
        //var panel;

        //alert(items['top']['center'].items[this.seq]);

        container = $('item-' + y + '-' + x);
        if (container == undefined)
            return;

        //panel = panels[y][x]
        //if (panel == null) {
        //    return;
        //}

        //alert("y:" + y + "x:" + x);
        var html;
        var p = {
            imgcode: this.img_code,
            x: x,
            y: y
        }
        if (items['top']['center'].items[this.seq] == this.img_code) {
            html = templates.accessoryHide.evaluate(p);
        } else {
        
            var arVersion = navigator.appVersion.split("MSIE")
            var version = parseFloat(arVersion[1])

            if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
                html = templates.accessoryImgIE6.evaluate(p);
            } else {
                html = templates.accessoryImg.evaluate(p);
            }
        }

        container.update(html);
    },

    showpanel: function(y, x) {
        var panel = panels[y][x];
        if (panel == null)
            return;

        panel.show();
    },


    hidepanel: function(y, x, delay) {
        var panel = panels[y][x];
        if (panel == null)
            return;

        if (delay == null) {
            delay = 250;
        }

        panel.hide(delay);

    },


    showdetail: function(y, x) {
      
        this.hidepanel(y, x, 0);

        dlgdetail.setHeader(this.gettitle());
        dlgdetail.setBody(this.getdetail());
        /*dlgdetail.setFooter('<a href="#" onclick="dlgdetail.hide()">'
        + '<img src="/files/templates/pen/tc/images/product/btn_close.gif"/>'
        + '</a>');*/
        dlgdetail.render(document.body);
        dlgdetail.show();
    },

    gettitle: function() {
        return this.title;
    },

    getsummary: function() {
        return this.summary;
    },
    getdetail: function() {
        return this.detail;
    },

    getlink: function(y, x) {
        var html;
        var p = {
            y: y,
            x: x
        }
        html = templates.accessoryLink.evaluate(p);
        return html;
    },


    move: function move(el, y, x) {
        items[y][x].hidepanel(y, x, 0);

        //alert(el);
        var attributes = {
            points: { to: [YAHOO.util.Region.getRegion("item-" + y + "-left").left + 251,
                    YAHOO.util.Region.getRegion("item-" + y + "-" + x).top]
            }
        };
        var anim = new YAHOO.util.Motion(el, attributes);

        if (this.seq >= 0 && this.seq < 15) {
            items['top']['center'].combine(items[y][x]);
        }

        anim.onComplete.subscribe(function() {
            items[y][x].hidepanel(y, x, 0);
            drawall();
        });
        anim.animate();


    }

});


var Panel = new JS.Class({
    initialize: function(y, x, offsety, offsetx, delay, panel) {
        this.x = x;
        this.y = y;
        this.panel = panel;

        var el;
        el = new YAHOO.util.Element(panel.element);
        el.on("mouseover", this.mouseover, this);
        el.on("mouseout", this.mouseout, this);

        this.timer = -1;
        this.ctxtimer = -1;

        this.delay = delay;

        this.offsetx = offsetx;
        this.offsety = offsety;
    },

    show: function() {
        try {
            clearTimeout(panelTimerId);
        } catch (e) {
        };

        panelTimerId = setTimeout('eval(panels["' + this.y + '"]["' + this.x + '"]).showdelay()', 300);
    },


    showdelay: function(e) {
        container = $('item-' + this.y + '-' + this.x);
        if (container == undefined)
            return;

        this.showctx();
        /*
        this.ctxtimer = setTimeout('eval(panels["' + this.y + '"]["' + this.x + '"]).showctx()', this.delay);

        this.panel.setHeader('');
        this.panel.setBody('');
        this.panel.setFooter('');
        */

        this.panel.cfg.setProperty("xy", 
        [YAHOO.util.Region.getRegion('item-' + this.y + '-' + this.x).left + this.offsetx,
        YAHOO.util.Region.getRegion('item-' + this.y + '-' + this.x).top + this.offsety]);

        //container.style = "background-image:url()"
        //this.panel.render(container);
        //alert(container.innerHTML);
        //this.panel.show();
        /*
        if ($('panel-' + this.y + '-' + this.x)) {
        var tempBackground = $('panel-' + this.y + '-' + this.x).getStyle('background-image')
        var checkIndex = tempBackground.indexOf('?') == -1 ?tempBackground.length -2 : tempBackground.indexOf('?')
        var tempBackground = tempBackground.substring(0, checkIndex) + '?' + Math.random() + '")';
        $('panel-' + this.y + '-' + this.x).setStyle({ backgroundImage: tempBackground });
        }
        */

    },

    showctx: function(e) {
        var item = items[this.y][this.x];

        this.panel.setHeader(item.gettitle());
        this.panel.setBody(item.getsummary());
        this.panel.setFooter(item.getlink(this.y, this.x));

        this.panel.render(container);
        this.panel.show();

        this.hide(5000);
    },

    hide: function(delay) {
        try {
            clearTimeout(panelTimerId);
            clearTimeout(this.timer);
        } catch (e) {
        };

        if (delay == null) {
            delay = 250;
        }
        this.timer = setTimeout('eval(panels["' + this.y + '"]["' + this.x + '"]).dohide()', delay);
    },


    dohide: function(e) {
        try {
            clearTimeout(this.ctxtimer);
        } catch (e) { };

        this.panel.hide();
    },

    mouseover: function(e, panel) {
        try {
            clearTimeout(panel.timer);
        }
        catch (e) { }
    },

    mouseout: function(e, panel) {

        // Determine if this is a real mouseout or internal to the panel
        // From http://www.quirksmode.org/js/events_mouse.html

        // target: place the mouse moved out of
        // relatedTarget: place the mouse moved to   
        var tg = YAHOO.util.Event.getTarget(e, true);
        if (tg.nodeName != 'DIV') { // Did mouse move out of a non-div?
            return;  // spurious mouseout from an anchor or something
        }

        // Is the relatedTarget (moved to place) a descendent of the panel?
        var reltg = YAHOO.util.Event.getRelatedTarget(e);
        tg = panel.panel.element;

        while (reltg != tg && reltg.nodeName != 'BODY')
            reltg = reltg.parentNode
        if (reltg == tg) return;

        // Mouseout took place
        clearTimeout(panel.ctxtimer);
        panel.panel.hide();
    }
});

function changecolor(color) {
    if (items['top']['center'].color == color)
        return;

    items['top']['center'].color = color;
    draw('top', 'center');
    
}

function nextitem(y) {
    var item = items[y]['left'];

    if (item == null)
        return;
    if (item.next == null) {
        return;
    }

    item = item.next;

    items[y]['left'] = item;
    items[y]['right'] = item.next;

    draw(y, 'left');
    draw(y, 'right');
}

function previtem(y) {
    var item = items[y]['left'];

    if (item == null)
        return;
    if (item.prev == null) {
        return;
    }

    item = item.prev;
    
    items[y]['left'] = item;
    items[y]['right'] = item.next;

    draw(y, 'left');
    draw(y, 'right');
}

function nextbody() {
    var item = items['top']['center'];

    if (item == null)
        return;
    if (item.next == null) {
        return;
    }

    item = item.next;

    items['top']['center'] = item;
    if (item != null) {
        if (item.colors == null) {
            item.color = -1;
        } else {
            item.color = 0;
        }
    }
    curr_body_id=item.id;
    //alert(top_accs_22.at(0).body_id);
    //alert(curr_body_id);
    
    
      eval("items['top']['left'] = top_accs_"+curr_body_id+".at(0)");
      eval("items['top']['right'] = top_accs_"+curr_body_id+".at(0).next");

      eval("items['middle']['left'] = middle_accs_"+curr_body_id+".at(0)");
      eval("items['middle']['right'] = middle_accs_"+curr_body_id+".at(0).next");
    
    
            
    drawall();
}

function prevbody() {
    var item = items['top']['center'];

    if (item == null)
        return;
    if (item.prev == null) {
        return;
    }

    item = item.prev;

    items['top']['center'] = item;

    if (item != null) {
        if (item.colors == null) {
            item.color = -1;
        } else {
            item.color = 0;
        }
    }
    curr_body_id=item.id;
    //alert(curr_body_id);
          eval("items['top']['left'] = top_accs_"+curr_body_id+".at(0)");
      eval("items['top']['right'] = top_accs_"+curr_body_id+".at(0).next");

      eval("items['middle']['left'] = middle_accs_"+curr_body_id+".at(0)");
      eval("items['middle']['right'] = middle_accs_"+curr_body_id+".at(0).next");
    
            
    drawall();
}

function drawall() {
    draw('top', 'left');
    draw('top', 'center');
    draw('top', 'right');

    draw('middle', 'left');
    draw('middle', 'right');

    //draw('bottom', 'left');
    //draw('bottom', 'right');

    drawcolor('bottom', 'center');
}

function draw(y, x) {
    
    container = $('item-'+y+'-'+x);
    if (container == undefined) 
        return;

    var item = items[y][x];
    if (item == null) {
        container.update('');
    } else {
        item.render(y, x);
    }    
}

function drawcolor(y, x) {

    container = $('item-' + y + '-' + x);
    if (container == undefined)
        return;

    var item = items['top']['center'];
    if (item == null) {
        container.update('');
    } else {
        item.rendercolor(y, x);
    }
}




var Artwork = new JS.Class({
    initialize: function(type, id, title, thumbnail, url, idx) {
        this.type = type,
        this.id = id,
        this.title = title,
        this.thumbnail = thumbnail,
        this.url = url,
        this.idx = idx
    }
});

var Frame = new JS.Class({
    initialize: function(container, artwork) {
        this.container = container,
        this.artwork = artwork
    },


    showidx: function() {
        var html = '';

        container = $(this.container);
        if (container == undefined)
            return;

        if (this.artwork != null) {
            html += this.drawidx(this.artwork);

            if (this.artwork.next != null && this.artwork != this.artwork.next) {
                html += this.drawidx(this.artwork.next);
                if (this.artwork.next.next != null && this.artwork.next != this.artwork.next.next && this.artwork != this.artwork.next.next) {
                    html += this.drawidx(this.artwork.next.next);
                }
            }
        }
        container.update(html);

    },

    drawidx: function(artwork) {
        var p;
        var html = '';

        p = {
            title: artwork.title,
            url: artwork.thumbnail,
            full_url: artwork.url,
            id: artwork.id,
            idx: artwork.idx,
            size: 250
        }
        if (artwork.type == 'photo') {
            html = templates.artworkPhotoIdx.evaluate(p);
        } else if (artwork.type == 'video') {
            html = templates.artworkVideoIdx.evaluate(p);
        } else if (artwork.type == 'wallpaper') {
            html = templates.artworkWallpaperIdx.evaluate(p);
        } else if (artwork.type == 'pdf') {
            html = templates.artworkPDFIdx.evaluate(p);
        } else if (artwork.type == 'download_video') {
            html = templates.artworkDownloadVideoIdx.evaluate(p);
        } else{         
            html = templates.artworkPDFIdx.evaluate(p);
        }
        return html;
    },

    show: function() {
        var p;
        var html = '';

        container = $(this.container);
        if (container == undefined)
            return;

        if (this.artwork != null) {
            p = {
                title: this.artwork.title,
                thumbnail: this.artwork.thumbnail,
                url: this.artwork.url,
                id: this.artwork.id
            }
            if (this.artwork.type == 'photo') {
                html = templates.artworkPhoto.evaluate(p);
            } else {
                html = templates.artworkVideo.evaluate(p);
            }

        }
        //alert(html)
        container.update(html);

        if (this.artwork.type == 'photo') {
            /*
            var oImg = $('photo_' + this.artwork.id);
            if (oImg == undefined)
                return;

            //EXIF.getData(oImg, this.showexif);

            //alert(oImg.id+":"+EXIF.pretty(oImg));
            
            
            //EXIF.getData(oImg, showexif_outside(this));
            showexif_outside(this);
            */
            showexif_ajax2(this);
        }

    },

    showexif: function() {
        var p;
        var html = '';

        var oImg = $('photo_' + this.artwork.id);
        if (oImg == undefined)
            return;
        //alert(oImg.id+":"+EXIF.pretty(oImg));

        container = $(this.container);
        if (container == undefined)
            return;

        if (this.artwork != null) {
            p = {
                title: this.artwork.title,
                url: this.artwork.url,
                id: this.artwork.id,
                ISOSpeedRatings: EXIF.getTag(oImg, "ISOSpeedRatings"),
                ShutterSpeedValue: EXIF.getTag(oImg, "ShutterSpeedValue"),
                ApertureValue: EXIF.getTag(oImg, "ApertureValue"),
                FocalPlaneXResolution: EXIF.getTag(oImg, "FocalPlaneXResolution"),
                FocalPlaneYResolution: EXIF.getTag(oImg, "FocalPlaneYResolution"),
                filesize: ''


            }
            if (this.artwork.type == 'photo') {
                html = templates.artworkPhotoExif.evaluate(p);
            }

        }
        container.update(html);
    },

    previdx: function() {
        this.artwork = this.artwork.prev;
        this.showidx();
    },

    prev: function() {
        this.artwork = this.artwork.prev;
        this.show();
    },

    next: function() {
        this.artwork = this.artwork.next;
        this.show();
    },

    nextidx: function() {
        this.artwork = this.artwork.next;
        this.showidx();
    },

    index: function() {
        var idx = -1;
        if (this.artwork != null) {
            idx = this.artwork.idx;
        }
        return idx;
    }

});


// add by evans 20091008 start
function showexif_outside(ob) {
    setTimeout(function(){showexif_outside2(ob);},1000);
}
function showexif_outside2(ob) {
    var p;
    var html = '';

    var oImg = $('photo_' + ob.artwork.id);
    if (oImg == undefined)
        return;
    //alert(oImg.id+":"+EXIF.pretty(oImg));

    container = $(ob.container);
    if (container == undefined)
        return;

    if (ob.artwork != null) {
        p = {
            title: ob.artwork.title,
            url: ob.artwork.url,
            id: ob.artwork.id,
            ISOSpeedRatings: EXIF.getTag(oImg, "ISOSpeedRatings"),
            ShutterSpeedValue: EXIF.getTag(oImg, "ShutterSpeedValue"),
            ApertureValue: EXIF.getTag(oImg, "ApertureValue"),
            FocalPlaneXResolution: EXIF.getTag(oImg, "FocalPlaneXResolution"),
            FocalPlaneYResolution: EXIF.getTag(oImg, "FocalPlaneYResolution"),
            filesize: ''


        }
        if (ob.artwork.type == 'photo') {
            html = templates.artworkPhotoExif.evaluate(p);
        }

    }
    container.update(html);
}

function showexif_ajax(ob) {
    if (ob.artwork != null) {

        var url = '/autoresizeEXIF.aspx';

        var params= Object.extend({ 
			    path:ob.artwork.url,
			    rand:Math.floor(Math.random()*10000000)
        });

        var myAjax = new Ajax.Request(
            url,
            {
                method: 'post',
                parameters: params,
                onComplete: function(originalRequest) {
                                //alert(originalRequest.responseText);
		  	  	                var EXIFData = originalRequest.responseText.evalJSON(true);
    		  	  	            
		  	  	                //alert(EXIFData.path);
		  	  	                if (EXIFData.path == "unknown") {
		  	  	                    setTimeout(function(){showexif_ajax(ob);},1000);
		  	  	                } else {
    		  	  	                p = {
                                        title: ob.artwork.title,
                                        url: ob.artwork.url,
                                        id: ob.artwork.id,
                                        Lens: EXIFData.lens_data,
                                        Exposure_mode: EXIFData.exposure_data,
                                        Art_Filter: EXIFData.art_data,
                                        Shutter_speed: EXIFData.shutter_data,
                                        Aperture_value: EXIFData.aperture_size,
                                        ISO_sensitivity: EXIFData.iso_data,
                                        White_balance: EXIFData.white_data,
                                        Image_size: EXIFData.imagesize_data,
                                        Recording_format: EXIFData.recording_data,
                                        filesize: EXIFData.file_size
                                    }
                                    
                                    if (ob.artwork.type == 'photo') {
                                        html = templates.artworkPhotoExif.evaluate(p);
                                    }
                                    
                                    container.update(html);
		  	  	                }
                            }
            }
        );
        
    }
}

function showexif_ajax2(ob) {
    if (ob.artwork != null) {
    
        var url = '/tc/pen/ajax_data/gallery_exif.html';

        var params= Object.extend({ 
			    id:ob.artwork.id,
			    rand:Math.floor(Math.random()*10000000)
        });

        var myAjax = new Ajax.Request(
            url,
            {
                method: 'post',
                parameters: params,
                onComplete: function(originalRequest) {
                                //alert(originalRequest.responseText);
		  	  	                var EXIFData = originalRequest.responseText.evalJSON(true);

    		  	  	            var html = "<table>";    		  	  	            
    		  	  	            for(var i=1; i <= EXIFData.Data.length; i++) {
    		  	  	                var temp_data = EXIFData.Data[i-1];
    		  	  	            
    		  	  	                html += "<tr>";
    		  	  	                html += "<td class=\"name\">"+temp_data.label+"</td>";
    		  	  	                
    		  	  	                if ((i % 2) == 1) {
    		  	  	                    html += "<td class=\"value-odd\">";
    		  	  	                } else {
    		  	  	                    html += "<td class=\"value\">";
    		  	  	                }
    		  	  	                
    		  	  	                html += temp_data.value+"</td>";
    		  	  	                html += "</tr>";
    		  	  	            }    		  	  	            
    		  	  	            html += "</table>";    		  	  	            
    		  	  	            
    		  	  	            //alert(html);
    		  	  	            if ($('gallery_exif_div') != null) {
                                    $('gallery_exif_div').innerHTML = html;
                                }
                            }
            }
        );
        
    }
}
// add by evans 20091008 end

function closephoto() {
    var idx = -1;
    if (frame != null) {
        idx = frame.index();
    }
    var url = '../gallery.html';
    if (idx > 0) {
        url += '?pi=' + idx;
    }
    window.open(url, '_self');
}

/*
function closevideo() {
    var idx = -1;
    if (frame != null) {
        idx = frame.index();
    }
    var url = '../gallery.html';
    if (idx > 0) {
        url += '?vi=' + idx;
    }
    window.open(url, '_self');
}
*/
function closevideo() {
    window.history.back(-1);
}


function showlens(title, url) {
    var dlglens = new YAHOO.widget.SimpleDialog("dlglens", {
        width: "675px",
        height: "400px",
        fixedcenter: true,
        constraintoviewport: true,
        modal: true,
        visible: false,
        draggable: false,
        effect: { effect: YAHOO.widget.ContainerEffect.FADE, duration: 1.0 }
    });

    dlglens.setHeader(title);
    dlglens.setBody("<img src="+url+" />");
   
    dlglens.render(document.body);
    dlglens.show();


}