
function initIW() {
	
	try
	{
	    initEnquiryForm();
    	
	    /* PHOTOS - thumbnails - select current thumbnail */
	    $('#thumbnails a:first').addClass('selected');
	    $('#thumbnails a').click(function() {
		    $('ul#thumbnails a').removeClass('selected');
		    $(this).addClass('selected');
		    var targetOffset = $('#photo').offset().top-110;
            var currentOffset = $('#iw-header').parent().scrollTop();
            $('#iw-header').parent().animate({scrollTop: targetOffset+currentOffset}, 500);
	    });
    	
	    $("#thumbnails a").mouseover(function(){$(this).addClass("over");}).mouseout(function(){$(this).removeClass("over");});
    	
	    $('.back-to-top').click(function() {
        try {$('#iw-header').parent().animate({scrollTop:0},'slow');} catch(err) {}
        return false;
        });
    }
    catch(ex)
    {
        raiseError('Error in initIW:'+ex.description);
    }
	
}

/* Gallery - set maximum size of photo */

var x = new Image();

function swapPhoto(photoSRC) {
	x.onload=setPhotoWidth;
	x.src = photoSRC;
}
	
function setPhotoWidth() {
    try
    {
	    var iw = x.width;
	    var ih = x.height;
	    var maxiw = '400';	

        $('#imgPhoto').width((iw > maxiw ? maxiw : iw));
	    $('#imgPhoto').attr('src',x.src);
	}
	catch(ex)
	{
	    raiseError('Error in setPhotoWidth:'+ex.description);
	}
}

