<!--

function myOnSubmitEventHandler() {
		try {
			if(typeof(document.getElementById('editor1').EscapeUnicode) == 'undefined') {
				throw "Error"
			} else {
				document.getElementById('editor1').EscapeUnicode = true;
				document.getElementById('xhtml1').value = document.getElementById('editor1').value;
			}			
		}
		catch(er) {
			document.getElementById('xhtml1').value = document.getElementById('alternate1').value;
		}
	}
	

function moveup(uSel) {
   var intNewValue;
   var strNewText;
	for (i=1;i<uSel.options.length;i++)
		if (uSel.options[i].selected)
		{
		   intNewText = uSel.options[i-1].text;
		   intNewValue = uSel.options[i-1].value;
		   uSel.options[i-1].text = uSel.options[i].text;
		   uSel.options[i-1].value = uSel.options[i].value;
		   uSel.options[i].text = intNewText;
		   uSel.options[i].value = intNewValue;
		   uSel.options[i].selected = false;    
		   uSel.options[i-1].selected = true;    
		}
		
}
function movedown(uSel) {
   var intNewValue;
   var strNewText;
	for (i=uSel.options.length - 2;i>=0;i--)
		if (uSel.options[i].selected)
		{
		   intNewText = uSel.options[i+1].text;
		   intNewValue = uSel.options[i+1].value;
		   uSel.options[i+1].text = uSel.options[i].text;
		   uSel.options[i+1].value = uSel.options[i].value;
		   uSel.options[i].text = intNewText;
		   uSel.options[i].value = intNewValue;
		   uSel.options[i].selected = false;    
		   uSel.options[i+1].selected = true;    
		   
		}
}	

function submitform(uSel,uTxt) {
    var strSubmitString
    strSubmitString = "";
  	for (i=0;i<uSel.options.length;i++)
  	    {
  		if (i == 0) {
  	       strSubmitString = uSel.options[i].value
           }
           else
           {
  	       strSubmitString = strSubmitString + "|" + uSel.options[i].value
           }
        }     
       uTxt.value = strSubmitString; 		   	    
}

function ImageLoadFailed() {
  window.event.srcElement.style.display = "None";
}


/*

addRemoveClass:

check if there is already a class applied and add the new one preceeded by a space if that is the case:
a - defines the action you want the function to perform.
o - the object in question.
c1 - the name of the first class
c2 - the name of the second class

Possible actions are:

swap - replaces class c1 with class c2 in object o.
add - adds class c1 to the object o.
remove - removes class c1 from the object o.
check - test if class c1 is already applied to object o and returns true or false. 

*/

function addRemoveClass(a,o,c1,c2)
{
  switch (a){
    case 'swap':
      o.className=!addRemoveClass('check',o,c1)?o.className.replace(c2,c1): o.className.replace(c1,c2);
    break;
    case 'add':
      if(!addRemoveClass('check',o,c1)){o.className+=o.className?' '+c1:c1;}
    break;
    case 'remove':
      var rep=o.className.match(' '+c1)?' '+c1:c1;
      o.className=o.className.replace(rep,'');
    break;
    case 'check':
      return new RegExp('\\b'+c1+'\\b').test(o.className)
    break;
  }
}

function findParent(elementID){
	var childElement = document.getElementById(elementID);
	for (var i=0; i<document.forms.length; i++) { 
		for (var x=0; x<document.forms[i].elements.length; x++) {
			alert(childElement.parentNode.id);
			if(childElement.id == elementID){
				return document.forms[i].id;
			}
		}
	} 
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	var str = new String(features);
	var hStartPos, hEndPos, hVal 
	var wStartPos, wEndPos, wVal	
	var x, y
	
	if((str.indexOf("height") >= 0)&&(str.indexOf("width") >= 0)) {
		hStartPos = str.indexOf("height");	
		hEndPos = str.indexOf(",", hStartPos);
		hVal = str.substring(hStartPos + 7, hEndPos);
	
		wStartPos = str.indexOf("width");	
		wEndPos = str.indexOf(",", wStartPos);
		wVal = str.substring(wStartPos + 6, wEndPos);
	
		x = (screen.availWidth / 2) - (wVal / 2)
		y = (screen.availHeight / 2) - (hVal / 2)
		
		var newWin = window.open(theURL,winName,features);
		newWin.moveTo(x, y);
	}
	else {
		window.open(theURL,winName,features);
	}
}

