/* Everite Door Co. web site Shared JavaScript (nnunn2008-03-24) */

// init main structure
var DesignCenter = new Object();
DesignCenter.door_id 		= null;		// door part
DesignCenter.door_type		= null;		// door type ("custom" or "semi-custom")
DesignCenter.door_img		= null;		// standard image for door_id
DesignCenter.top_id			= null;		// top part
DesignCenter.top_type		= null;		// top type ("wood" or "glass")
DesignCenter.top_img		= null;		// standard image for top_id
DesignCenter.grade			= null;		// grade (stain/paint)
DesignCenter.species		= null;		// type of wood
DesignCenter.inlay_panels	= null;		// inlay/panel option
DesignCenter.glass			= null;		// glass option
DesignCenter.single_or_dbl	= null;		// single/double door
DesignCenter.wide_feet		= null;		// door width (feet)
DesignCenter.wide_inches	= null;		// door width (inches)
DesignCenter.high_feet		= null;		// door height (feet)
DesignCenter.high_inches	= null;		// door height (inches)
DesignCenter.num_sections	= null;		// calculated number of door sections
DesignCenter.qty			= null;		// how many?
DesignCenter.no_hardware	= null;		// boolean: true if sections only (no track, hardware & springs)
DesignCenter.opt_stdtorsion	= null;		// option: standard torsion (disable if no hardware)
DesignCenter.opt_extsprings = null;		// option: extension springs (disable if no hardware)
DesignCenter.opt_insulate	= null;		// option: insulation
DesignCenter.opt_lowhead	= null;		// option: low head room
DesignCenter.spec_instr		= null;		// special instructions

DesignCenter.cached			= null;		// temp cache
DesignCenter.stdlog			= null;		// debug log

/*  .___________________________.
   / Defaults                   |
._/_____________________________!_________________________________________.   */

// output runtime trace log?
var debug_trace 		= true;

var defaults = new Object();
defaults.door_id 		= "Cambria";
defaults.door_type 		= "custom";
defaults.top_id 		= "SQ12";
defaults.top_type 		= "square-glass";
defaults.grade 			= "stain_grade";
defaults.single_or_dbl 	= "single_door";
defaults.qty 			= "1";
defaults.no_hardware 	= false;
defaults.opt_stdtorsion = false;
defaults.opt_extsprings = false;
defaults.opt_insulate 	= false;
defaults.opt_lowhead 	= false;

/*  .___________________________.
   / Images: Doors              |
._/_____________________________!_________________________________________.   */

// setup image arrays
// format is [door-id, thumbnail-imgsrc, large-imgsrc]

// doors: semi-custom
var semi_imgs = new Array();
semi_imgs[0] = ["Bradford", "images/doors/semi_bradford_th.jpg", "images/doors/semi_bradford.jpg"];
semi_imgs[1] = ["Susquehanna", "images/doors/semi_susquehanna_th.jpg", "images/doors/semi_susquehanna.jpg"];
semi_imgs[2] = ["Butler", "images/doors/semi_butler_th.jpg", "images/doors/semi_butler.jpg"];
semi_imgs[3] = ["Clearfield", "images/doors/semi_clearfield_th.jpg", "images/doors/semi_clearfield.jpg"];
semi_imgs[4] = ["Bucks", "images/doors/semi_bucks_th.jpg", "images/doors/semi_bucks.jpg"];
semi_imgs[5] = ["Chester", "images/doors/semi_chester_th.jpg", "images/doors/semi_chester.jpg"];
semi_imgs[6] = ["Allegheny", "images/doors/semi_allegheny_th.jpg", "images/doors/semi_allegheny.jpg"];

// doors: custom
var cust_imgs = new Array();
cust_imgs[0] = ["Lancaster", "images/doors/cust_lancaster_th.jpg", "images/doors/cust_lancaster.jpg"];
cust_imgs[1] = ["York", "images/doors/cust_york_th.jpg", "images/doors/cust_york.jpg"];
cust_imgs[2] = ["Cambria", "images/doors/cust_cambria_th.jpg", "images/doors/cust_cambria.jpg"];
cust_imgs[3] = ["Cameron", "images/doors/cust_cameron_th.jpg", "images/doors/cust_cameron.jpg"];
cust_imgs[4] = ["Huntingdon", "images/doors/cust_huntingdon_th.jpg", "images/doors/cust_huntingdon.jpg"];
cust_imgs[5] = ["Clarion", "images/doors/cust_clarion_th.jpg", "images/doors/cust_clarion.jpg"];
cust_imgs[6] = ["Franklin", "images/doors/cust_franklin_th.jpg", "images/doors/cust_franklin.jpg"];
cust_imgs[7] = ["Jefferson", "images/doors/cust_jefferson_th.jpg", "images/doors/cust_jefferson.jpg"];
cust_imgs[8] = ["Cumberland", "images/doors/cust_cumberland_th.jpg", "images/doors/cust_cumberland.jpg"];

