$(document).ready(function(){
	
	 $("#valuation").click(function() {    $(".valuation_dd").slideToggle("slow"); return false; });
	 
	 $(".request_info").click(function() {    $(".emailbox").slideToggle("slow");  $(".emailfriend").slideUp(); return false; });
	 $(".email_friend").click(function() {    $(".emailfriend").slideToggle("slow"); $(".emailbox").slideUp();  return false; });
	 
	 
	 
	 $("nav a, .valuation a").click(function() { this.blur();	return true; });
	 
	 if (navigator.appVersion.indexOf("Mac")!=-1) {
	$('nav li a').addClass('mac');
	$('.potw').addClass('mac_potw');
	
	} 
	
	
	 $('.print_button').click(function() {
  		window.print();
  		return false;
 		});

	
	
	
	$('.thumb').each(function() {
        var maxWidth = 140; // Max width for the image
        var maxHeight = 90;    // Max height for the image
        var ratio = 0;  // Used for aspect ratio
        var width = $(this).width();    // Current image width
        var height = $(this).height();  // Current image height
 
        // Check if the current width is larger than the max
        if(width > maxWidth){
            ratio = maxWidth / width;   // get ratio for scaling image
            $(this).css("width", maxWidth); // Set new width
            $(this).css("height", height * ratio);  // Scale height based on ratio
            height = height * ratio;    // Reset height to match scaled image
            width = width * ratio;    // Reset width to match scaled image
        }
 
        // Check if current height is larger than max
        if(height > maxHeight){
            ratio = maxHeight / height; // get ratio for scaling image
            $(this).css("height", maxHeight);   // Set new height
            $(this).css("width", width * ratio);    // Scale width based on ratio
            width = width * ratio;    // Reset width to match scaled image
        }
    });
	
	
	
	
	 $(".enlarge").click(function() {    
								  
								  var thisimage = $(this).attr("src");
								  //$(".valuation_dd").slideToggle("slow"); return false;
								 //alert(thisimage);
								  $('#mainimage').attr("src", thisimage);
								  return false;
								  });

							
 });



  
/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

function slideSwitch() {
    var $active = $('#banner img.active');

    if ( $active.length == 0 ) $active = $('#banner img:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#banner img:first');

    // uncomment the 3 lines below to pull the images in random order
    
    //var $sibs  = $active.siblings();
    //var rndNum = Math.floor(Math.random() * $sibs.length );
    //var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 6000 );
});