function changeDate(newDate) {
	var startDate = document.getElementById('txtDate');
	startDate.value = newDate;
	document.getElementById('frmUser').submit();
}

// fieldList is comma separated, no whitespace
function chkReqdFields(formName, fieldList) {
	var arrFields;
	var i = 0
//	alert('Checking ' + formName);

	arrFields = fieldList.split(',');
	for(i = 0; i<arrFields.length; i++) {
		//alert('Checking ' + arrFields[i]);
		if(isWhitespace(eval('document.forms["' + formName + '"].' + arrFields[i] + '.value'))) {
			alert("Please fill in all required fields.");
			return false;
		}
	}
	return true;
}

// Check whether string s is empty.
function isEmpty(s) {
   return ((s == null) || (s.length == 0))
}

// whitespace characters
var whitespace = " \t\n\r";

// Returns true if string s is empty or
// whitespace characters only.
function isWhitespace (s) {   
	var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
}
}

var popupLinkConfig = new Array;

//====Popup Window Parameters==============//
// popupLinkConfig["classname"] = new Array ( "targetname", "width=550,height=350,scrollbars=yes,resizable=yes,status=yes,toolbar=yes,location=yes,menubar=yes");
popupLinkConfig["popup"]    = new Array ( "", "width=500,height=450,scrollbars=yes,resizable=yes,menubar=no");
popupLinkConfig["glossary"] = new Array ( "help", "width=550,height=350,resizable=yes");
popupLinkConfig["coupon"]    = new Array ( "", "width=800,height=600,scrollbars=yes,resizable=yes,menubar=yes");
// ==========================================================================


function initPopupLinks()
{
  if (!document.getElementsByTagName) return true;
  var pageLinks = document.getElementsByTagName("a");
  for (var i = 0; i < pageLinks.length; i++) 
  {
    if (((pageLinks[i].className != null) && 
         (pageLinks[i].className != "")) ||
        ((pageLinks[i].parentNode.className != null) && 
         (pageLinks[i].parentNode.className != "")))
    {
      var linkClass = " " + pageLinks[i].className + " ";
      if ((linkClass == "  ") && (pageLinks[i].parentNode.className != ""))
      {
        linkClass = " " + pageLinks[i].parentNode.className + " ";
      }
      for (var theKey in popupLinkConfig) 
      {
        if (linkClass.indexOf(" " + theKey + " ") > -1)
        {
          if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
          {
            pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
          }
          pageLinks[i].settings = popupLinkConfig[theKey][1];
          pageLinks[i].onclick = popUp;
        }
      }
    }
  }
  return true;
}

function popUp()
{
  newWin = window.open(this.href, this.target, this.settings);
  newWin.focus();
  return false;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ + ".location='" + selObj.options[selObj.selectedIndex].value + "'");
  if (restore) selObj.selectedIndex=0;
}


