// Bedding counting program
// (c) 2004-2009 Baby SuperMall, LLC
// all rights reserved
///////////////////////////////////////////////////////////
//  Date            Modified By    Description
//  ----------      -----------    -------------------------------------------------------
//  12/28/2005	    DAS		   Added logic to highlight "View these" and "Clear Selections" Buttons.
//  08/21/2008	    DAS		   Added brandBX to accomodate subbrands.
//  12/30/2008	    SR		   Updated bedding finders to work from cookies, no longer cache.
//  01/19/2008	    SR		   Changed function load to Load_Bedding_Finder
//  01/23/2008      SR	   	   Fixed the Load_Bedding_Finder function so it loads all the filters
//  05/05/2009      SR	   	   Updated showbutton and resetbutton. Updated TotalOn, TotalOff, TotalMix functions
///////////////////////////////////////////////////////////
 // Product lookup table: each column is a product
 // --- BEGIN (AUTOMATIC) --- 
	var skus = 462;
	var homes = 366;
	var timestamp = 1257290471;
	genX =    new Array (3,3,3,2,3,2,3,3,3,3,2,3,2,3,2,2,3,2,2,3,2,2,3,2,2,1,1,2,2,1,3,2,3,1,2,2,1,1,2,3,2,2,3,2,3,1,3,3,3,3,3,1,1,2,3,3,2,1,2,2,3,3,1,2,3,3,2,2,3,2,3,3,1,3,2,1,2,3,3,2,2,3,2,1,1,2,3,2,1,1,2,3,3,2,2,2,3,3,3,3,1,3,2,2,3,2,1,2,2,2,1,2,3,3,1,3,1,3,3,1,2,1,3,2,1,2,3,1,2,2,1,1,2,2,3,2,1,2,3,3,1,2,3,1,2,2,3,1,2,3,2,2,2,2,2,1,2,1,1,1,2,2,3,1,2,2,3,3,3,3,3,3,3,3,3,1,3,2,2,2,3,3,3,3,3,3,3,3,3,3,2,2,2,3,3,3,2,2,2,3,2,2,2,3,3,3,2,2,2,3,3,3,3,3,3,3,3,3,2,2,2,3,3,3,2,2,2,1,1,2,3,3,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,2,2,2,2,3,3,3,2,2,2,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,1,2,2,2,2,2,2,2,2,1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2,2,2,1,1,1,1,2,2,2,2,2,2,2,2,1,4,4,4,4,4,3,3,3,2,2,2);
	brandX =  new Array (1,1,1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,25,25,25,25,25,25,25,25,25,25,25);
	brandBX =  new Array (0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);

	homeX = new Array (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,166,166,167,167,167,168,168,168,169,170,171,171,171,172,172,172,173,173,173,174,174,174,175,176,176,176,177,177,177,178,178,178,179,180,180,180,181,181,181,182,182,182,183,183,183,184,184,184,185,185,185,186,186,186,187,187,187,188,188,188,189,189,190,191,192,193,194,194,194,195,195,195,196,196,196,197,197,198,198,198,199,199,199,200,201,201,201,202,202,202,203,204,204,204,205,205,205,206,206,206,207,207,207,208,208,208,209,209,209,210,211,211,211,212,212,212,213,213,213,214,214,214,215,215,215,216,217,218,219,220,221,221,221,222,223,223,223,224,224,224,225,225,225,226,226,226,227,227,227,228,228,228,229,229,229,230,230,230,231,231,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365);

var bedding_cookie = "bedding-I-finder";
 // --- END (AUTOMATIC) --- 

var total;
var found;
var choices="";
var homes_found = new Array(homes);
var last_less = "";
var last_more = "";

// -----------------

function tally(i) {
 home = homeX[i];

 if (homes_found[home]) {return;}  // count homes once
 homes_found[home] = true;

 total++;
 found=found+home+",";
}

 var hard = new Array('gen', 'when', 'less', 'more', 'color', 'brand', 'theme1', 'theme2', 'theme3', 'theme4');
 var filters = hard;
 
function createCookie(name,value) {
	document.cookie = name+"="+value+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') { c = c.substring(1,c.length); }
		if (c.indexOf(nameEQ) === 0) { return c.substring(nameEQ.length,c.length); }
	}
	return null;
}

function Clear() {
	// clear all previous selections
	document.getElementById("BeddingSelect").reset();
}
		
