
/*-----------------------------------------------------------------------------------------------------------
  store.js
------------------------------------------------------------------------------------------------------------*/
var chooseone=new Array('','chooseone');

// Some of these need to be cleaned up
var smallMedLargeSize=new Array('Choose one','chooseone','S - Small','S','M - Medium','M','L - Large','L');
var mediumLargeOSSize=new Array('Choose one','chooseone','M - Medium','M','Large','L');
var size20Extra = new Array('Choose one','chooseone','XS - Extra Small','XS','S - Small','S','M - Medium','M','L - Large','L','XL - Extra Large','XL');
var size=new Array('Choose one','chooseone','XS - Extra Small','XS','S - Small','S','M - Medium','M','L - Large','L');
var sportsTether = new Array('Choose one','chooseone','Fixed','STD','Fixed Quick Disconnect','QD','Sliding','S');
var version=new Array('Extra Series','E');
var EconomyVersion=new Array('Extra Series','E');
var sportsTether = new Array('Choose one','chooseone','Fixed','STD', 'Fixed Quick Disconnect','QD','Sliding','S');
var ProVersion=new Array('Professional Series','P');


//The following are used:
// Applies only to: PRO 10, PRO 40
var mediumSize=new Array('M - Medium','M');

// Applies only to: PRO 30, SPORT 30
var mediumLargeSize=new Array('Choose one','chooseone','M - Medium','M','L - Large','L');
var size30Sport = new Array('Choose one','chooseone','M - Medium','M','L - Large','L')

// Applies only to: SPORT 20
var size20Sport = new Array('Choose one','chooseone','SS - Super Small','SS','M - Medium','M','L - Large','L');


// Applies only to: PRO 20
//Nov 03 2009 OG- removed Extra Large
var size20Pro = new Array('Choose one','chooseone','SS - Super Small','SS','S - Small','S','M - Medium','M','L - Large','L');

// Applies to all SERIES/ANGLE/SIZE permutations
// 01/25/2011 GBL : Quick click II are to be temporarely removed
//var anchor=new Array('Choose one','chooseone','Post Anchor','PA','Quick Click','QC','Quick Click II','QC2');
var anchor=new Array('Choose one','chooseone','Post Anchor','PA','Quick Click','QC');

// Applies to: QC Anchor and LW2 Anchor
var tetherQC=new Array('Choose one','chooseone','Fixed','STD','Sliding','S');

// Applies to: Post Anchor
var tether=new Array('Choose one','chooseone','Fixed','STD','Fixed Quick Disconnect','QD','Sliding','S');
var tetherBlank=new Array('Choose an Anchor','chooseone');
//Jan 6 2011 OG: Sport and Pro series now always Sliding only.
var tetherSlidingOnlyDefault = ['Sliding','S'];

//Jan 6 2011 OG: Helmets
var helmet = ['Choose one','chooseone','SA Helmet','SA','SAH Helmet','SAH'];
var helmetExplanation = [];
helmetExplanation['chooseone'] = null;
helmetExplanation['SA'] = 'Helmet requires nutwashers (Snell SA or similar) Check this selection if unsure';
helmetExplanation['SAH'] = 'Helmet has built in nutwashers (Snell SAH only)';


// Series
var versionSport=new Array('Sport Series','S');
var versionPro=new Array('Professional Series','P');
var versionSportII=new Array('Sport Series','SII');


var colorPadEco=new Array('Black (Standard All Versions)','1','Red (Available on Pro version only)','2','Blue (Available on Pro version only)','3','Yellow (Available on Pro version only)','4','Orange (Available on Pro version only)','5');
var colorPadPro=new Array('Black (Standard All Versions)','1','Red (Free with Pro Version)','2','Blue (Free with Pro Version)','3','Yellow (Free with Pro Version)','4','Orange (Free with Pro Version)','5');
var colorAncEco=new Array('Standard', '7', 'Silver (Available on Pro version only)', '1', 'Black (Available on Pro version only)','2','Red (Available on Pro version only)','3','Blue (Available on Pro version only)','4','Yellow (Available on Pro version only)');
var colorAncPro=new Array('Black (Standard Pro Version)', '2', 'Silver (Free with Pro Version)', '1', 'Red (Free with Pro Version)', '3','Blue (Free with Pro Version)', '4','Yellow (Free with Pro Version)', '5');

