
﻿
var isCaseHistoryPopup=true;var currentCampaignID="";jQuery(document).ready(function(){if(getQSParameter("load")=="immediate"&&getQSParameter("campaign")!=""){var showCH=getQSParameter("showCaseHistory");if(showCH==""||showCH=="false"){showPortfolioCampaign(getQSParameter("campaign"),false);}else{showPortfolioCampaign(getQSParameter("campaign"),true);}}});function setupPortfolioCampaignContainer(){jQuery('img.swapUpDnImage').hover(function(){jQuery(this).attr("src",jQuery(this).attr("src").replace("_up.","_dn."));},function(){jQuery(this).attr("src",jQuery(this).attr("src").replace("_dn.","_up."));});jQuery('a.swapUpDnImage').hover(function(){jQuery(this).children('img').attr("src",jQuery(this).children('img').attr("src").replace("_up.","_dn."));},function(){jQuery(this).children('img').attr("src",jQuery(this).children('img').attr("src").replace("_dn.","_up."));});jQuery('#PClgCaseHistoryBtnImg').click(function(){ShowCaseHistory();return false;});jQuery('#PCSmLargeViewBtn').click(function(){ShowCampaign();return false;});var gblCampaignID=getGlobalVar("globalCampaignID");if(gblCampaignID!=""){currentCampaignID=gblCampaignID;loadCarouselList(gblCampaignID);loadCaseHistoryInfo(gblCampaignID);}else{currentCampaignID=getQSParameter("campaign");loadCarouselList(getQSParameter("campaign"));loadCaseHistoryInfo(getQSParameter("campaign"));}
if(getGlobalVar("globalBoolShowCaseHistory")=="true"){ShowCaseHistory();}else{ShowCampaign();}
if(isCaseHistoryPopup){jQuery('#PCCHPager').hide();}}
function ShowCaseHistory(){jQuery('#PCCHContainer').css("width","882px");jQuery('#PCCHContainer').css("height","529px");jQuery('#PCLgContainer').css("width","1px");jQuery('#PCLgContainer').css("height","1px");resetCarousels();}
function ShowCampaign(){jQuery('#PCCHContainer').css("width","1px");jQuery('#PCCHContainer').css("height","1px");jQuery('#PCLgContainer').css("width","882px");jQuery('#PCLgContainer').css("height","529px");resetCarousels();}
function loadCaseHistory(idOfCH){isCaseHistoryPopup=true;showPortfolioCampaign(idOfCH,true);return false;};function loadCaseHistoryInfo(idOfCampaign){var d=new Date();jQuery.ajax({type:"GET",url:"/layouts/Godfrey/Developers Only/Portfolio CaseHistory as XML.aspx",data:"campaign="+idOfCampaign+"&currtime="+d.getTime(),cache:false,success:function(data){loadCaseHistoryData(data);},error:function(XMLHttpRequest,textStatus,errorThrown){alert("We are sorry but we were unable to retrieve the requested case history.");jQuery('#PClgCaseHistoryBtn').hide();},dataType:"xml"});}
function loadCaseHistoryData(listData){if(jQuery(listData).find("CaseHistory").find("Title").text().length==0){jQuery('#PClgCaseHistoryBtn').hide();}else{jQuery('#PClgCaseHistoryBtn').show();jQuery(listData).find("CaseHistory").each(function(){jQuery('#PCCaseHistoryHeading').html(jQuery(this).find("Title").text());jQuery('#PCCaseHistoryChallengeInfo').html(jQuery(this).find("Challenge").text());jQuery('.PCCaseHistoryHeading').show();var resultsText=jQuery(this).find("Results").text();if(resultsText.length>0){jQuery('#PCCaseHistoryResultsHeading').show();jQuery('#PCCaseHistoryResultsInfo').html(resultsText);}else{jQuery('#PCCaseHistoryResultsHeading').hide();}
var solutionText=jQuery(this).find("Solution").text();if(solutionText.length>0){jQuery('#PCCaseHistorySolutionHeading').show();jQuery('#PCCaseHistorySolutionInfo').html(solutionText);}else{jQuery('#PCCaseHistorySolutionHeading').hide();}
var downloadText=jQuery(this).find("Download").text();if(downloadText.length>0){jQuery('#PCCaseHistoryDownloadHeading').show();jQuery('#PCCaseHistoryDownloadInfo').html(downloadText);}else{jQuery('#PCCaseHistoryDownloadHeading').hide();}
jQuery('#PCCaseHistoryCopy').jScrollPane({showArrows:true,arrowSize:15,scrollbarWidth:40,scrollbarMargin:10,dragMinHeight:20,dragMaxHeight:20});});}}
function loadCarouselList(idOfCampaign){jQuery.ajax({type:"GET",url:"/layouts/Godfrey/Developers Only/Portfolio Campaign as XML.aspx",data:"campaign="+idOfCampaign,cache:false,success:function(data){loadCarouselListData(data);},error:function(XMLHttpRequest,textStatus,errorThrown){alert("We are sorry but we were unable to retrieve the requested portfolio campaign.");},dataType:"xml"});}
function loadCarouselListData(listData){CarouselItemList=[];var i=0;if(!isCaseHistoryPopup){CarouselItemList[i]={LgTopImage:"Loading previous ....",LgBotImage:"",SmTopImage:"Loading previous ....",SmBotImage:"",Title:"",Info:""};i++;}
jQuery(listData).find("Item").each(function(){var lgTopImage="<img src=\""+jQuery(this).find("LgImg").text()+"\" />";var lgBotImage="<img src=\""+jQuery(this).find("SmBWImg").text()+"\" />";var smTopImage="<img src=\""+jQuery(this).find("LgImg").text()+"?mh=175&mw=315\" />";var smBotImage="<img src=\""+jQuery(this).find("SmBWImg").text()+"?mh=25&mw=42\" />";var title=jQuery(this).find("Title").text();var info=jQuery(this).find("Info").text();CarouselItemList[i]={LgTopImage:lgTopImage,LgBotImage:lgBotImage,SmTopImage:smTopImage,SmBotImage:smBotImage,Title:title,Info:info};i++;});if(!isCaseHistoryPopup){CarouselItemList[i]={LgTopImage:"Loading next ....",LgBotImage:"",SmTopImage:"Loading next ....",SmBotImage:"",Title:"",Info:""}}
jQuery("#printPortfolioCampaign").click(function(){openPopupName('Print','/What-We-Do/Our-Work/Portfolio-Campaign?campaign='+currentCampaignID+'&print=1',450,600,50,50,0,1,1,1,0,0);});loadCarousels();}
var carousels={};var CarouselItemList;function loadCarousels(){try{if(jQuery('#PCLgTopCarousel').length==0||jQuery('#PCLgBotCarousel').length==0||jQuery('#PCSmTopCarousel').length==0||jQuery('#PCSmBotCarousel').length==0){var timer=setTimeout(loadCarousels,50);return;}
resetCarousels();jQuery('#PCLgTopCarousel').jcarousel({silent:true,scroll:1,animation:"slow",start:(isCaseHistoryPopup?1:2),size:CarouselItemList.length,itemLoadCallback:{onBeforeAnimation:PCLgTopCarousel_itemLoadCallback},initCallback:PCLgTopCarousel_initCallback,itemVisibleInCallback:{onAfterAnimation:PCLgTopCarousel_itemVisibleInCallbackAfterAnimation},itemFirstInCallback:{onAfterAnimation:TopCarousels_buttonPrevCallback},itemFirstOutCallback:{onAfterAnimation:TopCarousels_buttonNextCallback}});jQuery('#PCLgBotCarousel').jcarousel({silent:true,scroll:5,animation:"slow",size:(isCaseHistoryPopup?CarouselItemList.length:CarouselItemList.length-2),itemLoadCallback:{onBeforeAnimation:PCLgBotCarousel_itemLoadCallback},initCallback:PCLgBotCarousel_initCallback});jQuery('#PCSmTopCarousel').jcarousel({silent:true,scroll:1,animation:"slow",start:(isCaseHistoryPopup?1:2),auto:0,size:CarouselItemList.length,itemLoadCallback:{onBeforeAnimation:PCSmTopCarousel_itemLoadCallback},initCallback:PCSmTopCarousel_initCallback,itemVisibleInCallback:{onAfterAnimation:PCSmTopCarousel_itemVisibleInCallbackAfterAnimation},itemFirstInCallback:{onAfterAnimation:TopCarousels_buttonPrevCallback},itemFirstOutCallback:{onAfterAnimation:TopCarousels_buttonNextCallback}});jQuery('#PCSmBotCarousel').jcarousel({silent:true,scroll:5,animation:"slow",size:(isCaseHistoryPopup?CarouselItemList.length:CarouselItemList.length-2),itemLoadCallback:{onBeforeAnimation:PCSmBotCarousel_itemLoadCallback},initCallback:PCSmBotCarousel_initCallback});}catch(err){alert(err);}}
function PCLgTopCarousel_itemLoadCallback(theCarousel){LoadCallback(theCarousel,"LgTopImage",false,null,"");};function PCLgBotCarousel_itemLoadCallback(theCarousel){LoadCallback(theCarousel,"LgBotImage",true,carousels[0],"#PCLgBotCarousel");};function PCSmTopCarousel_itemLoadCallback(theCarousel){LoadCallback(theCarousel,"SmTopImage",false,null,"");};function PCSmBotCarousel_itemLoadCallback(theCarousel){LoadCallback(theCarousel,"SmBotImage",true,carousels[2],"#PCSmBotCarousel");};function LoadCallback(theCarousel,dataField,isSmallPager,targetCarousel,botCarouselID){if(CarouselItemList.length==0){return false;}
var start=1;var end=theCarousel.last;var useLoadingItems=false;if(!isSmallPager&&!isCaseHistoryPopup){useLoadingItems=true;}
if(useLoadingItems){start=2;}
for(var i=start;i<=end;i++){if(theCarousel.has(i)){continue;}
if(i>CarouselItemList.length||CarouselItemList.length==0){break;}
if(isSmallPager&&!isCaseHistoryPopup){theCarousel.add(i,CarouselItemList[i][dataField]);}else{theCarousel.add(i,CarouselItemList[i-1][dataField]);}}
if(isSmallPager){var liLg=jQuery(botCarouselID+' li').click(function(){if(!isCaseHistoryPopup){targetCarousel.scroll(jQuery.jcarousel.intval(liLg.index(this)+2));}else{targetCarousel.scroll(jQuery.jcarousel.intval(liLg.index(this)+1));}
jQuery(this).parent().find("img").attr("title","Click to View");jQuery(this).find("img").attr("title","");jQuery(this).parent().find("img").each(function(index){jQuery(this).attr("src",jQuery(this).attr("src").replace("Sjpg","Sgjpg"));});jQuery(this).find("img").attr("src",jQuery(this).find("img").attr("src").replace("Sgjpg","Sjpg"));if(botCarouselID=="#PCLgBotCarousel"){jQuery(this).parent().find("img").removeClass("selectedLgScrollerImage");jQuery(this).find("img").addClass("selectedLgScrollerImage");}else if(botCarouselID=="#PCSmBotCarousel"){jQuery(this).parent().find("img").removeClass("selectedSmScrollerImage");jQuery(this).find("img").addClass("selectedSmScrollerImage");}
return false;});var parentHTML=jQuery(botCarouselID).parent();if(parentHTML.html().indexOf("selectedLgScrollerImage")==-1&&parentHTML.html().indexOf("selectedSmScrollerImage")==-1){jQuery(botCarouselID+' li img').attr("title","Click to View");jQuery(botCarouselID+' li'+'[jcarouselindex="1"]').find("img").attr("title","");jQuery('#PCLgBotCarousel li'+'[jcarouselindex="1"]').find("img").addClass("selectedLgScrollerImage");jQuery('#PCSmBotCarousel li'+'[jcarouselindex="1"]').find("img").addClass("selectedSmScrollerImage");if(jQuery(botCarouselID+' li'+'[jcarouselindex="1"]').find("img").length>0){jQuery(botCarouselID+' li'+'[jcarouselindex="1"]').find("img").attr("src",jQuery(botCarouselID+' li'+'[jcarouselindex="1"]').find("img").attr("src").replace("Sgjpg","Sjpg"));}}
jQuery(botCarouselID+' li img').mouseover(function(){jQuery(this).attr("src",jQuery(this).attr("src").replace("Sgjpg","Sjpg"));});jQuery(botCarouselID+' li img').mouseout(function(){if(!jQuery(this).hasClass("selectedLgScrollerImage")&&!jQuery(this).hasClass("selectedSmScrollerImage")){jQuery(this).attr("src",jQuery(this).attr("src").replace("Sjpg","Sgjpg"));}});}}
function PCLgTopCarousel_initCallback(theCarousel){carousels[0]=theCarousel;};function PCLgBotCarousel_initCallback(theCarousel){carousels[1]=theCarousel;};function PCSmTopCarousel_initCallback(theCarousel){carousels[2]=theCarousel;};function PCSmBotCarousel_initCallback(theCarousel){carousels[3]=theCarousel;};function TopCarousels_buttonPrevCallback(theCarousel,liObj,idx,state){if(!isCaseHistoryPopup&&state=="prev"&&idx==1){resetCarousels("prev");}};function TopCarousels_buttonNextCallback(theCarousel,liObj,idx,state){if(!isCaseHistoryPopup&&state=="next"&&idx==theCarousel.options.size-1){resetCarousels("next");}};function PCLgTopCarousel_itemVisibleInCallbackAfterAnimation(carousel,item,idx,state){if(CarouselItemList.length>0){jQuery('#PCLgTitle').html(CarouselItemList[idx-1].Title);jQuery('#PCLgShortDesc').html(CarouselItemList[idx-1].Info);if(carousels[1]!=null){if(idx<carousels[1].first){carousels[1].prev();}else if(idx>carousels[1].last){carousels[1].next();}}
jQuery('.selectedLgScrollerImage').attr("src",function(){return jQuery(this).attr("src").replace("Sjpg","Sgjpg")});jQuery('#PCLgBotCarousel li').find("img").removeClass("selectedLgScrollerImage");jQuery('#PCLgBotCarousel li'+'[jcarouselindex="'+idx+'"]').find("img").addClass("selectedLgScrollerImage");jQuery('.selectedLgScrollerImage').attr("src",function(){return jQuery(this).attr("src").replace("Sgjpg","Sjpg")});}};function PCSmTopCarousel_itemVisibleInCallbackAfterAnimation(carousel,item,idx,state){if(CarouselItemList.length>0){if(carousels[3]!=null){if(idx<carousels[3].first){carousels[3].prev();}else if(idx>carousels[3].last){carousels[3].next();}}
jQuery('.selectedSmScrollerImage').attr("src",function(){return jQuery(this).attr("src").replace("Sjpg","Sgjpg")});jQuery('#PCSmBotCarousel li').find("img").removeClass("selectedSmScrollerImage");jQuery('#PCSmBotCarousel li'+'[jcarouselindex="'+idx+'"]').find("img").addClass("selectedSmScrollerImage");jQuery('.selectedSmScrollerImage').attr("src",function(){return jQuery(this).attr("src").replace("Sgjpg","Sjpg")});}};function resetCarousels(direction){var found=false;var nextID="";var prevID="";var firstID="";var lastID="";var i=0;jQuery('#portfolioHTMLList').find("li").each(function(){var href=jQuery(this).find("a").attr("href").replace("%7B","{").replace("%7D","}");var id=href.substring(href.indexOf("{"),href.indexOf("}")+1);if(found==true&&nextID==""){nextID=id;}
if(currentCampaignID==id){found=true;}
if(found==false){prevID=id;}
if(i==0){firstID=id;}
lastID=id;i++;});if(nextID==""){nextID=firstID;}
if(prevID==""){prevID=lastID;}
if(direction=="prev"){alert(prevID);setGlobalVar("globalCampaignID",prevID);setupPortfolioCampaignContainer();}else if(direction=="next"){alert(nextID);setGlobalVar("globalCampaignID",nextID);setupPortfolioCampaignContainer();}else{if(carousels[0]!=null&&jQuery('#PCLgTopCarousel').is(':visible')){carousels[0].reset();}
if(carousels[1]!=null&&jQuery('#PCLgBotCarousel').is(':visible')){carousels[1].reset();}
if(carousels[2]!=null&&jQuery('#PCSmTopCarousel').is(':visible')){carousels[2].reset();}
if(carousels[3]!=null&&jQuery('#PCSmBotCarousel').is(':visible')){carousels[3].reset();}}};