var myrules = {
		
		'.bbyCart' : function(element){
			element.onload = function(){
				document.getElementById('frmBBYCart').submit();
			}
		},
		
		'.selectBox' : function(element){
			element.onchange = function(){
				document.editTime.submit();
			}
		},
		'.popupPrintButton' : function(element){
			element.onclick = function(){
				window.print();
			}
		},
		'.btnCloseModal' : function(element){
			element.onclick = function(){
				parent.Control.Modal.close();
			}
		},
		'.btnCloseModalMount' : function(element){
			element.onclick = function(){
				parent.document.forms[0].submit();
				parent.Control.Modal.close();
			}
		},
		'.btnCloseModalAlt' : function(element){
			element.onclick = function(){
				parent.Control.Modal.close();
			}
		},
		/*'#btnOk' : function(element){
			element.onclick = function(){
				parent.Control.Modal.close();
			}
		},*/
		'.nextButton' : function(element){
			
		},
		'.checkSubmit' : function(element){
			element.onclick = function(){
				document.forms[0].submit();
			}
		},
		//HT
		'.btnSkipStep' : function(element){
			element.onclick = function(){
				document.forms[0].submit();
			}
		},
		'.btnAddToSystem02' : function(element){
			element.onclick = function(){
			    var ProductList = '';
			    for (var i=0; i < document.forms[0].chkProduct.length; i++)
                {
                if (document.forms[0].chkProduct[i].checked)
                  {
                  var ProductList = ProductList + document.forms[0].chkProduct[i].value + ',';
                  }
                }
			    document.forms[0].txtRetailerProductID.value = ProductList;
				document.forms[0].submit();
			}
		},
		'.btnContinue' : function(element){
			element.onclick = function(){
				document.forms[0].submit();
			}
		},
		'.btnBuyNow' : function(element){
		    element.onclick = function(){
		        parent.document.location = 'http://www.bestbuy.com/site/olspage.jsp?skuId=8353952&type=product&id=1177112313877';
				parent.Control.Modal.close();
		    }
		},
		'.radioPopup' : function(element){
			element.onclick = function(){
			
				for (var i=0; i < document.forms[0].rdoSelect.length; i++)
				   {
				   if (document.forms[0].rdoSelect[i].checked)
				      {
				      var RPID = document.forms[0].rdoSelect[i].value;
				      }
				   }
				   
				//var chkWebAvailability = document.forms[0].chkWebAvailability.value;
				//var chkStoreAvailability = document.forms[0].chkStoreAvailability.value;
				var parentURL = parent.document.location.href;
				
				var appendChar = '?';
				if (parentURL.indexOf('?')>0) appendChar = '&';
				parent.document.location = parent.document.location + appendChar + 'popRetailerProductID=' + RPID + '&popProductID=' + document.forms[0].ProductID.value;
				parent.Control.Modal.close();
			}
		},
		'.radioSubmit' : function(element){
			element.onclick = function(){
				document.forms[0].txtSearch.value = 'true';
				document.forms[0].submit();
			}
		},
		'.radioIndex' : function(element){
			element.onclick = function(){
			document.forms[0].submit();
			}
		},
		'.productLink' : function(element){
			element.onclick = function(){
				loadOpener(element.href);
				return false;
			}
		},
		'#frmTime' : function(element){
			element.onsubmit = function(){
				return chkReqdFields('frmTime','selTask');
			}
		},
		'#selAvailableTime' : function(element){
			element.onchange = function(){
				document.getElementById('frmUser').submit();
			}
		},
		'#chkShowAll' : function(element){
			element.onclick = function(){
				var formName = findParent(element.id)
				document.getElementById(formName).submit();
			}
		},
		'.btnPopupCancel' : function(element){
			element.onclick = function(){
				window.close();
			}
		},
		'.aBBReturn' : function(element){
			element.onclick = function(){
				window.close();
			}
		},
		'.saveLink' : function(element){
			element.onclick = function(){    
				document.forms[0].secondAction.value = 'save';
				document.forms[0].txtCart.value = 'N';
				document.forms[0].submit();
			}
		},
		'fieldset' : function(element){
			element.onmouseover = function(){
				addRemoveClass('add',this,'over');
			}
			element.onmouseout = function(){
				addRemoveClass('remove',this,'over');
			}
		},
		'.submitButton' : function(element){
			element.onmouseover = function(){
				addRemoveClass('add',this,'over');
			}
			element.onmouseout = function(){
				addRemoveClass('remove',this,'over');
			}
		},
		'.productInfo' : function(element){
			var myDt = element.getElementsByTagName("dt").item(0);
			element.onmouseover = function(){
				addRemoveClass('add',this,'over');
			}
			element.onmouseout = function(){
				addRemoveClass('remove',this,'over');
			}
		},
		'.deleteProductButton' : function(element){
			element.onclick = function(){
				window.confirm("Are you sure you want to remove this item from your cart?");
			}
		}
	}

function ajaxCart(){
	var cartList = $('cartItems');
	if (!document.getElementById("cartItems")) return false;
		/*cartList.hide();*/
		Effect.BlindUp(cartList);
	var reviewLink = $('reviewDetails');
		reviewLink.onclick = function(){
			/*Element.toggle(cartList);*/
			var oldChild = reviewLink.firstChild;
			var newChild = document.createTextNode("Hide Details");
			var altChild = document.createTextNode("Review Details");
			if (oldChild.nodeValue == "Review Details"){
				reviewLink.replaceChild(newChild, oldChild);
				Effect.BlindDown(cartList);
			}
			else {
				reviewLink.replaceChild(altChild, oldChild);
				Effect.BlindUp(cartList);
			}
			return false;
		}
}

