		
		function changeVideo(clipID,w,h) {
			var embedCode = "";
			if (clipID == null || clipID == "") {
				clipID = defaultVideoID;
			}
			if(w==undefined){
				w=612;
			}
			if(h==undefined){
				h=345;
			}
			
			
			// calculate the aspect ratio and resize (shrink) if necessary
			var vim_maxWidth = 612;
			var vim_aspectRatio = w/h;
			if(w>vim_maxWidth){
				w=vim_maxWidth;
				h=Math.round(w/vim_aspectRatio);
			}
			
			embedCode += "<object width='"+w+"' height='"+h+"'>";
			embedCode += "<param name='allowfullscreen' value='true' />";
			embedCode += "<param name='bgcolor' value='#FFFFEE' />";
			embedCode += "<param name='allowscriptaccess' value='always' />";
			embedCode += "<param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id="+clipID+"&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=888877&amp;fullscreen=1&autoplay=1' />";
			embedCode += "<embed src='http://vimeo.com/moogaloop.swf?clip_id=" + clipID + "&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=888877&amp;fullscreen=1&autoplay=1' type='application/x-shockwave-flash' allowfullscreen='true' bgcolor='#FFFFEE' allowscriptaccess='always' width='"+w+"' height='"+h+"'></embed>";
			embedCode += "</object>";
			
			jQuery("#vidPlayer").html(embedCode);
			selectThumb(clipID);
			if(window.pageYOffset>200){
				jQuery.scrollTo({ top:200, left:0}, 800);
			}
		}
		
		
		
		
		function selectThumb(clipID) {
		
			jQuery(".TVThumb").removeClass("selected");
		
			var thumbName = ".clipID-" + clipID;
			jQuery(thumbName).toggleClass("selected");
		}	
			
		jQuery(document).ready(function() {
			if (jQuery.query.get('vid')) {
				changeVideo(jQuery.query.get('v'));
			} else {
				changeVideo(defaultVideoID,defaultVideoW,defaultVideoH);
			}
		});
			
