function phantomtext(targetElem, textStr){
	
	elem = document.getElementById( targetElem );
	if(elem.value==textStr)
		elem.value='';
	else if(elem.value=='')
		elem.value=textStr;
	else
		elem.value=elem.value;
}

function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'';
}

function toggleRow(whichLayer){
        var row = document.getElementById(whichLayer);
	if (row.style.display == '')  row.style.display = 'none';
	else row.style.display = '';
    }

function showRow(whichLayer){
        var row = document.getElementById(whichLayer);
	row.style.display = '';
    }

function hideRow(whichLayer){
        var row = document.getElementById(whichLayer);
	row.style.display = 'none';
    }
	
function hideLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'none':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'none';
}

function showLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'':'';
  vis.display = (vis.display==''||vis.display=='block')?'':'';
}
	
	
function loadContent(id, url) {
	  var req = false;
	  // For Safari, Firefox, and other non-MS browsers
	  if (window.XMLHttpRequest) {
		try {
		  req = new XMLHttpRequest();
		} catch (e) {
		  req = false;
		}
	  } else if (window.ActiveXObject) {
		// For Internet Explorer on Windows
		try {
		  req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		  try {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (e) {
			req = false;
		  }
		}
	  }
	 var element = document.getElementById(id);
	 if (!element) {
	  alert("Bad id " + id + 
	   " passed to clientSideInclude." +
	   "You need a div or span element " +
	   "with this id in your page.");
	  return false;
	 } 
		
	  if (req) {
		// Synchronous request, wait till we have it all
		req.open('GET', url, false);
		req.send(null);
		element.innerHTML = req.responseText;
	  } else {
		element.innerHTML =
	   "Sorry, your browser does not support " +
		  "XMLHTTPRequest objects. This page requires " +
		  "Internet Explorer 5 or better for Windows, " +
		  "or Firefox for any system, or Safari. Other " +
		  "compatible browsers may also exist.";
	  }
	  return false;
}

function getContent(url) {
	  var req = false;
	  // For Safari, Firefox, and other non-MS browsers
	  if (window.XMLHttpRequest) {
		try {
		  req = new XMLHttpRequest();
		} catch (e) {
		  req = false;
		}
	  } else if (window.ActiveXObject) {
		// For Internet Explorer on Windows
		try {
		  req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		  try {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (e) {
			req = false;
		  }
		}
	  }
	  
	  if (req) {
		// Synchronous request, wait till we have it all
		req.open('GET', url, false);
		req.send(null);
		return(req.responseText);
	  } else {
		return(
	   "Sorry, your browser does not support " +
		  "XMLHTTPRequest objects. This page requires " +
		  "Internet Explorer 5 or better for Windows, " +
		  "or Firefox for any system, or Safari. Other " +
		  "compatible browsers may also exist.");
	  }
}

function swapOptionImg(optionString)
	{
		var optionArray = optionString.split("|");
		document.images.swapimg.src="/images_product/normal/" + optionArray[5];
		document.getElementById("swapimglink").href="/images_product/normal/" + optionArray[5];
	}
	
function swapAddonImg(image, id)
	{
		document.getElementById("addon" + id).src="/images_product/small/" + image;
		document.getElementById("addonlink" + id).href="/images_product/large/" + image;
	}
	
function swapMainImg(url)
	{
		document.images.swapimg.src='/images_product/normal/' + url;
		document.getElementById("swapimglink").href='/images_product/large/' + url;
	}
	
function swapMediaImg(url, id)
	{
		document.images.swapimg.src='/images_media/' + id + '/normal/' + url;
		document.getElementById("swapimglink").href='/images_media/' + id + '/large/' + url;
	}

function SwapImg(idx, img) 
	{
	   document.images[idx].src = img;
	}
function deptnav(dept) 
	{
	}

function setfocus(element) 
	{
	}
function OpenInvStatus()
	{
	thewindow = window.open('/help_invstatus.lasso', 'invstatus', config='height=400,width=300,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
	}
	
function OpenSizeInfo()
	{
	thewindow = window.open('/help_sizes.lasso', 'sizes', config='height=400,width=300,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
	}
	
function OpenHandlingInfo()
	{
	thewindow = window.open('/help_handling.lasso', 'cartinfo', config='height=300,width=300,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
	}
	
function OpenShippingInfo()
	{
	thewindow = window.open('/help_shipping.lasso', 'cartinfo', config='height=200,width=300,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
	}

function OpenCardCode()
	{
	thewindow = window.open('/help_cardcode.lasso', 'cartinfo', config='height=200,width=300,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
	}

function goToPage( id ) {
  var node = document.getElementById( id );
  // Check to see if valid node and if node is a SELECT form control
  
  if( node && node.tagName == "SELECT" ) {

    // Go to web page defined by the VALUE attribute of the OPTION element
    window.location.href = node.options[node.selectedIndex].value;
    
  } // endif  
}

function RKModalElement(element){
	
	$(element).modal();
}

function RKModalURL(url){
	content=getContent(url);
	$.modal(content);
}

function deleteElement(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
 if (!element) {
  alert("Bad id " + id + 
   " passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
 var elementSaved = document.getElementById(id + '_saved');
 if (!element) {
  alert("Bad id " + id + 
   "_Saved passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
  }
elementSaved.innerHTML = element.innerHTML;
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}

function restoreElement(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
 if (!element) {
  alert("Bad id " + id + 
   " passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
 var elementSaved = document.getElementById(id + '_saved');
 if (!element) {
  alert("Bad id " + id + 
   "_Saved passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);
	var resultString = req.responseText;
	var resultStringPosition = resultString.search('Restored');
	
	if(resultStringPosition >=1){
		element.innerHTML = elementSaved.innerHTML;
		elementSaved.innerHTML = "";
	}
	else {
		element.innerHTML = req.responseText;
		elementSaved.innerHTML = "";
	}
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}

function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function

function getSelectedCheckbox(buttonGroup) {
   // Go through all the check boxes. return an array of all the ones
   // that are selected (their position numbers). if no boxes were checked,
   // returned array will be empty (length will be zero)
   var retArr = new Array();
   var lastElement = 0;
   if (buttonGroup[0]) { // if the button group is an array (one check box is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            retArr.length = lastElement;
            retArr[lastElement] = i;
            lastElement++;
         }
      }
   } else { // There is only one check box (it's not an array)
      if (buttonGroup.checked) { // if the one check box is checked
         retArr.length = lastElement;
         retArr[lastElement] = 0; // return zero as the only array value
      }
   }
   return retArr;
} // Ends the "getSelectedCheckbox" function

function getSelectedCheckboxValue(buttonGroup) {
   // return an array of values selected in the check box group. if no boxes
   // were checked, returned array will be empty (length will be zero)
   var retArr = new Array(); // set up empty array for the return values
   var selectedItems = getSelectedCheckbox(buttonGroup);
   if (selectedItems.length != 0) { // if there was something selected
      retArr.length = selectedItems.length;
      for (var i=0; i<selectedItems.length; i++) {
         if (buttonGroup[selectedItems[i]]) { // Make sure it's an array
            retArr[i] = buttonGroup[selectedItems[i]].value;
         } else { // It's not an array (there's just one check box and it's selected)
            retArr[i] = buttonGroup.value;// return that value
         }
      }
   }
   return retArr;
} // Ends the "getSelectedCheckBoxValue" function

$(document).ready(function(){

	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
	
	$("ul.topnav li span").click(function() { //When trigger is clicked...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});

});

function SwapImg(idx, img) 
{
   document.images[idx].src = img;
}
function deptnav(dept) 
{
}

function setfocus(element) 
{
   
}
function OpenInvStatus()
	{
	thewindow = window.open('/help/help_invstatus.lasso', 'invstatus', config='height=400,width=300,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
	}
	
function OpenSizeInfo()
	{
	thewindow = window.open('/help/help_sizes.lasso', 'sizes', config='height=400,width=300,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
	}
	
function OpenHandlingInfo()
	{
	thewindow = window.open('/help/help_handling.lasso', 'cartinfo', config='height=300,width=300,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
	}
	
function OpenShippingInfo()
	{
	thewindow = window.open('/help/help_shipping.lasso', 'cartinfo', config='height=200,width=300,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
	}

function OpenCardCode()
	{
	thewindow = window.open('/help/help_cardcode.lasso', 'cartinfo', config='height=200,width=300,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
	}

