var _siteRoot='/tpn/';

	function lookup_(inputString) {
		if(inputString.length == 0) {
			// Hide the suggestion box.
			jQuery('#search_div').hide();
	
		
		} else {
			jQuery.post("code/includes/srpc.asp", {queryString: ""+inputString+""}, function(data){
				if(data.length >0) {

					
					jQuery('#search_div').show();
					jQuery('#search_div').html(data);
				} else {
				jQuery('#search_div').hide();
				}
			});
		}
	} // lookup
	
	function fill_() {
		
		setTimeout("jQuery('#search_div').hide();", 200);
	}
	
var latest={
 dur:500,delay:25,
 nav:'<a href="#" id="latest-nav-l" onclick="latest.move(-1);return false;" class="nav" onfocus="this.blur();">&lt;</a>'+
     '<a href="#" id="latest-nav-r" onclick="latest.move(+1);return false;" class="nav" onfocus="this.blur();">&gt;</a>',
 html:'<div><a href="%0%" class="img"><img src="%1%" alt="%2%" /></a><br /><a href="%0%" class="bold">%2%</a><br />By <a href="%3%">%4%</a></div>',
 id:'',imgs:[],ti:null,
 n:0,p:0,bw:0,sw:0,h:0,
 init:function(id){
  if(!id || id=='' || !jQuery('#'+id).length || !latest.imgs.length)
   return false;

  latest.id=id;
  if(latest.imgs.length%2) latest.imgs.pop();
  latest.n=latest.imgs.length;
  latest.n2=latest.imgs.length/2;
  latest.mp=(latest.imgs.length/4)-1;
  $d=jQuery('#'+id);

  for(var i=4;i<latest.imgs.length;i++){
   var ihtml=latest.html;
   
   if(latest.imgs[i][2].length>10)
    latest.imgs[i][2]=latest.imgs[i][2].substring(0,10)+'&hellip;';
   
   ihtml=ihtml.replace(/%0%/gi,latest.imgs[i][0]);
   ihtml=ihtml.replace(/%1%/gi,latest.imgs[i][1]);
   ihtml=ihtml.replace(/%2%/gi,latest.imgs[i][2]);
   ihtml=ihtml.replace(/%3%/gi,latest.imgs[i][3]);
   ihtml=ihtml.replace(/%4%/gi,latest.imgs[i][4]);
   $d.append(ihtml);
  }

  $dd=$d.find('div');
  latest.bw=$d.width();
  latest.sw=$dd.width();
  latest.h=$dd.height();

  $d.css({position:'absolute'});
  $dd.css({position:'absolute'});

  $dd.each(function(i){
   _t=i<latest.n2?0:latest.h;
   _l=(latest.bw-latest.sw)*(i-(i<latest.n2?0:latest.n2));
   jQuery(this).css({left:_l,top:_t});
  });

  jQuery(document.body).append(latest.nav);
  jQuery('#latest-nav-l').css({left:$d.offset().left+$d.width()-40,top:$d.offset().top-20});
  jQuery('#latest-nav-r').css({left:$d.offset().left+$d.width()-19,top:$d.offset().top-20});
	
  latest.setnav();
  latest.auto();
 },
 move:function(d){
  window.clearTimeout(latest.ti);
  latest.auto();
  if(!((d<0 && latest.p>0) || (d>0 && latest.p<latest.mp)))
   return false;

  jQuery('#'+latest.id).find('div').each(function(i){
   x=i-((latest.p+1*d)*2);
   var _l=(latest.bw-latest.sw)*(x-(i<latest.n2?0:latest.n2)),_obj=this;
   window.setTimeout(function(){
    jQuery(_obj).animate({left:_l},{duration:latest.dur},'swing');
   },i*latest.delay);
  });
  latest.p+=d;
  latest.setnav();
 },
 setnav:function(){
  jQuery('#latest-nav-l,#latest-nav-r').removeClass('nav').removeClass('navoff').addClass('nav');
  if(!latest.p){
   latest.dir=1;
   jQuery('#latest-nav-l').removeClass('nav').addClass('navoff');
  }else if(latest.p==latest.mp){
   latest.dir=-1;
   jQuery('#latest-nav-r').removeClass('nav').addClass('navoff');
  }
 },
 auto:function(){
	latest.ti=window.setTimeout('latest.autorun();',5000);
 },
 dir:1,
 autorun:function(){
  if(!latest.p)
   latest.dir=1;
  else if(latest.p==latest.mp)
   latest.dir=-1;

  if(latest.dir>0) $$=jQuery('#latest-nav-r');
  else $$=jQuery('#latest-nav-l');
  $$.animate({opacity:0.25},100).animate({opacity:1},100)
    .animate({opacity:0.25},100).animate({opacity:1},100);
  window.setTimeout('latest.move(latest.dir);',150); 
	latest.auto();
 }
};

jQuery(function(){
 latest.init('home-latest');
 
 jQuery('div.pnav a').each(function(i){
  jQuery(this).hide().parent().width(jQuery(this).siblings().length*24);
  var _obj=this;
  window.setTimeout(function(){jQuery(_obj).fadeIn(350);},i*100);
 });
 
 jQuery('div#content div.bignav a.bignav').css({opacity:0});
 
 pg_show();


});

jQuery(window).load(function(){
 jQuery('div#content div.bignav a.bignav').css({opacity:1}).each(function(){
  var _t=jQuery(this).parent().find('img').height()/2;
  jQuery(this).css({marginTop:_t});
 }).fadeIn(1500);
 


});

function pg_show(){
 jQuery('div#photos-grid div').each(function(i){
  jQuery(this).css({opacity:0});
  var _obj=this;
  window.setTimeout(function(){jQuery(_obj).css({opacity:1});},i*50);
 });
}
function pg_hide(){
 jQuery('div#photos-grid div').each(function(i){
  var _obj=this;
  window.setTimeout(function(){jQuery(_obj).animate({opacity:0},5000);},i*50);
 });
}

/*
var font={src:_siteRoot+'flash/arial.swf'};
sIFR.activate(font);

sIFR.replace(font,{
 selector:'div#content h2',
 css:['.sIFR-root{color:#656565;background-color:#181818;font-weight:normal;'],
 fitExactly:true,
 wmode:'transparent'
});
*/