// JavaScript Document

$(document).ready(function(){
	//onload				   
	ResizeBody();
	InitThumbs();
});

var ResizeBody = function()
{
	//define containers
	var $oFeatureCon = $("div.feature_con");
	var $oBodyCon = $("div.body_con");
	if($oBodyCon[0] == undefined){
		$oBodyCon = $("div.detailbody_con");
	}
	var $oNavCon = $("div.nav_con");
	
	if($oNavCon[0] == undefined){
		$oNavCon = $("div.adminnav_con");
	}
	
	var $oSearchCon = $("div.search_con");
	
	//get the highest element
	var NavHeight = $oNavCon.offset().top + $oNavCon.height();
	var SearchHeight = $oSearchCon.offset().top + $oSearchCon.height();
	var FeatureHeight = $oFeatureCon.offset().top + $oFeatureCon.height();
	
	var TargetHeight = $oBodyCon.offset().top + $oBodyCon.height();
	TargetHeight = (TargetHeight < NavHeight)?NavHeight:TargetHeight;
	TargetHeight = (TargetHeight < SearchHeight)?SearchHeight:TargetHeight;
	TargetHeight = (TargetHeight < FeatureHeight)?FeatureHeight:TargetHeight;
	
	//set the body height (min height for standards aware browsers)
	$oBodyCon.css(($.browser.msie && $.browser.version < 7 ? '' : 'min-') + 'height',TargetHeight + "px");

}

var InitThumbs = function() {
    var $oMainImgCon = $("div.mainimagebox");
    var $oThumbCon = $("div.thumbsarea");
    var oMainImg = $("div.mainimagebox img")[0];
    var $oThumbCol = $("div.thumbsarea a");

    for (var x = 0; x < $oThumbCol.length; x++) {
        $oThumbCol[x].onclick = function() {
            this.blur();
			oMainImg.src = this.href;
            oMainImg.title = this.title;
            oMainImg.alt = this.title;
            return false;
        }
    }
};