var colorPadAnc=new Array('Black','1','Red','2','Blue','3','Yellow','4');	//june 25th 09 - removed orange
//var colorPadOnly=new Array('Black','1','Silver','2','Red','3','Blue','4','Yellow','5'); //July 09 2010 - removed yellow
var colorPadOnly=new Array('Black','1','Silver','2','Red','3','Blue','4');

//Contour Pad data
var contPadSize=new Array('Choose one','chooseone','Small','S','Medium/Large','ML');
var contPadColor=new Array('Standard Vinyl - no charge','1','Black - $20 extra','2','Blue - $20 extra','3','Red - $20 extra','4','Yellow - $20 extra','5'); //june 25th 09 - removed orange
var contPadColorFree=new Array('Standard Vinyl - no extra cost','1','Black - no extra cost','2','Blue - no extra cost','3','Red - no extra cost','4','Yellow - no extra cost','5','Orange - no extra cost','6');



function initialize() {
	
	if (window.model) {
		document.getElementById("modelNo").innerHTML = "Model " + model;
		document.getElementById("imageCell").innerHTML = stripImageHtml(defaultPicHTML);
		document.getElementById("DetailedDescription").innerHTML = defaultDesc;
  
		if (model == 10) {
			initializeModel(mediumSize, versionPro, anchor, tetherSlidingOnlyDefault, helmet);
		
		} else if (model == 20) {
			if(hardVersion=='pro') {
				initializeModel(size20Pro, versionPro, anchor, tetherSlidingOnlyDefault, helmet);
			} else if(hardVersion=='sport') {
				initializeModel(size20Sport, versionSport, anchor, tetherSlidingOnlyDefault, helmet);
			} else if(hardVersion=='sport2'){
				initializeModel(mediumLargeSize,versionSportII, anchor, tetherSlidingOnlyDefault, helmet);
			}
			
		} else if (model == 30) {
			if(hardVersion=='pro') {
				initializeModel(mediumLargeSize, versionPro, anchor, tetherSlidingOnlyDefault, helmet);
			} else if(hardVersion=='sport') {
				initializeModel(size30Sport, versionSport, anchor, tetherSlidingOnlyDefault, helmet);
			}
			
		} else if (model == 40) {
			initializeModel(mediumSize, versionPro, anchor, tetherSlidingOnlyDefault, helmet);
		}
	
	} else if(window.PadsAnchorID){
		document.getElementById("storeDisplayName").innerHTML = window.storeDisplayName;
		if (window.PadsAnchorID	== 5481) {
			list=colorPadOnly;
			var paddingBox=document.forms['configForm'].custcolkitanchorcolor;
		} else {
			list=colorPadAnc;
			var paddingBox=document.forms['configForm'].custcol24;
		}
		
		paddingBox.options.length=0;
		initializeList(paddingBox, list);
		//convertId(PadsAnchorID);
		convertPadId(PadsAnchorID);
	
	} else if(window.contourPadSeries){
		document.getElementById("modelNo").innerHTML = "Contour Padding " + contourPadSeries;
		document.getElementById("imageCell").innerHTML = defaultPicHTML;
		document.getElementById("DetailedDescription").innerHTML = defaultDesc;
		document.getElementById("price").innerHTML = "Unit price : " + defaultPrice;
		var list;
	
		if(contourPadSeries=='Extra Series') {
		    var sizeBox=document.forms['configForm'].size;
		    sizeBox.options.length=0;
		    initializeList(sizeBox, contPadSize);

		   /* var colorBox=document.forms['configForm'].custcol_contour_padding_color;
		    colorBox.options.length=0;
			initializeList(colorBox, chooseone);*/
		
		} else if(contourPadSeries=='Pro Series') {
		    var sizeBox=document.forms['configForm'].size;
		    sizeBox.options.length=0;
			initializeList(sizeBox, contPadSize);

		   /* var colorBox=document.forms['configForm'].custcol_contour_padding_color;
		    colorBox.options.length=0;
			initializeList(colorBox, chooseone);*/
		}
	}
}

