function clickVideo(id,width,height,img){
	$(id).click(function () {
	    var url = $(this).attr('name');
	
	    $.fancybox({
	        'padding': 0,
	        'autoDimensions': false,
	        'width': width,
	        'height': height,
	        'content': '<div class="video-js-box vim-css">' +
	                    '<video id="video_head" class="video-js" autoplay="autoplay" width="'+width+'" height="'+height+'" controls="controls" preload="auto">' +
	                    '<source src="../media/videos/' + url + '.mp4" type=\'video/mp4; codecs="avc1.42E01E, mp4a.40.2"\' />' +
	                    '<source src="../media/videos/' + url + '.ogg" type=\'video/ogg; codecs="theora, vorbis"\' />' +
	                      '<!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. -->' +
	                      '<object id="flash_fallback_1" class="vjs-flash-fallback" width="'+width+'" height="'+height+'" type="application/x-shockwave-flash"' +
	                        'data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf">' +
	                        '<param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" />' +
	                        '<param name="allowfullscreen" value="true" />' +
	                        '<param name="flashvars" value=\'config={"playlist":[{"url": "http://bebeduemedic.com/media/videos/' + url + '.flv","autoPlay":true,"autoBuffering":true}]}\' />' +
	                      '</object>' +
	                    '</video>' +
	                    '</div>',
	        'onStart': function(){
				window.location.hash = id;
			},
	        'onComplete': function () { 
	        	$("#fancybox-content div:first").css({ 'overflow': 'visible' });
	        	
	        	if (Modernizr.video){
	        		VideoJS.setupAllWhenReady();
	        		myPlayer = $("#video_head")[0].player;
	        		//$("#fancybox-inner, #fancybox-content div:first").css({ 'overflow': 'visible' });
	        	};
	        }/*,
	        'onClosed': function () {
	        	$("#fancybox-inner").empty();
	        	window.location.hash = "";
	        }*/
	    });
	    return false;
	}); // fancyvideo
	
	
}

function enterFade(id,delay,speed){
	if ($.browser.msie && parseFloat($.browser.version)<9) {
	  	$(id).css({"margin-top":"60px"}).delay(delay).animate({"margin-top":"0px"},speed);
	}else{
		$(id).css({"opacity":0,"margin-top":"60px"}).delay(delay).animate({"opacity":1,"margin-top":"0px"},speed);	
	}
}

function modal(id,autodim,callback){
	
	$(id).fancybox({
		'autoDimensions':autodim,
		'padding':0,
		'margin':0,
		'width':950,
		'scrolling':'no',
		'height':530,
		'onComplete': callback,
		'onStart': function(event){
			window.location.hash = $(id).attr("id");
		}/*,
		'onClosed': function(){
			window.location.hash = "";
		} */
		
	});
}
function modal_simple(id_content,width,height){
	$("#modal").remove();
	$("#fancybox-wrap").append('<div id="modal"><div class="close"></div></div>');
	$("#modal").css({"width":width+"px","height":height+"px","margin-left":"-"+(width/2)+"px","margin-top":"-"+(height/2)+"px"}).append($(id_content).clone()).fadeIn();
	$("#modal .close").click(function(){
		$("#modal").fadeOut(function(){ $(this).remove(); });
	});
}
function ajaxURL(){
	hash = window.location.hash;
	if (!hash == ""){
		$(hash).click();
	}
}

/* plugin preload images */

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery);

