Learn how to use jQuery at the Blog

Save money with Gates « visit

  • Added 8 months ago
  • 91 Lines of Code shown
  • 3 Links of Interest
http://savemoneywithgates.com
This is my Source Code and I don't want to show it here
View Source Code only (as overlay)
// That code snippet belongs to Save money with Gates - http://savemoneywithgates.com

$(document).ready(function(){
	
	//  headerimg 
	var flashImg = $("#headerimg");
	// The name of the session cookie 
	var cookieName = 'dontshowflash';
	// The value of the session cookie (any value will work)
	var cookieValue = 1;

	//	if cookie exists > show flash header loop version, else show header onload
	if ($.cookie(cookieName)) {
		// Remove the image
		flashImg.remove();		
		$('#masthead').flash({
			src: 'flash/mastheadloop.swf',
			width: 970,
			height: 278,
			menu:false,
			flashvars: { homepage: 'true' }
		});
	}


//make all shortcuts fully clickable:
	$("#shortcuts li").css('cursor', 'pointer');
	$("#shortcuts li").click(function(){
	  	window.location=$(this).find("a").attr("href"); return false;
	});

	//Rollover for shortcuts right menu, not for IE6:
	if($.browser.msie && $.browser.version.substr(0, 1) < 7){
	
	//do nothing
	}else{
		$('#shortcuts li').hover(
		  function () {
			var myImage = $(this).find("img");
			var src = myImage.attr("src").match(/[^\.]+/) + "_mouseover.png";
			//var src = myImage.attr("src").replace(/\.(.+)$/i, "_on.$1");
			myImage.attr("src", src);
		  }, 
		  function () {
			var myImage = $(this).find("img");
			var src =  myImage.attr("src").replace("_mouseover", "");
			myImage.attr("src", src);
		  }
		);
	}

}); // end .ready

$(window).bind('load', function() {
    var preload = new Array();
    $('#shortcuts li img').each(function() {
        s = $(this).attr("src").replace(/\.(.+)$/i, "_mouseover.$1");
        preload.push(s)
    });
    var img = document.createElement('img');
    $(img).bind('load', function() {
        if(preload[0]) {
            this.src = preload.shift();
        }
    }).trigger('load');

// headerimg = image to show when flash is hidden
	var flashImg = $("#headerimg");
	// The name of the session cookie 
	var cookieName = 'dontshowflash';
	// The value of the session cookie (any value will work)
	var cookieValue = 1;
		
	//First time here, no cookie, show header onload
	if (!$.cookie(cookieName)) {
		
		// Remove the image
		flashImg.remove();						
				
		// Show the flash
		$('#masthead').flash({
			src: 'flash/masthead.swf',
			width: 970,
			height: 278,
			menu:false,
			flashvars: { homepage: 'true' }
		});
		
		// Set a session cookie so it isn't shown again
		$.cookie(cookieName, cookieValue);
	}

});