﻿/**
 *  Gallery Script
 *
 *  Date:       08/02/2008
 *  Author:     Michael Giuliano
 *  Copyright:  Live Nation Music UK
 */

var Gallery = Class.create();
Gallery.prototype = {

    /** Parameters **/ 
    __FEED_PAGE: '/gallery/gallery.aspx',
    
    /** Global Variables **/ 
    gal_Id: '',
    gal_Obj: null,
    gal_Params: null,
    gal_fo: null,
    
    initialize: function(args) {

        this.gal_Id = args[0];
        this.gal_Obj = $(args[0]);
        this.gal_Params = args[1];
        
        // Add Flash Object
        this.gal_fo = new SWFObject(
            this.gal_Params['flash_src'],
            this.gal_Id, 
            this.gal_Params['flash_dimensions'][0], 
            this.gal_Params['flash_dimensions'][1], 
            this.gal_Params['flash_version'], 
            this.gal_Params['flash_bg']
        );
        
        // Get QueryString
        var qs = location.search;
        if(qs == '') {
            var search_term = { 
                s_type: 'DEFAULT',
                s_string: 'DEFAULT'
            };
        } else {
            var s = qs.split('?')[1];
            var search_term = { 
                s_type: s.split('=')[0],
                s_string: s.split('=')[1]
            };            
        }
        this.setGallery(search_term);
        
    },
	
	setGallery: function(g) {
	    var url = this.__FEED_PAGE + '?galleryName=' + g['s_type'] + '_' + g['s_string'];
	    this.gal_fo.addVariable('xmlfile', url);
	    this.gal_fo.write(this.gal_Obj);
    }
    

};