/**
 * Javascript for SBS World News
 * Jeff Lowder - 0419 350 760
 * www.different.com.au
 */
var SBSHome = function(){
    // private variables - only available to SBS method
    return {
	    startCarousel: function(carousel_name){
	        hCarousel = new UI.Carousel("horizontal_carousel",{scrollInc: 3});
	    },
	    
	    loadPhotoContent: function(photo,current){
	        // remove class=current from all of the items in the carousel
	        if(current == null){
	            // initial load of the page
	        } else {
	            $$('#horizontal_carousel a.current').each(function(item){
	               $(item).removeClassName('current');
	            });
	            $(current).addClassName('current');
	        }
	        // do the ajax load of page content
	        //$('photo_content').innerHTML = '<img src="images/ajax_loading.gif" alt="loading" />';
	        var photourl = 'includes/_photo_gallery_content.php';
	        var photopars = 'photo=' + photo;
	        var target = $('photo_content');
	        var photos = new Ajax.Updater(target, photourl, {
	                method: 'get',
	                parameters: photopars
	            });
	    },
	    
        initialise: function(){
             /**
             * if there's a photo gallery - load the ajax content and add the onclick functions
             */
            if($('photo_gallery')){
                $$('#photo_gallery li a').each(function(photo){
                    photo.onclick = function(){
                    	SBSHome.loadPhotoContent(this.rel,this);
                    }
                });
                SBSHome.startCarousel('horizontal_carousel');
                SBSHome.loadPhotoContent('photo1');
            }
        }
    };
    
}();