/*  .___________________________.
   / Images: Tops               |
._/_____________________________!_________________________________________.   */

// tops: square-glass
var sq_glass_imgs = new Array();
sq_glass_imgs[0] = ["SQ6", "images/doors_tops/SQ6_th.jpg", "images/doors_tops/SQ6.jpg"];
sq_glass_imgs[1] = ["SQ8", "images/doors_tops/SQ8_th.jpg", "images/doors_tops/SQ8.jpg"]; 
sq_glass_imgs[2] = ["SQ12", "images/doors_tops/SQ12_th.jpg", "images/doors_tops/SQ12.jpg"];
sq_glass_imgs[3] = ["SQ16", "images/doors_tops/SQ16_th.jpg", "images/doors_tops/SQ16.jpg"];

// tops: square-solid
var sq_solid_imgs = new Array();
sq_solid_imgs[0] = ["SQ2P", "images/doors_tops/SQ2P_th.jpg", "images/doors_tops/SQ2P.jpg"];
sq_solid_imgs[1] = ["SQ4P", "images/doors_tops/SQ4P_th.jpg", "images/doors_tops/SQ4P.jpg"];
sq_solid_imgs[2] = ["SQ6P", "images/doors_tops/SQ6P_th.jpg", "images/doors_tops/SQ6P.jpg"];
sq_solid_imgs[3] = ["SQ8P", "images/doors_tops/SQ8P_th.jpg", "images/doors_tops/SQ8P.jpg"];

// tops: arched-glass
var ar_glass_imgs = new Array();
ar_glass_imgs[0] = ["AR6", "images/doors_tops/AR6_th.jpg", "images/doors_tops/AR6.jpg"];
ar_glass_imgs[1] = ["AR8", "images/doors_tops/AR8_th.jpg", "images/doors_tops/AR8.jpg"];
ar_glass_imgs[2] = ["AR12", "images/doors_tops/AR12_th.jpg", "images/doors_tops/AR12.jpg"];
ar_glass_imgs[3] = ["AR16", "images/doors_tops/AR16_th.jpg", "images/doors_tops/AR16.jpg"];

// tops: arched-solid
var ar_solid_imgs = new Array();
ar_solid_imgs[0] = ["AR2P", "images/doors_tops/AR2P_th.jpg", "images/doors_tops/AR2P.jpg"];
ar_solid_imgs[1] = ["AR4P", "images/doors_tops/AR4P_th.jpg", "images/doors_tops/AR4P.jpg"];
ar_solid_imgs[2] = ["AR6P", "images/doors_tops/AR6P_th.jpg", "images/doors_tops/AR6P.jpg"];
ar_solid_imgs[3] = ["AR8P", "images/doors_tops/AR8P_th.jpg", "images/doors_tops/AR8P.jpg"];

// tops: everite
var everite_imgs = new Array();
everite_imgs[0] = ["EV1", "images/doors_tops/EV01_th.jpg", "images/doors_tops/EV01.jpg"];
everite_imgs[1] = ["EV2", "images/doors_tops/EV02_th.jpg", "images/doors_tops/EV02.jpg"];
everite_imgs[2] = ["EV3", "images/doors_tops/EV03_th.jpg", "images/doors_tops/EV03.jpg"];
everite_imgs[3] = ["EV4", "images/doors_tops/EV04_th.jpg", "images/doors_tops/EV04.jpg"];

/*  .___________________________.
   / Images: Utils              |
._/_____________________________!_________________________________________.   */

