/*
	PHH
	requires: jQuery 1.4.2
	beware! jQuery doesn't like to compete with window.onload used by other scripts
	last edited: 14 May 2010
*/

var phh=phh||{};(function($){phh.dev=false;$(function(){if(phh.options){$.extend(true,phh.prefs,phh.options);}
phh.init();});phh.prefs={text:{backtotop:"back to top",page:"Page",faq:{open_str:"Expand to read Answer",close_str:"Hide expanded Answer"},external_link:"Opens in new window"},cookie_expires:90};phh.init=function(){if(phh.ie6){phh.prepIE6();}
phh.jsCSS();phh.prepExternalLinks(phh.prefs.text.external_link);phh.cardRotation.init();if(phh.hasOwnProperty('prefs')){if(phh.prefs.hasOwnProperty('text')){if(phh.prefs.text.hasOwnProperty('faq')){phh.faq.init(phh.prefs.text.faq);}}}
if(phh.hasOwnProperty('prefs')){if(phh.prefs.hasOwnProperty('maps')){phh.googleMap.init(phh.prefs.maps);}}};phh.prepIE6=function(){document.createElement('abbr');};phh.html5=function(){document.createElement('header');document.createElement('nav');document.createElement('section');document.createElement('article');document.createElement('aside');document.createElement('footer');};phh.prepExternalLinks=function(message){message=message||"(Opens in new window)";$("a[rel*='external']").click(function(){window.open($(this).attr('href'));return false;}).each(function(){var title=$(this).attr("title");if(!title){$(this).attr("title",message);}});};phh.jsCSS=function(){$('body').addClass('js');};phh.googleMap={prefs:{maps:[{selector_str:".g-map",zoom:6,centre:{lat:54,lng:-2.5},markers:{teddington:{lat:51.430682,lng:-0.33607,title:"ActiveIS",info_window:"Teddington, TW11 8DH"}}}]},init:function(options){var
the=this,maps,i,i_map;maps=$.extend(the.prefs.maps,options);if(!google){return false;}
for(i=0;i<maps.length;i+=1){i_map=maps[i];the.makeMap(i_map);}},makeMap:function(map){var
the=this,map_options,map_el,g_centre,g_map,marker;g_centre=new google.maps.LatLng(map.centre.lat,map.centre.lng);map_options={zoom:map.zoom,center:g_centre,mapTypeId:google.maps.MapTypeId.ROADMAP};map_el=$(map.selector_str)[0];g_map=new google.maps.Map(map_el,map_options);if(map.markers){for(marker in map.markers){if(map.markers.hasOwnProperty(marker)){the.addMarkerClosure(map.markers[marker],g_map);}}}},addMarkerClosure:function(marker_data,g_map){var
info_str,g_infowindow,g_marker,marker_hash;if(!(marker_data.hasOwnProperty('lat'))||!(marker_data.hasOwnProperty('lng'))){return false;}
marker_hash={position:new google.maps.LatLng(marker_data.lat,marker_data.lng),map:g_map};if(marker_data.hasOwnProperty('title')){marker_hash.title=marker_data.title;}
g_marker=new google.maps.Marker(marker_hash);if(marker_data.hasOwnProperty('info_window')){info_str=marker_data.info_window;info_str='<div class="g-box" ><h3>'+marker_data.title+'</h3>';info_str=info_str+'<p>'+marker_data.info_window+'</p></div>';g_infowindow=new google.maps.InfoWindow({content:info_str,maxWidth:355});google.maps.event.addListener(g_marker,'click',function(){g_infowindow.open(g_map,g_marker);});}}};
phh.cardRotation={prefs:[{group_class:'cards', card_class:'card',overlay_class:'overlay',pause:5000,fade_speed:3000}],init:function(options){var
the,prefs,i;the=this;prefs=$.extend(the.prefs,options);for(i=0;i<prefs.length;i+=1){the.initPrefsSet(the,prefs[i]);}},initPrefsSet:function(the,prefs){var
$groups,group_class,cardset_class;group_class='.'+prefs.group_class;if((prefs.hasOwnProperty('cardset_class'))&&(prefs.cardset_class!=='')){cardset_class='.'+prefs.cardset_class;$groups=$(group_class,cardset_class);}else{$groups=$(group_class);}
$groups.each(function(){var
$cards_group,$cards,card_width,group_width_str,number_of_cards;$cards_group=$(this);$cards=$('.'+prefs.card_class,$cards_group);number_of_cards=$cards.length;card_width=$cards.get(0).offsetWidth;group_width_str=(card_width*number_of_cards)+"px";$cards_group.get(0).style.width=group_width_str;if(!$cards_group.get(0).style.left){$cards_group.get(0).style.left="0px";}
the.cardGroupClosure(prefs,$cards_group,number_of_cards,card_width);});},cardGroupClosure:function(prefs,$group,number_of_cards,card_width){var
current_card=0,timeout,timeoutCardFunction,$overlay;$overlay=$('<div></div').addClass(prefs.overlay_class).css("display","none").fadeTo(0,0).css("height","0px").appendTo($group.parent());timeoutCardFunction=function(){var position;$overlay.css("display","block").css("height","auto").fadeTo(prefs.fade_speed,1,function(){current_card++;if(current_card>=number_of_cards){current_card=0;}
position=0-(current_card*card_width);$group.get(0).style.left=position+"px";$overlay.fadeTo(prefs.fade_speed,0,function(){$overlay.css("display","none");clearTimeout(timeout);timeout=setTimeout(timeoutCardFunction,prefs.pause);});});};timeout=setTimeout(timeoutCardFunction,prefs.pause);}};phh.faq={prefs:{question_header_level:2,answer_header_level:3,recycle_question_bool:true,show_answer_header:false,selector_str:".question",toggle_link_str_bool:false,open_str:"Expand to read Answer",close_str:"Hide expanded Answer"},init:function(options){var
the,prefs,$question_id,$answer_id,$questions,$answers,$faq;the=this;prefs=$.extend(the.prefs,options);$question_id=$('#questions');$answer_id=$('#answers');$questions=$('.question',$question_id);$answers=$('.answer',$answer_id);if(($questions.length===0)||($answers.length===0)){return false;}
$faq=$('<div/>',{"id":"faq"});$question_id.before($faq);$questions.each(function(){var
$question,$answer,href,$div,$a,question_header,answer_header;$question=$(this);href=$question.attr('href');question_header="h"+prefs.question_header_level;answer_header="h"+prefs.answer_header_level;$answer=$(href);if($answer.length>0){$('.backtotop',$answer).remove();$div=$('<div/>',{"class":"faq"});$div.append($answer);$faq.append($div);if(prefs.recycle_question_bool){$question.prependTo($div).wrap('<'+question_header+'/>');if(prefs.show_answer_header){$('<'+answer_header+'/>').html(function(){return $(':header',$answer).filter(':first').remove().text();}).prependTo($answer);}else{$(':header',$answer).filter(':first').remove();}}else{$a=$('<a/>',{"class":"question","href":href});$('h2',$answer).prependTo($div).wrapInner($a);}}else{if(phh.dev){alert('Q & A mismatch');}}});$question_id.remove();$answer_id.remove();phh.addHrefSlideToggle.init({selector_str:prefs.selector_str,toggle_link_str_bool:prefs.toggle_link_str_bool,open_str:prefs.open_str,close_str:prefs.close_str});}};phh.addHrefSlideToggle={prefs:{selector_str:".href-toggle",hidden_class_str:"display-false",open_str:"Read more",close_str:"Hide expanded article",toggle_link_str_bool:true},init:function(options){var
the,prefs,$links,hide,removeStyle;the=this;prefs=$.extend(the.prefs,options);hide=function(){$(this).addClass(prefs.hidden_class_str).removeAttr("style");};removeStyle=function(){$(this).removeAttr("style");};$links=$(prefs.selector_str);$links.each(function(){var
$link,$display,href_str,link_open_str,link_txt;$link=$(this);if(prefs.toggle_link_str_bool){link_txt=$link.text();if(link_txt.length===0){link_open_str=prefs.open_str;$link.text(link_open_str);}else{link_open_str=link_txt;}}else{$link.attr("title",prefs.open_str);}
href_str=$link.attr("href");$display=$(href_str);$display.addClass(prefs.hidden_class_str);$link.click(function(){if($display.is(':visible')){$display.slideUp('slow',hide);if(prefs.toggle_link_str_bool){$link.text(link_open_str);}else{$link.attr("title",prefs.open_str);}
$link.parent().addClass('closed');$link.parent().removeClass('open');}else{$display.slideDown('slow',removeStyle).removeClass(prefs.hidden_class_str);if(prefs.toggle_link_str_bool){$link.text(prefs.close_str);}else{$link.attr("title",prefs.close_str);}
$link.parent().addClass('open');$link.parent().removeClass('closed');}
$link.blur();return false;}).parent().addClass('closed');});}};}(jQuery));