﻿// global namespace
var DMG = {};

/****** On dom ready ******/
$(document).ready( function() {
    $(".imgover")
    .hover(
        function () {
            this.src = this.src.replace(".png","x.png").replace(".gif","x.gif");
        },
        function () {
            this.src = this.src.replace("x.png",".png").replace("x.gif",".gif");
        }
    );
    
    
});

/****** On Window loaded ******/
$(window).bind('load', function () {
//once window is fully loaded including all images etc
    $(".imgover").each( 
        function () {
            $('<img />')
            .attr('src', this.src.replace(".png","x.png").replace(".gif","x.gif"))
            .load(function(){
                $('#hidden').append( $(this) );
            });
        });
});

/****** 
 * display movie on element click
 * alex 27.5.2009
 *******/

DMG.expandMovie = function (obj) {
        
    var that = this;
    var id = obj.id;
    var element = $('#'+id);
    var movie = obj.movie;
    
    that.show = function () {       
        
        if(!$('#movieholder').length) {
            //if no holder exists then create the holder
            $('div:last').after('<div id="movieholder"><div id="movieclose">close &raquo;&nbsp;&nbsp;</div><div id="playerdiv"></div></div>');
        }
        
        //set the close event
        $('#movieclose').click(function () {that.hide();});
        
        //position the holder
        var xe = $('#movieholder');
        xe.css({'top' : element.offset().top, "left" : element.offset().left , 'position' : 'absolute' });
        
        //show the holder
        xe.show(500, function() {
            //on complete write the movie into the holder
            var so = new SWFObject('http://www.the7thchamber.com/show/mediaplayer.swf','mpl','300','250','9','#000000');
		    so.addParam('allowfullscreen','false');
		    so.addParam('allowscriptaccess','always');
		    so.addVariable('file',''+ movie +'');
		    so.addVariable('height','250');
		    so.addVariable('width','300');
		    so.addVariable('frontcolor','0xffffff');
		    so.addVariable('backcolor','0x000000');
		    so.addVariable('lightcolor','0xff6600');
		    so.addVariable('shuffle','false');
		    so.addVariable('overstretch','true');
		    so.addVariable('autostart','true');
		    so.addVariable('searchbar','false');
		    so.write('playerdiv');
      
        });
        
        
        
        
    }
    
    that.hide = function () {        
        //unload player
        $('#playerdiv').empty();
        $('#movieholder').hide(500);
    }
      
    return {
        init : function () {
            element.click(
                function () {   
                    that.show();  
                }
            );
        }(),
        show : that.show,
        hide : that.hide
    }
};
