Learn how to use jQuery at the Blog

Timothy van Sas « visit

  • Added 7 months ago
  • 95 Lines of Code shown
  • 5 Links of Interest
http://incg.nl
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 Timothy van Sas - http://incg.nl

function badBrowser(){
	if($.browser.msie && parseInt($.browser.version) <= 6){ return true;}
	return false;
}

function getBadBrowser(c_name)
{
	if (document.cookie.length>0)
	{
	c_start=document.cookie.indexOf(c_name + "=");
	if (c_start!=-1)
		{ 
		c_start=c_start + c_name.length+1; 
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}	

function setBadBrowser(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

if(badBrowser() && getBadBrowser('browserWarning') != 'seen' ){
	$(function(){
		$("<div id='browserWarning'>I've stopped supporting IE6. Switch to <a href='http://getfirefox.com'>FireFox</a>, <a href='http://www.apple.com/safari/'>Safari</a> or <a href='http://www.microsoft.com/windows/downloads/ie/getitnow.mspx'>Internet Explorer 7</a>. I &hearts; web standards&nbsp;&nbsp;&nbsp;[<a href='#' id='warningClose'>close</a>] </div> ")
			.css({
				backgroundColor: '#000000',
				'width': '100%',
				'font-size': '1.6em',
				'font-weight': 'bold',
				'color': '#ffffff',
				'border-top': 'solid 6px #000',
				'border-bottom': 'solid 6px #000',
				'text-align': 'center',
				padding:'15px 0px 15px 0px'
			})
			.prependTo("body");
		
		$('#warningClose').click(function(){
			setBadBrowser('browserWarning','seen');
			$('#browserWarning').slideUp('slow');
			return false;
		});
	});	
}



$(function() {
	// Open link in new window
	$(".external").attr("target","_blank");
	
	// Place a vintage border on top of the slider on the home page
	$("#slider").prepend("<img src='images/globals/work_overlay.png' alt='Overlay' class='overlay_slider' />");
	
	// Toggle hidden elements
	$("div.hidden_element").hide()
	$("a.bullet").click(function() {
		$("div.hidden_element").slideToggle("slow");
	});
	
	// Animate menu
	$('.main_nav a')
		.css( {backgroundPosition: "0 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0 -52px)"}, {duration:300})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:300, complete:function(){
				$(this).css({backgroundPosition: "0px 0px"})
			}})
		})

				
	// Set the scroll to anchor
	anchor.init()
	
});

anchor = {
	init : function()  {
		$("a.anchorLink").click(function () {	
			elementClick = $(this).attr("href")
			destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 1100 );
		  	return false;
		})
	}
}