var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',toolbar=0,location=0,statusbar=0,menubar=yes,resizable=yes,'
win = window.open(mypage,myname,settings)
}


function setupRollovers() {
 var img, sh, sn, sd
 for (var i = 0; (img = document.images[i]); i++) {
  if (img.getAttribute) {

   sn = img.getAttribute("src");
   sh = img.getAttribute("hsrc");
   sd = img.getAttribute("dsrc");

   if (sn != "" && sn != null) {
    img.n = new Image();
    img.n.src = img.src;
   
    if (sh != "" && sh != null) {
     img.h = new Image();
     img.h.src = sh;
     img.onmouseover = soopaSwapOn
     img.onmouseout  = soopaSwapOff
    }

    if (sd != "" && sd != null) {
     img.d = new Image();
     img.d.src = sd;
     img.onmousedown = soopaSwapDown
    }
   }
  }
 }
}

function soopaSwapOn() {
 this.src = this.h.src;
}

function soopaSwapOff() {
 this.src  = this.n.src;
}

function soopaSwapDown() {
 this.src  = this.d.src;
 this.temp = typeof(document.onmouseup) != 'undefined' && typeof(document.onmouseup) != 'unknown' ? document.onmouseup : "";
 soopaSwapUp.img = this;
 document.onmouseup = soopaSwapUp;
}

function soopaSwapUp() {
 var ths = soopaSwapUp.img;
 ths.src = ths.n.src;
 if (ths.temp) document.onmouseup = ths.temp;
}


/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

var offsetfrommouse=[5,20]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.
var currentimageheight = 270;	// maximum image size.

if (document.getElementById || document.all){
	document.write('<div id="PhotoPopupWindow">');
	document.write('</div>');
}

function gettrailobj(){
if (document.getElementById)
return document.getElementById("PhotoPopupWindow").style
else if (document.all)
return document.all.SignPopupWindow.style
}

function gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("PhotoPopupWindow")
else if (document.all)
return document.all.SignPopupWindow
}


function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ShowPopUpSign(imagename,title,description){

	document.onmousemove=followmouse;

	newHTML = '<DIV CLASS="SignPopupWindowBorder">';
	newHTML = newHTML + '<img src="' + imagename + '" border="0"></div>';
	newHTML = newHTML + '</div>';
	gettrailobjnostyle().innerHTML = newHTML;
	gettrailobj().display="inline";
}
function HidePopUpSign(){
	gettrailobj().innerHTML = " ";
	gettrailobj().display="none"
	document.onmousemove=""
	gettrailobj().left="-500px"

}

function ShowPopUpPhoto(imagename){

	document.onmousemove=followmouse;

	newHTML = '<DIV CLASS="PhotoPopupWindowBorder">';
	newHTML = newHTML + '<div align="center" style="padding: 8px 2px 2px 2px;">';
	newHTML = newHTML + '<img src="' + imagename + '" border="0"></div>';
	newHTML = newHTML + '</div>';
	gettrailobjnostyle().innerHTML = newHTML;
	gettrailobj().display="inline";
}


function HidePopUpPhoto(){
	gettrailobj().innerHTML = " ";
	gettrailobj().display="none"
	document.onmousemove=""
	gettrailobj().left="-500px"

}

function followmouse(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	//if (document.all){
	//	gettrailobjnostyle().innerHTML = 'A = ' + truebody().scrollHeight + '<br>B = ' + truebody().clientHeight;
	//} else {
	//	gettrailobjnostyle().innerHTML = 'C = ' + document.body.offsetHeight + '<br>D = ' + window.innerHeight;
	//}

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 220){
			xcoord = e.pageX - xcoord - 225; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 10)){
			ycoord += e.pageY - Math.max(0,(10 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 220){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 225; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + 10)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(10 + currentimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
		if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}