// preload: images in this array are processed by the image preloader when doc is loaded
var preload_imgs = new Array();
preload_imgs.concat("images/doors/cust_cambria_4.jpg", 
                    "images/doors/cust_cameron_4.jpg",
					"images/doors/cust_clarion_4.jpg",
					"images/doors/cust_huntingdon_4.jpg",
					"images/doors/cust_lancaster_4.jpg",
					"images/doors/cust_york_4.jpg",
					"images/doors/semi_allegheny_4.jpg",
					"images/doors/semi_bucks_4.jpg",
					"images/doors/semi_chester_4.jpg",
					"images/doors/cust_cambria_6.jpg",
					"images/doors/cust_cameron_6.jpg",
					"images/doors/cust_clarion_6.jpg",
					"images/doors/cust_huntingdon_6.jpg",
					"images/doors/cust_lancaster_6.jpg",
					"images/doors/cust_york_6.jpg",
					"images/doors/semi_allegheny_6.jpg",
					"images/doors/semi_bucks_6.jpg",
					"images/doors/semi_chester_6.jpg");

//
//
function theImageSet(set_id) {
  switch(set_id) {
    case "semi-custom":		return semi_imgs;
    case "custom":			return cust_imgs;
    case "square-glass":	return sq_glass_imgs;
    case "square-solid":	return sq_solid_imgs;
    case "arched-glass":	return ar_glass_imgs;
    case "arched-solid":	return ar_solid_imgs;
    case "everite":			return everite_imgs;
  }
}

//
//
function theTopType(set_id) {
  switch(set_id) {
	  case "square-glass":
	  case "arched-glass":
	  case "everite":
		return "glass";
	  
	  case "square-solid":
	  case "arched-solid":
		return "wood";
  }
}

/*  .___________________________.
   / Misc Options               |
._/_____________________________!_________________________________________.   */

var styles_stain = new Object();
styles_stain["stain_grade"] = "Stain Grade";
styles_stain["paint_grade"] = "Paint Grade";

var measure = new Object();
measure.inches = ["0\"", "1\"", "2\"", "3\"", "4\"", "5\"", "6\"", "7\"", "8\"", "9\"", "10\"", "11\""];

measure.singleWide = ["8\'", "9\'", "10\'"];
measure.doubleWide = ["10\'", "11\'", "12\'", "13\'", "14\'", "15\'", "16\'", "17\'", "18\'"];

measure.bothHeight = ["7\'", "8\'", "9\'", "10\'"];

var styles_glass = ["1/8\" Clear DBS",
					"1/8\" Clear Tempered",
					"7/16\" Clear Insulated",
					"1/2\" Insulated Tempered",
					"1/8\" Bronze Non Tempered",
					"3/16\" Rain Glass Non Tempered",
					"1/4\" Mirror Glass (one way)",
					"1/8\" Pattern Obscure Glass"
					];

/*  .___________________________.
   / Trim Options               |
._/_____________________________!_________________________________________.   */

// options: overlay/trim
var styles_trim = ["Clear Hemlock",								//  0
                   "Clear Meranti",								//  1
                   "Clear Radiata Pine",						//  2
                   "Clear Yellow Poplar",						//  3
                   "Clear Meranti",								//  4
                   "Clear Sapele Mahogany",						//  5
                   "Clear Western Red Cedar",					//  6
                   "Clear Spanish Cedar",						//  7
				   "Finger Jointed Hemlock", 					//  8
				   "Clear Yellow Poplar Overlay",				//  9
				   "Paint Grade Not Available"					// 10
				  ];

