﻿// JavaScript Document

function showPopup(iname, w, h, popupimage){
	if(!popupimage) {
		var popupimage = 'image';
	}

	$('overlayColour').style.display = 'block';
	
	document.getElementById("popBox").style.width = Number(w) + Number(24) + 'px';
	document.getElementById("topMidBrace").style.width = Number(w) + 'px';
	document.getElementById("botMidBrace").style.width = Number(w) + 'px';
	
	document.getElementById("popBox").style.left = ((document.body.clientWidth - w)/2) + 'px';
	
	var scrollY = 0;
    if (document.documentElement && document.documentElement.scrollTop) {
        scrollY = document.documentElement.scrollTop;
    } else if (document.body && document.body.scrollTop) {
        scrollY = document.body.scrollTop;
    } else if (window.pageYOffset) {
        scrollY = window.pageYOffset;
    } else if (window.scrollY) {
        scrollY = window.scrollY;
    }
	
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
  
	if(scrollY){	
		document.getElementById("popBox").style.top = ((myHeight - (Number(h) + Number(24)))/2 + scrollY) + 'px';
			
	}else{
		//Need a ccheck to make sure that the image fits on the screen.
		if(myHeight < (Number(h) + Number(24))){
			document.getElementById("popBox").style.top = Number(24) + 'px';
		}else{
			document.getElementById("popBox").style.top = ((myHeight - (Number(h) + Number(24)))/2 + scrollY) + 'px';
		}
	}
	
	if(popupimage == 'image'){
		$('swapFrame').update('<img src="' + iname + '"/>');
	}else{
		$('swapFrame').update(iname);
	}
	$('popBox').show();
}

function showPhoto1(iname, sname, w, h, e){
	document.getElementById("popBox2").style.left = mouseX = Event.pointerX(e) + 120 + 'px';
	document.getElementById("popBox2").style.top = (mouseY = Event.pointerY(e)) - (w/2) + 'px';
	$('popBox2').update('<img src="' + iname + '"/><br/>' + sname);
	$('popBox2').show();
}

function showPhoto2(iname, sname, w, h, e){
	document.getElementById("popBox2").style.left = mouseX = Event.pointerX(e) - (w + 120) + 'px';
	document.getElementById("popBox2").style.top = (mouseY = Event.pointerY(e)) - (w/2) + 'px';
	$('popBox2').update('<img src="' + iname + '"/><br/>' + sname);
	$('popBox2').show();
}

function showPhoto3(iname, sname, w, h, e){
	document.getElementById("popBox2").style.left = '270px';
//	document.getElementById("popBox2").style.top =  '372px';
 	document.getElementById("popBox2").style.top = (mouseY = Event.pointerY(e)) - (w/2) + 'px';
	$('popBox2').update('<img src="' + iname + '"/><br/>' + sname);
	$('popBox2').show();
}

function hideBox( s_boxName ){
	$(s_boxName).hide();
	$('overlayColour').hide();
}
