//jQuery.noConflict();
var $j = jQuery.noConflict();

var nNetSplash = {
	
	// Setup vars
	popi : 0,
	autoPopper : true,
	community : '.community img',
	sports : '.sports img',
	buyandsell : '.buyandsell img',
	congratulations : '.congratulations img',
	popupElement : ['.popup_community','.popup_sports','.popup_buyandsell','.popup_congratulations'],

	autoPopperOnLoad : function(){
		if(this.popi < this.popupElement.length && this.autoPopper){
			currentItem = this.popupElement[this.popi];
			_popthis = this;
			$j(this.popupElement[this.popi]).fadeIn('100', function(){
				timer = setTimeout("nNetSplash.autoPopperIterator()", 1500);
			});
		} else {
			nNetSplash.autoPopper = false; 
		}
	},
	
	autoPopperIterator : function(){
		$j(_popthis.popupElement[_popthis.popi]).fadeOut(); 
		_popthis.popi++; 
		_popthis.autoPopperOnLoad();
	},
	
	stopAutoPopper : function(){
		if(this.autoPopper == true){
			nNetSplash.autoPopper = false;
			$j(_popthis.popupElement[_popthis.popi]).hide();
		}
		
	},
	
	ani_community : function() {
	  $j(this.community).fadeIn(800, function() {
	    var this_comm = $j(this);     
	    setTimeout(function() { this_comm.fadeOut(800, 
	      function() { 
	        nNetSplash.ani_community();
	      });
	    },1000); // Loop timeout
	  });
	},
	
	ani_sports : function() {
	  $j(this.sports).fadeOut(500, function() {
	    var this_sports = $j(this);     
	    setTimeout(function() { this_sports.fadeIn(500, 
	      function() { 
	        nNetSplash.ani_sports();
	      });
	    },4000); // Loop timeout
	  });
	},
	
	ani_buyandsell : function() {
	  $j(this.buyandsell).fadeIn(800, function() {
	    var this_buyandsell = $j(this);     
	    setTimeout(function() { this_buyandsell.fadeOut(800, 
	      function() { 
	        nNetSplash.ani_buyandsell();
	      });
	    },1600); // Loop timeout
	  });
	},
	
	ani_congratulations : function() {
	  $j(this.congratulations).fadeIn(1200, function() {
	    var this_congratulations = $j(this);     
	    setTimeout(function() { this_congratulations.fadeOut(800, 
	      function() { 
	        nNetSplash.ani_congratulations();
	      });
	    },2000); // Loop timeout
	  });
	},
	
	
	hoverTrigger : function(){
		// Popup hover events
		$j('.hit_community a, .community').hover(
			function(){ $j('.popup_community').show(); nNetSplash.stopAutoPopper(); },
			function(){ $j('.popup_community').hide(); }
		);

		$j('.hit_sports a').hover(
			function(){ $j('.popup_sports').show(); nNetSplash.stopAutoPopper(); },
			function(){ $j('.popup_sports').hide(); }
		);

		$j('.hit_buyandsell a, .buyandsell').hover(
			function(){ $j('.popup_buyandsell').show(); nNetSplash.stopAutoPopper(); },
			function(){ $j('.popup_buyandsell').hide(); }
		);

		$j('.hit_congratulations a, .congratulations').hover(
			function(){ $j('.popup_congratulations').show(); nNetSplash.stopAutoPopper(); },
			function(){ $j('.popup_congratulations').hide(); }
		);
	},
	
	init : function(){
		// Trigger autoshow popups
		nNetSplash.autoPopperOnLoad();
		nNetSplash.hoverTrigger();
		
		// Start animation loops
		nNetSplash.ani_community();
		nNetSplash.ani_sports();
		nNetSplash.ani_buyandsell();
		nNetSplash.ani_congratulations();

	}
	
};

$j(document).ready(function(){

	nNetSplash.init();
	
	$j('.hit_sports').bgiframe();
	$j('.hit_community').bgiframe();
	$j('.hit_buyandsell').bgiframe();
	$j('.hit_congratulations').bgiframe();
	if ($j.browser.msie && $j.browser.version.substring(0,1) === '6'){
	    try {
			document.execCommand('BackgroundImageCache', false, true);
		} catch(e) {};
	}
});