//
// given a door name & coating, returns a list of overlay/trim options
//
function theTrimStyle(paint_stain, door_name) {
  var styles_out = [];

  switch(paint_stain) {
  
    //
    case "stain_grade":
      switch(door_name) {
      
		case "Allegheny":
		case "Bradford":
		case "Bucks":
		case "Butler":
		case "Chester":
		case "Clearfield":
		case "Susquehanna":
		  styles_out = [0, 1];
		  break;
   
		case "Cambria":
		case "Cameron":
		case "Clarion":
		case "Cumberland":
		case "Franklin":
		case "Huntingdon":
		case "Jefferson":
		case "Lancaster":
		case "York":
		  styles_out = [2, 0, 3, 1, 5, 6, 7]; 
		  break;
      }
      break;

    //
    case "paint_grade":
      switch(door_name) {
      
		case "Allegheny":
		case "Bradford":
		case "Bucks":
		case "Butler":
		case "Chester":
		case "Clearfield":
		case "Susquehanna":
		  styles_out = [8];
		  break;

		case "Cambria":
		case "Cameron":
		case "Clarion":
		case "Franklin":
		case "Huntingdon":
		case "Jefferson":
		case "Lancaster":
		case "York":
		  styles_out = [9];
		  break;

		case "Cumberland":
		  styles_out = [10];
		  break;
      }
      break;

    //
    case "prime_regardless":
      switch(door_name) {
      
		case "Allegheny":
		case "Bradford":
		case "Bucks":
		case "Butler":
		case "Chester":
		case "Clearfield":
		case "Susquehanna":
		  styles_out = [8, 0];
		  break;
		  
		case "Cambria":
		case "Cameron":
		case "Clarion":
		case "Franklin":
		case "Huntingdon":
		case "Jefferson":
		case "Lancaster":
		case "York":
		  styles_out = [9, 2, 0, 3];
		  break;

		case ("Cumberland"):
		  styles_out = [10];
		  break;
      }
      break;
  }

  return styles_out;
}

/*  .___________________________.
   / Panel Options              |
._/_____________________________!_________________________________________.   */

var styles_panels = ["1/4\" Clear Luan Plywood",	// 0
					 "3/4\" Clear Hemlock",			// 1
					 "3/4\" Clear Meranti",			// 2
					 "3/4\" Clear Raised Hemlock",	// 3
					 "3/4\" Clear Raised Meranti",	// 4
					 "3/4\" Smooth Matching Overlay",	// 5
					 "3/4\" Clear Hemlock 4\" Tongue & Groove",	// 6
					 "3/4\" Clear Meranti 6\" Tongue & Groove", // 7
					 "3/4\" Clear Meranti 4\" Tongue & Groove",	// 8
					 "4\" Tongue & Groove",		// 9
					 "6\" Tongue & Groove",		// 10
					 "Clear Raised Panels with Matching Overlay",	// 11
					 "1/2\" Extera Marine Grade MDF",	// 12
					 "1/2\" Extera Marine Grade MDF 6\" V-Groove",	// 13
					 "1/2\" Extera Marine Grade MDF 4\" V-Groove.",	// 14
					 "MDF with Clear Yellow Poplar Overlay - Smooth",	// 15
					 "MDF 4\" V-Groove",		// 16
					 "MDF 6\" V-Groove",		// 17
					 "MDF Smooth",					// 18
					 "Paint Grade Not Available"	// 19
					];

//
// given a door name & coating, returns a list of inlay/panel options
//
function thePanelStyle(paint_stain, door_name) {
  var styles_out = [];
  
  switch(paint_stain) {
  
    //
    case "paint_grade":
      switch(door_name) {
      
		case "Bradford":
		case "Susquehanna":
		  styles_out = [0];
		  break;
		  
		case "Butler":
		case "Clearfield":
		  styles_out = [3];
		  break;
		  
		case "Chester":
		case "Bucks":
		  styles_out = [0, 16, 17];
		  break;

		case "Allegheny":
		  styles_out = [16, 17];
		  break;

		case "Lancaster":
		case "York":
		case "Cameron":
		case "Huntingdon":
		case "Clarion":
		  styles_out = [0, 16, 17];
		  break;

		case ("Cambria"):
		case ("Cumberland"):
		  styles_out = [16, 17];
		  break;

		case "Franklin":
		case "Jefferson":
		  styles_out = [11];
		  break;
      }
      break;

    //
    case "stain_grade":
      switch(door_name) {
      
		case "Bradford":
		case "Susquehanna":
		  styles_out = [0, 1, 2];
		  break;

		case "Butler":
		case "Clearfield":
		  styles_out = [3, 4];
		  break;

		case "Bucks":
		case "Chester":
		  styles_out = [0, 9];
		  break;

		case ("Allegheny"):
		  styles_out = [9];
		  break;

		case "Lancaster":
		case "York":
		  styles_out = [0, 9];
		  break;

		case ("Cambria"):
		  styles_out = [9];
		  break;

		case "Cameron":
		case "Huntingdon":
		case "Clarion":
		  styles_out = [5, 9];
		  break;

		case "Franklin":
		case "Jefferson":
		  styles_out = [11];
		  break;

		case ("Cumberland"):
		  styles_out = [9];
		  break;
      }
      break;

    //
    case "prime_regardless":
      switch(door_name) {
		case "Bradford":
		case "Susquehanna":
		  styles_out = [0, 12, 1];
		  break;

		case "Butler":
		case "Clearfield":
		  styles_out = [3];
		  break;

		case "Bucks":
		case "Chester":
		  styles_out = [0, 1, 12, 13, 14, 5, 6];
		  break;
		
		case ("Allegheny"):
		  styles_out = [13, 14, 5, 6];
		  break;

		case "Lancaster":
		case "York":
		  styles_out = [15, 16, 17, 0, 9, 10];
		  break;

		case ("Cambria"):
		  styles_out = [16, 17, 9, 10];
		  break;

		case "Cameron":
		case "Huntingdon":
		case "Clarion":
		  styles_out = [15, 16, 17, 0, 9, 10];
		  break;
		  
		case "Franklin":
		case "Jefferson":
		  styles_out = [11];
		  break;

		case ("Cumberland"):
		  styles_out = [19];
		  break;
	  }
	  break;
  }
  
  return styles_out;
}

