var cloadgallery = '';
function loadgallery(sitesrc,pname,picsrc,count){
	if(cloadgallery != "") document.getElementById('nav'+cloadgallery).style.fontWeight = 'normal';
	document.getElementById('nav'+pname).style.fontWeight = 'bold';
	document.getElementById('iframegallery').src = sitesrc+'/gallery_'+pname;
	document.getElementById('iframeimg').src = sitesrc+'/index.php?page='+pname+'&type=gallery&pic='+picsrc;
	cloadgallery = pname;
	ccount = count;
}

function loadnextgallery(){
	nextgallery = ccount;
	nextgallery++;
	if(nextgallery > ctotal) nextgallery = 1;
	func = document.getElementById('link'+nextgallery).href;
	setTimeout(func,1);
	func = func.substring(25,func.length-3);
	func = func.split("','");
	if (!window.XMLHttpRequest) setTimeout("loadgallery"+func[0]+"','"+func[1]+"','"+func[2]+"','"+func[3]+"');",1);
	else setTimeout("loadgallery('"+func[0]+"','"+func[1]+"','"+func[2]+"','"+func[3]+"');",1);
}

function loadprevgallery(){
	nextgallery = ccount;
	nextgallery--;
	if(nextgallery < 1) nextgallery = ctotal;
	func = document.getElementById('link'+nextgallery).href;
	setTimeout(func,1);
	func = func.substring(25,func.length-3);
	func = func.split("','");
	if (!window.XMLHttpRequest) setTimeout("loadgallery"+func[0]+"','"+func[1]+"','"+func[2]+"','"+func[3]+"');",1);
	else setTimeout("loadgallery('"+func[0]+"','"+func[1]+"','"+func[2]+"','"+func[3]+"');",1);
}

function housegallerynav(dir,id){
	if(dir == 2){
		document.getElementById('thumb'+id).className = 'selected';
		document.getElementById('thumb'+cgallery).className = '';
		tmplink =  document.getElementById('thumb'+id).href+'&picid='+id;
		document.getElementById('iframeimg').src = tmplink;
		cgallery = id;
	}else{		
		if(dir == 1){ cgoto = cgallery+1; if(cgoto > tgallery) cgoto = 1;
		}else{ cgoto = cgallery-1; if(cgoto < 1) cgoto = tgallery; }
		tmplink =  document.getElementById('thumb'+cgoto).href+'&picid='+id;
		document.getElementById('iframeimg').src = tmplink;
		document.getElementById('thumb'+cgoto).className = 'selected';
		document.getElementById('thumb'+cgallery).className = '';
		cgallery = cgoto;
		scrollme = Math.ceil(cgallery/4)*87;
		if(scrollme <= (348)) scrollme = 0;
		scrollBox.setSlider(scrollme);
	}
}

function windowH(){
	var winH = 580;
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winH = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winH = document.body.offsetHeight;
	 }
	}
	return winH;
}

function winposet(){
	var winH = windowH();
	var obj1 = document.getElementById('wrapper')
	var obj2 = document.body;
	if(winH < 650){
		if(winH > 580){
			var spacer = (winH-574)/2-52;
		}else{
			var spacer = -52;
		}
		obj1.style.marginTop = spacer+'px';
		obj2.style.backgroundPosition = 'right '+spacer+'px';
	}else{
		obj1.style.marginTop = '0px';
		obj2.style.backgroundPosition = 'right top';
	}
}

var isfooter = false;
function ifooter(){
	if(isfooter == true){
		document.getElementById('footer').style.bottom = '-100%';
		document.getElementById('bfooter').style.bottom = '53px';
		document.getElementById('bfooterplus').innerHTML = '[ + ]';
		isfooter = false;
	}else{
		document.getElementById('footer').style.bottom = '50px';
		document.getElementById('bfooter').style.bottom = Number(document.getElementById('footer').clientHeight)+Number(50)+'px';
		document.getElementById('bfooterplus').innerHTML = '[ - ]';
		isfooter = true;
	}
}

window.addEvent('domready', function() {	
			
	var myScrollArea = new MooScroll({
		selector:'#content'
	});
});
