$(document).ready(function() {

	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	
	$('.selector').click(function() {
		$('.quote_box').hide();
    $('#col_left > .text').hide();
		$('.selector').removeClass("selector_on").addClass("selector_off");
		var text = "#" + $(this).attr('id') + "_text";
		var quote = "#" + $(this).attr('id') + "_quote";
		$(quote).show();
		$(text).toggle('slow');
		$(this).removeClass("selector_off").addClass("selector_on");
		
		$('.video').html(function() {
		  var vid_name = $(this).attr('id').substring(5);
			var html = '<img src="/video/'+ vid_name +'.jpg" width="320" height="286" border="0" />';
			return html;
		});
		
	});
	
	var myFile = document.location.toString();
	
	if (myFile.match('#')) { // the URL contains an anchor
		// click the navigation item corresponding to the anchor
		var myAnchor = '#' + myFile.split('#')[1];
		$(myAnchor).click();
	} else {
		// click the first navigation item
		$('.selector:first').click();
	}
	
	$('.video').click(function(event) {
		var aChildren = $(this).children();
		if(aChildren[0].nodeName != "VIDEO") {
			event.preventDefault();
			$(this).attr('href', 'javascript:void(0)')
			$(this).html(function() {
					var vid_name = $(this).attr('id').substring(5);
					var html = '<video width="320" height="286" controls id="'+vid_name+'_vid" autoplay>';
					html += '<source src="/video/'+ vid_name+'.mp4"  type=\'video/mp4; codecs="avc1.42E01E, mp4a.40.2"\'>';
					html += '<source src="/video/'+ vid_name+'.webm" type=\'video/webm; codecs="vp8, vorbis"\'>';
					html += '<source src="/video/'+ vid_name+'.ogv"  type=\'video/ogg; codecs="theora, vorbis"\'>';
					html += '<object width="320" height="286" type="application/x-shockwave-flash" data="/video/'+ vid_name + '.swf" id="'+ vid_name + '_flash" class="movies">';
					html += '<param name="movie" value="/video/'+ vid_name+'.swf" />';
					html += '<param name="allowScriptAccess" value="sameDomain" />';
					html += '<param name="flashvars" value="autoPlay=true&controlbar=over&amp;image=/video/'+ vid_name+'.jpg&amp;file=/video/'+ vid_name + '.flv" />';
					html += '<img src="/video/'+vid_name+'.jpg" width="320" height="286" alt="'+ vid_name+'" />';
					html += '</object></video>';
					return html;
			});
		}
	});
	
	
	
});
