//<!-- Start JavaScript
 
browser = ( (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 3 ) || parseInt(navigator.appVersion) >= 4 );
	
if (document.images && browser) {
	var back_on = new Image() ;
	back_on.src = "/images/btn_back_on.gif" ;
	var back_off = new Image() ;
	back_off.src = "/images/btn_back_off.gif" ;
}

	
// Wrap the frameset around this page if opened by itself  
if (window.top.location==self.location && location.href.toUpperCase().indexOf ("_NEW")<0) {
	sPage = location.href ;

	// find out what 'store' subfolder they are in so we can select the Store automatically
	if (sPage.indexOf ("vancouver") >= 0)
		sStore = "&store=vancouver";
	else if (sPage.indexOf ("seattle") >= 0)
		sStore = "&store=seattle";
	else
		sStore = "";

	sPage = sPage.substring(sPage.lastIndexOf("/") + 1);		
	sPage = sPage.substring(0, sPage.length - 4);
	// Doesn't work in the dynamic page - only built pages
	if (sPage !="catalog_body")
		self.location.replace("../?pg=" + sPage + sStore);
}
	
function AutoRun() {
	// Not used at this time
}


function IsStyleAware() {
	if(navigator.appName=="Netscape") {
		if (parseInt(navigator.appVersion) > 4) return true;
		else return false;
	}
	else {
		if (parseInt(navigator.appVersion) > 3) return true;
		else return false;
	}
}


function ByQuotationInfo() {
// Popup a message explaining items "by quotation" 
	var msg = "This item is 'by quotation' - your Pedersens representative will quote you the current price when they contact you. (This item will show a $0.00 price when you add it to your Order-form)" ;
	alert(msg) ;
}


function PopPhoto (PhotoID, PhotoSizeID) {
	// PhotoSizeID=81; // hard-code 900x600px size for all photos
	// Standard Photo Window Options
	var
		res			= 1280	// default - CODE to pass to view.cfm to indicate screen size 
	,	pHeight		= 400	// default - Height for 640 resolution 
	,	pWidth		= 600	// default - Width for 640 resolution 
	,	scrWidth	= 640	// default - increased below if we can determine screen size 
	,	scrHeight	= 450	// default - increased below if we can determine screen size 
	,	winTop		= ""	// will be skipped if not a ver 4 browser 
	,	winLeft		= ""	// will be skipped if not a ver 4 browser 
	,	winScroll	= 0		// default is no scrollbar 
	,	winSizable	= 1		// default is resizable
	;

	pHeight = 800 ;  // ACTUAL Photo Height -- HACK

	// Check user's screen resolution if possible  
	if (screen.availWidth) {
		scrWidth=screen.availWidth;
		scrHeight=screen.availHeight;
	}

	// Determine window size needed for photo 
	if 		(screen.width >=1280)	res=1280; // MAX image size
	else if (screen.width >=1024)	res=1024;
	else if (screen.width >=800)	res=800;
	else if (screen.width >=640)	res=640;

	var
		// Window Width 
		minWidth		= pWidth + 20 
	,	winWidth		= minWidth + 20	// Horz. breathing room - if available
	,	winBorderWidth	= 12			// Avoid side-border widths from pushing right side off-screen
		// Window Height 
	,	winTitlebarHeight = 35			// Avoid titlebar & bottom-border heights from pushing bottom off-screen
	,	minHeight		= pHeight + 20 
	,	winHeight		= minHeight + 35 + winTitlebarHeight // Vert. breathing room - if available
	;
	// OVERRIDE previous code and set ALL windows to be FULL SCREEN !!!
	winHeight = scrHeight - winTitlebarHeight;
	winWidth = scrWidth - winBorderWidth;

	// See if scrollbar is required 
	if (scrHeight < minHeight ) { 
		winScroll = 1 }

	// Round off all numbers and add string components required 
	winWidth = "width=" + Math.round (winWidth) ;
	winHeight = ",height=" + Math.round (winHeight) ;
	if (winLeft >= 0 ) {
		winLeft = Math.round (winLeft) ; 
		winLeft = ",screenX=" + winLeft + ",left=" + winLeft ;
		winTop = Math.round (winTop) ;
		winTop = ",screenY=" + winTop + ",top=" + winTop ;
	}
	winScroll = ",scrollbars=" + winScroll ;
	winSizable = ",resizable=" + winSizable ;
	
	// Assemble all string components into a complete "New Window Options" string 
	winOptions = winWidth + winHeight + winTop + winLeft + winScroll + winSizable

	// Create pageURL with all parameters 
	pageURL = "view.cfm?id=" + PhotoID + "&sizeid=" + PhotoSizeID ;

	newWin= window.open (pageURL, "ProofPreview", winOptions) ;
	if (document.all || document.layers || document.getElementById)	{ newWin.focus () } 
}


