//-- author:	Andy Squires
//-- date:		10th September 2002
//-- desc:		Functions to open up various types of windows from a call on a web page.
//						(read function descriptions for more details
//-- note:		Copy PARAMETERS section and any function(s) you need
//						Either add to script section on page or if many windows are required
//						throughout site then add to js file and include 'REL' tag in each page
//------------------------------------------------------------------------------
//------------------- add pop-up window ----------------------------------------
//------------------- DEFINE PARAMETERS ----------------------------------------
// -- work out available screen size
screenH = window.screen.availHeight;
screenW = window.screen.availWidth;
//- set up parameters of pop-up (width, height, position)
winW    = 550; 
winH    = 450;
//-- set up left and top position for window to ensure center of screen
posLeft = (screenW/2) - (winW/2);
posTop  = (screenH/2) - (winH/2);
//-- define the width and height of the users window
fullWinH= screenH;
fullWinW= screenW;//------------------------------------------------------------------------------//-- function:	open a page in new window, size window and center it in users window
function openScrollWin(pName,wW,wH){// -- work out available screen size
screenH = window.screen.availHeight;
screenW = window.screen.availWidth;
	//-- if no values passed set width and height to default values
	if(wW == 0){wW = winW;}
	if(wH == 0){wH = winH;}
	//-- set position coords	posLeft = (screenW/2) - (wW/2);
	posTop  = (screenH/2) - (wH/2);	winParam = "menubar=0,toolbar=0,resizable=no,scrollbars=yes,toolbar=0,status=0,width=" + wW + ",height=" + wH + ",top=" + posTop + ",left=" + posLeft;
	newWin = window.open(pName,'pwNewWin',winParam);
	newWin.focus();
}//------------------------------------------------------------------------------
//-- function:	open a page in new window, size window and center it in users window
//-- pName:			page name and extension passed to function
//-- winParam:	sets up parameters of window
function openPageSize(pName,wW,wH){
	//-- if no values passed set width and height to default values
	if(wW == 0){wW = winW;}
	if(wH == 0){wH = winH;}
	//-- set position coords	posLeft = (screenW/2) - (wW/2);
	posTop  = (screenH/2) - (wH/2);	winParam = "menubar=0,toolbar=0,resizable=no,scrollbars=no,toolbar=0,status=0,width=" + wW + ",height=" + wH + ",top=" + posTop + ",left=" + posLeft;
	newWin = window.open(pName,'pwNewWin',winParam);
	newWin.focus();
	}
//------------------------------------------------------------------------------
//-- function:	open a page as a full screen window with no furniture
//-- pName:			page name and extension passed to function
//-- winParam:	sets up parameters of window
function openFullPage(pName){
	winParam = "menubar=0,toolbar=0,resizable=no,scrollbars=no,toolbar=0,status=0,width=" + fullWinW + ",height=" + fullWinH + ",top=0,left=0";
	newWin = window.open(pName,'siteWin',winParam);
	newWin.focus();
	}	//------------------------------------------------------------------------------
//-- function:	open a page as a sized window with no furniture
//-- pName:			page name and extension passed to function
//-- winParam:	sets up parameters of window	//-- set position coordsfunction openSizedPage(pName,winW,winH){
	posLeft = (screenW/2) - (winW/2);
	posTop  = (screenH/2) - (winH/2);	winParam = "menubar=0,toolbar=0,resizable=no,scrollbars=no,toolbar=0,status=0,width=" + winW + ",height=" + winH + ",top=" + posTop + ",left=" + posLeft;
	newWin = window.open(pName,'siteWin',winParam);
	newWin.focus();
	}	