/**
* CMC_CHANGE: added anchorList to parameters
* This function initialises the dropdown boxes on the HANS Device Model pages
**/
function initializeModel(sizeList, versionList, anchorList, tetherList, helmetList) {
			var sizeBox=document.forms['configForm'].size;
			sizeBox.options.length=0;
			initializeList(sizeBox, sizeList);

			var versionBox=document.forms['configForm'].version;
			versionBox.options.length=0;
			initializeList(versionBox, versionList);
			
			// CMC_CHANGE: added anchor, anchorBox, anchorList
			var anchorBox=document.forms['configForm'].anchor;
			anchorBox.options.length=0;
			initializeList(anchorBox, anchorList);
			

			var tetherBox=document.forms['configForm'].tether;
			tetherBox.options.length=0;
			initializeList(tetherBox, tetherList);
			
			var helmetBox=document.forms['configForm'].helmet;
			helmetBox.options.length=0;
			initializeList(helmetBox, helmetList);
}

/**
* This function initialises dropdown boxes
**/
function initializeList(p_object, p_list) {
	p_object.options.length=0;
	for(i=0;i<p_list.length;i+=2) {
	  p_object.options[i/2]=new Option(p_list[i],p_list[i+1]);
	}
}


function switchProduct(itemPrice, imagePath, itemDescription) {
    var oVersion=document.forms['configForm'].version.value;
	var oAnchor=document.forms['configForm'].anchor.value;
    var oTether=document.forms['configForm'].tether.value;
	var oHelmet=document.forms['configForm'].helmet.value;
    var selection = 1; //document.forms['configForm'].custcolkitpadcolor.value;

	if (itemPrice != '') {
 	  document.getElementById("price").innerHTML = "Unit price as selected : " + itemPrice;
	  document.getElementById("DetailedDescription").innerHTML = itemDescription;
      if (oVersion=="P" || oVersion=='S' || oVersion=='SII') {
 	    document.getElementById("imageCell").innerHTML = stripImageHtml(imagePath);
	  }
	}
	else {
		document.getElementById("price").innerHTML = "You must select Options to determine price.";
	}
    
    if ((oVersion == "P") && (oTether == "STD")) {
        switch (selection) {
            case '1':{
				document.getElementById('imageCell').getElementsByTagName('img')[0].src = picblkSTD.src;
				break;
			}
            case '2':{
                document.getElementById('imageCell').getElementsByTagName('img')[0].src = picredSTD.src;
                break;
            }
            case '3':{
                document.getElementById('imageCell').getElementsByTagName('img')[0].src = picbluSTD.src;
                break;
            }
            case '4':{
                document.getElementById('imageCell').getElementsByTagName('img')[0].src = picylwSTD.src;
                break;
            }
            case '5':{
                document.getElementById('imageCell').getElementsByTagName('img')[0].src = picorgSTD.src;
                break;
            }
            default:
                {
                }
        }
    }
    else if ((oVersion=="P") && (oTether=="QD")) {
      switch (selection) {
        case '1': { document.getElementById('imageCell').getElementsByTagName('img')[0].src = picblkQD.src; break }
        case '2': { document.getElementById('imageCell').getElementsByTagName('img')[0].src = picredQD.src; break }
        case '3': { document.getElementById('imageCell').getElementsByTagName('img')[0].src = picbluQD.src; break }
        case '4': { document.getElementById('imageCell').getElementsByTagName('img')[0].src = picylwQD.src; break }
        case '5': { document.getElementById('imageCell').getElementsByTagName('img')[0].src = picorgQD.src; break }
        default: { }
      }
    }
}

/**
* This function removes any other tag around an <img> tag, such as <h ref>
**/
function stripImageHtml(imageHtml) {
	var returnValue = imageHtml;
	var htmlArray = new Array();
	htmlArray = imageHtml.split('<');
	
	for(var i=0; i<htmlArray.length; i++) {
		var htmlSegment = htmlArray[i];
		if(htmlSegment.substr(0,3)=='img') {
			returnValue = '<'+htmlSegment;
		}
	}	
	return returnValue;
}