function Photo (ItemID, PhotoSizeID, SrcPage, AltPhoto) {

	// Standard Photo Window Options for NEW PHOTOS - default for old browsers 
	var res = 0	;			// default - CODE to pass to view.cfm to indicate screen size 
	var scrWidth = 640 ;	// default - increased below if we can determine screen size 
	var scrHeight = 450 ;	// default - increased below if we can determine screen size 
	var winTop = "" ;		// will be skipped if not a ver 4 browser 
	var winLeft = "" ;		// will be skipped if not a ver 4 browser 
	var winScroll = 0 ;		// default is no scrollbar 
	var winSizable = 1 ;	// default is resizable 
	
	// Check user's screen resolution if possible  
	if (screen && screen.availWidth) {
		if (screen.availWidth) scrWidth = screen.availWidth;
		if (screen.availHeight) scrHeight = screen.availHeight;
	}
	
	// If is an Oversize photo (higher screen resolutions), then "reduce" as necessary 
	if (PhotoSizeID > 70 ) {	// Greater than 640 resolution, so check screen... 
		if (scrWidth >= 1200 && scrHeight >= 900 ) {	// 1280x1024 resolution 
			res = 1200 ; 
			// Can use ANY RESOLUTION of photo
		}
		else if (scrWidth >= 950 ) {	// 1024x768 resolution 
			res = 1024 ; 
			if (PhotoSizeID > 90 ) PhotoSizeID -= 10; 
		}
		else if (scrWidth >= 800 ) { 	// 800x600 resolution 
			res = 800 ; 
			if (PhotoSizeID > 90 ) PhotoSizeID -= 20; 
			else if (PhotoSizeID > 80 ) PhotoSizeID -= 10; 
		}
		else {		                   	// 640x480 resolution (minimum)
			res = 640 ; 
			if (PhotoSizeID > 90 ) PhotoSizeID -= 30; 
			else if (PhotoSizeID > 80 ) PhotoSizeID -= 20; 
			else if (PhotoSizeID > 70 ) PhotoSizeID -= 10;
		}
	}			
	
	// Determine window size needed for photo 

	// 1280x1024 Resolution Sizes ================== 
	if (PhotoSizeID > 90) {				// 1280x1024 res 
		pHeight = 800;					// Height for this resolution 
		if (PhotoSizeID == 91)			// 1200x800 Horizontal  (6x4) 
			pWidth = 1200;
		else if (PhotoSizeID == 93)		// 1000x800 Horizontal  (5x4) 
			pWidth = 1000;
		else if (PhotoSizeID == 95)		// 800x800 Square  (4x4) 
			pWidth = 800;
		else if (PhotoSizeID == 97)		// 640x800 Vertical  (4x5) 
			pWidth = 640;
		else if (PhotoSizeID == 99)		// 533x800 Vertical  (4x6) 
			pWidth = 533;
	}
	
	// 1024x768 Resolution Sizes ================== 
	else if (PhotoSizeID > 80) {		// 1024x768 res 
		pHeight = 600;					// Height for this resolution 
		if (PhotoSizeID == 81)			// 900x600 Horizontal  (6x4) 
			pWidth = 900;
		else if (PhotoSizeID == 83)		// 750x600 Horizontal  (5x4) 
			pWidth = 750;
		else if (PhotoSizeID == 85)		// 600x600 Square  (4x4) 
			pWidth = 600;
		else if (PhotoSizeID == 87)		// 480x600 Vertical  (4x5) 
			pWidth = 480;
		else if (PhotoSizeID == 89)		// 400x600 Vertical  (4x6) 
			pWidth = 400;
	}
	
	// 800x600 Resolution Sizes ================== 
	else if (PhotoSizeID > 70) {		// 800x600 res 
		pHeight = 500;					// Height for this resolution 
		if (PhotoSizeID == 71)			// 750x500 Horizontal  (6x4) 
			pWidth = 750;
		else if (PhotoSizeID == 73)		// 625x500 Horizontal  (5x4) 
			pWidth = 625;
		else if (PhotoSizeID == 75)		// 500x500 Square  (4x4) 
			pWidth = 500;
		else if (PhotoSizeID == 77)		// 420x500 Vertical  (4x5) 
			pWidth = 400;
		else if (PhotoSizeID == 79)		// 333x500 Vertical  (4x6) 
			pWidth = 333;
	}
	
	// 640x480 Resolution Sizes =================== 
	else if (PhotoSizeID > 60) {        // 640x480 res  
		pHeight = 400;					// Height for this resolution 
		if (PhotoSizeID == 61)			// 600x400 Horizontal  (6x4) 
			pWidth = 600;
		else if (PhotoSizeID == 63)		// 500x400 Horizontal  (5x4) 
			pWidth = 500;
		else if (PhotoSizeID == 65)		// 400x400 Square  (4x4) 
			pWidth = 400;
		else if (PhotoSizeID == 67)		// 320x400 Vertical  (4x5) 
			pWidth = 320;
		else if (PhotoSizeID == 69)		// 267x400 Vertical  (4x6) 
			pWidth = 267;
	}

	// OLD Photo Sizes 
	else if (PhotoSizeID == 1) {		// OLD: 420x290 Horizontal Popup 
		pWidth = 420;
		pHeight = 290;
	}
	else if (PhotoSizeID == 2 ) {		// OLD: 190x300 Vertical Popup 
		pWidth = 190;
		pHeight = 300;
	}
	else if (PhotoSizeID == 7) {		// OLD: 300x375 Vertical - Linen Feature 
		pWidth = 300;
		pHeight = 375;
	}
	
	// No PhotoSizeID ??? - so set to 640x480 Resolution  
	else {
		PhotoSizeID = 61;				// 600x400 Horizontal  (6x4) 
		pHeight = 400;
		pWidth = 600;
	}

	// IF we can determine the screen size - then adjust window & photo as required 
	
	// Set 'minimum window width' to fit Photo Names 
	if (pWidth < 300 ) pWidth = 300;
	
	// Window Width 
	var minWidth = pWidth + 20; 
	var winWidth = minWidth + 25;	// Horz. breathing room - if available
	var winBorderWidth = 12 ;		// Avoid side-border widths from pushing right side off-screen
	// Window Height 
	var minHeight = pHeight + 40; 
	var winHeight = minHeight + 35;	// Vert. breathing room - if available
	var winTitlebarHeight = 40;		// Avoid titlebar & bottom-border heights from pushing bottom off-screen
	
	// Check window width 
	if (scrWidth < winWidth) { 
		winWidth = scrWidth ;
		winLeft = 0;
	}
	else { 
		winLeft = (scrWidth - (winWidth+winBorderWidth) ) / 2 ; 
		if (winLeft < 0 ) winLeft = 0;
	}
		
	// Check window height 
	if (scrHeight < winHeight) { 
		winHeight = scrHeight ; 
		winTop = 0;
	}
	else { 
		winTop = (scrHeight - (winHeight + winTitlebarHeight) ) / 2 ;
		if (winTop < 0 ) winTop = 0;
	}
		
	// See if scrollbar is required 
	if (scrWidth < minWidth || scrHeight < minHeight )
		winScroll = 1;

	// Round off all numbers and add string components required 
	winWidth = "width=" + Math.round(winWidth) ;
	winHeight = ",height=" + Math.round(winHeight) ;
	if (winLeft >= 0 ) {
		winLeft = Math.round(winLeft) ; 
		winLeft = ",screenX=" + winLeft + ",left=" + winLeft ;
		winTop = Math.round(winTop) ;
		winTop = ",screenY=" + winTop + ",top=" + winTop ;
	}
	winScroll = ",scrollbars=" + winScroll ;
	winSizable = ",resizable=" + winSizable ;
	
	// Assemble all string components into a complete "New Window Options" string 
	winOptions = winWidth + winHeight + winTop + winLeft + winScroll + winSizable		

	// Create a photo path - dependant on "what type" of photo it is 
	// Create common pageURL root 
	pageURL = "/catalog/view.cfm?id=" + ItemID + "&src=" + SrcPage ;
	
	// Append other parameters as or if necessary 

	// called from a Catalog OR Package page for a "Catalog Photo" by "ItemID" 
	if (AltPhoto == null)	pageURL += "&item=1";  

	// called from Backend Interface for a "Catalog Photo" by "PhotoID" 
	else if (AltPhoto == 0)	pageURL += "&cat=1";  

	// called from a Package OR Gallery page for a "Package Photo" 
	else if (AltPhoto == 1)	pageURL += "&pkg=1";

	// called from Gallery Preview page for a "Gallery Photo" - displays the "Gallery Title"
	else if (AltPhoto == 2)	pageURL += "&gal=1";

	// called from Gallery Preview page for a "Catalog Photo" - displays the "Gallery Title"
	else if (AltPhoto == 3)	pageURL += "&galcat=1";

	// called from Gallery Preview page for a "Package Photo" - displays the "Gallery Title"
	else if (AltPhoto == 4)	pageURL += "&galpkg=1";
	
	// SPECIAL Parmeters used only for previewing photos in backend interfaces 
	
	// called from a 'Backend Interface' for a "Gallery Photo" - displays the "Photo Name" !!! 
	else if (AltPhoto == 5)	pageURL += "&galX=1";

	// called from a 'Backend Interface' for a "Linen Photo" - displays the "Photo Name"
	else if (AltPhoto == 6)	pageURL += "&lin=1";

	// See if we need to pass a parameter that indicates oversize photo is TOO BIG! 
	if (res > 0)			pageURL += "&res=" + res; 

	try {
		newWin= window.open(pageURL, "", winOptions) ;
		newWin.focus();
	}
	catch (ex) {}
}


