var $auto_search_request=null;try{document.execCommand("BackgroundImageCache",false,true);}catch(e){}
function fixPNG(element){if(/MSIE (5\.5|6).+Win/.test(navigator.userAgent)){var src;if(element.tagName=='IMG'){if(/\.png$/.test(element.src)){src=element.src;element.src="img/s.gif";}}else{src=element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
if(src){src=src[1];element.runtimeStyle.backgroundImage="none";}}
var re_scale_mode=/iesizing\-(\w+)/;var m=re_scale_mode.exec(element.className);var scale_mode=(m)?m[1]:'crop';if(src){element.runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"',sizingMethod='"+scale_mode+"')";}}}
$(document).ready(function(){$('table[class!=layout] tr:even').addClass('even');$('tr:first',$('table').not('.layout')).addClass('header');if($('#promo').length){initPromo();}
if($.browser.msie){$('.login-form input').css({position:'relative',top:'-1px'});}
if($('#contact_us_container').length){initContactUs();}
fixHeights();fixHeights();$('.top-level-item-v-sep, .top-level-item-h-sep').show();$('.corner-wrap').css('display','block');initCaseStudiesScroller();watch_anchor();});function initCaseStudiesScroller()
{if(typeof(CaseStudies)=='undefined')return;$("<img>").attr("src",'img/prev_arrow_active.gif');$("<img>").attr("src",'img/next_arrow_active.gif');$('#case_studies_scroller').scrollLeft(0);$('#prev_case_study').hide();$("#prev_case_study").hover(function(){$(this).attr('src',"img/prev_arrow_active.gif")},function(){$(this).attr('src',"img/prev_arrow.gif")}).click(function(){ScrollCaseStudies(195);});$("#next_case_study").hover(function(){$(this).attr('src',"img/next_arrow_active.gif")},function(){$(this).attr('src',"img/next_arrow.gif")}).click(function(){LoadCaseStudies();ScrollCaseStudies(-195);});if(CaseStudies.total>CaseStudies.displayed){$("#next_case_study").show();}}
function ScrollCaseStudies(offset)
{$('#case_studies_content').queue(function(){var target=$('#case_studies_content').position().left+offset;$('#case_studies_content').animate({left:target},700,'easeOutQuad');CaseStudies.current+=offset<0?1:-1;if(CaseStudies.current>1){$('#prev_case_study').show();}
else{$('#prev_case_study').hide();}
if(CaseStudies.total>=(CaseStudies.current+CaseStudies.displayed)-1){$('#next_case_study').show();}
else{$('#next_case_study').hide();}
$(this).dequeue();});}
function LoadCaseStudies()
{if(CaseStudies.loaded>=CaseStudies.total){return;}
number=4;$.get(CaseStudies.load_url,{start:CaseStudies.loaded,number:number,mode:CaseStudies.mode,tag_id:CaseStudies.tag,related_page:CaseStudies.related_page,home_page:CaseStudies.home_page},function(data){CaseStudies.loaded+=number;var $container=$('#case_studies_content');var $more_case_study=$('.show-all',$container);$container.css('width',$('#case_studies_content').width()+number*195);if($more_case_study.length==1){$more_case_study.before(data);}
else{$container.append(data);}
apply_case_study_effect('#case_studies_content .case-study-small.ajax');$('.case-study-small.ajax',$container).removeClass('ajax');});}
function openCaseStudy(params)
{window.location.href=params.link+(params.mode!=''?'?mode='+params.mode+'&tag_id='+params.tag+'&related_page='+params.related_page:'');return false;}
function apply_case_study_effect($case_study_selector){$($case_study_selector).hover(function(){$('a.case-study-small-image img',this).animate({opacity:'0.7',top:'2'},100);},function(){$('a.case-study-small-image img',this).animate({opacity:'1',top:'0'},100);});}
function fixHeights()
{$('.fix-height').each(function(i){var max=0;$('> *',this).each(function(ii){if($(this).outerHeight()>max){max=$(this).outerHeight();}}).not('.dont-fix-height, :has(.dont-fix-height)').each(function(ii){var outer=this;if(!$('.inner-block',this).each(function(iii){$(this).height($(this).height()+max-$(outer).outerHeight());}).length)
{$(this).height(max-($(this).outerHeight()-$(this).height()));}});});}
function register_promo_view(target_num){var $block_id=promo_blocks[target_num].id;if(!promo_blocks[target_num].viewed){promo_blocks[target_num].viewed=true;$.get($promo_stats_url.replace('#ID#',$block_id).replace('#EVENT#','OnRegisterView'));}}
function switchPromo(target_num,quick){register_promo_view(target_num);var target=$('#promo_title'+target_num);var current=$('#promo_title'+current_promo);var duration=promo_transition_effect;if($('#promo_selector').css('display')=='none'){duration=1;}
var target_top=target.position().top-6;$('#promo_selector:hidden').css('top',target_top);if(quick){$('#promo_selector').stop().show();fadeImg($('#promo_link img:visible'),promo_blocks[target_num].image,duration,null,target_num);fadeBackground('.promo-back-container:visible',promo_blocks[target_num].rightClass,duration);$('#promo_selector').css('top',target_top).show();target.animate({color:'#1b91b1'},duration/2);current.animate({color:'#fff'},duration/2);}
else{current.animate({color:'#fff'},duration/2);$('#promo_selector').stop().show().animate({top:target_top},duration,'',function(){});target.animate({color:'#1b91b1'},duration);fadeImg($('#promo_link img:visible'),promo_blocks[target_num].image,duration,null,target_num)
fadeBackground('.promo-back-container:visible',promo_blocks[target_num].rightClass,duration);}
$('.corner-wrap .transp-corner').css('display','block').css('z-index',10);$('#promo_link').attr('href',promo_blocks[target_num].promoLink);$('#promo_link').attr('target',promo_blocks[target_num].openInNewWindow?'_blank':'_self');$('#promo_link').attr('promo_id',promo_blocks[target_num].id);current_promo=parseInt(target_num);}
function fadeImg(img,target_src,duration,callback,target_num)
{if($(img).attr('src')==target_src)return;var the_img=$(img);tmp=$('[src='+target_src+']',img.parentNode);if(!tmp.length){var tmp=the_img.clone().css({position:'absolute',display:'none'}).attr('src',target_src);the_img.before(tmp);}
tmp.fadeIn(duration,callback).attr('alt',promo_blocks[target_num].name);the_img.fadeOut(duration);}
function fadeBackground(elem,targetClass,duration)
{if($(elem+':visible').hasClass(targetClass)){$('.corner-wrap .transp-corner').css('display','none').css('display','block');return;}
var the_elem=$(elem);tmp=$('.'+targetClass,the_elem[0].parentNode);if(!tmp.length){var tmp=the_elem.clone().empty().css({display:'none'}).removeClass().addClass('promo-back-container '+targetClass);the_elem.after(tmp);}
tmp.fadeIn(duration,function(){$('.corner-wrap').css('display','none').css('display','block');});the_elem.fadeOut(duration,function(){$('.corner-wrap').css('display','none').css('display','block');});}
var promo_interval=null;var promo_count=0;function startPromo()
{promo_interval=window.setInterval(function(){var next_num=current_promo+1;if(next_num>promo_count){next_num=1;switchPromo(next_num,1);}
else{switchPromo(next_num);}},promo_speed)}
function initPromo()
{pos=$('#promo_right_box').position();w=$('#promo_right_box').width();h=$('#promo_right_box').height();$('.promo-back-container').css({left:pos.left,top:pos.top,width:w,height:h}).show();$('#promo_right_box').removeClass().addClass('promo-choice')
for(var i in promo_blocks){$("<img>").attr("src",promo_blocks[i].image);promo_count++;}
switchPromo(1);$('.promo-item').click(function(){switchPromo(this.id.replace(/^promo_title/,''));});startPromo();$(window).resize(function(){$('.promo-back-container').css('left',$('#promo_right_box').position().left)})
$('#promo').mouseover(function(){clearInterval(promo_interval);}).mouseout(startPromo);}
var initial_form_left=false;function initContactUs(){if($.browser.msie){$('#contact_us_form input, #contact_us_form textarea').css({position:'relative',top:'-1px'});}
$(window).resize(function(){var button_offset=$('#contact_us_button').offset();initial_form_left=button_offset.left-$('#contact_us_container').width()-2;})
$('#contact_us_button, #contact_us_button_active, .contact-trigger, .contact-us-button').click(function($event){toggle_form('toggle');});$('#contact_us_close').click(function(){toggle_form('close')});$('#contact_us_container *:input').focus(function($event){if($(this).val()==default_values[this.id]){$(this).val('');}}).blur(function($event){var $me=$(this),$default=default_values[$me.attr('id')];if($me.val()==''){$me.val($default);}
$me.toggleClass('not-hint',$me.val()!=$default);});var button_offset=$('#contact_us_button').offset();initial_form_left=button_offset.left-$('#contact_us_container').width()-2;$('#send_button').click(function($event){$.post($('#contact_us_form').attr('action'),$('#contact_us_form').serializeArray(),function($data){$data=eval('('+$data+')');if($data.status=='ok'){toggle_form('close');$('#contact-us-scroll .contact-us-button').css({backgroundPosition:'-652px 0px'});try{pageTracker._trackPageview("contact-us/submitted.html");}catch(err){}}
else{var first_set=false;for(i in $data.errors){if($('#'+i).length){$('#'+i).addClass('contact-form-error').attr('title',$data.errors[i]).focus(function($event){$(this).removeClass('contact-form-error').attr('title','');});if(!first_set){$('#contact_us_error').html($data.errors[i]);$('#'+i).focus(function(){$('#contact_us_error').html('');})
first_set=true;}}}}})});}
function toggle_form(mode){var button_offset=$('#contact_us_button').offset();var form_offset=$('#contact_us_container').offset();var left=button_offset.left-$('#contact_us_container').width()-2;var top=button_offset.top+$('#contact_us_button').height()-$('#contact_us_container').height();if(typeof(mobile_contact_us)=='number'){top+=130;}
if(mode=='close'||$('#contact_us_container').attr('opened')==1){$('#contact_us_container').stop().css({left:'-489px'}).animate({left:'0px',width:'0px'},'normal','',function(){$('#contact_us_button_active').hide();$(this).hide();}).attr('opened',0);$('#contact-us-scroll .contact-us-button').css({backgroundPosition:'0px 0px',margin:'0px',width:'321px'});}
else{try{pageTracker._trackPageview("contact-us/opened-form.html");}catch(err){}
$('#contact_us_button_active').show();$('#contact_us_container').stop().animate({left:'-13px',width:'15px'},10).animate({left:'-499px',width:'490px'}).attr('opened',1);$('#contact-us-scroll .contact-us-button').css({backgroundPosition:'-321px 0px',margin:'0 0 0 -10px',width:'331px'});}}
function Testimonial(){}
Testimonial.url='';Testimonial.ids=[];Testimonial.heights=[];Testimonial.timer=null;Testimonial.interval=null;Testimonial.fetchSpeed=10;Testimonial.paused=false;Testimonial.height=[175,85];Testimonial.fetchRandom=function(){var $me=this;$.get($me.url.replace('#EXCLUDE_IDS#',$me.ids.join(',')),function($data){$data=$.trim($data);clearTimeout($me.timer);if($data.length>0){$('#testimonial_container').append($data);$me.timer=setTimeout("Testimonial.fetchRandom()",$me.fetchSpeed*1000);}
else{clearInterval($me.timer);$me.timer=setInterval("Testimonial.showNext()",$me.fetchSpeed*1000);}
$me.showNext();});}
Testimonial.add=function($id){this.ids.push($id);var $last_content=$('.testimonial:last .content','#testimonial_container');this.heights.push(this.getContentHeight($last_content));}
Testimonial.getContentHeight=function($content_element){var $height_before=$content_element.height();$content_element.css('height','auto');var $height_after=$content_element.height();$content_element.height($height_before);if($height_after>this.height[1]){$('div.bottom',$content_element.parents('.testimonial:first')).addClass('more');}
return $height_after;}
Testimonial.showNext=function(){if(this.paused){return;}
var $me=this;var $current_testimonial=this.getCurrent();var $container=$('#testimonial_container');var $testimonial_count=$('.testimonial',$container).length;if($current_testimonial+1>$testimonial_count){$('.testimonial','#testimonial_container').css({'visibility':'visible','opacity':1}).show();$('.testimonial:eq('+($testimonial_count-1)+')').animate({'opacity':0},'slow',function(){$container.css('top',$me.height[0]).animate({top:0},'slow');});$('.testimonial:eq(0)').css('opacity',0).animate({opacity:1},2000);}
else{$container.animate({top:(-1)*$current_testimonial*this.height[0]},'slow');$('.testimonial:eq('+($current_testimonial-1)+')','#testimonial_container').animate({opacity:0},'slow',function(){$(this).css('visibility','hidden')});$('.testimonial:eq('+($current_testimonial)+')','#testimonial_container').css('opacity',0).animate({'opacity':1},2000);}}
Testimonial.getCurrent=function(){var $top=parseInt($('#testimonial_container').css('top'));if(isNaN($top)){$top=0;}
return(Math.abs($top)/this.height[0])+1;}
Testimonial.run=function($url){var $me=this;this.url=$url;this.timer=setTimeout("Testimonial.fetchRandom()",this.fetchSpeed*1000);$(document).ready(function(){$('#testimonial_scroller').hover(function(){var $current_testimonial=$me.getCurrent()-1;var $content_height=$me.heights[$current_testimonial];var $scroller_height=$me.height[0]+($content_height-$me.height[1]);if($content_height>$me.height[1]){$me.setHeight($current_testimonial,$content_height,$scroller_height,true);}
$me.paused=true;},function(){var $current_testimonial=$me.getCurrent()-1;var $content_height=$me.heights[$current_testimonial];if($content_height>$me.height[1]){$me.setHeight($current_testimonial,$me.height[1],$me.height[0],false);}
$me.paused=false;});});}
Testimonial.setHeight=function($testimonial_number,$content_height,$scroller_height,$expand){$('.testimonial:eq('+$testimonial_number+') .bottom','#testimonial_container').toggleClass('more',!$expand);$('.testimonial:eq('+$testimonial_number+') .content','#testimonial_container').stop(true,false).animate({height:$content_height},'slow');$('#testimonial_scroller').stop(true,false).animate({height:$scroller_height},'slow');}
function fix_cs_prev_next($pagination_bar){var $page_count=parseInt($('a.page-link:last',$pagination_bar).attr('page'));var $current_page=parseInt($('a.page-link.selected',$pagination_bar).attr('page'));var $prev_page=$('a.arrow-left','div.cs-pagination');$prev_page.toggleClass('disabled',$current_page==1);var $url_parts=$prev_page.attr('href').split('#');$url_parts[1]=$current_page>1?'page'+($current_page-1):'';$prev_page.attr('href',$url_parts.join('#'));var $next_page=$('a.arrow-right','div.cs-pagination');$next_page.toggleClass('disabled',$current_page==$page_count);var $url_parts=$next_page.attr('href').split('#');$url_parts[1]=$current_page<$page_count?'page'+($current_page+1):'';$next_page.attr('href',$url_parts.join('#'));}
function watch_anchor(){var $last_anchor='';setInterval(function(){if(window.location.hash!=$last_anchor){$last_anchor=window.location.hash;var $new_anchor=$last_anchor?$last_anchor.substring(1):'';$('body').trigger('anchorchanged',[$new_anchor]);}},100);}
function smooth_pagination(block_half_width){if(block_half_width===undefined)block_half_width=308;var $pagination_bars=$('div.cs-pagination');var pagination_leftmargin=block_half_width-($pagination_bars.width()/2)-5;if($.browser.msie&&$.browser.version==6){pagination_leftmargin=pagination_leftmargin/2;}
$pagination_bars.css('margin-left',pagination_leftmargin).show();fix_cs_prev_next($pagination_bars.get(0));$('a.arrow-left, a.arrow-right',$pagination_bars).click(function($e){return!$(this).hasClass('disabled');});$('body').bind('anchorchanged',function($e,$anchor){if($anchor.match(/^page([\d]+)$/)){var $page=RegExp.$1;var $page_link=$("a[page='"+$page+"']",'div.cs-pagination');if($page_link.hasClass('selected')){return;}
$('a.selected','div.cs-pagination').removeClass('selected');$page_link.addClass('selected');fix_cs_prev_next($page_link.parents('div.cs-pagination:first').get(0));var $props={left:(-1)*($page-1)*626};$('#cs-items').animate($props,700);}})}
function search_on_change($e){if($auto_search_request!=null){$auto_search_request.abort();}
if($e.which==13||$.trim($('#search-box-small-input').val()).length<3){$('.search-box-small-results').hide();return;}
var $form=$('#search_form');$auto_search_request=$.get($form.attr('action'),$form.serialize(),function($data){$('.search-box-small-header').html($data);if($.trim($data)!=''){$('.search-box-small-results').show();}
else{$('.search-box-small-clear').click();}});}
function general_menu_animation(){$(".top-level-item").hover(function(){$(this).find("div.top-level-item-content a").css("color","#fc8605");$(this).find("div.top-level-icon").animate({"paddingTop":"10px"},150).animate({"paddingTop":"0px"},75).animate({"paddingTop":"5px"},50);},function(){$(this).find("div.top-level-item-content a").css("color","#0688aa");});}
