﻿$(document).ready(function() {
    flash();
    // re-bind
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_endRequest(function() {
        flash();
    }); 
});

function flash() {

    $("div #three-d").css("left", ($(window).width() - 780) / 2 + "px");

    // lnk3d =>(.NET)=> ctl00_mainContent_lnk3d
    $("div #ctl00_mainContent_dvLink3d").click(function () {
        //        inject3d();
        //        var pathSwf = "/_repository/_resources/_swf/360-view-v4.swf";
        //        var params = { menu: false };
        //        var attributes = {};
        //        var flashvars = { pName: pName3d, pPath: path3d, controller: "true", controllerColor: "0xd70000" };
        //        swfobject.embedSWF(pathSwf, "three-fl", "688", "480", "8.0.0", "/_repository/_resources/_ecma/2010/swfobject/expressInstall.swf", flashvars, params, attributes);
        var index = 0;
        var img = path3d + pName3d + '_000' + index + '.png';
        $("#image").attr('src', img);
        
        var imges = new Array();
        for (index = 0; index < 12; index++) {
            if (index < 10) { img = path3d + pName3d + '_000' + index + '.png'; } else { img = path3d + pName3d + '_00' + index + '.png'; }
            imges[index] = img;
        }
        $("div #three-d").css("display", "block"); $("div.overDetail").css("display", "block");
        
        $("#image").threesixty({ images: imges, method: 'click', direction: 'forward', sensibility: 1 });

        return false;
    });
    $("#three-close").click(function() {
        $("div #three-flash").empty().append('<p id="three-fl"></p>');
        $("div #three-d").css("display", "none"); $("div.overDetail").css("display", "none");
    });
    //$(".facebox").facebox();
}

function inject3d() {
    $("p #three-fl").empty().append('<h1>Whoops!</h1><p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a>');
}