function uncheckRadio(radioname){
	
	var cBoxes = document.forms[0](radioname);
		
	for(var i=0, n=cBoxes.length; i<n; ++i){
		cBoxes[i].checked = false;
	}
}

function uncheckComputer(radioname){
	
	var cBoxes = document.forms[0](radioname);
		
	for(var i=0, n=cBoxes.length; i<n; ++i){
		cBoxes[i].checked = false;
	}
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

//Used in Home Theater
function clickRow(obj,LifestyleID,CSSTag)
{    
    
    for (var i=0; i < document.forms[0].rdoTag.length; i++)
    {
    if (document.forms[0].rdoTag[i].value == CSSTag) {
        if (document.forms[0].rdoTag[i].checked) {
            document.forms[0].rdoTag[i].checked = false
        }
        else
        {
            document.forms[0].rdoTag[i].checked = true
        }
    }
    }
    
    var cont = document.getElementById('imageTable');  
    var myObjColl = getElementsByClassName('selectedType', 'tr', cont);
        for (var i = 0, j = myObjColl.length; i < j; i++) {
           
           //if (document.forms[0].rdoTag[i+1].checked){
           //     myObjColl[i].className = 'selectedType';
           //}
           //else {
                myObjColl[i].className = '';
           //}
        }
         
    obj.className='selectedType';
    document.getElementById('roomPic').innerHTML = '<img src="images/bgLifestyle'+ LifestyleID + '.jpg" alt="" />';
    
}

function highlightRow(obj,LifestyleID,CSSTag,LifestylePage)
{
    var Tag = '';
    var TagList = ''
    for (var i=0; i < document.forms[0].rdoTag.length; i++)
    {
    if (document.forms[0].rdoTag[i].checked)
      {
      Tag = document.forms[0].rdoTag[i].value;
      TagList = TagList + document.forms[0].rdoTag[i].value + ',';
      }
    }
    
    //only change row color if tag not selected or changing tag
    if (Tag == '' || Tag == CSSTag)
    {
    var cont = document.getElementById('imageTable');  
    var myObjColl = getElementsByClassName('selectedType', 'tr', cont);
        for (var i = 0, j = myObjColl.length; i < j; i++) {
        
           //if (document.forms[0].rdoTag[i+1].checked){
           //     myObjColl[i].className = 'selectedType';
           //}
           //else {
                myObjColl[i].className = '';
           //}
        }
         
    obj.className='selectedType';
    document.getElementById('roomPic').innerHTML = '<img src="images/bgLifestyle'+ LifestyleID + '.jpg" alt="" />';
    }
}

//Computer or Camera Code for Skill Page
function skillCheck()
{
    var Skill = '';
    for (var i=0; i < document.forms[0].rdoSkillID.length; i++)
    {
    if (document.forms[0].rdoSkillID[i].checked)
      {
      var Skill = document.forms[0].rdoSkillID[i].value;
      }
    }
    
    if (Skill == '')
    {
        alert('You must select an option before continuing.');
        return false
    }

}

//DI / Computer Code for Prompt
function questionModal() 
{ 
    var Tag = '';
    for (var i=0; i < document.forms[0].rdoTag.length; i++)
    {
    if (document.forms[0].rdoTag[i].checked)
      {
      var Tag = document.forms[0].rdoTag[i].value;
      }
    }
    
    if (document.forms[0].Required.value == 'Y')
    {
        if (Tag == '')
        {
            alert('You must select an option before continuing.');
            return false
        }
        else {
            document.forms[0].submit();
        }
    }
    else
        {
        document.forms[0].submit();
        }
} 

//HT Code for Launching Dimension Questions
function customModal() 
{ 
    var Tag = '';
    for (var i=0; i < document.forms[0].rdoTag.length; i++)
    {
    if (document.forms[0].rdoTag[i].checked)
      {
      var Tag = document.forms[0].rdoTag[i].value;
      }
    }
    
    if (document.forms[0].Required.value == 'Y')
    {
        if (Tag == '')
        {
            alert('You must select an option before continuing.');
            return false
        }
        
        if (Tag == 'Furniture' || Tag == 'Mounted')
        {   
        
            modal = new Control.Modal($('Furniture'),{ iframe: true, width: 640, height: 325 });
            modal.href= modal.href + "?action=" + Tag; 
            modal.open();
            return false;
            //document.forms[0].submit();
        }
        else
        {
        document.forms[0].submit();
        }
    }
    else
        {
        document.forms[0].submit();
        }
} 

//HT Code for Product Compare Page
function compareModal() 
{ 
    var ProductList = '';
    var HiddenProductList = '';
    HiddenProductList = document.forms[0].txtCompareList.value;
    
    var x = 0
    
    var myProducts = new Array()
    for (var i=0; i < document.forms[0].chkProductCompare.length; i++)
    {
    if (document.forms[0].chkProductCompare[i].checked)
      {
      var ProductList = ProductList + document.forms[0].chkProductCompare[i].value + ',';
      myProducts[x] =  document.forms[0].chkProductCompare[i].value;
      x = x + 1
      }
    }
    
    //alert(myProducts.length);
    
    if (HiddenProductList.length > 0)
    {
        ProductList = HiddenProductList + ',' + ProductList;
        var myProducts = ProductList.split(',');
    }
    
    if (myProducts.length < 2)
    {   
        alert('You must select between 2-5 products to compare.');
        return false;
    } 
    
     if (myProducts.length > 5)
    {   
        alert('You may only select 5 products to compare.');
        return false;
    } 
    
    modal = new Control.Modal($('Compare'),{ iframe: true, width: 740, height: 500 });
    modal.href= modal.href + "?RetailerProductList=" + ProductList + '&ToolStepID=' + document.forms[0].ToolStepID.value + '&RetailerGroupID=' + document.forms[0].RetailerGroupID.value; 
    modal.open();
     
} 

function mountModal() 
{
        
    modal = new Control.Modal($('TVMount'),{ iframe: true, width: 640, height: 500 });
    modal.href= 'pProductCompare.aspx?action=Mount';
    modal.open();
}

function receiverModal() 
{
        
    modal = new Control.Modal($('Receiver'),{ iframe: true, width: 540, height: 300 });
    modal.href= 'pDisplayOption.aspx?action=Receiver';
    modal.open();
}

function dvdModal() 
{
        
    modal = new Control.Modal($('Receiver'),{ iframe: true, width: 540, height: 300 });
    modal.href= 'pDisplayOption.aspx?action=DVD';
    modal.open();
}

function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;
  var objColl = objContElm.getElementsByTagName(strTag);
  if (!objColl.length &&  strTag == "*" &&  objContElm.all) objColl = objContElm.all;
  var arr = new Array();
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
  var arrClass = strClass.split(delim);
  for (var i = 0, j = objColl.length; i < j; i++) {
    var arrObjClass = objColl[i].className.split(' ');
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (var k = 0, l = arrObjClass.length; k < l; k++) {
      for (var m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]);
          break comparisonLoop;
        }
      }
    }
  }
  return arr;
}

