(function() {

		
	var arrImages = new Array();
	var arrTips = new Array();
    var arrLinks = new Array();
    
				arrImages[0] = 'http://www.stickmanknows.org/photos/pedestrians/tip1.png';
				arrTips[0] = '<strong>Pedestrian Tip #1:</strong><br /><br />Cross the street at marked crosswalks and intersections.';
		arrLinks[0] = 'http://www.stickmanknows.org/tips/pedestrian/1';
					arrImages[1] = 'http://www.stickmanknows.org/photos/bicyclists/tip3.png';
				arrTips[1] = '<strong>Bicyclist Tip #3:</strong><br /><br />Be predictable! Use hand signals to tell motorists what you intend to do.';
		arrLinks[1] = 'http://www.stickmanknows.org/tips/bicyclist/3';
					arrImages[2] = 'http://www.stickmanknows.org/photos/bicyclists/tip7.png';
				arrTips[2] = '<strong>Bicyclist Tip #7:</strong><br /><br />Don\'t pass on the right. Motorists may not look for or see a bicycle passing on the right.';
		arrLinks[2] = 'http://www.stickmanknows.org/tips/bicyclist/7';
					arrImages[3] = 'http://www.stickmanknows.org/photos/pedestrians/tip5.png';
				arrTips[3] = '<strong>Pedestrian Tip #5:</strong><br /><br />Stay visible after dark and in bad weather.';
		arrLinks[3] = 'http://www.stickmanknows.org/tips/pedestrian/5';
					arrImages[4] = 'http://www.stickmanknows.org/photos/drivers/tip3.png';
				arrTips[4] = '<strong>Motorist Tip #3:</strong><br /><br />Yield to pedestrians and cyclists when turning.';
		arrLinks[4] = 'http://www.stickmanknows.org/tips/motorist/3';
					arrImages[5] = 'http://www.stickmanknows.org/photos/bicyclists/tip9.png';
				arrTips[5] = '<strong>Bicyclist Tip #9:</strong><br /><br />Keep your bike in good repair. Check brakes and tires regularly.';
		arrLinks[5] = 'http://www.stickmanknows.org/tips/bicyclist/9';
					arrImages[6] = 'http://www.stickmanknows.org/photos/pedestrians/tip6.png';
				arrTips[6] = '<strong>Pedestrian Tip #6:</strong><br /><br />Watch out for trucks and buses backing out of parking spaces and driveways.';
		arrLinks[6] = 'http://www.stickmanknows.org/tips/pedestrian/6';
					arrImages[7] = 'http://www.stickmanknows.org/photos/bicyclists/tip8.png';
				arrTips[7] = '<strong>Bicyclist Tip #8:</strong><br /><br />Dress for the weather. Dress in layers so you can adjust to the temperature and always wear bright clothing.';
		arrLinks[7] = 'http://www.stickmanknows.org/tips/bicyclist/8';
					arrImages[8] = 'http://www.stickmanknows.org/photos/bicyclists/tip4.png';
				arrTips[8] = '<strong>Bicyclist Tip #4:</strong><br /><br />Ride in a straight line to the right of traffic (on two-way streets) and a little more than a car-door width away from parked cars.';
		arrLinks[8] = 'http://www.stickmanknows.org/tips/bicyclist/4';
					arrImages[9] = 'http://www.stickmanknows.org/photos/pedestrians/tip4.png';
				arrTips[9] = '<strong>Pedestrian Tip #4:</strong><br /><br />Begin crossing the street on "Walk" signal.';
		arrLinks[9] = 'http://www.stickmanknows.org/tips/pedestrian/4';
					arrImages[10] = 'http://www.stickmanknows.org/photos/drivers/tip2.png';
				arrTips[10] = '<strong>Motorist Tip #2:</strong><br /><br />Slow down and obey the posted speed limit.';
		arrLinks[10] = 'http://www.stickmanknows.org/tips/motorist/2';
					arrImages[11] = 'http://www.stickmanknows.org/photos/drivers/tip6.png';
				arrTips[11] = '<strong>Motorist Tip #6:</strong><br /><br />Allow 3 feet when passing bicyclists.';
		arrLinks[11] = 'http://www.stickmanknows.org/tips/motorist/6';
					arrImages[12] = 'http://www.stickmanknows.org/photos/drivers/tip4.png';
				arrTips[12] = '<strong>Motorist Tip #4:</strong><br /><br />Look before opening your door.';
		arrLinks[12] = 'http://www.stickmanknows.org/tips/motorist/4';
					arrImages[13] = 'http://www.stickmanknows.org/photos/bicyclists/tip5.png';
				arrTips[13] = '<strong>Bicyclist Tip #5:</strong><br /><br />Always wear a helmet and never ride with headphones. Helmets dramatically reduce the risk of head injury in a bicycle crash.';
		arrLinks[13] = 'http://www.stickmanknows.org/tips/bicyclist/5';
					arrImages[14] = 'http://www.stickmanknows.org/photos/pedestrians/tip3.png';
				arrTips[14] = '<strong>Pedestrian Tip #3:</strong><br /><br />Use pedestrian pushbuttons.';
		arrLinks[14] = 'http://www.stickmanknows.org/tips/pedestrian/3';
					arrImages[15] = 'http://www.stickmanknows.org/photos/pedestrians/tip7.png';
				arrTips[15] = '<strong>Pedestrian Tip #7:</strong><br /><br />Excessive alcohol consumption can impair the motor skills and judgment of pedestrians just as it does for drivers. Don\'t take the risk.';
		arrLinks[15] = 'http://www.stickmanknows.org/tips/pedestrian/7';
					arrImages[16] = 'http://www.stickmanknows.org/photos/drivers/tip5.png';
				arrTips[16] = '<strong>Motorist Tip #5:</strong><br /><br />Be careful when passing stopped vehicles.';
		arrLinks[16] = 'http://www.stickmanknows.org/tips/motorist/5';
					arrImages[17] = 'http://www.stickmanknows.org/photos/pedestrians/tip8.png';
				arrTips[17] = '<strong>Pedestrian Tip #8:</strong><br /><br />Very small children should not cross street by themselves. Make sure your children are aware of pedestrian safety tips and laws.';
		arrLinks[17] = 'http://www.stickmanknows.org/tips/pedestrian/8';
					arrImages[18] = 'http://www.stickmanknows.org/photos/bicyclists/tip1.png';
				arrTips[18] = '<strong>Bicyclist Tip #1:</strong><br /><br />Obey all regulatory signs and traffic lights.';
		arrLinks[18] = 'http://www.stickmanknows.org/tips/bicyclist/1';
					arrImages[19] = 'http://www.stickmanknows.org/photos/bicyclists/tip2.png';
				arrTips[19] = '<strong>Bicyclist Tip #2:</strong><br /><br />Never ride against traffic. When a bicycle and car are moving towards each other, there is much less time to take corrective action. Ride with traffic to avoid potential accidents.';
		arrLinks[19] = 'http://www.stickmanknows.org/tips/bicyclist/2';
					arrImages[20] = 'http://www.stickmanknows.org/photos/pedestrians/tip2.png';
				arrTips[20] = '<strong>Pedestrian Tip #2:</strong><br /><br />Before crossing, look left, right, then left again.';
		arrLinks[20] = 'http://www.stickmanknows.org/tips/pedestrian/2';
					arrImages[21] = 'http://www.stickmanknows.org/photos/bicyclists/tip6.png';
				arrTips[21] = '<strong>Bicyclist Tip #6:</strong><br /><br />Use lights and reflectors at night and when visibility is poor.';
		arrLinks[21] = 'http://www.stickmanknows.org/tips/bicyclist/6';
					arrImages[22] = 'http://www.stickmanknows.org/photos/drivers/tip1.png';
				arrTips[22] = '<strong>Motorist Tip #1:</strong><br /><br />Stop for pedestrians at crosswalks.';
		arrLinks[22] = 'http://www.stickmanknows.org/tips/motorist/1';
			    
        
    var nCurrent = 0;
    var nMax = 22;

	// Localize jQuery variable
	var jQuery;
	
	/******** Load jQuery if not present *********/
	if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.4.2') {
		var script_tag = document.createElement('script');
		script_tag.setAttribute("type","text/javascript");
		script_tag.setAttribute("src",
			"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js");
		script_tag.onload = scriptLoadHandler;
		script_tag.onreadystatechange = function () { // Same thing but for IE
			if (this.readyState == 'complete' || this.readyState == 'loaded') {
				scriptLoadHandler();
			}
		};
		// Try to find the head, otherwise default to the documentElement
		(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
	} else {
		// The jQuery version on the window is the one we want to use
		jQuery = window.jQuery;
		main();
	}
	
	/******** Called once jQuery has loaded ******/
	function scriptLoadHandler() {
		// Restore $ and window.jQuery to their previous values and store the
		// new jQuery in our local jQuery variable
		jQuery = window.jQuery.noConflict(true);
		// Call our main function
		main(); 
	}
	
	/******** Our main function ********/
	function main() { 
	
		jQuery(document).ready(function($) { 
		
			/******* Load CSS *******/
			var css_link = $("<link>", { 
				rel: "stylesheet", 
				type: "text/css", 
				href: "http://www.stickmanknows.org/widget/stickman-widget.css?unique=20120223031101" 
			});
			css_link.appendTo('head');   
			
			loadTip(); 
	
			function loadTip() {
	
                $('#stickman-widget').html('<div id="stickman-widget-image"><a href="' + arrLinks[nCurrent] + '" target="_blank"><img border="0" src="' + arrImages[nCurrent] + '"></a></div>');
                $('#stickman-widget').append('<div id="stickman-widget-image-cover"></div>');
                $('#stickman-widget').append('<div id="stickman-widget-url"><a href="http://www.stickmanknows.org" target="_blank"><img src="http://www.stickmanknows.org/widget/widget-stickman-knows.png" border="0"></a></div>');
                $('#stickman-widget').append('<div id="stickman-widget-next"><img src="http://www.stickmanknows.org/widget/widget-next-w-shadow.png" border="0"></div>');
                
                $('#stickman-widget-image-cover').animate({
                    
                    opacity: 0
                
                }, 700, function () {
                
                	$('#stickman-widget').append('<div id="stickman-widget-tip">' + arrTips[nCurrent] + '</div>');
                    $('#stickman-widget-image-cover').remove();
                
                    nCurrent++;
                    if (nCurrent > nMax) {
                        nCurrent = 1;
                    }
                
                });
			}
			
			$("#stickman-widget-next").live("click",function() {
            
            	$('#stickman-widget-tip').html('');
            
            	$('#stickman-widget-image').animate({
                    
                    opacity: 0
                
                }, 700, function() {
        
                    loadTip();
                    
                });
			});
		});
	}

})(); // We call our anonymous function immediately
