function openWin(url,w,h,s){
	var l=(screen.width-w)/2;
	var t=(screen.height-h)/2;
	
	if(window.thiswin != undefined){
		thiswin.close();
	}
	thiswin = window.open(url,"popwin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+s+",resizable=0,width="+w+",height="+h+",left="+l+",top="+t);
}

function showLogin(){
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	//calculate login box verticle position:
	var loginBoxOffset = (windowHeight - 320) / 2;

	document.getElementById("siteoverlay").style.width=pageWidth+"px";
	document.getElementById("siteoverlay").style.height=pageHeight+"px";
	document.getElementById("loginbox").style.top=loginBoxOffset+"px";
	new Effect.Appear("siteoverlay", { duration: 0.5, from: 0.0, to: 0.8 });
	document.getElementById("loginboxcont").style.display="";
	new Effect.Appear("loginbox", { duration: 0.5 });
	hideSelectBoxes();
}

function hideLogin(){
	new Effect.Fade("siteoverlay", { duration: 0.5 });
	new Effect.Fade("loginbox", { duration: 0.5 });
	document.getElementById("loginboxcont").style.display="";
	setTimeout ("showSelectBoxes()",500);
}

function showSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

function hideSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

function changeThumb(img){
	var nthumbs = document.getElementById("nthumbs").value;
	for(var i=1;i<=nthumbs;i++){
		document.getElementById("mainimage"+i).style.display="none";
	}
	if(img != 0){
		document.getElementById("mainimage"+img).style.display="";
		document.getElementById("imageContainer").style.display="none";
	}else{
		document.getElementById("imageContainer").style.display="";
	}
}

function showHideScroll(id,delay){
    if(document.getElementById(id+'_scroll').value == 0){
		document.getElementById(id+'_scroll').value = 1;
		if(document.getElementById(id).style.display == "none"){
			$(id).blindDown({ duration: delay });
		}else{
			$(id).blindUp({ duration: delay });
		}
		setTimeout('document.getElementById(\''+id+'_scroll\').value = 0',(delay*1000));
	}
}