// To cover IE 5.0's lack of the push method
Array.prototype.push = function(value) {
  this[this.length] = value;
}


function loadOpener(theURL)
{
//self.opener.location.href=theURL;
//self.opener.focus();

if(self.opener)
{
    if (self.opener.closed)
    {
    //self.location.href = theURL;
    window.open(theURL);
    }
    else
    {
    self.opener.location.href = theURL;
    self.opener.focus();
    }
}
else
{
    window.open(theURL);
}
    
return false;
}

//Used in Home Theater
function addProduct(RetailerProductID, LaunchPopup)
{
    document.forms[0].txtRetailerProductID.value = RetailerProductID;
    //var PopupID = document.forms[0].PopupID.value;
    
    if (LaunchPopup == 'Y') {
    
        request.open("GET", 'checkPopup.aspx?RetailerProductID=' + RetailerProductID); 
	    request.onreadystatechange = sever_interaction;
	    request.send('');
    }
    else {
        document.forms[0].submit();
    }
}

//Used for TV Popup
function creat_Object()
{ 
var xmlhttp;
// This if condition for Firefox and Opera Browsers 
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
{
try 
{
xmlhttp = new XMLHttpRequest();
} 
catch (e) 
{
alert("Your browser is not supporting XMLHTTPRequest");
xmlhttp = false;
}
}
// else condition for ie
else
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlhttp;
}

