var currentcase = -1; var casepoints = new Array(); var casewidth = new Number(); var audiolength = new String(); var casepointon = -1; var casewidths = [ 0, 1050, 1130, 1130, 1130, 1130, 1130, 1130 ]; var caselengths = [ 0, 392, 201, 236, 222, 249, 160, 0 ]; var slidemode = false; var firstrun = true; var inpause = false; var receptive = true; var recInterval = new Number(); var autocloseInterval = new Number(); var narrationup = false; $(window).resize(function () { var ch = $("#caseholder").position(); arrowupdate(ch.left); }); function caserollin (targetnum) { $("#itemhead").css({ 'background-color': '#ff0000' }); $("#casetitle").html($("#cs" + targetnum + 's').find(".casehead:first").text()); $("#casetag").html($("#cs" + targetnum + 's').find(".casetag:first").text()); } function caserollout (targetnum) { $("#itemhead").css({ 'background-color': '#444444' }); $("#casetitle").html($("#cs" + currentcase + 's').find(".casehead:first").text()); $("#casetag").html($("#cs" + currentcase + 's').find(".casetag:first").text()); } function casefocus (target,collapsemap){ if(currentcase != parseInt(target.substring(1,2))){ casepoints.length = 0; casepointon = -1; $("#itemhead").css({ 'background-color': '#444444' }); $(".caselist li").each(function (){ $(this).removeClass('csel'); $(this).addClass('cl'); $(this).unbind("mouseover"); $(this).unbind("mouseout"); $(this).mouseover(function () { caserollin($(this).attr('cn')); }); $(this).mouseout(function () { caserollout($(this).attr('cn')); }); }); receptive = true; $(".casebottom").find(".ppstory").hide(); clearInterval(recInterval); currentcase = parseInt(target.substring(1,2)); $("#s" + currentcase).addClass('csel'); $("#s" + currentcase).removeClass('cl'); $("#s" + currentcase).unbind("mouseover"); $("#s" + currentcase).unbind("mouseout"); $("#cs" + currentcase + 's').show(); $("#casetitle").html($("#cs" + currentcase + 's').find(".casehead:first").text()); $("#casetag").html($("#cs" + currentcase + 's').find(".casetag:first").text()); var str = '
'; $("#caseinner").html(str); if(collapsemap){ $(".mapreturn").show(); } var inf = new String(); var xcnt = 20; var xc = 0; var tcd = new String(); narrationup = false; $.ajax({ type: "GET", url: "../media/case" + currentcase + ".xml?" + (Math.floor(Math.random() * 20) * caselengths[currentcase]), dataType: "xml", success: function(xml) { casewidth = casewidths[currentcase]; $("#caseholder").css({ 'width': casewidth + 'px' }); $("#casepoints").css({ 'width': casewidth + 'px' }); $(xml).find('pt').each( function () { var thiscase = new Object(); thiscase.isvideo = ($(this).attr('vid') != undefined)? true:false; thiscase.haslink = ($(this).attr('lin') != undefined)? true:false; thiscase.isspecial = ($(this).attr('spc') != undefined && $(this).attr('spc') == '1')? true:false; thiscase.isupdate = ($(this).attr('upd') != undefined && $(this).attr('upd') == '1')? true:false; thiscase.title = $(this).find('tit').text(); if(thiscase.title != 'c1_11'){ inf += '
'; if(thiscase.isvideo){ inf += '
'; } if(thiscase.isupdate){ inf += '
UPDATE
'; } inf += ''; inf += '
'; } thiscase.bodytext = $(this).find('bod').text(); thiscase.photocredit = $(this).find('cred').text(); thiscase.linktext = $(this).find('lint').text(); thiscase.videoid = $(this).attr('vid'); thiscase.link = $(this).attr('lin'); thiscase.x = parseInt($(this).attr('x')); thiscase.y = parseInt($(this).attr('y')); thiscase.img = $(this).attr('img'); thiscase.imgwidth = $(this).attr('imgw'); thiscase.imgbackoffset = $(this).attr('imgb'); var tim = $(this).attr('tim'); var tp = tim.split(':'); thiscase.timecode = (parseInt(tp[0]) * 60) + parseFloat(tp[1]); if(xc > 0){ tcd += '|'; } if(!isNaN(thiscase.timecode)){ tcd += thiscase.timecode; } else { tcd += '0'; } xcnt++; xc++; casepoints.push(thiscase); if(thiscase.isspecial){ inf += '
Watch the story »
'; } }); comms_init(target,tcd,caselengths[currentcase]); $("#casepoints").html(inf); $("#casepoints").fadeIn('slow'); $(".boxen").each(function () { $(this).click(function () { point_click($(this).attr('id')); }); }); arrowupdate(0); $("#narrationlink").fadeIn(); narrationup = true; $("#narrationlink").click(function () { comms_startaudio(); }); $("#leftar").click(function () { mover(150); }); $("#rightar").click(function () { mover(-150); }); } }); } } function comms_init (target,timecodes,timelen) { if(firstrun){ swfobject.embedSWF('../art/casemgr_nocache.swf','casemanager',"100%","31","9",null,{ 'target': target, 'timecodes':timecodes, 'timelen':timelen },{wmode:"opaque",allowScriptAccess:"always"},{ id:'casemgrid',name:'casemgrna' }); firstrun = false; } else { var a; if(navigator.appName.indexOf("Microsoft")!=-1) { a=window['casemgrid']; } else { a=document['casemgrid']; } a.caseload( target,timecodes,timelen); } } function comms_started () { $("#narrationlink").fadeOut(); narrationup = false; } function comms_pause () { var a; if(navigator.appName.indexOf("Microsoft")!=-1) { a=window['casemgrid']; } else { a=document['casemgrid']; } a.extpause(); inpause = true; clearInterval(autocloseInterval); } function comms_startaudio () { var a; if(navigator.appName.indexOf("Microsoft")!=-1) { a=window['casemgrid']; } else { a=document['casemgrid']; } a.startaudio(); } function comms_play () { var a; if(navigator.appName.indexOf("Microsoft")!=-1) { a=window['casemgrid']; } else { a=document['casemgrid']; } a.extplay(); inpause = false; } function comms_point (targetid) { if(receptive){ if(currentcase == 1 && targetid == 0){ targetid = 4; } point_click('cs' + (targetid), true); } } function point_unclick () { point_retract('cs'+casepointon,true); clearInterval(autocloseInterval); } function point_click (targetid, narrclick) { var itemidx = targetid.substring(2,targetid.length); if(parseInt(itemidx) != casepointon){ if(narrclick){ clearInterval(autocloseInterval); autocloseInterval = setTimeout(point_unclick,12000); } var ch = $("#caseholder").position(); var newwidth = 292; var thiscase = casepoints[itemidx]; var newmargin = (thiscase.x - 90); if(!narrclick){ receptive = false; clearInterval(recInterval); recInterval = setTimeout(receptiveagain,10000); } if(casepointon > -1){ point_retract('cs'+casepointon); } var outp = 'CLOSE X<\/a>'; if(slidemode){ } else { if(thiscase.isvideo){ newwidth = 322; if(thiscase.bodytext != ''){ outp += '
'; } else { outp += '
'; } } else { if(thiscase.haslink){ outp += '
'; if(thiscase.haslink){ outp += '<\/a>'; } } var thistext = thiscase.bodytext; if(thiscase.haslink){ outp += '' + lint + ' »<\/a>'; } if(thiscase.isvideo && narrclick){ thistext += ' Click to watch the video'; } if(thiscase.bodytext != undefined && thiscase.bodytext != ''){ newwidth = 500; outp += thistext; } else { if(!thiscase.isvideo && !thiscase.haslink){ newwidth = thiscase.imgwidth; newmargin = (thiscase.x - 30); } } if(thiscase.isvideo && newwidth < 386){ newwidth = 386; } if(thiscase.photocredit != ''){ outp += ' ' + thiscase.photocredit + '<\/span>'; } if((parseInt(newwidth) + parseInt(thiscase.x)) > casewidth){ newmargin = parseInt(casewidth) - (parseInt(newwidth) + 50); } $("#" + targetid).removeClass('boxen'); $("#" + targetid).addClass('boxenon'); $("#" + targetid).css({ 'z-index':40 }); $("#" + targetid).animate({ 'width': newwidth + 'px', 'height':'260px','margin-top':'5px','margin-left':newmargin + 'px' }, 400, function () { $("#" + targetid).html(outp); if(thiscase.isvideo){ if(narrclick){ videoembed(thiscase.videoid,false); } else { videoembed(thiscase.videoid,true); } } }); $("#" + targetid).html(''); } if(narrationup){ comms_started(); } $("#" + targetid).unbind('click'); $("#" + targetid).click( function () { }); refocus(thiscase.x); casepointon = parseInt(itemidx); } } function receptiveagain () { receptive = true; } function point_manualclose (targetid) { clearInterval(receptiveagain); recInterval = setTimeout(receptiveagain,5000); point_retract(targetid,true); } function point_retract (targetid,viaclose) { if(viaclose){ casepointon = -1; } var itemidx = targetid.substring(2,targetid.length); $("#" + targetid).css({ 'z-index':(20 + parseInt(itemidx)) }); if(slidemode){ } else { $("#" + targetid).animate({ 'width':'90px', 'height':'90px','margin-top':casepoints[itemidx].y + 'px', 'margin-left':casepoints[itemidx].x + 'px'}, 800, function () { $("#" + targetid).removeClass('boxenon').addClass('boxen'); $("#" + targetid).click( function () { point_click(targetid); }); }); $("#" + targetid).unbind('click'); var inf = ''; if(casepoints[itemidx].isvideo){ inf += '
'; $("#vidid").remove(); } if(casepoints[itemidx].isupdate){ inf += '
UPDATE
'; } inf += ''; $("#" + targetid).html(inf); } } function videoembed (videoid,playnow){ var refv = new Array(); refv.pap_url = window.location.href; if(playnow){ refv.pap_play = true; } refv.pap_url = window.location.href; refv.pap_usecache = true; refv.pap_hash = videoid; refv.pap_arrowonly = true; refv.pap_buttoncolor = 'ff0000'; refv.pap_buttonroll = 'b848c2'; refv.pap_standalone = true; refv.pap_segmentlisten = 'comms_pause'; refv.pap_replaymode = true; swfobject.embedSWF(_papevideourl,'vid',386,248,"9",null,refv,{wmode:"opaque",allowFullScreen:"true",allowScriptAccess:"always"},{ id:'vidid',name:'vidna' }); } function refocus (x) { var ch = $("#caseholder").position(); var vis = (0 - parseInt(ch.left)) + $("#caseinner").width(); var targetx = x - 130; if(targetx > (casewidth - $("#caseinner").width())){ targetx = (casewidth - $("#caseinner").width()); } if(targetx < 0){ targetx = 0; } $("#caseholder").animate({ "left" : (0 - targetx) + "px" }, 1000); arrowupdate(0-targetx); } function arrowupdate (targetx) { if(targetx < - 50){ $("#leftar").show(); } else { $("#leftar").hide(); } var ch = $("#caseholder").position(); var vis = (0 - targetx) + $("#caseinner").width(); if(vis < (casewidth - 100)){ $("#rightar").show(); } else { $("#rightar").hide(); } } function mover (newx) { var ch = $("#caseholder").position(); var targetx = ch.left + newx; arrowupdate(targetx); if(targetx > 0){ targetx = 0; } $("#caseholder").animate({ "left" : targetx + "px" }, 700); } function openpromo() { $(".promowin").slideDown('slow'); $(".promo").hide(); $(".promo1").show(); } function closepromo() { $(".promowin").slideUp('slow'); $(".promo1").hide(); $(".promo").show(); } function showtalk (onoff,text){ if(document.getElementById('subtitle')){ if(onoff){ $("#subtitle").stop(); $("#subtitle").css({opacity:"1"}); $("#subtitle").fadeIn(300); document.getElementById('subtitle').innerHTML = text; } else { $("#subtitle").stop(); document.getElementById('subtitle').style.display = 'none'; } } }