//------------------------------------------------------------------------------	
//-- function:	- open a page in a sized window with no furniture
//							- writes html to the window to display an image.
//							- amend 'winLayout' to add any other features that are required in the page
//-- sTitle:		title to be displayed in window title bar
//-- imageName:	name / path of image to be displayed in window, including extension
//-- wW:				width of new window	(if no value then default value is taken)
//-- wH:				height of new window	(if no value then default value is taken)
function openDynamicWin(sTitle,sText,classPath,imageName,wW,wH){
	//-- if no values passed set width and height to default values
	if(wW == 0){wW = winW;}
	if(wH == 0){wH = winH;}
	//-- set top and left attributes
	posLeft = (screenW/2) - (wW/2);
	posTop  = (screenH/2) - (wH/2);	
	winLayout = "<html><head><title>" + sTitle + "</title>"	if(classPath != ""){winLayout = winLayout + "<link rel='stylesheet' type='text/css' href='" + classPath + "'>"}	winLayout = winLayout + "<head><body><table width=100% height=100%><tr><td align=right height=17><a href='javascript:self.close()'><img src='images/btn_close.gif' border=0></a></td></tr><tr><td align=center>" + sText + "</td></tr><tr><td align=center valign=center><img src='" + imageName + "'></td></tr></table></body>";
	winParam = "menubar=0,toolbar=0,resizable=no,scrollbars=no,toolbar=0,status=0,width=" + wW + ",height=" + wH + ",top=" + posTop +",left= " + posLeft;
	newWin = window.open('','newWin',winParam);
	newWin.document.write(winLayout);
	newWin.focus();
}
//-----------------------------------------------------------------------------//-- function:	- open an image in a sized window with no furniture
//							- writes html to the window to display an image.
//							- image displayed with a custom close button at head 
//-- sTitle:		title to be displayed in window title bar
//-- imageName:	name / path of image to be displayed in window, including extension
//-- wW:				width of new window	(if no value then default value is taken)
//-- wH:				height of new window	(if no value then default value is taken)
function openImgWin(sTitle,imageName,wW,wH){	//-- if no values passed set width and height to default values
	if(wW == 0){wW = winW;}
	if(wH == 0){wH = winH;}
	//-- set top and left attributes
	posLeft = (screenW/2) - (wW/2);
	posTop  = (screenH/2) - (wH/2);	
	winLayout = "<html><head><title>" + sTitle + "</title><link rel='stylesheet' type='text/css' href='style/style.css'></head><body bgcolor='#000000' leftmargin='0' rightmargin='0' topmargin='0' bottommargin='0'><table width='100%' height='100%' border='0'><tr><td width='145px' height='55px'><img src='images/popup_logo.gif' alt='Down to Earth Flowers'></td><td class='portfolioImg' align='center'>" + sTitle + "</td><td width='145px' align='right' class='portfolioImg'><a href='javascript:self.close()'>close</a>&nbsp;</td></tr><tr><td colspan='3' align='center' valign='center'><img src='images/" + imageName + "'></td></tr></table></body>";
	winParam = "menubar=0,toolbar=0,resizable=no,scrollbars=no,toolbar=0,status=0,width=" + wW + ",height=" + wH + ",top=" + posTop +",left= " + posLeft;
	newWin = window.open('','newWin',winParam);
	newWin.document.write(winLayout);
	newWin.focus();
}//-----------------------------------------------------------------------------//-- function:	- open an image in a sized window with no furniture
//							- writes html to the window to display an image.
//							- image displayed with a custom close button at head 
//-- sTitle:		title to be displayed in window title bar
//-- imageName:	name / path of image to be displayed in window, including extension
//-- wW:				width of new window	(if no value then default value is taken)
//-- wH:				height of new window	(if no value then default value is taken)
function openImgWin2(sTitle,imageName,wW,wH){	//-- if no values passed set width and height to default values
	if(wW == 0){wW = winW;}
	if(wH == 0){wH = winH;}
	//-- set top and left attributes
	posLeft = (screenW/2) - (wW/2);
	posTop  = (screenH/2) - (wH/2);	
	winLayout = "<html><head><title>" + sTitle + "</title><link rel='stylesheet' type='text/css' href='style/style.css'></head><body bgcolor='#EEEEFF'><table width=100% height=100%><tr><td class=prodTitleSub>" + sTitle + "</td><td align=right><a href='javascript:self.close()'><img src='images/btn_crossBorder.gif' border=0></a></td></tr><tr><td colspan=2 align=center valign=center><img src='images/" + imageName + "'></td></tr></table></body>";
	winParam = "menubar=0,toolbar=0,resizable=no,scrollbars=no,toolbar=0,status=0,width=" + wW + ",height=" + wH + ",top=" + posTop +",left= " + posLeft;
	newWin = window.open('','newWin',winParam);
	newWin.document.write(winLayout);
	newWin.focus();
}
//-----------------------------------------------------------------------------//-- function:	- open a page in a sized window (static size) (e.g. website etc)//--							this window DOES have all the furniture shown and is designed to be functional//--							(the only real difference between this function and opening a window with the TARGET tag is that//--							it sizes and positions the window on the screen - always a little bit nicer!)
//-- imageName:	name / path of image to be displayed in window, including extension
//-- wW:				width of new window	(if no value then default value is taken)
//-- wH:				height of new window	(if no value then default value is taken)//-- NOTE: this function needs to be called from an onClick event of the <a> tag - not sure why - need to find out!
function openSizedWin(pName){wW = screenW * .80
wH = screenH * .80
//-- set width and height to full screen if less than 800x600if(wW <= 800){wW = 800}
if(wH <= 600){wH = 600}	//-- if no values passed set width and height to default values
	if(wW == 0){wW = winW;}
	if(wH == 0){wH = winH;}
	//-- set top and left attributes
	posLeft = parseInt(screenW/2) - parseInt(wW/2);
	posTop  = parseInt(screenH/2) - parseInt(wH/2);		posTop = parseInt(posTop/2) - 20;
	winParam = "menubar=1,toolbar=1,resizable=yes,scrollbars=yes,toolbar=1,status=1,width=" + wW + ",height=" + wH + ",top=" + posTop +",left= " + posLeft;
	newWin = window.open(pName,'newWin',winParam);
	newWin.focus();
}
//-----------------------------------------------------------------------------
//-- function:	- open a page in a sized window (user defined size) (e.g. website etc)//--							this window DOES have all the furniture shown and is designed to be functional//--							(the only real difference between this function and opening a window with the TARGET tag is that//--							it sizes and positions the window on the screen - always a little bit nicer!)
//-- imageName:	name / path of image to be displayed in window, including extension
//-- wW:				width of new window	(set by user - if no value then default value is taken)
//-- wH:				height of new window (set by user - if no value then default value is taken)//-- NOTE: this function needs to be called from an onClick event of the <a> tag - not sure why - need to find out!
function openVarSizedWin(pName, wW, wH){
//-- if no values passed set width and height to default values
	if(wW == 0){wW = screenW * .80}
	if(wH == 0){wH = screenH * .80}
	//-- set top and left attributes
	posLeft = (screenW/2) - (wW/2);
	posTop  = (screenH/2) - (wH/2);		posTop = posTop/2;

	winParam = "menubar=1,toolbar=1,resizable=yes,scrollbars=yes,toolbar=1,status=1,width=" + wW + ",height=" + wH + ",top=" + posTop +",left= " + posLeft;
	newWin = window.open(pName,'newWin',winParam);
	newWin.focus();
}
//-----------------------------------------------------------------------------

