/**
 * Board.js
 */
function Board(BSTY_ID, numBoardSizes, buyNowFormName, topsheetSelectName, baseSelectName, defaultBSBG_ID_TOPSHEET, defaultBSBG_ID_BASE) {

////////////////////////////////////////////////////////////////////////////////
// properties

// data members
this.BSTY_ID = BSTY_ID;
this.numBoardSizes = 0;
this.buyNowFormName = "";
this.topsheetSelectName = "";
this.baseSelectName = "";
this.currentBSBG_ID_TOPSHEET = "";
this.currentBSBG_ID_BASE = "";

// configuration members
this.controllerURL = "controller.php";

this.constructionWidth = 600;
this.constructionHeight = 500;

this.profileWidth = 500;
this.profileHeight = 500;

this.specsWidth = 300;
this.specsHeight = 400;

this.tuningWidth = 500;
this.tuningHeight = 500;

this.zoomWidth = 730;
this.zoomHeight = 500;

this.videoWidth = 500;
this.videoHeight = 400;

this.isIE = (document.all ? true : false);
this.isDOM = (document.getElementById ? true : false);

////////////////////////////////////////
// method headers

Board.prototype.selectTopsheet = selectTopsheet;
Board.prototype.selectBase = selectBase;
Board.prototype.selectZoomTopsheet = selectZoomTopsheet;
Board.prototype.selectZoomBase = selectZoomBase;

Board.prototype.viewConstruction = viewConstruction;
Board.prototype.viewProfile = viewProfile;
Board.prototype.viewSpecs = viewSpecs;
Board.prototype.viewTuning = viewTuning;
Board.prototype.viewZoom = viewZoom;
Board.prototype.viewVideo = viewVideo;


////////////////////////////////////////
// constructor statements

if (typeof(numBoardSizes) != "undefined") {
	this.numBoardSizes = numBoardSizes;
	this.specsWidth += 50 * this.numBoardSizes;
}

if (typeof(buyNowFormName) != "undefined") {
	this.buyNowFormName = buyNowFormName;
}

if (typeof(topsheetSelectName) != "undefined") {
	this.topsheetSelectName = topsheetSelectName;
}

if (typeof(baseSelectName) != "undefined") {
	this.baseSelectName = baseSelectName;
}

if (typeof(defaultBSBG_ID_TOPSHEET) != "undefined") {
	this.currentBSBG_ID_TOPSHEET = defaultBSBG_ID_TOPSHEET;
}

if (typeof(defaultBSBG_ID_BASE) != "undefined") {
	this.currentBSBG_ID_BASE = defaultBSBG_ID_BASE;
}

////////////////////////////////////////
// method definitions

/**
 * Selects topsheet.
 *
 * @param (String) BSBG_ID
 * @param (String) imageURL
 */
function selectTopsheet(BSBG_ID, imageURL) {

	// swap sheet image
	imgSrc('board_topsheet', imageURL);

	// update currently selected topsheet
	this.currentBSBG_ID_TOPSHEET = BSBG_ID;

	// update buy-now attribute
	document.forms[this.buyNowFormName].elements[this.topsheetSelectName].value = BSBG_ID;	
}

/**
 * Selects base.
 *
 * @param (String) BSBG_ID
 * @param (String) imageURL
 */
function selectBase(BSBG_ID, imageURL) {

	// swap sheet image
	imgSrc('board_base', imageURL);

	// update currently selected base
	this.currentBSBG_ID_BASE = BSBG_ID;

	// update buy-now attribute
	document.forms[this.buyNowFormName].elements[this.baseSelectName].value = BSBG_ID;	
}

/**
 * Selects topsheet on zoom page.
 *
 * @param (String) imageURL
 */
function selectZoomTopsheet(imageURL) {

	// swap sheet image
	imgSrc('board_zoom_topsheet', imageURL);
}

/**
 * Selects base on zoom page.
 *
 * @param (String) imageURL
 */
function selectZoomBase(imageURL) {

	// swap sheet image
	imgSrc('board_zoom_base', imageURL);
}

/**
 * Launches construction popup.
 *
 * @param (String) pageURL
 */
function viewConstruction(pageURL) {

	var width = this.constructionWidth;
	var height = this.constructionHeight;

	window.open(pageURL,"BOARD_"+this.BSTY_ID,"location=0,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+width+",height="+height);
}

/**
 * Launches profile popup.
 *
 * @param (String) pageURL
 */
function viewProfile(pageURL) {

	var width = this.profileWidth;
	var height = this.profileHeight;

	window.open(pageURL,"BOARD_"+this.BSTY_ID,"location=0,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+width+",height="+height);

}

/**
 * Launches specs popup.
 *
 * @param (String) BSTY_ID
 */
function viewSpecs(BSTY_ID) {

	var width = this.specsWidth;
	var height = this.specsHeight;

	window.open(this.controllerURL+"?op=viewSpecsBOARD_STYLE&BSTY_ID="+this.BSTY_ID,"BOARD_"+this.BSTY_ID,"location=0,toolbar=0,status=0,menubar=0,scrollbars=0,resizable=1,width="+width+",height="+height);
}

/**
 * Launches tuning popup.
 *
 * @param (String) pageURL
 */
function viewTuning(pageURL) {

	var width = this.tuningWidth;
	var height = this.tuningHeight;

	window.open(pageURL,"BOARD_"+this.BSTY_ID,"location=0,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+width+",height="+height);
}

/**
 * Launches zoom popup.
 *
 * @param (String) BSTY_ID
 */
function viewZoom(BSTY_ID) {

var width = screen.availWidth;
	var height = screen.availHeight;

	window.open(this.controllerURL+"?op=viewZoomBOARD_STYLE&BSTY_ID="+this.BSTY_ID+"&BSBG_ID_TOPSHEET="+this.currentBSBG_ID_TOPSHEET+"&BSBG_ID_BASE="+this.currentBSBG_ID_BASE,"BOARD_"+this.BSTY_ID,"location=0,left=0,top=0,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+width+",height="+height);
}

/**
 * Launches video popup.
 *
 * @param (String) video
 */
function viewVideo(video) {

	var width = this.videoWidth;
	var height = this.videoHeight;

	window.open("p_ski_video.php?video="+video,"BOARD_"+this.BSTY_ID,"location=0,toolbar=0,status=0,menubar=0,scrollbars=0,resizable=0,width="+width+",height="+height);
}

} // end class
