function closeit(){

if(onpage){
	
	var fdpage="#"+onpage;
	onpage = "";
	
	 $(fdpage).fadeOut('slow', function() { 
   });
	
	}

}

function toggleIt( whichLayer )
{


//$('#gallery').hide();
   //$('#gallery').show();
   if(galleryon==1) {
   document.getElementById('navigation').style.bottom = 3;
   $('#gallery').fadeOut('slow', function() { 
   });
	galleryon=0;
	inv();
	} else {
	galleryon=1;
	document.getElementById('navigation').style.bottom = 75;
	$('#gallery').fadeIn('slow', function() {   
    });
	}
}

scrollStep=1

sID=0;

timerLeft=""
timerRight=""


function toLeft(id){
  document.getElementById(id).scrollLeft=0
}

function scrollDivLeft(id){
  clearTimeout(timerRight) 
  document.getElementById(id).scrollLeft+=scrollStep
  timerRight=setTimeout("scrollDivLeft('"+id+"')",10)
}

function scrollDivRight(id){
  clearTimeout(timerLeft)
  document.getElementById(id).scrollLeft-=scrollStep
  timerLeft=setTimeout("scrollDivRight('"+id+"')",10)
}

function toRight(id){
  document.getElementById(id).scrollLeft=document.getElementById(id).scrollWidth
}

function stopMe(){
  clearTimeout(timerRight) 
  clearTimeout(timerLeft)
}




function loadthis(pg,w,h){

  if(galleryon==1) {
   document.getElementById('navigation').style.bottom = 3;
   $('#gallery').fadeOut('slow', function() { 
   });
	galleryon=0;
	}
	
	if(onpage){
	
	var fdpage="#"+onpage;
	
	 $(fdpage).fadeOut('slow', function() { 
   });
	
	}
	
	onpage = pg;
	
	var fdinpage = "#"+onpage;
	
	$(fdinpage).fadeIn('slow', function() { 
	// try{Typekit.load();}catch(e){}
   });
  
	
	

//tb_show("Page",pg+"?This=true&TB_iframe=true&width="+w+"&height="+h);

}

var ii=-1;
var yheight=0;
var xwidth=0;
var xw=0;

function loadImage( )
{

++ii;
if(ii > 45) ii=0;

isrunning=1;


  $('#mediabody').fadeOut(1000, function() {
  
  loadit();

  });


  $('#mediabody').fadeIn(2000, function() {
    // Animation complete.
  });

}


function loadit(){

document.getElementById('imgbd').innerHTML = "";



var img = new Image();
  
  //var imageSrc = $("#productZoom").attr("href");
    //    $("#productImage").attr('src', imageSrc);  
	
	if($.browser.msie){
	
	$("#imgbd").append("<img src='/gallery/album1/large/"+ii+".jpg'>");
	
	var pic_real_width =$("#imgbd img").width();
	var pic_real_height=$("#imgbd img").height();
	
	xw = yheight * pic_real_width / pic_real_height;
	
	$("#imgbd img").width(xw);
	$("#imgbd img").height(yheight);
	
	
	
/*	// wrap our new image in jQuery, then:
  $(img)
    // once the image has loaded, execute this code
    .load(function () {
	
	
	
	var pic_real_width = img.width;
    var pic_real_height = img.height;
	
	xw = yheight * pic_real_width / pic_real_height;
	
	alert(yheight+' '+pic_real_width+' '+pic_real_height);
	
      $('#imgbd')
    	
        .append(this);
	
    })
    
    // if there was an error loading the image, react accordingly
    .error(function () {
      // notify the user that the image could not be loaded
    })
    
    // *finally*, set the src attribute of the new image to our image
    //.attr('src', '/gallery/album1/large/'+ii+'.jpg');
	
	.attr({ 
          src: '/gallery/album1/large/'+ii+'.jpg' ,
		  height:yheight,
		   width:xw
        });
		
		
		
	*/	


	}else{
  
  // wrap our new image in jQuery, then:
  $(img)
    // once the image has loaded, execute this code
    .load(function () {
    
      $('#imgbd')
    	
        .append(this);
	
    })
    
    // if there was an error loading the image, react accordingly
    .error(function () {
      // notify the user that the image could not be loaded
    })
    
    // *finally*, set the src attribute of the new image to our image
    //.attr('src', '/gallery/album1/large/'+ii+'.jpg');
	
	.attr({ 
          src: '/gallery/album1/large/'+ii+'.jpg',
           height:yheight
		   //,
		//   width:xwidth
         
        });

		
	}

	
}