/*  .___________________________.
   / Door Images                |
._/_____________________________!_________________________________________.   */

// given an set_id & img_id, returns image src
// set set_id as 'top' to search all top sets, or 'btm' for all main door sets
// set is_thumb true to receive small image, or false for large image
// returns image src
//
function stdPanelImage(set_id, img_id, is_thumb) {

  // special handler for cumberland
  if (img_id == "Cumberland-TOP") { return "images/doors_tops/topCUMBERLAND.jpg"; }

  // which image sets to search?
  var seq = new Array();
  if (set_id == "btm") {
    seq = ["semi-custom", "custom"];
  } else if (set_id == "top") {
    seq = ["square-glass", "square-solid", "arched-glass", "arched-solid", "everite"];
  } else {
    seq = [set_id];
  }

  // find & return the specified image
  for (var s = 0; s < seq.length; s++) {
    var img_set = theImageSet(seq[s]);
	for (var i = 0; i < img_set.length; i++) {
	  if (img_set[i][0] == img_id) {
		return (is_thumb ? img_set[i][1] : img_set[i][2]);
	  }
	}
  }  
} // stdPanelImage()

// given a door_name, stain_grade & panel_style
// returns optional door image src
//
function optPanelImage(stain_grade, panel_style, door_name) {
//  alert("optPanelImage(): " + stain_grade + ", " + panel_style + ", " + door_name);

  // special handler for cumberland 
  if (door_name == "Cumberland") { return "images/doors/cust_cumberland.jpg"; }
  
  // we begin with standard image for this door
  var xform_img = stdPanelImage("btm", door_name, false);
  
  // pick an alternate 4 section door image?
  if (DesignCenter.num_sections == 4) {
  
    switch (DesignCenter.door_id) {
    
      case "Allegheny":
      case "Bradford":
      case "Bucks":
      case "Butler":
      case "Chester":
      case "Clearfield":
      case "Susquehanna":
        var dotidx = xform_img.indexOf(".jpg");
		xform_img = xform_img.substr(0, dotidx) + "4s.jpg";
		break;
    }
  }
  
  // pick an alternate panel image for this door?
  switch (panel_style) {
  
    // use custom 6" panel image
  	case styles_panels[7]:
  	case styles_panels[10]:
  	case styles_panels[13]:
  	case styles_panels[17]:
  	  var dotidx = xform_img.indexOf(".jpg");
  	  xform_img = xform_img.substr(0, dotidx) + "_6.jpg";
  	  break;

    // use custom 4" panel image
  	case styles_panels[6]:
  	case styles_panels[8]:
  	case styles_panels[9]:
  	case styles_panels[14]:
  	case styles_panels[16]:
  	  var dotidx = xform_img.indexOf(".jpg");
  	  xform_img = xform_img.substr(0, dotidx) + "_4.jpg";
  	  break;
  }

//  alert("optPanelImage() >> " + xform_img);
  return xform_img;

} // optPanelImage()

