﻿/* -- */

function openWin(url) {
	var img = new Image();
	img.src = url;
	window.open(url,
	'win',
	'width='+img.width+',height='+img.height+', status=no,scrollbars=no,directories=no,menubar=no,resizable=no,toolbar=no')
	}
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
function changeImagesArray(array) {
	if (preloadFlag == true) {
		var d = document; var img;
		for (var i=0; i<array.length; i+=2) {
			img = null; var n = array[i];
			if (d.images) {img = d.images[n];}
			if (!img && d.getElementById) {img = d.getElementById(n);}
			if (img) {img.src = array[i+1];}
		}
	}
}
function changeImages() {
	changeImagesArray(changeImages.arguments);
}





/* a collection of window tricks. */

/* first, declare the variable newWin that will be used 
for the new window object. */
var newWin;

function basicWindow(url,w,h) {
settings = '"toolbar=no, directories=no,menubar=no,scrollbars=no,resizable=no,status=no,width='+w+',height='+h+'"';
closeWindow();
newWin = window.open(url,'newWin',settings);
newWin.focus();
}

function allWindow(url,w,h) {
settings = '"toolbar=yes,titlebar=yes,location=yes,explorer=yes,directories=yes,menubar=yes,fullscreen=yes,scrollbars=yes,resizable=yes,status=yes"';
closeWindow();
newWin = window.open(url,'newWin',settings);
newWin.focus();
}

function plainwindow() {
newWin = window.open() 
}




function centeredWindow(url,winname,w,h) {
windowleft = (screen.width - w)/2;
windowtop = (screen.height - h)/2;
settings = '"toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,status=no,width='+w+',height='+h+ ',left='+windowleft+',top='+windowtop+'"';
closeWindow();
newWin = window.open(url,winname,settings);
newWin.focus();
}


/* a centered window with a visible status bar. */ 

function centeredWinstatus(url,winname,w,h) {
windowleft = (screen.width - w)/2;
windowtop = (screen.height - h)/2;
settings = '"toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,status=yes,width='+w+',height='+h+ ',left='+windowleft+',top='+windowtop+'"';
closeWindow();
newWin = window.open(url,winname,settings);
newWin.focus();
}


function closeWindow() {
if (newWin && !newWin.closed) {
newWin.close();}
}


function centeredscrollingWindow(url,winname,w,h) {
windowleft = (screen.width - w)/2;
windowtop = (screen.height - h)/2;
settings='"toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,status=no,width='+w+',height='+h+ ',left='+windowleft+',top='+windowtop+'"';
closeWindow();
newWin = window.open(url,winname,settings);
newWin.focus();
}


function closeWindow() {
if (newWin && !newWin.closed) {
newWin.close();}
}


function placedWinTop(url,winname,w,h) {
windowleft = (screen.width-w)/2;
centerver = screen.height/2;
windowtop = centerver - h-20;

settings = '"toolbar=no, directories=no,menubar=no,scrollbars=no,resizable=no,status=no,width='+w+',height='+h+',left='+windowleft+',top='+windowtop+'"';

newWindow1 = window.open(url,winname,settings);
newWindow1.focus();
}


function placedWinBottom(url,winname,w,h) {
windowleft = (screen.width-w)/2;
centerver = screen.height/2;
windowtop = centerver+10;

settings = '"toolbar=no, directories=no,menubar=no,scrollbars=no,resizable=no,status=no,width='+w+',height='+h+',left='+windowleft+',top='+windowtop+'"';

newWindow2 = window.open(url,winname,settings);
newWindow2.focus();
}


function placedWinSide(graphic) {
w = 100;
h = 100;
centerver = screen.height/2;
windowtop = centerver -50;
if (navigator.userAgent.indexOf('MSIE') != -1) {windowleft = screen.width/2 + document.body.clientWidth/2 + 25;}
else {windowleft = (screen.width)/2 + window.outerWidth/2 + 20;}
settings = '"toolbar=no, directories=no,menubar=no,scrollbars=no,resizable=no,status=no,width='+w+',height='+h+',left='+windowleft+',top='+windowtop+'"';
sidewincontent = "<html><head><title>side<\/title><\/head>";
sidewincontent += "<body marginheight=\"0\" marginwidth=\"0\" style=\"margin:0\">";
sidewincontent +="<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">";
sidewincontent +="<tr><td width=\"100\">";
sidewincontent += "<a href=\"javascript:opener.close();window.close();\"><img src=\""+graphic+"\"alt=\"close window\" width=\"100\" height=\"100\"border=\"0\"><\/a><\/td>";
sidewincontent += "<\/tr><\/table><\/body><\/html>";

newWindow3 = window.open('','sidewin',settings);
newWindow3.document.write (sidewincontent);
newWindow3.document.close();
newWindow3.focus();
}


// moving the window and blurring it.
function moveWindow(w,h) {
window.moveTo(0,0);
window.blur();
}


// changing the page loaded in the parent window.

function changeParent(url) {
if (opener) {
opener.document.location = url;
}
}


/* The window scrolling function.*/

var vPos=0;

function scrollWindow(h) {
if (window.scroll) {
do {
vPos+=1;
window.scroll(0,vPos);
} while (vPos <= h);
do {
vPos += -1;
window.scroll(0,vPos);
  } while (vPos > 0);
 }
}


function insertname(text) {
textstring = " Welcome, "+text +". Please enjoy your stay.";
opener.document.nameform.namefield.value=textstring;
}


/* This final script is an 'extra'.  */

/* Opens the form window the first time someone visits the site and writes the name into a cookie. On subsequent visits the visitor is greeted with a welcome back message.*/

function welcome() {
if ((document.cookie.indexOf('username') == -1) || (document.cookie.length <= 0)) {
centeredWindow('formwindow.html','formwin',300,100);
}
else {
text = getcookie('username');
textstring = " Welcome back, "+text +".";
document.nameform.namefield.value=textstring;
   }
}

