var ready=false;function onYouTubePlayerReady(){ready=true;}
function playVideo(video){if(!ready){var callback=function(){playVideo(video);}
setTimeout(callback,10);return;}
ready=false;video.playVideo();}
function showVideo(panel,video){$('.videobox'+panel+' .currentvideo .title'+video).fadeIn();$('.videobox'+panel+' .video span').hide();$('.videobox'+panel+' .video .video'+video).show();$('.videobox'+panel+' .morevideos .play').fadeIn();$('.videobox'+panel+' .morevideos .now_playing').fadeOut();$('.videobox'+panel+' .morevideos .thumb'+video+' .play').fadeOut();$('.videobox'+panel+' .morevideos .thumb'+video+' .now_playing').fadeIn();var videoobject=$('.videobox'+panel+' .video .video'+video+' embed').get(0);var callback=function(){playVideo(videoobject);}
setTimeout(callback,10);}
function resetVideos(){$('.videobox .currentvideo span').hide();$('.videobox .video span').hide();$('.videobox .morevideos .thumb .now_playing').hide();}
$(document).ready(function(){if($('.videobox').length){$('.videobox').hide();resetVideos();}
$('body').prepend('<div id="shadow_mask"></div>');$('.videopanel a').click(function(){var panel='.'+$(this).parent().attr('class').substr(11);$('#shadow_mask').fadeTo("fast",0,function(){$('#shadow_mask').show();$('.videobox_container').show();$('select').hide();var top=document.documentElement.scrollTop+30;var height=document.body.offsetHeight;$('.videobox_container').css({top:top});$('#shadow_mask').css({height:height});$('#shadow_mask').fadeTo("normal",0.7);});$('.videobox'+panel).fadeIn();var video=$(this).attr('class').substr(5);showVideo(panel,video);return false;});$('.videobox .morevideos a').click(function(){var panel='.'+$(this).parent().parent().parent().attr('class').substr(9);var video=$(this).attr('class').substr(5);$('.videobox'+panel+' .currentvideo span').fadeOut();showVideo(panel,video);return false;});$('.videobox a.close').click(function(){$('#shadow_mask').fadeOut();$('.videobox').fadeOut("normal",function(){resetVideos();$('.videobox_container').hide();});$('select').show();return false;});$('.videobox').click(function(){return false;});$('.videobox_container').click(function(e){$('.videobox a.close').trigger('click');});});