//
//
function preload_images() {
	if (document.images)
		{
			image_array = new Array();
			image_array[0] = "images/doors/semi_bradford_th.jpg";
			image_array[1] = "images/doors/semi_bradford.jpg";
			image_array[2] = "images/doors/semi_susquehanna_th.jpg";
			image_array[3] = "images/doors/semi_susquehanna.jpg";
			image_array[4] = "images/doors/semi_butler_th.jpg";
			image_array[5] = "images/doors/semi_butler.jpg";
			image_array[6] = "images/doors/semi_clearfield_th.jpg";
			image_array[7] = "images/doors/semi_clearfield.jpg";
			image_array[8] = "images/doors/semi_bucks_th.jpg";
			image_array[9] = "images/doors/semi_bucks.jpg";
			image_array[10] = "images/doors/semi_chester_th.jpg";
			image_array[11] = "images/doors/semi_chester.jpg";
			image_array[12] = "images/doors/semi_allegheny_th.jpg";
			image_array[13] = "images/doors/semi_allegheny.jpg";
			image_array[14] = "images/doors/cust_lancaster_th.jpg";
			image_array[15] = "images/doors/cust_lancaster.jpg";
			image_array[16] = "images/doors/cust_york_th.jpg";
			image_array[17] = "images/doors/cust_york.jpg";
			image_array[18] = "images/doors/cust_cambria_th.jpg";
			image_array[19] = "images/doors/cust_cambria.jpg";
			image_array[20] = "images/doors/cust_cameron_th.jpg";
			image_array[21] = "images/doors/cust_cameron.jpg";
			image_array[22] = "images/doors/cust_huntingdon_th.jpg";
			image_array[23] = "images/doors/cust_huntingdon.jpg";
			image_array[24] = "images/doors/cust_clarion_th.jpg";
			image_array[25] = "images/doors/cust_clarion.jpg";
			image_array[26] = "images/doors/cust_franklin_th.jpg";
			image_array[27] = "images/doors/cust_franklin.jpg";
			image_array[28] = "images/doors/cust_jefferson_th.jpg";
			image_array[29] = "images/doors/cust_jefferson.jpg";
			image_array[30] = "images/doors/cust_cumberland_th.jpg";
			image_array[31] = "images/doors/cust_cumberland.jpg";
			image_array[32] = "images/doors_tops/SQ6_th.jpg";
			image_array[33] = "images/doors_tops/SQ6.jpg";
			image_array[34] = "images/doors_tops/SQ8_th.jpg";
			image_array[35] = "images/doors_tops/SQ8.jpg";
			image_array[36] = "images/doors_tops/SQ12_th.jpg";
			image_array[37] = "images/doors_tops/SQ12.jpg";
			image_array[38] = "images/doors_tops/SQ16_th.jpg";
			image_array[39] = "images/doors_tops/SQ16.jpg";
			image_array[40] = "images/doors_tops/SQ2P_th.jpg";
			image_array[41] = "images/doors_tops/SQ2P.jpg";
			image_array[42] = "images/doors_tops/SQ4P_th.jpg";
			image_array[43] = "images/doors_tops/SQ4P.jpg";
			image_array[44] = "images/doors_tops/SQ6P_th.jpg";
			image_array[45] = "images/doors_tops/SQ6P.jpg";
			image_array[46] = "images/doors_tops/SQ8P_th.jpg";
			image_array[47] = "images/doors_tops/SQ8P.jpg";
			image_array[48] = "images/doors_tops/AR6_th.jpg";
			image_array[49] = "images/doors_tops/AR6.jpg";
			image_array[50] = "images/doors_tops/AR12_th.jpg";
			image_array[51] = "images/doors_tops/AR12.jpg";
			image_array[52] = "images/doors_tops/AR16_th.jpg";
			image_array[53] = "images/doors_tops/AR16.jpg";
			image_array[54] = "images/doors_tops/AR2P_th.jpg";
			image_array[55] = "images/doors_tops/AR2P.jpg";
			image_array[56] = "images/doors_tops/AR4P_th.jpg";
			image_array[57] = "images/doors_tops/AR4P.jpg";
			image_array[58] = "images/doors_tops/AR6P_th.jpg";
			image_array[59] = "images/doors_tops/AR6P.jpg";
			image_array[60] = "images/doors_tops/AR8P_th.jpg";
			image_array[61] = "images/doors_tops/AR8P.jpg";
			image_array[62] = "images/doors_tops/EV01_th.jpg";
			image_array[63] = "images/doors_tops/EV01.jpg";
			image_array[64] = "images/doors_tops/EV02_th.jpg";
			image_array[65] = "images/doors_tops/EV02.jpg";
			image_array[66] = "images/doors_tops/EV03_th.jpg";
			image_array[67] = "images/doors_tops/EV03.jpg";
			image_array[68] = "images/doors_tops/EV04_th.jpg";
			image_array[69] = "images/doors_tops/EV04.jpg";
			
			image_array[70] = "images/doors/cust_cambria_4.jpg";
			image_array[71] = "images/doors/cust_cameron_4.jpg";
			image_array[72] = "images/doors/cust_clarion_4.jpg";
			image_array[73] = "images/doors/cust_huntingdon_4.jpg";
			image_array[74] = "images/doors/cust_lancaster_4.jpg";
			image_array[75] = "images/doors/cust_york_4.jpg";
			image_array[76] = "images/doors/semi_allegheny_4.jpg";
			image_array[77] = "images/doors/semi_bucks_4.jpg";
			image_array[78] = "images/doors/semi_chester_4.jpg";
			image_array[79] = "images/doors/cust_cambria_6.jpg";
			image_array[80] = "images/doors/cust_cameron_6.jpg";
			image_array[81] = "images/doors/cust_clarion_6.jpg";
			image_array[82] = "images/doors/cust_huntingdon_6.jpg";
			image_array[83] = "images/doors/cust_lancaster_6.jpg";
			image_array[84] = "images/doors/cust_york_6.jpg";
			image_array[85] = "images/doors/semi_allegheny_6.jpg";
			image_array[86] = "images/doors/semi_bucks_6.jpg";
			image_array[87] = "images/doors/semi_chester_6.jpg";

			image_array[88] = "images/doors/semi_allegheny4s_4.jpg";
			image_array[89] = "images/doors/semi_allegheny4s_6.jpg";
			image_array[90] = "images/doors/semi_allegheny4s.jpg";
			image_array[91] = "images/doors/semi_bradford4s.jpg";
			image_array[92] = "images/doors/semi_bucks4s_4.jpg";
			image_array[93] = "images/doors/semi_bucks4s_6.jpg";
			image_array[94] = "images/doors/semi_bucks4s.jpg";
			image_array[95] = "images/doors/semi_butler4s.jpg";
			image_array[96] = "images/doors/semi_chester4s_4.jpg";
			image_array[97] = "images/doors/semi_chester4s_6.jpg";
			image_array[98] = "images/doors/semi_chester4s.jpg";
			image_array[99] = "images/doors/semi_clearfield4s.jpg";
			image_array[100] = "images/doors/semi_susquehanna4s.jpg";
			
			image_array[101] = "images/doors_tops/topCUMBERLAND.jpg";			

			preload_image_object = new Image(); 
			var i = 0;
       			for(i=0; i<=image_array.length; i++) 
				{
         				preload_image_object.src = image_array[i];
				}		

		}
}