var request = creat_Object();


function sever_interaction()
{
	if(request.readyState == 4)
	{
	    var answer = request.responseText;
	    //var PopupID = document.forms[0].PopupID.value;
	    //document.forms[0].AjaxResults.value = answer;
    	
	    myString = answer
        //alert(myString);
        if (myString.indexOf("Launch=Y") > 0)
        {
            modal = new Control.Modal($('TVMount'),{ iframe: true, width: 640, height: 500 });
            modal.href= 'pProductCompare.aspx?action=Mount&RetailerProductID=' + document.forms[0].txtRetailerProductID.value ; //+ '&ToolStepID=' + PopupID;
            modal.open();
        }
        else {
            document.forms[0].submit();
        }
	}
}


//End of TV Popup

function bbyCart()
{
	document.getElementById('frmBBYCart').submit();
}

function changeProductColor(id, newClass) {

identity=document.getElementById(id);
identity.className=newClass;

if (id == 'rdoDesktopLabel') {
	identity=document.getElementById('rdoNotebookLabel');
	identity.className='selectButton';
}

if (id == 'rdoNotebookLabel') {
	identity=document.getElementById('rdoDesktopLabel');
	identity.className='selectButton';
}

}


function changeColor(id, newClass) {

identity=document.getElementById(id);
identity.className=newClass;

if (id == 'rdoProductLabel01') {
	identity=document.getElementById('rdoProductLabel02');
	identity.className='selectButton';
	identity=document.getElementById('rdoProductLabel03');
	identity.className='selectButton';
}

if (id == 'rdoProductLabel02') {
	identity=document.getElementById('rdoProductLabel01');
	identity.className='selectButton';
	identity=document.getElementById('rdoProductLabel03');
	identity.className='selectButton';
}

if (id == 'rdoProductLabel03') {
	identity=document.getElementById('rdoProductLabel01');
	identity.className='selectButton';
	identity=document.getElementById('rdoProductLabel02');
	identity.className='selectButton';
}

}


function changeEssentialColor(id, newClass, chkName) {

identity=document.getElementById(chkName);

//alert(identity.checked);

if (identity.checked == true) {
	identity=document.getElementById(id);
	identity.className=newClass;	
} else {
	identity=document.getElementById(id);
	identity.className='selectButton';
	}
}

function changeSingleEssentialColor(id, newClass, chkName, id2, id3) {

identity=document.getElementById(chkName);

if (identity.checked == true) {
	identity=document.getElementById(id);
	identity.className=newClass;	
} else {
	identity=document.getElementById(id);
	identity.className='selectButton';
	}

identity=document.getElementById(id2);
identity.className='selectButton';

identity=document.getElementById(id3);
identity.className='selectButton';
}