function inv(){

if(isrunning ==1){
isrunning=0;
clearInterval(intervalname);
}else{
loadImage();
intervalname = setInterval ( "loadImage()", 7000 );
}

}

function showi(iie){

ii = iie;
isrunning=0;
clearInterval(intervalname);

//document.getElementById(iie).className="contentb";

document.getElementById('imgbd').innerHTML = "";


var img = new Image();
  
  //var imageSrc = $("#productZoom").attr("href");
    //    $("#productImage").attr('src', imageSrc);  
  
  
  if($.browser.msie){
  
  	$("#imgbd").append("<img src='/gallery/album1/large/"+ii+".jpg'>");
	
	var pic_real_width =$("#imgbd img").width();
	var pic_real_height=$("#imgbd img").height();
	
	xw = yheight * pic_real_width / pic_real_height;
	
	$("#imgbd img").width(xw);
	$("#imgbd img").height(yheight);

  
  /*
  $(img)
    // once the image has loaded, execute this code
    .load(function () {
	
	var pic_real_width = this.width;
    var pic_real_height = this.height;
	
	
	
	xw = yheight * pic_real_width / pic_real_height;
	
	   
      $('#imgbd')
    	
        .append(this);
	
    })
    
    // if there was an error loading the image, react accordingly
    .error(function () {
      // notify the user that the image could not be loaded
    })
    
    // *finally*, set the src attribute of the new image to our image
    //.attr('src', '/gallery/album1/large/'+ii+'.jpg');
	
	.attr({ 
          src: '/gallery/album1/large/'+ii+'.jpg',
           height:yheight,
		   width:xw
         
        });
		
*/
  
  }else {
  // wrap our new image in jQuery, then:
  $(img)
    // once the image has loaded, execute this code
    .load(function () {
	
	   
      $('#imgbd')
    	
        .append(this);
	
    })
    
    // if there was an error loading the image, react accordingly
    .error(function () {
      // notify the user that the image could not be loaded
    })
    
    // *finally*, set the src attribute of the new image to our image
    //.attr('src', '/gallery/album1/large/'+ii+'.jpg');
	
	.attr({ 
          src: '/gallery/album1/large/'+ii+'.jpg',
           height:yheight
         
        });
		

	}

	
}


function getH(ee){

//if (ee) yheight = $(window).height() - 24 - 90;
//else yheight = $(window).height() - 24;

yheight = $(window).height() -5;

//alert(yheight);

xwidth = $(window).width();
//var xw= $(window).width();
//var xwp = xw * .1 * 2;
//xwidth = xw - xwp; 

//height='"+yheight+"' 
document.getElementById('mediabody').style.width = xwidth;
document.getElementById('mediabody').style.height = yheight;
document.getElementById('mediabody').style.minHeight = yheight;
document.getElementById('imgbd').style.width = xwidth;
document.getElementById('imgbd').style.height = yheight;
document.getElementById('imgbd').style.minHeight = yheight;
document.getElementById('navigation').style.width = xwidth;
//!document.getElementById('gallery').style.width = xwidth;

}

function ccss(cl,iie){

document.getElementById(iie).className=cl;

}

$(document).ready(function(){
$(".naviimg").fadeTo("slow", 0.3); // This sets the opacity of the thumbs to fade down to 30% when the page loads
$(".naviimg").hover(function(){
$(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
  },function(){
var qtID = $(this).attr("id");
if(qtID != sID) $(this).fadeTo("slow", 0.3); // This should set the opacity back to 30% on mouseout
});
$(".naviimg").click(function(){
 var qtID = $(this).attr("id");
 
 if(sID) {
var exSid = "#"+sID;
 $(exSid).fadeTo("slow", 0.3); 
 }

 sID=qtID;

//$(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
  },function(){
//$(this).fadeTo("slow", 0.3); // This should set the opacity back to 30% on mouseout
});


});



var intervalname; 
var isrunning=0;
var galleryon=0;
var onpage="";

intervalname = setInterval ( "loadImage()", 7000 );