// output HTML string segment w/ option input tags
//	in_array	- an atomic array of values (values whose position/index do not
//				appear in 'idx_list' are ignored and not output).
//  idx_list 	- an array of numeric indexes into 'in_array' which should be 
//				included in the option list output. optionally, if 'idx_list' is 
//				set as boolean value 'true' all 'in_array' values are output.
//  'select_id' is the selected/active value. if null, then not considered.
//
function theOptionsList(in_array, idx_list, select_id) {
  var all_mode = ((typeof(idx_list) == "boolean") && (idx_list = true) ? true : false);
  var focal_point = (all_mode ? in_array : idx_list);
  var out = "";
  var t_val;
  for (var i = 0; i < focal_point.length; i++) {
    t_val = (all_mode ? in_array[i] : in_array[idx_list[i]]);
	out += "<option value=\"" + t_val.replace("\"", "&quot;") + "\""
				+ ((select_id != null) && (select_id == t_val) ? " selected" : "") + ">"
				+ t_val + "</option>";
  }
  return out;
}

// given a door height, returns number of sections
//
function computeSections(high_feet, high_inches) {
//   alert("computeSections():"
//   			+ "\n.high_feet= " + high_feet
//   			+ "\n.high_inches= " + high_inches);

  var num_sections = 3;
  if ( ((high_feet == 7) && (high_inches >= 4)) || (high_feet > 7) ) {
    num_sections = 4;
  }
  return num_sections;
}