function Load_Bedding_Finder() {
	filters = hard;
	cookie = readCookie(bedding_cookie);
	if (cookie === null) {
		loaded = true;
		this.UpdateTotal();
		return;
	} 
	else {
		var ca = cookie.split('|');
		for(var i=0;i < ca.length;i++) {
			var instance = ca[i].split(":");
			id = instance[0];
			value = instance[1];
			document.getElementById(id).selectedIndex = value;
		}
		loaded = true;
		this.UpdateTotal();
	}
}

function UpdateTotal () {
 // more friendly vars
 var gen = document.getElementById("gen").value;
 var when = document.getElementById("when").value;
 var less = document.getElementById("less").value;
 var more = document.getElementById("more").value;
 var color = document.getElementById("color").value;
 var brand = document.getElementById("brand").value;
 var theme1 = document.getElementById("theme1").value;
 var theme2 = document.getElementById("theme2").value;
 var theme3 = document.getElementById("theme3").value;
 var theme4 = document.getElementById("theme4").value;

 cookie = "";
 for (i=0; i<= filters.length -1; i++) {
	 if (cookie == "") { 
		cookie += document.getElementById(filters[i]).id + ":" + document.getElementById(filters[i]).selectedIndex; 
	 }
	 else { 
		cookie += "|" + document.getElementById(filters[i]).id + ":" + document.getElementById(filters[i]).selectedIndex; 
	 }
 }
 createCookie(bedding_cookie, cookie);
 
 // error check less and more
 if (less!=last_less && (less==1 && more >=2 || less==2 && more >=3 || less==3 && more >=4)) {
   document.getElementById("more").value = 0;
   more=0;
 }
 else {
  if (more!=last_more && (less==1 && more >=2 || less==2 && more >=3 || less==3 && more >=4)) {
   document.getElementById("less").value = 0;
   less=0;
  }
 }

 last_less = less;
 last_more = more;

 choices = gen+","+when+","+less+","+more+","+color+","+brand+","+theme1+","+theme2+","+theme3+","+theme4;

 var FormIsReset = true;
 if (gen+when+less+more+color+brand+theme1+theme2+theme3+theme4 > 0) {FormIsReset = false;}

 document.getElementById("gen").style.background = (gen > 0) ? "#FFFFCC" : "#FFFFFF";
 document.getElementById("when").style.background = (when > 0) ? "#FFFFCC" : "#FFFFFF";
 document.getElementById("less").style.background = (less > 0) ? "#FFFFCC" : "#FFFFFF";
 document.getElementById("more").style.background = (more > 0) ? "#FFFFCC" : "#FFFFFF";
 document.getElementById("color").style.background = (color > 0) ? "#FFFFCC" : "#FFFFFF";
 document.getElementById("brand").style.background = (brand > 0) ? "#FFFFCC" : "#FFFFFF";
 document.getElementById("theme1").style.background = (theme1 > 0) ? "#FFFFCC" : "#FFFFFF";
 document.getElementById("theme2").style.background = (theme2 > 0) ? "#FFFFCC" : "#FFFFFF";
 document.getElementById("theme3").style.background = (theme3 > 0) ? "#FFFFCC" : "#FFFFFF";
 document.getElementById("theme4").style.background = (theme4 > 0) ? "#FFFFCC" : "#FFFFFF";

 total = 0;
 found = "";	// index values found
 homes_found = new Array(homes);	// clear

 for (i = 0; i < skus; i++) {

  // check for non-themes
  if (gen > 0 && genX[i] < 3 && gen != genX[i]) {continue;}

  if (when > 0 && whenX[i] > when) {continue;}
  if (less > 0 && lessX[i] > less) {continue;}
  if (more > 0 && moreX[i] < more) {continue;}
  if (brand > 0 && brandX[i] != brand && brandBX[i] != brand) {continue;}

  if (color > 0 && colorAX[i] != color && colorBX[i] != color && colorCX[i] != color) {continue;}

  // no themes checked?
  if (theme1 == 0 && theme2 == 0 && theme3 == 0 && theme4 == 0) {tally(i); continue;}

  // check for any selected themes
  if (theme1 > 0) {
   if (themeAX[i] == theme1) {tally(i); continue;}
   if (themeBX[i] == theme1) {tally(i); continue;}
   if (themeCX[i] == theme1) {tally(i); continue;}
   if (themeDX[i] == theme1) {tally(i); continue;}
  }
  if (theme2 > 0) {
   if (themeAX[i] == theme2) {tally(i); continue;}
   if (themeBX[i] == theme2) {tally(i); continue;}
   if (themeCX[i] == theme2) {tally(i); continue;}
   if (themeDX[i] == theme2) {tally(i); continue;}
  }
  if (theme3 > 0) {
   if (themeAX[i] == theme3) {tally(i); continue;}
   if (themeBX[i] == theme3) {tally(i); continue;}
   if (themeCX[i] == theme3) {tally(i); continue;}
   if (themeDX[i] == theme3) {tally(i); continue;}
  }
  if (theme4 > 0) {
   if (themeAX[i] == theme4) {tally(i); continue;}
   if (themeBX[i] == theme4) {tally(i); continue;}
   if (themeCX[i] == theme4) {tally(i); continue;}
   if (themeDX[i] == theme4) {tally(i); continue;}
  }
 }

 found = found.substring(0,found.length-1);	// remove last ,

 // Make total a link if > 0
 if (total > 0) {
   showtotal='<a href="javascript:GotoSets();">'+total+'</a>';
   showtotal_off='<a href="javascript:GotoSets();" style="color:#FFFFFF">'+total+'</a>';

   if (navigator.appName == "Microsoft Internet Explorer") {
     document.getElementById("resultsarea2").style.cursor='hand';
   }
   else {
     document.getElementById("resultsarea2").style.cursor='pointer';
   }
 }
 else {
   showtotal=total;
   showtotal_off='<font color="#FFFFFF">'+total+'</font>';
   document.getElementById("resultsarea2").style.cursor='';
 }

 // Show GO button
 var showbutton = "";
 if (total > 0) {
  var verb='this ';
  if (total > 1) {verb='these '}
  //showbutton = '<input type=submit value="VIEW  '+verb+total+'" class="cribfinder" onmouseover="this.className=\'cribfinder_hov\'" onmouseout="this.className=\'cribfinder\'" >';
  showbutton = '<input type="image" src="/images/btn_results-1.gif" onmousedown="this.src=\'/images/btn_resultsDown-1.gif\';" onmouseup="this.src=\'/images/btn_results-1.gif\';" onmouseout="this.src=\'/images/btn_results-1.gif\';">';

 }

 // Show RESET button
 var resetbutton = "&nbsp;";
 if (!FormIsReset) {
   //resetbutton = '<input type=reset value="Clear Selections" onClick="ResetForm();" class="clearselections" onmouseover="this.className=\'clearselections_hov\'" onmouseout="this.className=\'clearselections\'">';
   resetbutton = '<input type="image" src="/images/btn_Clear_Selection-1.gif" onClick="ResetForm();" onmousedown="this.src=\'/images/btn_Clear_SelectionDown-1.gif\';" onmouseup="this.src=\'/images/btn_Clear_Selection-1.gif\';" onmouseout="this.src=\'/images/btn_Clear_Selection-1.gif\';"/>';
 }

 document.getElementById("showbutton1").innerHTML=showbutton;
 document.getElementById("resetbutton1").innerHTML=resetbutton;

 // Blink total
 TotalOn();
 var intrvl=0;
 for(nTimes=0; nTimes<2; nTimes++){
  intrvl += 200;
  setTimeout("TotalOff();",intrvl);
  intrvl += 200;
  setTimeout("TotalOn();",intrvl);
 }
  intrvl += 200;
  setTimeout("TotalMix();",intrvl);

 return 1;
}

function GotoSets() {
 window.location = "/cgi-bin/bedding-calc.cgi?TS="+timestamp+"&tot="+total+"&show="+found+"&choices="+choices+"&type=I&format=bedthumbs";
 return 1;
}

function GotoSets2() {
 if (total == 0) {return 1;}
 window.location = "/cgi-bin/bedding-calc.cgi?TS="+timestamp+"&tot="+total+"&show="+found+"&choices="+choices+"&type=I&format=bedthumbs";
 return 1;
}

function ResetForm() {
 document.getElementById("BeddingSelect").reset();
 UpdateTotal();
 return 1;
}

function TotalOn() {
  document.getElementById("showtotal1").innerHTML=showtotal + "<br/><span class='important'>Matching Results</span>";
  document.getElementById("resultsarea").style.border="2px solid #02567f";
}
function TotalOff() {
  document.getElementById("showtotal1").innerHTML=showtotal_off + "<br/><span class='important'>Matching Results</span>";
  document.getElementById("resultsarea").style.border="2px solid #ffffff";
}
function TotalMix() {
  document.getElementById("showtotal1").innerHTML=showtotal + "<br/><span class='important'>Matching Results</span>";
  document.getElementById("resultsarea").style.border="2px solid #fadaad";
}

