function SelectLayout(oEl) {
	var w=oEl.clientWidth,h=oEl.clientHeight;


	var oContain=$(oEl).parent().parent().get(0);
	var oContainChild=$(oEl).parent().get(0);
	var oSkin=$(oEl).parent().next().get(0);
	var oSkinChild=$(oSkin).children(":first").get(0);
	var oLower=$(oSkinChild).next().get(0);

	if(w<h)
	{
		oContain.className="Gallery1";
		oContainChild.className="BigPic";
		oSkin.className="GalleryExhibition";
		oSkinChild.className="GalTop";
		oLower.className="ExhibitionSideButtons";
		document.getElementById("buttons").style.top = "100%";
		document.getElementById("buttons").style.marginTop = "-71px";
	}
	else
	{
		oContain.className="Gallery";
		oContainChild.className="BigPic";
		oSkin.className="GalleryExhibition";
		oSkinChild.className="ETop";
		oLower.className="EBottom";
	}

	oContain = oEl.parentNode;
	if (oEl.offsetWidth > oContain.offsetWidth)
	{
		var iRatio = oContain.offsetWidth / oEl.offsetWidth;
		oEl.style.width = oContain.offsetWidth + "px";
		oEl.style.height = (oContain.offsetHeight * iRatio) + "px";
	}
	
	if (oEl.offsetHeight > oContain.offsetHeight) {
		var iDiff=oEl.offsetHeight - oContain.offsetHeight + 11,iSkin=oSkin.offsetHeight - iDiff,iSkinChild=oSkinChild.offsetHeight - iDiff;
	    oContain.style.height = oEl.offsetHeight + "px";
	    oSkin.style.height = iSkin + "px";
	    oSkinChild.style.height = iSkinChild + "px";
		/*var iRatio = oEl.offsetWidth / oContain.offsetWidth;
		oEl.style.height = oContain.offsetHeight + "px";
		oEl.style.width = (oContain.offsetWidth * iRatio) + "px";*/
	}

	oEl.style.visibility = "visible";

	var oGalleryCont = document.getElementById("GalleryCont");
	var publicLoc;

	$(oGalleryCont).find("A[href!='']:first").each(function() {
		
		publicLoc = location.href.indexOf("oImages.Previews") == -1 ? this.href : location.href;
		if (this.href == publicLoc) {
			$("#btnPrev").css("display","none");
		}
	});

	$(oGalleryCont).find("A[href!='']:last").each(function() {
		
		if (this.href == publicLoc) {
			$("#btnNext").css("display","none");
		}
	});

}