function setValues(model)
{ 
	if(!isIntegers()){return false;}
	var msubmit=document.forms['buttonForm'].submitButton;
	var series=model;
	var size=document.forms['configForm'].size.value;
	var tether=document.forms['configForm'].tether.value;
	var helmet=document.forms['configForm'].helmet.value;
	//CMC_CHANGE: added anchor
	var anchor=document.forms['configForm'].anchor.value;
	var version=document.forms['configForm'].version.value;
	var qtyVal=document.forms['configForm'].quantityForm.value;
	var qty=trimString(qtyVal);//Clip the zeros at start

	//CMC_CHANGE: verify new ProductCode
	var ssProductCode=model+size+version+"_"+anchor+"_"+tether+"_"+helmet;
	convertId(ssProductCode,qty);//back to the html page for conversion to netsuite
}

function submitForm() {
	if(!isIntegers()){return false;}
	var msubmit=document.forms['buttonForm'].submitButton;
	var series=model;
	var size=document.forms['configForm'].size.value;
	var tether=document.forms['configForm'].tether.value;
	var helment=document.forms['configForm'].helmet.value;
	
	//CMC_CHANGE: added anchor
	var anchor=document.forms['configForm'].anchor.value;
	
	var version=document.forms['configForm'].version.value;
	var qtyVal=document.forms['configForm'].quantityForm.value;
	var qty=trimString(qtyVal)//Clip the zeros at start

	/*
	document.forms['form115'].custcolkitanchorcolor.value=document.forms['configForm'].custcolkitanchorcolor.value;
	document.forms['form115'].custcolkitpadcolor.value=document.forms['configForm'].custcolkitpadcolor.value;
	*/
	if(size=="chooseone"){alert("Please choose a Size");return false;}
	if(version=="chooseone"){alert("Please choose a Version");return false;}	
	//CMC_CHANGE: added anchor
	if(anchor=="chooseone"){alert("Please choose an Anchor");return false;}
	if(tether=="chooseone"){alert("Please choose a Tether");return false;}
	if(helmet=="chooseone"){alert("Please choose a Helmet");return false;}

	if(qty==null || qty=="")
	{
		alert("Please enter a Quantity");
		document.forms['configForm'].quantityForm.focus();
		return false;
	}
	else {
		document.forms['form115'].qty.value = qty;
	}
	//add.style.visibility="visible";
	msubmit.style.visibility="hidden";

	if(document.forms['form115'].onsubmit())
	{
		document.forms['form115'].submit();
		return false;
	}
}

//Begining of Contour Padding functions --->
function swapOptionContourPadding(oTarget, oName)
{
	var selection=oTarget.value;
	var oSize=document.forms['configForm'].size.value;
	
	//March 29 2010 removed color option as per Gary
	/*var oColor=document.forms['configForm'].custcol_contour_padding_color.value;
	
	var listColor;
	
	if(contourPadSeries=='Extra Series')
	{
		if(oName=='size')
		{
			if(selection=='chooseone')
			{
				listColor = chooseone;
			}
			else
			{
				listColor=contPadColor;
			}
		}
		if(oName!='custcol_contour_padding_color')
		{
			var colorBox=document.forms['configForm'].custcol_contour_padding_color;
			colorBox.options.length=0;
			for(i=0;i<listColor.length;i+=2)
			{
				colorBox.options[i/2]=new Option(listColor[i],listColor[i+1]);
			}
		}
	}
	else if(contourPadSeries=='Pro Series')
	{
		if(oName=='size')
		{
			if(selection=='chooseone')
			{
				listColor = chooseone;
			}
			else
			{
				listColor=contPadColorFree;
			}
		}

		if(oName!='custcol_contour_padding_color')
		{
			var colorBox=document.forms['configForm'].custcol_contour_padding_color;
			colorBox.options.length=0;
			for(i=0;i<listColor.length;i+=2)
			{
				colorBox.options[i/2]=new Option(listColor[i],listColor[i+1]);
			}
		}
	}*/
	setValuesContourPad();
}

