/** Created by TR to add javascript/Ajax specific to Q8 **/
var baseDir = ( ( typeof( appBaseDir ) != "undefined" ) ? appBaseDir : "" );
var urlSite = '';
var slideSpeed = 300;
var jumpToSingleStaffMember = !true;
var currentSelection = "world";
var sizeSelection = "";
var regionIdSelected = "";
var countrySelected = "";
var newsSelected = "";
var staffSelected = "";
var timeoutTopStyle = 0;
var timeoutId = "";
var scriptLoaded = new Array();
var ptConversion = "";
/** display block all div item:body from the news page */
function selectNews( divName )
{
var currDivList = document.getElementsByTagName( "div" );
newsSelected = "";
for( var i = 0 ; i < currDivList.length ; i++ )
{
if( currDivList[i].id.indexOf( 'ITEM_BODY' ) == 0 )
{
if( currDivList[i].id == divName )
{
if( currDivList[i].style.display == "block" )
{
$(currDivList[i]).hide( "slow", function() {
scrollUpBisArea( divName, "list27" );
} );
}
else
{
$(currDivList[i]).show( "slow", function() {
scrollUpBisArea( divName, "list27" );
} );
newsSelected = currDivList[i].id;
staffSelected = "";
}
}
else
{
$(currDivList[i]).hide(); //$(currDivList[i]).hide( "slow" ); //.style.display = "none";
scrollUpBis( divName, "list27" );
}
}
}
}
/** display block all div item:body from the team page */
function selectTeam( divName )
{
var currDivList = document.getElementsByTagName( "div" );
for( var i = 0 ; i < currDivList.length ; i++ )
{
if( currDivList[i].id.indexOf( 'CATEGORY:EMPLOYEES' ) == 0 )
{
if( currDivList[i].id == divName )
{
if( currDivList[i].style.display == "block" )
{
$(currDivList[i]).hide( "slow" ); //.style.display = "none";
scrollUpBis( divName );
}
else
{
$(currDivList[i]).show("slow"); //.style.display = "block";
scrollUpBis( divName );
}
}
else
{
$(currDivList[i]).hide( "slow" ) //.style.display = "none";
}
}
}
}
/** display block all div item:body from the team page */
function selectDiv( divName, divRoot, listItemId, divNameItem )
{
var currDivList = document.getElementsByTagName( "div" );
var parentDivList = null;
for( var i = 0 ; i < currDivList.length ; i++ )
{
if( currDivList[i].id.indexOf( divRoot ) == 0 )
{
//LIST: listHandle :EMPLOYEE
if( currDivList[i].id == divName )
{
if( currDivList[i].style.display == "block" )
{
$(currDivList[i]).slideUp( "normal" ); //.style.display = "none";
parentDivList = document.getElementById( currDivList[i].id.replace( "EMPLOYEES", "" ) );
if( parentDivList.className.indexOf( "category0" ) != -1 )
{
parentDivList.className = "category0";
}
else
{
parentDivList.className = "category";
}
}
else
{
$(currDivList[i]).slideDown( "slow" ); //.style.display = "block";
newsSelected = "";
staffSelected = listItemId;
parentDivList = document.getElementById( currDivList[i].id.replace( "EMPLOYEES", "" ) );
if( parentDivList.className.indexOf( "category0" ) != -1 )
{
parentDivList.className = "category0Selected";
}
else
{
parentDivList.className = "categorySelected";
}
getStaffContent( listItemId, divNameItem );
}
}
else
{
$(currDivList[i]).hide("normal"); //.style.display = "none";
parentDivList = document.getElementById( currDivList[i].id.replace( "EMPLOYEES", "" ) );
if( parentDivList.className.indexOf( "category0" ) != -1 )
{
parentDivList.className = "category0";
}
else
{
parentDivList.className = "category";
}
}
}
}
}
function getStaffContent2( listItemId, divName )
{
var divLoading = document.getElementById( divName );
divLoading.innerHTML = "Loading staff details...";
var http = false; /** for AJAX calls */
if( navigator.appName == "Microsoft Internet Explorer" )
{
http = new ActiveXObject( "Microsoft.XMLHTTP.1.0" );
}
else
{
http = new XMLHttpRequest();
}
http.open( "POST", baseDir + "/js/getAjaxContent.jsp", true );
http.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
http.onreadystatechange = function()
{
if( http.readyState == 4 )
{
var responseFromFile = http.responseText;
var ajaxResponse = responseFromFile;
var div = document.getElementById( divName );
newsSelected = "";
staffSelected = listItemId;
$(div).hide();
div.innerHTML = ajaxResponse;
$(div).show( "slow" );
setTimeout( "scrollTeam('" + div.id + "');", 600 );
}
}
http.send( "listItemId=" + listItemId );
}
function getStaffContent( listItemId, divName )
{
$("#" + divName).fadeOut( "slow", function() {
var cb = Math.round( Math.random() * 20000 );
$(this).load( baseDir + "/js/getAjaxContent.jsp?listItemId=" + listItemId + "&__cb=" + cb, function() {
$(this).fadeIn( "slow", function() {
newsSelected = "";
staffSelected = listItemId;
scrollTeam( divName );
} );
} );
} );
}
function getHighVis()
{
return $("body").hasClass( "highVis" );
}
function resetMapRegion( mapName )
{
var highVisDir = ( getHighVis() ? "highVis/" : "" );
document.getElementById(mapName).src = baseDir + '/art/' + highVisDir + 'map/' + currentSelection.replace( " ", "" ) + sizeSelection + '.png';
}
function resetMapRegionSmall( mapName )
{
var highVisDir = ( getHighVis() ? "highVis/" : "" );
document.getElementById(mapName).src = baseDir + '/art/' + highVisDir + 'map/' + currentSelection.replace( " ", "" ) + '_small.png';
}
function changeMapRegion( mapName, regionName, currentSelect, leftDivName )
{
var highVisDir = ( getHighVis() ? "highVis/" : "" );
document.getElementById(mapName).src = baseDir + '/art/' + highVisDir + 'map/' + regionName.replace( " ", "" ) + '.png';
regionIdSelected = "";
countrySelected = "";
if( currentSelect.length > 0 )
{
currentSelection = currentSelect;
var leftDiv = document.getElementById( leftDivName );
var http = false; /** for AJAX calls */
if( navigator.appName == "Microsoft Internet Explorer" )
{
http = new ActiveXObject( "Microsoft.XMLHTTP.1.0" );
}
else
{
http = new XMLHttpRequest();
}
http.open( "POST", baseDir + "/js/getMapInfo.jsp", true );
http.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
http.onreadystatechange=function()
{
if( http.readyState == 4 )
{
leftDiv.innerHTML = http.responseText; //"
" +
}
}
if( urlSite.indexOf( "#" ) == -1 )
{
urlSite = urlSite.substring( urlSite.indexOf( "?" )+1, urlSite.length );
}
else
{
urlSite = urlSite.substring( urlSite.indexOf( "?" )+1, urlSite.indexOf( "#" ) );
}
http.send( "mode=getRegionData®ionName=" + regionName + "&mainurl=" + escape( urlSite ) );
}
}
function selectCountry( regionId, countryId )
{
var leftDiv = document.getElementById( 'Q8_Questions:BODY:AirportList' );
var http = false; /** for AJAX calls */
if( navigator.appName == "Microsoft Internet Explorer" )
{
http = new ActiveXObject( "Microsoft.XMLHTTP.1.0" );
}
else
{
http = new XMLHttpRequest();
}
http.open( "POST", baseDir + "/js/getMapInfo.jsp", true );
http.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
http.onreadystatechange=function()
{
if( http.readyState == 4 )
{
regionIdSelected = regionId;
countrySelected = countryId;
$(leftDiv).hide();
leftDiv.innerHTML = http.responseText;
$(leftDiv).show( "slow" );
}
}
var linkArray = document.getElementsByTagName( "a" ); //all links from this div
for( var i=0; linkArray!=null && i=0 )
{
if( linkArray[i].name == 'country' + countryId )
{
linkArray[i].className = "countryListSelected";
}
else
{
linkArray[i].className = "countryList";
}
}
}
if( urlSite.indexOf( "#" ) == -1 )
{
urlSite = urlSite.substring( urlSite.indexOf( "?" )+1, urlSite.length );
}
else
{
urlSite = urlSite.substring( urlSite.indexOf( "?" )+1, urlSite.indexOf( "#" ) );
}
http.send( "mode=getCountryData®ionId=" + regionId + "&countryId=" + countryId + "&mainurl=" + escape( urlSite ) );
}
function selectAirport( regionId, countryId, airportId )
{
var leftImg = document.getElementById( 'Q8_Questions:SMALLMAPIMAGE' );
var airportListDiv = document.getElementById( 'Q8_Questions:BODY:AirportList' );
var leftBodyDiv = document.getElementById( 'Q8_Questions:BODY' );
var leftDiv = document.getElementById( 'smallQ8_map' );
var rightDiv = document.getElementById( 'categoryQ3' );
var http = false; /** for AJAX calls */
if( navigator.appName == "Microsoft Internet Explorer" )
{
http = new ActiveXObject( "Microsoft.XMLHTTP.1.0" );
}
else
{
http = new XMLHttpRequest();
}
http.open( "POST", baseDir + "/js/getMapInfo.jsp", true );
http.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
http.onreadystatechange=function()
{
if( http.readyState == 4 )
{
var highVisDir = ( getHighVis() ? "highVis/" : "" );
leftImg.src = baseDir + '/art/' + highVisDir + 'map/' + currentSelection.replace( " ", "" ) + '_small.png';
alert( leftImg.src );
$(leftDiv).show( "slow" ); //.style.display = 'block';
rightDiv.innerHTML = http.responseText;
airportListDiv.style.height = '140px';
var airportDiv = document.getElementById( 'airportItem9' );
airportDiv.style.styleFloat = 'right';
airportDiv.style.float = 'right';
airportDiv = document.getElementById( 'airportItem1' );
airportDiv.style.styleFloat = 'right';
airportDiv.style.float = 'right';
}
}
if( urlSite.indexOf( "#" ) == -1 )
{
urlSite = urlSite.substring( urlSite.indexOf( "?" )+1, urlSite.length );
}
else
{
urlSite = urlSite.substring( urlSite.indexOf( "?" )+1, urlSite.indexOf( "#" ) );
}
http.send( "mode=getAirportData&airportId=" + airportId + "®ionId=" + regionId + "&countryId=" + countryId + "&mainurl=" + escape( urlSite ) );
}
function setHighVis()
{
var highVis = getHighVis();
var imageArray = document.getElementsByTagName( "img" );
var linkHighVis = document.getElementById( 'highVisLink' );
for( var k = 0 ; imageArray != null && k < imageArray.length ; k++ )
{
if( imageArray[k].src.indexOf( "circle." ) != -1 ||
imageArray[k].src.indexOf( "/map/" ) != -1 ||
imageArray[k].src.indexOf( "printerFriendly.png" ) != -1 )
{
if( imageArray[k].src.indexOf( "highVis" ) != -1 )
{
imageArray[k].src = imageArray[k].src.replace( "highVis/", "" );
}
else
{
imageArray[k].src = imageArray[k].src.replace( "art/", "art/highVis/" );
}
}
}
if( highVis )
{
$("body").removeClass( "highVis" );
linkHighVis.innerHTML = linkHighVis.innerHTML.replace( "HIGH VISIBILITY", "STANDARD" );
}
else
{
$("body").addClass( "highVis" );
linkHighVis.innerHTML = linkHighVis.innerHTML.replace( "STANDARD", "HIGH VISIBILITY" );
}
$.getJSON( baseDir + "/js/setHighVis.jsp?highVis=" + ( !highVis ), function( d, s ) {
// alert( d.highVis );
} );
return false;
}
function loadDepartment( theLink )
{
if( typeof( theLink ) == "undefined" )
{
theLink = $('#sideMenu a').get( 0 );
}
$('#sideMenu a').removeClass( "current" );
$(theLink).addClass( "current" );
var parentId = theLink.href.substring( theLink.href.lastIndexOf( "/" ) + 1 ).replace( /\?/, "&" );
if( theLink.href.indexOf( "cat=" ) < 0 )
{
$('.sideMenuLinks').slideUp( slideSpeed );
$('#sideMenuLinks_' + parseInt( parentId ) ).stop().slideToggle( slideSpeed );
}
$('#staffMember').fadeOut();
$('#department').fadeOut( function() {
$('#department').load( "/lists/list.jsp?l=q8_staff&parentId=" + parentId + "&__cb=" + new Date().getTime(), function( d, s ) {
$('#department').fadeIn();
if( $('#department a').length == 1 && jumpToSingleStaffMember )
{
loadStaffMember( $('#department a').get( 0 ) );
}
} );
} );
return false;
}
function loadStaffMember( theLink )
{
if( typeof( theLink ) != "string" )
{
$('#department a').removeClass( "current" );
$(theLink).addClass( "current" );
theLink = theLink.href;
}
$('#staffMember').fadeOut( function() {
$('#staffMember').load( "/items/item.jsp?i=" + theLink.substring( theLink.lastIndexOf( "/" ) + 1 ) + "&__cb=" + ( new Date().getTime() ) + "&__cb=" + new Date().getTime(), function( d, s ) {
$('#department').hide();
$('#staffMember').fadeIn();
} );
} );
return false;
}
function printPage( queryString )
{
var mainDiv = document.getElementById( "Q8_Questions:BODY" );
var mainDiv2 = document.getElementById( "LIST:q8_staff:EMPLOYEE" );
if( staffSelected.length > 0 )
{
queryString += "&otherItemId=" + staffSelected.replace( "ITEM:BODY", "" );
}
else if( newsSelected.length > 0 )
{
queryString += "&otherItemId=" + newsSelected.replace( "ITEM:BODY", "" );
}
else if( queryString.indexOf( "f=27" ) >=0 )
{
queryString += "&mode=allnews";
}
else if( currentSelection.length > 0 && queryString.indexOf( "f=26" )>=0 )
{
queryString += "®ionName=" + currentSelection;
if( regionIdSelected.length>0 )
{
queryString += "®ionId=" + regionIdSelected;
}
if( countrySelected.length>0 )
{
queryString += "&countryId=" + countrySelected;
}
}
window.open( baseDir + "/pages/printFriendly.jsp?" + queryString, "_blank", "scrollbars=yes,toolbar=no,height=700,width=600" );
}
function checkStyle()
{
if( timeoutId != null )
{
clearTimeout( timeoutId );
timeoutId = null;
}
if( document.documentElement.clientHeight == 0 ) //browser not supporting this property, use document.body.clientHeight instead with default dimensions
{
if( document.body.clientHeight > 615 && getElt( "backdrop" ).className.indexOf( "backdropNoPadding" ) != -1 )
{
getElt( "backdrop" ).className = "backdrop";
}
else if( document.body.clientHeight <= 615 && getElt( "backdrop" ).className.indexOf( "backdropNoPadding" ) == -1 )
{
getElt( "backdrop" ).className = "backdropNoPadding";
}
}
else if( document.documentElement.clientHeight > ( document.body.clientHeight + 5 ) && getElt( "backdrop" ).className.indexOf( "backdropNoPadding" ) != -1 ) //scrollable need to take off the padding
{
getElt( "backdrop" ).className = "backdrop";
}
else if( document.documentElement.clientHeight < ( document.body.clientHeight - 5 ) && getElt( "backdrop" ).className.indexOf( "backdropNoPadding" ) == -1 )
{
getElt( "backdrop" ).className = "backdropNoPadding";
}
}
function setCheckStyle()
{
return;
clearTimeout( timeoutId );
if( timeoutTopStyle < 200 )
{
timeoutTopStyle = timeoutTopStyle + 20;
}
timeoutId = setTimeout( "checkStyle()", timeoutTopStyle );
}
function showSubPage( theHref, num, i, t, f )
{
showSubMenu( theHref, num );
if( i )
{
if( t )
{
bf_flickBannerStart( t );
}
$('.contentcell').load( "/items/item.jsp?i=" + i + "&f=" + f + "&t=" + t + "§ion=" + num, function() {
columnateClasses( "columnContent", [ 258, 258 ], 24 );
$('.health img:first').addClass( "rightCol" );
$('.health img:last').addClass( "floatright" );
} );
return false;
}
return true;
}
function showSubMenu( theHref, num )
{
$('.sideMenu a').removeClass( 'current' );
$(theHref).addClass( 'current' );
$('.sideMenuLinks').slideUp( slideSpeed );
$('#sideMenuLinks_' + num).stop().slideDown( slideSpeed );
return true;
}
function pageLoad()
{
if( q8_oldload != null && typeof( q8_oldload ) != "undefined" )
{
q8_oldload();
q8_oldload = null;
}
setCheckStyle();
}
var q8_oldload = window.onload;
window.onload = pageLoad;
window.onresize = setCheckStyle;