﻿
if (typeof(HOSP2) == 'undefined') {
	HOSP2		= {};
	HOSP2.UI	= {};
}

HOSP2.UI.Global	= function()
{
	var init	= function() {
    
    
		//imageSwitch();
		slidesIn();
		//preload("../images/rollover/1.jpg","../images/rollover/2.jpg","../images/rollover/60.jpg","../images/rollover/53.jpg");
        for(var i = 0; i<arguments.length; i++)
	    {
	                
	        preload(arguments[i]);
	    }
	}
	
	var preload = function() {
	  for(var i = 0; i<arguments.length; i++)
	  {
	    $("<img>").attr("src", "../images/rollover/"+arguments[i]+".jpg");	   
	  }
	}
	
	
	var imageSwitch = function() {
		
		$("#switch > li > a").mouseover(function() {
			
			var theid = this.id
			var newimage = theid+'.jpg';
			$("#feature-box").css("background-image","url(../images/rollover/"+newimage+")");
		}
			
		);
		
	}
	    
	var slidesIn = function() {
		var imagearray = new Array();
		//read in the xml.			
		$.get(venueXmlFile,{},function(xml) { 		
			$('ITEM',xml).each(function() {			    
				var img = {};
				img.path = this.getAttribute('pic');		
				img.cur = false;
				imagearray[imagearray.length] = img;				
			});
				
			if (imagearray.length>0) {			    
    		
			    var h = $("#slideshow-box").height();
			    var w = $("#slideshow-box").width();
			    $("#slideshow-box").prepend('<div id="smokescreen" style="position: absolute; height: '+h+'px; width: '+w+'px; background-color: white;"></div>');
    			
			    if($.browser.msie && $.browser.version == '6.0') {
				    $("#slideshow-box").css('position', 'relative').prepend('<div id="ie6mustdie" style="width:0px; overflow: hidden; height: '+(h-25)+'px; position: absolute; z-index:101;"><img src="../images/venue_mask.gif" style="position: absolute; top: 0; right:0; width:656px; height:243px;" /></div>');
			    }
    			
			    var showSlide = function() {
				    var thisimage = false;
    				
				    for(var i = 0; i < imagearray.length; i++) {			
					    if(imagearray[i].cur == true) {					
						    if(imagearray[i+1]) {
							    thisimage = imagearray[i+1];
							    imagearray[i].cur = false;
							    thisimage.cur = true;
						    } else {
							    imagearray[i].cur = false;
							    thisimage = imagearray[0];
							    imagearray[0].cur = true;							
						    }
						    break;
					    }
				    }
				    if(!thisimage) {
					    thisimage = imagearray[0];
					    imagearray[0].cur = true;
				    }
    			
				    $("#smokescreen").fadeIn(2000, function() {
					    $("#slideshow-box").css("background-image","url("+thisimage.path+")");
					    $("#smokescreen").fadeOut(3000, function(){
						    showSlide();
					    });
				    });
    		
			    }
			    showSlide();
    					
		    };
		    
		});
		
			
	}	    
	    
	return {
		init: init
	}
	
}();

jQuery(function($) { HOSP2.UI.Global.init(); });