//
//
function setDoorPreview(scale_down) {
//  alert("setDoorPreview():\n" + dcDebugOut());
  
  // set top img
  if (DesignCenter.top_id != null) {
  
    DesignCenter.top_img = stdPanelImage("top", DesignCenter.top_id, false);
    document.mainDoorTopLeft.src = DesignCenter.top_img;
    if (document.mainDoorTopRight) { document.mainDoorTopRight.src = DesignCenter.top_img; }
  }
  
  // set door img
  if (DesignCenter.door_id != null) {

    var s4 = ((DesignCenter.num_sections == 4) && (DesignCenter.door_id != "Cumberland"));
	var h1 = ((scale_down == true) ? 102 : 154);
	var h2 = ((scale_down == true) ? 139 : 211);
  
    DesignCenter.door_img = optPanelImage(DesignCenter.grade, DesignCenter.inlay_panels, DesignCenter.door_id);
    document.mainDoorBottomLeft.src = DesignCenter.door_img;
    document.mainDoorBottomLeft.style.height = ( s4 == true ? h2 : h1) + "px";
    		
    if (document.mainDoorBottomRight) { 
      document.mainDoorBottomRight.src = DesignCenter.door_img; 
      document.mainDoorBottomRight.style.height = ( s4 == true ? h2 : h1) + "px";
    }

  }
}

//
function dcDebugOut() {
  return ("DesignCenter"
  			+ "\n.door_id= " + DesignCenter.door_id
  			+ "\n.door_type= " + DesignCenter.door_type
  			+ "\n.door_img= " + DesignCenter.door_img
  			+ "\n.top_id= " + DesignCenter.top_id
  			+ "\n.top_type= " + DesignCenter.top_type
  			+ "\n.top_img= " + DesignCenter.top_img
  			+ "\n.grade= " + DesignCenter.grade
  			+ "\n.species= " + DesignCenter.species
  			+ "\n.inlay_panels= " + DesignCenter.inlay_panels
  			+ "\n.glass= " + DesignCenter.glass
  			+ "\n.single_or_dbl= " + DesignCenter.single_or_dbl
  			+ "\n.wide_feet= " + DesignCenter.wide_feet
  			+ "\n.wide_inches= " + DesignCenter.wide_inches
  			+ "\n.high_feet= " + DesignCenter.high_feet
  			+ "\n.high_inches= " + DesignCenter.high_inches
  			+ "\n.num_sections= " + DesignCenter.num_sections
  			+ "\n.qty= " + DesignCenter.qty
  			+ "\n.no_hardware= " + DesignCenter.no_hardware
  			+ "\n.opt_stdtorsion= " + DesignCenter.opt_stdtorsion
  			+ "\n.opt_extsprings= " + DesignCenter.opt_extsprings
  			+ "\n.opt_insulate= " + DesignCenter.opt_insulate
  			+ "\n.opt_lowhead= " + DesignCenter.opt_lowhead
  			+ "\n.spec_instr= " + DesignCenter.spec_instr);
}
             /*.___________________________.
              / Revision History    v1.0d1 |
.____________/_____________________________!__________________________________. 

nnunn2008-06-20:
- fix bug which broke door height resize

nnunn2008-06-10:
- fix bug in theOptionsList() where ' were dropped from values
- add theTopType()
- revise optPanelImage() to return special 4-section door images

nnunn2008-05-28:
- add stdPanelImage()

marco2008-04-10:
- modified inch and feet qutation marks
- revised glass options

nnunn2008-03-31:
- add computeSections()

nnunn2008-03-29:
- theOptionsList() now supports a current 'select_id', and will output all input array values if 'idx_list' is set to boolean 'true'

marco2008-03-27:
- updated door specific panel options

nnunn2008-03-26:
- add optPanelImage()

marco2008-03-25:
- updated styles_panels select list labels
- updated thePanelStyle door specific options by number
- swapped door specific options for paint and stain grade in thePanelStyle
- commented out Prime Regardless select option
- modified styles_trim label for item 9 (removed 1/2" MDF)

nnunn2008-03-22:
- serious housecleaning
- add styles_trim[], theTrimStyle()
- add styles_panels[], thePanelStyle()
- add theOptionsList()

nnunn2008-03-20:
- validation checks in submitQuote()

v1.0d1
nnunn2008-03-24:
- import relevant sources from designcenter.js
- init
*/