var mediaDisplayAreaMaxWidth=316;var mediaDisplayAreaDefaultHeight=234;var audioPlayerMaxWidth=260;var audioPlayerMaxHeight=20;var photoGalleryMaxWidth=mediaDisplayAreaMaxWidth;var photoGalleryMaxHeight=274;var vmixMaxWidth=mediaDisplayAreaMaxWidth;var vmixMaxHeight=257;var videoControlsHeightSWF=0;var videoControlsHeightWMV=45;var videoControlsHeightMOV=0;var scrollToTopHeight=237;var vmix_asset_id_replace=/%|!|\.|\*|\$/g;var currDomain=document.domain;if(currDomain.indexOf("miamiherald")!=-1){var mediaServerURL="http://media.miamiherald.com";}if(currDomain.indexOf("elnuevoherald")!=-1){var mediaServerURL="http://media.elnuevoherald.com";}var storyVideoCount=0;var storyVideoBoxCount;var storyVideoOldTypeCount;var storyAudioCount;var storyPhotoCount;var storyPhotoGalleryCount;var storySoundslidesCount;var storyGoogleMapCount;var storyMapBoxCount;var storyVideoCurrent=0;var defaultAssetID=getQueryStrVariable('asset_id');var defaultAssetType=getQueryStrVariable('asset_type');$(document).ready(function(){$('#storyBodyContent').removeClass('cf');$("#txtResizeMinusLink").click(function(){txtResizeSmaller();});$("#txtResizePlusLink").click(function(){txtResizeLarger();});$('div.storyTools_footer div.storyShareTextBar div.shareLinksArea ul.shareLinks li.buzzStoryLink span.yahooBuzzBadge a span span').css({'background-image':'none','background':'none'});$('div.storyTools_footer div.storyShareTextBar div.shareLinksArea ul.shareLinks li.buzzStoryLink span.yahooBuzzBadge a span').css({'padding-left':'0','padding':'0'});$('div.storyTools_footer div.storyShareTextBar div.shareLinksArea ul.shareLinks li.buzzStoryLink span.yahooBuzzBadge a').css({'background-position':'left'});$('#storyAssetMediaDisplayAreaLinks #storyAudioLinksArea ul li.storyAssetSingle a.media_jquery_audio_link').click(function(){alertTest('CLICKED - Audio  - Link href = '+$(this).attr('href'));loadAudioEmbed($(this).attr('href'));setstoryAssetNowPlaying(this);return false;});$('#storyAssetMediaDisplayAreaLinks a.storyPhotoGalleryLink').click(function(){alertTest('CLICKED - Photo Gallery  - Link href = '+$(this).attr('href'));loadPhotoGalleryEmbed($(this).attr('href'));setstoryAssetNowPlaying(this);return false;});$('#storyAssetMediaDisplayAreaLinks #storyAssetAttachPhotoLink').click(function(){alertTest('CLICKED - single photo - Link href = '+$(this).attr('href'));hideAllMedia();$('#storyPhotoContentArea div.storyAssetSingle').show();setstoryAssetNowPlaying(this);return false;});$('#storyAssetMediaDisplayAreaLinks li.storyAssetSingle a.media_jquery_video_link').click(function(){alertTest('CLICKED - Video  - Link CLASS = '+$(this).attr('class'));loadVideoOldTypeEmbed($(this).attr('href'));setstoryAssetNowPlaying(this);return false;});$('#storyNonImageContentArea ul.link_list li.storyAssetSingle a.storyMapLink').click(function(){alertTest('CLICKED - MAP BOX  - Link CLASS = '+$(this).attr('class'));hideAllMedia();$('#storyAssetMediaDisplayArea #storyGoogleMapBoxContentArea div.storyAssetSingle').show();if(storyGoogleMapCount){reInitializeGoogleMap();}else if(storyMapBoxCount){initmap();}setstoryAssetNowPlaying(this);scrollToTop('map');return false;});$('div.storyTools div.storyShareTextBar div.shareLinksArea ul.shareLinks li.shareStoryLink a').click(function(){$('div.storyTools div.storyShareToolsBar').toggle();return false;});$('div.storyTools_footer div.storyShareTextBar div.shareLinksArea ul.shareLinks li.shareStoryLink a').click(function(){$('div.storyTools_footer div.storyShareToolsBar').toggle();return false;});var footerRecommendLI=$('div.storyTools_footer div.storyShareTextBar div.shareLinksArea ul.shareLinks li.recommendStoryLink');var footerRecommendLink=$(footerRecommendLI).find('a');$(footerRecommendLink).click(function(){var pluckRecommendedLI=$('div.storyTools div.storyShareTextBar div.shareLinksArea ul.shareLinks li.recommendStoryLink');var pluckRecommendLink=$(pluckRecommendedLI).find('a');alertTest('Pluck link clicked now');$(footerRecommendLink).addClass('pluck_recommended');$(footerRecommendLink).text('recommended');$(pluckRecommendLink).addClass('pluck_recommended');if(($(this).hasClass('pluck_recommended'))||($(pluckRecommendedLI).find('#story_recommended_count'))){alertTest('Pluck ALREADY clicked');return false;}else{alertTest('This is the pluck footer link');artRecommend();return false;}});loadStoryAssetMediaDisplayArea();});var storyAssetMediaLoadingImage='<div class="storyAssetMediaLoadingImage"><img alt="Loading..." src="/static/images/redesign/ajax-loader_media-assets.gif"/></div>';function hideAllMedia(){alertTest('Hiding all media display area content');if($('div.storyVideoBoxContentArea').html()!=""){alertTest('Video Box (Vmix) Area EXISTS and will be removed');$('div.storyVideoBoxContentArea div.storyAssetSingle div').remove();$('div.storyVideoBoxContentArea div.storyAssetSingle').empty();}if($('div.storyVideoOldTypeContentArea').html()!=""){alertTest('Video File (Old Type) Area EXISTS and will be removed');$('div.storyVideoOldTypeContentArea div.storyAssetSingle').remove();$('div.storyVideoOldTypeContentArea').empty();}if($('div.storyAudioContentArea').html()!=""){alertTest('Audio File Area EXISTS and will be removed');$('div.storyAudioContentArea div.storyAssetSingle').remove();$('div.storyAudioContentArea').empty();}$('#storyAssetMediaDisplayArea #storyGoogleMapBoxContentArea div.storyAssetSingle').hide();$('#storyPhotoContentArea div.storyAssetSingle').hide();if($('#storyPhotoGalleryContentArea div.storyAssetSingle').html()!=""){alertTest('Photo Gallery Area EXISTS and will be removed');$('#storyPhotoGalleryContentArea div.storyAssetSingle object').remove();$('#storyPhotoGalleryContentArea div.storyAssetSingle').empty();}$('#storyAssetMediaDisplayArea .getFlashPlayer').css('display','none');}function setstoryAssetNowPlaying(thisLink){alertTest('storyAssetNowPlaying triggered. Link CLASS = '+$(thisLink).attr('class'));$('.storyAssetNowPlaying').removeClass('storyAssetNowPlaying');$(thisLink).addClass('storyAssetNowPlaying');}function loadPhotoGalleryEmbed(flashvarsXML){var params={};params.quality="best";params.allowfullscreen="true";params.allowscriptaccess="always";params.wmode="transparent";var attributes={};attributes.id="PhotoGallery";var photoGalDestinationID="photoGalleryPlaceHolder";var flashvars={};if(flashvarsXML.charAt(0)=='#'){flashvarsXML=mediaServerURL+flashvarsXML.substring(1);}flashvars.xmlfile=flashvarsXML;hideAllMedia();alertTest('Photo Gallery Area is UNDEFINED and will be created');$('#storyPhotoGalleryContentArea div.storyAssetSingle').append('<div id="'+photoGalDestinationID+'"></div>');$('#storyPhotoGalleryContentArea div.storyAssetSingle div').attr('id',photoGalDestinationID);swfobject.embedSWF(mediaServerURL+"/static/multimedia/story_detail/StoryLevel-PhotoGallery.swf",photoGalDestinationID,photoGalleryMaxWidth,photoGalleryMaxHeight,"9.0.115",mediaServerURL+"/scripts/expressInstall.swf",flashvars,params,attributes);checkStoryAssetNoFlashLink($('#'+photoGalDestinationID));}function showVideoVmixEmbed(media_id,vmix_player_id,vmix_token){alertTest('Vmix video being displayed as embedded');var destinationID="inlineVmixPlaceHolder_"+media_id;document.write('<div id="'+destinationID+'">'+storyAssetMediaLoadingImage+'</div>');$('#vmix_title_'+media_id).parents('div.html_module').addClass('vmix_html_module').css({'display':'inline','float':'left'});$(document).ready(function(){displayVideoVmixEmbed('#?media_id='+media_id+'&player_id='+vmix_player_id+'&token='+vmix_token+'&vmix_title=%26nbsp%3B&vmix_descrip=%26nbsp%3B&vmix_credit=%26nbsp%3B',destinationID);});}var vmix_titles=new Object;var vmix_descrips=new Object;var vmix_credits=new Object;var vmix_asset_id=new Object;var linkAreaUL="";var newLink="";var newLinkHref="";var newLinkIcon="";function displayVideoVmixEmbedLink(media_id,vmix_player_id,vmix_token){vmix_titles[media_id]=escape($('#vmix_title_'+media_id).html());vmix_descrips[media_id]=escape($('#vmix_descrip_'+media_id).html());vmix_credits[media_id]=escape($('#vmix_credit_'+media_id).html());vmix_asset_id[media_id]=$('#vmix_title_'+media_id).parents('.html_module').attr('id').replace(vmix_asset_id_replace,"");alertTest('templateType == "'+templateType+'"');if(templateType.indexOf("story")==0){linkAreaUL=$('#storyAssetMediaDisplayAreaLinks #storyVideoLinksArea ul.mediaAssetList');newLinkHref='#player_id='+vmix_player_id+'&token='+vmix_token+'&media_id='+media_id+'&vmix_title='+vmix_titles[media_id]+'&vmix_credit='+vmix_credits[media_id]+'&vmix_descrip='+vmix_descrips[media_id];}alertTest('STORY LEVEL: WRITE OUT VMIX LINK: '+newLinkHref);$(linkAreaUL).append('<li></li>');$(linkAreaUL).find('li:last').addClass('storyAssetSingle').append('<a onclick="javascript:return false; ">'+unescape(vmix_titles[media_id])+newLinkIcon+'</a>');$(linkAreaUL).find('li.storyAssetSingle:last a').attr('href',newLinkHref).addClass('vmixLink asset_type_html_module '+vmix_asset_id[media_id]);alertTest('linkAreaUL class: '+$(linkAreaUL).attr('class'));if(templateType.indexOf("story")==0){storyVideoCurrent++;if(storyVideoCurrent==storyVideoCount){alertTest('LAST html_module FOUND, initialize vmix links: storyVideoCount = '+storyVideoCount);$(linkAreaUL).find('li.storyAssetSingle a.vmixLink').click(function(){alertTest('CLICKED - html_module - Link CLASS = '+$(this).attr('class'));var flashvarsHref=$(this).attr('href');displayVideoVmixEmbed(flashvarsHref);setstoryAssetNowPlaying(this);return false;});if(!(defaultAssetID)||(defaultAssetType=='audio')){$('a.vmixLink:first').trigger('click');}if(defaultAssetType=='html_module'){alertTest('Running displayDefaultAsset() for html_module');displayDefaultAsset();}}}}function displayVideoVmixEmbed(flashvarsHref,destinationID){var params={};params.quality="best";params.allowfullscreen="true";params.allowscriptaccess="always";params.wmode="transparent";var attributes={};attributes.id="VideoBox";attributes.name="UnifiedVideoPlayer";var flashvars={};if(flashvarsHref.charAt(0)=='#'){flashvarsHref=flashvarsHref.substring(1);}var vmix_media_id=getQueryStrVariable('media_id',flashvarsHref);var vmix_player_id=getQueryStrVariable('player_id',flashvarsHref);var vmix_token=getQueryStrVariable('token',flashvarsHref);var vmix_title=unescape(getQueryStrVariable('vmix_title',flashvarsHref));var vmix_descrip=unescape(getQueryStrVariable('vmix_descrip',flashvarsHref));var vmix_credit=unescape(getQueryStrVariable('vmix_credit',flashvarsHref));flashvars.player_id=vmix_player_id;flashvars.token=vmix_token;if(destinationID){var videoBoxDestinationID=destinationID;}else{var videoBoxDestinationID="videoBoxPlaceHolder_"+vmix_media_id;}hideAllMedia();alertTest('Video Box Area is UNDEFINED and will be created');$('div.storyVideoBoxContentArea div.storyAssetSingle').append('<div id="'+videoBoxDestinationID+'"></div>');$('div.storyVideoBoxContentArea div.storyAssetSingle div').attr('id',videoBoxDestinationID);swfobject.embedSWF(mediaServerURL+"/static/multimedia/story_detail/UnifiedVideoPlayer.swf",videoBoxDestinationID,vmixMaxWidth,vmixMaxHeight,"9.0.115",mediaServerURL+"/scripts/expressInstall.swf",flashvars,params,attributes);if((vmix_title)||(vmix_descrip)||(vmix_credit)){$('div.storyVideoBoxContentArea div.storyAssetSingle').append('<div class="vmixCaptionArea"></div>');$('div.storyVideoBoxContentArea div.storyAssetSingle div:last').addClass('vmixCaptionArea');}if(vmix_title){$('div.storyVideoBoxContentArea div.storyAssetSingle div.vmixCaptionArea').append('<div class="vmixTitle">'+vmix_title+'</div>');$('div.storyVideoBoxContentArea div.storyAssetSingle div.vmixCaptionArea div:last').addClass('vmixTitle');}if(vmix_descrip){$('div.storyVideoBoxContentArea div.storyAssetSingle div.vmixCaptionArea').append('<div class="vmixDescrip">'+vmix_descrip+'</div>');$('div.storyVideoBoxContentArea div.storyAssetSingle div.vmixCaptionArea div:last').addClass('vmixDescrip');}if(vmix_credit){$('div.storyVideoBoxContentArea div.storyAssetSingle div.vmixCaptionArea').append('<div class="vmixCredit">'+vmix_credit+'</div>');$('div.storyVideoBoxContentArea div.storyAssetSingle div.vmixCaptionArea div:last').addClass('vmixCredit');}}function loadVideoOldTypeEmbed(storyAssetVideoFileURL){var videoFileDestinationID="videoFilePlaceHolder";if(storyAssetVideoFileURL.charAt(0)=='#'){storyAssetVideoFileURL=storyAssetVideoFileURL.substring(1);}if(storyAssetVideoFileURL.indexOf("http")!=0){storyAssetVideoFileURL=mediaServerURL+storyAssetVideoFileURL;}hideAllMedia();alertTest('Video File (Old Type) Area will be created. URL was passed as: '+storyAssetVideoFileURL);$('div.storyVideoOldTypeContentArea').append('<div class="storyAssetSingle"></div>');$('div.storyVideoOldTypeContentArea div').addClass('storyAssetSingle');$('div.storyVideoOldTypeContentArea div.storyAssetSingle').append('<div id="'+videoFileDestinationID+'"></div>');$('div.storyVideoOldTypeContentArea div.storyAssetSingle div').attr('id',videoFileDestinationID);var thisVideo=$('div.storyVideoOldTypeContentArea div.storyAssetSingle #'+videoFileDestinationID);thisVideo=$(thisVideo).append('<a href="'+storyAssetVideoFileURL+'" class="media_jquery_video">Loading video...</a>');thisVideo=$(thisVideo).addClass('media_jquery_video');thisVideo=$(thisVideo).attr('href',storyAssetVideoFileURL);alertTest('This Video File HREF is: '+$(thisVideo).attr('href'));var aryVideoOldTypeSize=[getQueryStrVariable('width',storyAssetVideoFileURL),getQueryStrVariable('height',storyAssetVideoFileURL)];if((aryVideoOldTypeSize[0])&&(aryVideoOldTypeSize[1])){var aryVideoOldTypeSizeScaled=['none','none'];getMediaDisplayAreaScaled(mediaDisplayAreaMaxWidth,mediaDisplayAreaDefaultHeight,aryVideoOldTypeSize,aryVideoOldTypeSizeScaled);alertTest('Old Width: '+aryVideoOldTypeSize[0]+', New Width: '+aryVideoOldTypeSizeScaled[0]+'\nOld Height: '+aryVideoOldTypeSize[1]+', New Height: '+aryVideoOldTypeSizeScaled[1]);}else{var aryVideoOldTypeSizeScaled=[mediaDisplayAreaMaxWidth,mediaDisplayAreaDefaultHeight];}if((storyAssetVideoFileURL.indexOf(".wmv")!=-1)&&(aryVideoOldTypeSizeScaled[1]>0)){alertTest('This Video File height is being adjusted for WMV: '+$(thisVideo).attr('href'));aryVideoOldTypeSizeScaled[1]+=videoControlsHeightWMV;}$(thisVideo).show();$(thisVideo).media({width:aryVideoOldTypeSizeScaled[0],height:aryVideoOldTypeSizeScaled[1],autoplay:1,caption:false});}function loadAudioEmbed(storyAssetAudioFileURL){var audioFileDestinationID="audioFilePlaceHolder";if(storyAssetAudioFileURL.charAt(0)=='#'){storyAssetAudioFileURL=storyAssetAudioFileURL.substring(1);}if(storyAssetAudioFileURL.indexOf("http")!=0){storyAssetAudioFileURL=mediaServerURL+storyAssetAudioFileURL;}hideAllMedia();alertTest('Audio File Area will be created. URL was passed as: '+storyAssetAudioFileURL);$('div.storyAudioContentArea').append('<div class="storyAssetSingle"></div>');$('div.storyAudioContentArea div').addClass('storyAssetSingle');$('div.storyAudioContentArea div.storyAssetSingle').append('<div id="'+audioFileDestinationID+'"></div>');$('div.storyAudioContentArea div.storyAssetSingle div').attr('id',audioFileDestinationID);var thisAudio=$('div.storyAudioContentArea div.storyAssetSingle #'+audioFileDestinationID);thisAudio=$(thisAudio).append('<a href="'+storyAssetAudioFileURL+'" class="media_jquery_audio">Loading audio...</a>');thisAudio=$(thisAudio).addClass('media_jquery_audio');thisAudio=$(thisAudio).attr('href',storyAssetAudioFileURL);alertTest('This Audio File HREF is: '+$(thisAudio).attr('href'));$(thisAudio).show();$(thisAudio).media({width:audioPlayerMaxWidth,height:audioPlayerMaxHeight,autoplay:1,caption:false});}function getMediaDisplayAreaScaled(maxwidth,defaultHeight,aryOldSize,aryNewSize){if(isInteger(aryOldSize[0])){alertTest('isInteger Passed');var thisratio=maxwidth/aryOldSize[0];aryNewSize[1]=thisratio*aryOldSize[1];aryNewSize[0]=maxwidth;}else{aryNewSize[0]=maxwidth;aryNewSize[1]=defaultHeight;}}function isInteger(s){if(s){return(s.toString().search(/^-?[0-9]+$/)==0);}else{alertTest('isInteger Failed due to undefined');return false;}}function txtResizeSmaller(){var currentTxtSize=$("#storyBodyContent > p").css("font-size");var newTxtSize=currentTxtSize.split("px");var currentTxtLineHeight=$("#storyBodyContent > p").css("line-height");var newTxtLineHeight=currentTxtLineHeight.split("px");if(parseInt(newTxtSize[0])<=8){$("#txtResizeMinus").hide();$("#txtResizeMinusFade").show();}else{currentTxtSize=parseInt(newTxtSize[0])-2;currentTxtLineHeight=parseFloat(newTxtLineHeight[0])-2;if(parseInt(currentTxtSize)<=8){$("#txtResizeMinus").hide();$("#txtResizeMinusFade").show();}currentTxtSize=currentTxtSize+"px";currentTxtLineHeight=currentTxtLineHeight+"px";}$("#txtResizePlus").show();$("#txtResizePlusFade").hide();$("#storyBodyContent > p").css("font-size",currentTxtSize);$("#storyBodyContent > p").css("line-height",currentTxtLineHeight);}function txtResizeLarger(){var currentTxtSize=$("#storyBodyContent > p").css("font-size");var newTxtSize=currentTxtSize.split("px");var currentTxtLineHeight=$("#storyBodyContent > p").css("line-height");var newTxtLineHeight=currentTxtLineHeight.split("px");if(parseInt(newTxtSize[0])>=24){$("#txtResizePlus").hide();$("#txtResizePlusFade").show();}else{currentTxtSize=parseInt(newTxtSize[0])+2;currentTxtLineHeight=parseFloat(newTxtLineHeight[0])+2;if(parseInt(currentTxtSize)>=24){$("#txtResizePlus").hide();$("#txtResizePlusFade").show();}currentTxtSize=currentTxtSize+"px";currentTxtLineHeight=currentTxtLineHeight+"px";}$("#txtResizeMinus").show();$("#txtResizeMinusFade").hide();$("#storyBodyContent > p").css("font-size",currentTxtSize);$("#storyBodyContent > p").css("line-height",currentTxtLineHeight);}function checkStoryAssetNoFlashLink(destinationElement){$(document).ready(function(){if(($(destinationElement).html()=='')){}});}function loadStoryAssetMediaDisplayArea(){if((storyVideoOldTypeCount>0)||(storyAudioCount>0)){alertTest2('jQuery Media Player defaults will be loaded');$.fn.media.defaults.flvPlayer=mediaServerURL+'/static/media/flvplayer_embedded.swf';$.fn.media.defaults.mp3Player=mediaServerURL+'/static/media/mp3player.swf';$.fn.media.mapFormat('mp4','quicktime');}else{alertTest2('NO JQUERY MEDIA PLAYER NEEDED');}if(storyVideoOldTypeCount>0){alertTest2('VIDEO FILES FOUND: storyVideoOldTypeCount = '+storyVideoOldTypeCount);}else{alertTest2('NO VIDEO FILES FOUND');}if((defaultAssetType)&&(defaultAssetType!='html_module')){displayDefaultAsset();if(defaultAssetType!='audio'){return;}}else{alertTest2('NO PRESELECTED MEDIA ASSET ID - else html_module found');}if(storyVideoCount>0){alertTest2('VMIX html_module FOUND: storyVideoCount = '+storyVideoCount);return;}else{alertTest2('VMIX html_module FOUND');}if(storyVideoBoxCount>0){alertTest2('VIDEO BOX (vmix) FOUND: storyVideoCount = '+storyVideoCount);return;}else{alertTest2('VIDEO BOX (vmix) FOUND');}if(storyPhotoCount==1){alertTest2('SINGLE PHOTO FOUND: storyPhotoCount = '+storyPhotoCount);$('#storyPhotoLinksArea').css('border-top','none');setstoryAssetNowPlaying($('#storyAssetAttachPhotoLink'));return;}else{alertTest2('NO PHOTOS FOUND');}if((storyPhotoCount>0)||(storyPhotoGalleryCount>0)){alertTest2('PHOTO GALLERY FOUND: storyPhotoGalleryCount = '+storyPhotoGalleryCount);$('#storyAssetMediaDisplayAreaLinks a.storyPhotoGalleryLink:first').trigger('click');$('#storyPhotoLinksArea').css('border-top','none');return;}else{alertTest2('NO PHOTO GALLERY FOUND');}if(storyAudioCount>0){alertTest2('AUDIO FOUND: storyAudioCount = '+storyAudioCount);$('#storyAudioLinksArea').css('border-top','none');}else{alertTest2('NO AUDIO FOUND');}if(storyGoogleMapCount>0){alertTest2('GOOGLE MAP FOUND: storyGoogleMapCount = '+storyGoogleMapCount);}else{alertTest2('NO GOOGLE MAP FOUND');}}function displayDefaultAsset(){alertTest2("URL Media Asset Position Id (defaultAssetID): "+defaultAssetID+"\nURL Media Asset Type (defaultAssetType): "+defaultAssetType);var defaultAssetID_temp=defaultAssetID;if(defaultAssetID.indexOf("asset_id_")!=0){defaultAssetID_temp='asset_id_'+defaultAssetID;}if(defaultAssetType.indexOf("asset_type_")!=0){defaultAssetType_temp='asset_type_'+defaultAssetType;}$('a.'+defaultAssetID_temp.replace(vmix_asset_id_replace,"")+'.'+defaultAssetType_temp).trigger("click");}function scrollToTop(){window.scrollTo(0,scrollToTopHeight);}