var wWidth, wHeight, wTop, wLeft, wTop1;

// Core code from - quirksmode.org
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		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;
	if (self.innerHeight) {	// all except Explorer
		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 = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function show_blackscreen(b) {
	var o = document.getElementById ? document.getElementById("blackscreen") : document.all.blackscreen;

		if (b) {
			var psize = getPageSize();
			var pscroll = getPageScroll();
		
			o.style.top = "0px";//pscroll[1]+"px";
			
			o.style.width = psize[0];
			o.style.height = psize[1];
			
			o.style.display = "block";
		}
		else {
			o.style.display = "none";
		}

}


function change_window_position() {
	var w = document.all ? document.all["zWindow"] : document.getElementById("zWindow");
	var a = document.all ? document.all['imgFullscreenFalse'] : document.getElementById('imgFullscreenFalse');
	
	wTop = 124;
	wTop1 = 124;
	wLeft = (window.innerWidth ? window.innerWidth : document.body.clientWidth)/2 - wWidth/2;
	if (a.style.display == "none") {
		var pscroll = getPageScroll();
		w.style.top = wTop+pscroll[1];
		w.style.left = wLeft;
	}
}
function change_window_size() {
	var wc = document.all ? document.all['wContent'] : document.getElementById('wContent');
	switch (screen.height)
	{
		case 600:		wHeight = 250;
						wWidth = 650;
						break;
		case 720:		wHeight = 350;
						wWidth = 650;
						break;
		case 768:		wHeight = 400;
						wWidth = 800;
						break;
		default:		wHeight = 500;
						wWidth = 800;
						break;
	}
	change_window_position();
	if ((navigator.appName == "Opera") || (navigator.userAgent.indexOf("Firefox") != -1)) {
		wc.style.height = wHeight-28;
	}
}

function show_window(b) {
	change_window_size();
	show_blackscreen(b);
	var w = document.all ? document.all["zWindow"] : document.getElementById("zWindow");
	var display_style = 'table';
	fullscreen_window(0);
	if (navigator.appName == "Microsoft Internet Explorer") display_style = 'block';
	w.style.display = b ? display_style : 'none';
}

function fullscreen_window(x) {
	var w = document.all ? document.all['zWindow'] : document.getElementById('zWindow');
	var a = document.all ? document.all['imgFullscreenTrue'] : document.getElementById('imgFullscreenTrue');
	var b = document.all ? document.all['imgFullscreenFalse'] : document.getElementById('imgFullscreenFalse');
	var c = document.all ? document.all['aFullscreenTrue'] : document.getElementById('aFullscreenTrue');
	var d = document.all ? document.all['aFullscreenFalse'] : document.getElementById('aFullscreenFalse');
	var wc = document.all ? document.all['wContent'] : document.getElementById('wContent');
	var pscroll = getPageScroll();
	if (x) {
		w.style.width = "100%";
		w.style.height = "100%";
		a.style.display = "none";
		b.style.display = "inline";
		c.style.display = "none";
		d.style.display = "inline";
		wTop = w.style.top;
		wLeft = w.style.left;
		w.style.top = pscroll[1]+"px";
		w.style.left = "0px";
		if (navigator.userAgent.indexOf("Firefox") != -1) {
			wc.style.height = document.body.clientHeight - 40;
		}
		if (navigator.appName == "Opera") {
			w.style.height = "99%";
			wc.style.height = "97%";
		}		
	}
	else {
		w.style.width = wWidth+"px";
		w.style.height = wHeight+"px";
		a.style.display = "inline";
		b.style.display = "none";
		c.style.display = "inline";
		d.style.display = "none";
		w.style.top = wTop1+pscroll[1];
		w.style.left = wLeft;
		if ((navigator.userAgent.indexOf("Firefox") != -1) || (navigator.appName == "Opera")) {
			wc.style.height = wHeight-28;
		}
	}
}

function wContent_resize() {
	var wc = document.all ? document.all['wContent'] : document.getElementById('wContent');
	var a = document.all ? document.all['imgFullscreenTrue'] : document.getElementById('imgFullscreenTrue');
	if (a.style.display == "none") {
		if (navigator.userAgent.indexOf("Firefox") != -1) {
			wc.style.height = document.body.clientHeight - 40;
		}
	}
	change_window_position();
}