function ViewLinens(ItemID, SrcPage) {
	// Standard Linen Viewer Window Options - default for old browsers 
	winWidth = 600;
	winHeight = 400;	// ALL 'NEW' photos are the 'same height' (400) 
	winTop = "";		// will be skipped if not a ver 4 browser 
	winLeft = "";		// will be skipped if not a ver 4 browser 
	
	// IF we can determine the screen size - then adjust window if smaller than ideal window 
	if (screen && screen.availWidth)	{
		if (screen.availWidth >= 830 ) { 
			winWidth = 750;	// Maximum Width for ANY screen resolution 
			winLeft = (screen.availWidth - 750) / 2;
		}
		else {
			winWidth = screen.availWidth * 0.9;
			winLeft = screen.availWidth * 0.05;
		}
		if (screen.availHeight >= 600) {
			winHeight = 540 ;	 // Maximum Height for ANY screen resolution 
			winTop = (screen.availHeight - 540) / 2;
		}
		else {
			winHeight = screen.availHeight * 0.9;
			winTop = screen.availHeight *0.05;
		}
	}

	winWidth = "width=" + Math.round(winWidth) ;
	winHeight = ",height=" + Math.round(winHeight) ;
	winScroll = ",scrollbars=0" ;	    // n/a for frameset! 
	winSizable = ",resizable=1" ;		// default for all 
	if (winLeft >= 0 ) {
		winLeft = Math.round(winLeft) ; winTop = Math.round(winTop) ;
		winLeft = ",screenX=" + winLeft + ",left=" + winLeft ;
		winTop = ",screenY=" + winTop + ",top=" + winTop ;
	}
	
	winOptions = winWidth + winHeight + winTop + winLeft + winScroll + winSizable
	
	if (top.window.location.href.indexOf("/packages") >= 0 )
		// called from a Package page 
		pageURL = "../linens/viewer.cfm?Item=" + ItemID + "&src=" + SrcPage ;
	else	
		// called from a Catalog page 
		pageURL = "../../linens/viewer.cfm?Item=" + ItemID + "&src=" + SrcPage ;

	try {
		newWin= window.open(pageURL, "LinenViewer", winOptions) ;
		newWin.focus();
	}
	catch (ex) {}
}


function BrowseLinens(PageName) {
	top.location = "../../linens/?pg=" + PageName
}


function GoBookmark (bookmark) {
	sPage = location.href;
	iBookmark = sPage.lastIndexOf("#");
	if (iBookmark > 0)
		sPage = sPage.substring (0, iBookmark);		
	sPage += "#"+ bookmark;
	self.location = sPage;
}


// -- End JavaScript -->