function setValuesContourPad()
{
	if(!isIntegers()){return false;}
	var msubmit=document.forms['buttonForm'].submitButton;
	var series=contourPadSeries;
	var size=document.forms['configForm'].size.value;
	//var color=document.forms['configForm'].custcol_contour_padding_color.value;
	var qtyVal=document.forms['configForm'].quantityForm.value;
	var qty=trimString(qtyVal);//Clip the zeros at start
	
	var colored='n';
	//if(color!='1') colored='y';
	
	if(series=='Extra Series') 
	{
		var ssProductCode=series+" "+size+" "+colored;
	}
	else
	{
		var ssProductCode=series+" "+size;
	}
	convertContourId(ssProductCode,qty);//back to the html page for conversion to netsuite
}

function submitFormContourPad()
{
	if(!isIntegers()){return false;}
	var msubmit=document.forms['buttonForm'].submitButton;
	var series=contourPadSeries;
	var size=document.forms['configForm'].size.value;
	var qtyVal=document.forms['configForm'].quantityForm.value;
	var qty=trimString(qtyVal)//Clip the zeros at start

	//document.forms['form115'].custcol_contour_padding_color.value=document.forms['configForm'].custcol_contour_padding_color.value;

	if(size=="chooseone"){alert("Please choose a Size");return false;}

	if(qty==null || qty=="")
	{
		alert("Please enter a Quantity");
		document.forms['configForm'].quantityForm.focus();
		return false;
	}
	else 
	{
		document.forms['form115'].qty.value = qty;
	}
	//add.style.visibility="visible";
	msubmit.style.visibility="hidden";

	if(document.forms['form115'].onsubmit())
	{
	 document.forms['form115'].submit();
	 return false;
	}
}

function switchProductContourPad(itemPrice, imagePath, itemDescription) {
	if (itemPrice != '') {
 	  document.getElementById("price").innerHTML = "Unit price : " + itemPrice;
	  document.getElementById("DetailedDescription").innerHTML = itemDescription;
	}
	else {
		document.getElementById("price").innerHTML = "Unit price : " + defaultPrice;
	}
}
//<----End of Contour Padding functions


function swapOption(oTarget,oName) {
	var selection=oTarget.value;
	var oSize=document.forms['configForm'].size.value;
	var oTether=document.forms['configForm'].tether.value;
	//CMC_CHANGE: oAnchor
	var oAnchor=document.forms['configForm'].anchor.value;
	var oVersion=document.forms['configForm'].version.value;
	var oHelmet = document.forms['configForm'].helmet.value;

	//Jan 06 2011 OG: added popup for helmet explanation
	if (oName == 'helmet') {
		var helmetPopup = helmetExplanation[oHelmet];
		if (helmetPopup != null) {
			alert(helmetPopup);
		}
	}
	
  	setValues(model);
}


function switchProductPadAnc(itemPrice, imagePath, itemDescription) {
    if(PadsAnchorID == 5481){
		var selection = document.forms['configForm'].custcolkitanchorcolor.value;
	} else {
		var selection = document.forms['configForm'].custcol24.value;
	}

	if (itemPrice != '') {
		if (selection == 1) {	
			document.getElementById("price").innerHTML = "Price as selected : " + itemPrice;
		}else {	
			document.getElementById("price").innerHTML = "Price as selected : " + itemPrice;
		}	
		document.getElementById("DetailedDescription").innerHTML = itemDescription;
		document.getElementById("imageCell").innerHTML = imagePath;
	}else {
		document.getElementById("price").innerHTML = "You must select Options to determine price.";
	}
}

function submitFormPadAnc() {
	if(!isIntegers()){return false;}
	
	var msubmit=document.forms['buttonForm'].submitButton;
	var qtyVal=document.forms['configForm'].quantityForm.value;
	var qty=trimString(qtyVal)//Clip the zeros at start

	if(PadsAnchorID == 5481) {
		if(document.forms['form115'].custcolkitanchorcolor) {
			document.forms['form115'].custcolkitanchorcolor.value=document.forms['configForm'].custcolkitanchorcolor.value;
		}
	} else {
		if(document.forms['form115'].custcol24)  {
			document.forms['form115'].custcol24.value=document.forms['configForm'].custcol24.value;
		} else if(document.forms['form115'].custcol33)  {
			document.forms['form115'].custcol33.value=document.forms['configForm'].custcol24.value;
		} else {
			document.forms['form115'].custcolanchors.value=document.forms['configForm'].custcol24.value;
		}
	}

	if(qty==null || qty=="") {
		alert("Please enter a Quantity");
		document.forms['configForm'].quantityForm.focus();
		return false;
	} else {
		document.forms['form115'].qty.value = qty;
	}
	msubmit.style.visibility="hidden";

	if(document.forms['form115'].onsubmit()) {
		document.forms['form115'].submit();
		return false;
	}
}