function calcOrderTotal(varAmount, varFieldName, lngRowCount) {
//	alert(varAmount);
	var curVal = 0;
	var newVal = 0;
	var salesTax = 0;
	var shippingCost = 0;
	var grandTotal = 0;
		
	//first block of code inserts line item pricing via div tags	
	if(varFieldName!=undefined){
		if(varAmount > 0) {
			document.getElementById(varFieldName).innerHTML = formatNumber(varAmount, "0.00");
		}
		else {
			document.getElementById(varFieldName).innerHTML = '0.00';
		}	
	}		          

	//remaining code calculates total, tax, and shipping
	//curVal = frmReview.txtTotal.value;
	curVal = document.getElementById('Total').innerHTML;
	curVal = curVal.replace(/,/,"");
	
	
	//change row colors
	var table = document.getElementById("reviewTable");   
	var rows = table.getElementsByTagName("tr");  
	
	lngRowCount = lngRowCount - 1;
	
	if(varAmount < 0) {
		newVal = curVal - Math.abs(varAmount);
		rows[lngRowCount].className = "grayout";
	}
	else {
		newVal = eval(curVal) + eval(varAmount);
		rows[lngRowCount].className = "white"; 
	}
	//frmReview.txtTotal.value = formatNumber(newVal, "0.00");
	document.getElementById('Total').innerHTML = formatNumber(newVal, "0.00");
}

  var separator = ",";  // use comma as 000's separator
  var decpoint = ".";  // use period as decimal point
  var percent = "%";
  var currency = "$";  // use dollar sign for currency

  function formatNumber(number, format, print) {  // use: formatNumber(number, "format")
    if (print) document.write("formatNumber(" + number + ", \"" + format + "\")<br>");

    if (number - 0 != number) return null;  // if number is NaN return null
    var useSeparator = format.indexOf(separator) != -1;  // use separators in number
    var usePercent = format.indexOf(percent) != -1;  // convert output to percentage
    var useCurrency = format.indexOf(currency) != -1;  // use currency format
    var isNegative = (number < 0);
    number = Math.abs (number);
    if (usePercent) number *= 100;
    format = strip(format, separator + percent + currency);  // remove key characters
    number = "" + number;  // convert number input to string

     // split input value into LHS and RHS using decpoint as divider
    var dec = number.indexOf(decpoint) != -1;
    var nleftEnd = (dec) ? number.substring(0, number.indexOf(".")) : number;
    var nrightEnd = (dec) ? number.substring(number.indexOf(".") + 1) : "";

     // split format string into LHS and RHS using decpoint as divider
    dec = format.indexOf(decpoint) != -1;
    var sleftEnd = (dec) ? format.substring(0, format.indexOf(".")) : format;
    var srightEnd = (dec) ? format.substring(format.indexOf(".") + 1) : "";

     // adjust decimal places by cropping or adding zeros to LHS of number
    if (srightEnd.length < nrightEnd.length) {
      var nextChar = nrightEnd.charAt(srightEnd.length) - 0;
      nrightEnd = nrightEnd.substring(0, srightEnd.length);
      if (nextChar >= 5) nrightEnd = "" + ((nrightEnd - 0) + 1);  // round up

 // patch provided by Patti Marcoux 1999/08/06
      while (srightEnd.length > nrightEnd.length) {
        nrightEnd = "0" + nrightEnd;
      }

      if (srightEnd.length < nrightEnd.length) {
        nrightEnd = nrightEnd.substring(1);
        nleftEnd = (nleftEnd - 0) + 1;
      }
    } else {
      for (var i=nrightEnd.length; srightEnd.length > nrightEnd.length; i++) {
        if (srightEnd.charAt(i) == "0") nrightEnd += "0";  // append zero to RHS of number
        else break;
      }
    }

     // adjust leading zeros
    sleftEnd = strip(sleftEnd, "#");  // remove hashes from LHS of format
    while (sleftEnd.length > nleftEnd.length) {
      nleftEnd = "0" + nleftEnd;  // prepend zero to LHS of number
    }

    if (useSeparator) nleftEnd = separate(nleftEnd, separator);  // add separator
    var output = nleftEnd + ((nrightEnd != "") ? "." + nrightEnd : "");  // combine parts
    output = ((useCurrency) ? currency : "") + output + ((usePercent) ? percent : "");
    if (isNegative) {
      output = (useCurrency) ? "(" + output + ")" : "-" + output;
    }
    return output;
  }

  function strip(input, chars) {  // strip all characters in 'chars' from input
    var output = "";  // initialise output string
    for (var i=0; i < input.length; i++)
      if (chars.indexOf(input.charAt(i)) == -1)
        output += input.charAt(i);
    return output;
  }

  function separate(input, separator) {  // format input using 'separator' to mark 000's
    input = "" + input;
    var output = "";  // initialise output string
    for (var i=0; i < input.length; i++) {
      if (i != 0 && (input.length - i) % 3 == 0) output += separator;
      output += input.charAt(i);
    }
    return output;
  }
  
  function gup( name ){  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  var regexS = "[\\?&]"+name+"=([^&#]*)";  var regex = new RegExp( regexS );  var results = regex.exec( window.location.href );  if( results == null )    return "";  else    return results[1];}

//=======Onload=============//
  
window.onload=function(){
 externalLinks();
 initPopupLinks();
 Behaviour.register(myrules);
}