if (/msie/i.test (navigator.userAgent)) //only override IE
{
	document.nativeGetElementById = document.getElementById;
	document.getElementById = function(id)
	{
		var elem = document.nativeGetElementById(id);
		if(elem)
		{
			//make sure that it is a valid match on id
			if(elem.id == id)
			{
				return elem;
			}
			else
			{
				//otherwise find the correct element
				for(var i=1;i<document.all[id].length;i++)
				{
					if(document.all[id][i].id == id)
					{
						return document.all[id][i];
					}
				}
			}
		}
		return null;
	};
}

jQuery.noConflict();  
jQuery(document).ready(function(){
	/* This code is executed after the DOM has been completely loaded */
	
	var totWidth=0;
	var positions = new Array();
	var movie = document.getElementById("mpl");
	
	
	jQuery('#prdslides .slide').each(function(i){
		
		/* Traverse through all the slides and store their accumulative widths in totWidth */
		
		positions[i]= totWidth;
		totWidth += jQuery(this).width();
		
		/* The positions array contains each slide's commulutative offset from the left part of the container */
		
		if(!jQuery(this).width())
		{
			alert("Please, fill in width & height for all your images!");
			return false;
		}
		
	});
	
	jQuery('#prdslides').width(totWidth);

	/* Change the cotnainer div's width to the exact width of all the slides combined */

	jQuery('#slidemenu ul li a').click(function(e){

			/* On a thumbnail click */           
			jQuery('li.menuItem').removeClass('act').addClass('inact');
			jQuery(this).parent().addClass('act');
			
			var pos = jQuery(this).parent().prevAll('.menuItem').length;
			
			jQuery('#prdslides').stop().animate({marginLeft:-positions[pos]+'px'},450);
			/* Start the sliding animation */

			/* Start or Stop movie */
			if(pos == 0) {
			    movie.sendEvent("Play");
		    } else {
			    movie.sendEvent("Stop");
			}
						
			e.preventDefault();
			/* Prevent the default action of the link */
	});    
	
	jQuery('#slidemenu ul li.menuItem:first').addClass('act').siblings().addClass('inact');
	/* On page load, mark the first thumbnail as active */
	
});