//CMC_COMMENT: Not Affected
function setValuesPad(model)
{ 
  if(!isIntegers()){return false;}
  var msubmit=document.forms['buttonForm'].submitButton;
  var qtyVal=document.forms['configForm'].quantityForm.value;
  var qty=trimString(qtyVal);//Clip the zeros at start

  var ssProductCode=model;
  convertPadId(ssProductCode,qty);//back to the html page for conversion to netsuite
}

function swapOptionPadAnc() {

	if (PadsAnchorID == 5481) {
		newPadsAnchorID = 5481;
	} else {
		var oColor=document.forms['configForm'].custcol24.value;
		if (PadsAnchorID == 5137 && oColor != 1) {
		newPadsAnchorID = 5159;	
		}
		if (PadsAnchorID == 5137 && oColor == 1) {
		newPadsAnchorID = 5137;
		}
		if (PadsAnchorID == 5112 && oColor != 1) {
		newPadsAnchorID = 5163;	
		}
		if (PadsAnchorID == 5112 && oColor == 1) {
		newPadsAnchorID = 5112;
		}
		if (PadsAnchorID == 5138 && oColor != 1) {
		newPadsAnchorID = 5167;	
		}
		if (PadsAnchorID == 5138 && oColor == 1) {
		newPadsAnchorID = 5138;
		}
	}
	setValuesPad(newPadsAnchorID);
}

function convertId(oName,oQty){
	
	try {
		callConvertAction(ITEM_CONVERSION[oName]);
		document.forms['form115'].buyid.value = ITEM_CONVERSION[oName][0];
		document.forms['form115'].qty.value = oQty;
	}catch(err){
		//do nothing
	}
}

function callConvertAction(IdArray){
	switchProduct(IdArray[1], IdArray[2], IdArray[3]);
}

//CMC_COMMENT: Not Affected
function setItemCount(ItemNumber) {
  if (ItemNumber != 0) {
    document.getElementById('itemCount').innerHTML = 'Item(s) in cart : ' + ItemNumber;
  }
  else {
    document.getElementById('itemCount').innerHTML = 'Your cart is empty';
  }
}

//CMC_COMMENT: Not Affected
function getkey(e)
{
  if(e)
  {
    return e.keyCode;
  }
  else
  {
    return null;
  }
}

//CMC_COMMENT: Not Affected
function goodcharacter(keychar,goods)
{
  keychar=keychar.toLowerCase();
  var goods=goods.toLowerCase();
  if(goods.indexOf(keychar) != -1) //check goodkeys
  {
    return true;
  }
  return false;
}

//CMC_COMMENT: Not Affected
function goodchars(e,goods)
{
  var key=getkey(e);
  if(key==null)
  {
   return true;
  }
  if(key==null || key==0 || key==8 || key==9 || key==13 || key==27) //control keys
  {
   return true;
  }
  var keychar=String.fromCharCode(key); //get character
  return goodcharacter(keychar, goods);
}

//CMC_COMMENT: Not Affected
function isIntegers(oForm)
{
  var goods="0123456789";
  var form="";
  if(oForm)//passing in a form name
  {
    form=document.getElementById(oForm);
  }
  else
  {
    form=document.forms['configForm'].quantityForm;
  }
  var oVal=form.value;
  var result=true;
	for(var i=0;i<oVal.length;i++)
		if(goods.indexOf(oVal.substr(i,1))<0)
		{
			result=false;
			alert("Please enter only numbers in the Quantity field.");
      form.focus();
      form.select();
      return;
		}
	return result;
}

//CMC_COMMENT: Not Affected
function trimString(str)
{
  while(str.charAt(0)=='0')
    str=str.substring(1);
  return str;
}
//CMC_COMMENT: Not Affected
function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}



<!-- 69 30% #16-->
<!-- [ acct-java010.svale.netledger.com ] -->

