$(window).bind("unload", function() {});

$(document).ready(function() {	
$(document).pngFix(); 		   
	
$('img.hover').live('hover',function(){
	$(this).imH();
	 }).each(function(){
	 	$(this).preLoad();
	 });


var location=window.location.href;

$('#footer_menu a').each(function(){
	var id=$(this).attr("id");
	var loc="loc="+$.loc;
	  if(loc.indexOf(id)>=0){
		 $(this).css("border-bottom","1px solid #e4e4e4");
	  }
});




$('#imageholder div.im_wrapper').each(function(index){
	var numUp=parseInt(index)+1;
	if($('#picnum'+index).length<1){
	$('#picnums').append("<a class='picnum' id='picnum"+index+"'>"+numUp+"</a> ");
	}
});

$.numUp=0;

$('#imageholder div.im_wrapper').hide().click(function(){
			$('#nextpic').click();
});

$('#imageholder div.im_wrapper').each(function(){
		var num=$('#imageholder div.im_wrapper').index($(this));
		if(num==0){
			var image = new Image();
	   		image.src=$(this).children('img:first').attr('src')+"?ran="+Math.random();
			image.onload=function(){
			switchpic($.gallFade);
			}
		}
			
});


			
$('a.picnum').live('click', function() {
			$.numUp=$('#picnum_wrapper a.picnum').index($(this));
			$.currentpic=$('#imageholder div.im_wrapper:eq('+$.numUp+') img');
			switchpic($.gallFade);
			return false;
});

$('#prevpic').click(function(){
	$.numUp==0 ? $.numUp=$('#imageholder div.im_wrapper').length-1 : $.numUp-=1;
	switchpic($.gallFade);
	return false;
});

$('#nextpic').click(function(){
	$.numUp== $('#imageholder div.im_wrapper').length-1 ? $.numUp=0 : $.numUp+=1;
	switchpic($.gallFade);
	return false;
});
			
function switchpic(speed){
	$.currentpic=$('#imageholder div.im_wrapper:eq('+$.numUp+')');
	$.currentpic.fadeIn(speed, function(){$.inFade=false;});
	$('#imageholder div.im_wrapper:visible').not($.currentpic).fadeOut(speed, function(){$.inFade=false;});
	$('a.picnum:eq('+$.numUp+')').css('color','#000');
	$('a.picnum').not('a.picnum:eq('+$.numUp+')').css('color','#666');
}

if($('#imageholder').hasClass('slideshow')){
	setInterval(function(){$.gallFade=$.slideFade;$('#nextpic').click()},$.slideSpeed);
}





	

});

