var Common = {
	// Common classes methods
	Class : {
		match: function(oElement, sClassName) {
			return (oElement.className && oElement.className.match(new RegExp('(^|\\s+)' + sClassName + '($|\\s+)')))? true : false;	
		},
		add: function(oElement, sClassName){
			if(!Common.Class.match(oElement, sClassName)) {oElement.className += ' ' + sClassName;}
		},
		replace: function(oElement, sClassNameFrom, sClassNameTo) {
			if(Common.Class.match(oElement, sClassNameFrom)) {
				oElement.className = (oElement.className.replace( new RegExp("(^|\\s+)(" + sClassNameFrom + "|" + sClassNameTo + ")($|\\s+)", "g"), "$1" ) + ' ' + sClassNameTo ).replace( /^\s+/, '');
			}
			else {
				Common.Class.add(oElement, sClassNameTo);
			}			
		},
		remove: function(oElement, sClassName) {
			oElement.className = oElement.className.replace(new RegExp('(.*)(^|\\s+)(' + sClassName + ')($|\\s+)(.*)'), '$1$4$5').replace(/(^)\s/, '$1');	
		}
	}
}


function ShowRoom(){

var eViewer = document.getElementById('Viewer') || null;
var aMiniViews;
var eCurrent;

if (eViewer && document.getElementById('navCat') && ((document.getElementById('navCat')).getElementsByTagName('a')).length > 0)
{
	var aMiniViews = (document.getElementById('navCat')).getElementsByTagName('a');
	eCurrent = aMiniViews[0];

	for (var i=0; i<aMiniViews.length; i++)
	{
		aMiniViews[i].onclick = function ()
		{
			eViewer.src = this;

			if (eCurrent && eCurrent != this)
			{
				Common.Class.remove(eCurrent.parentNode, 'active');
				Common.Class.add(this.parentNode,'active');
				eCurrent = this;
				hideAll(document.getElementById('GetMore'));
			}

			if(this.rel && document.getElementById(this.rel)) { hideAll(document.getElementById('GetMore')); on_off(document.getElementById(this.rel)); }

			return false;
		}
	}
}

}

function show_hide(ShowPage)
	{ ShowPage.style.display = (ShowPage.style.display == 'none') ? 'block' : 'none'; }

function on_off(ShowPage)
	{ ShowPage.className = (ShowPage.className == 'off') ? 'on' : 'off'; }

function hideAll(GetMore)
	{	
		var nav = GetMore.getElementsByTagName('div');
		for(var j=0; j<nav.length; j++) nav[j].className="off";
	}
