//Universal Window Function Type "yes" or "no" for scrollBar
  function flexWin(aU,aS,aW,aH,aN,aO,aX,aY,aC){
   var wN = aN ? aN : "myWin" + nocacheRandom();
   var oV = aO == "all" ? 1 : 0;
   var oS = "history="+oV+",toolbar="+oV+",location="+oV+",directories="+oV+",status="+oV+",menubar="+oV+",resizable="+oV;
   var wO = aO != "all" ? aO : oS;
   var wW = aW ? aW : 800;wO += ",width=" + wW;
   var wH = aH ? aH : 600;wO += ",height=" + wH;
   var sB = ",scrollbars="+aS;wO+=sB;
   var wX = aX ? aX :(screen.availWidth-wW)/2;wO+=",left="+wX+",screenX="+wX;
   var wY = aY ? aY :((screen.availHeight-wH)/2)-40;wO+=",top="+wY+",screenY="+wY;
   window.open(aU,wN,wO);
   aC ? window.close():"";
  }

//Universal image swapfunction
function rollover(aIN, aIS, aDA){var dA = "";if(document.layers && aDA){for( var i = 0; i < aDA.length; i++ ){dA += 'document.' + aDA[i] + '.';}eval(dA + 'document.' + aIN + '.src ="' + aIS + '";');return true;}else{document[aIN].src = aIS;}}

//Universal function to take user to a page in main window
function targetMainWindow(aU){if(window.blur){self.blur();}if (window.opener.closed){window.open(aU,"newWin");}else{window.opener.location = aU;}}

//Universal function for no cache
function nocacheRandom(){var axel = Math.random() + "";var ord = axel * 1000000000000000000;return ord;}

// generate random number within range passed in
function generateRandomNumber( argRange ) {return 1 + Math.round( Math.random() * ( argRange - 1 ) );}

//Universal function to get parameter from url string
function getParameter(aP){var qS = new String(location.search.substring(1,location.search.length));var p = qS.split("&");var val = "";if(aP){for(i=0;i<p.length;i++){if(p[i].split( "=" )[0] == aP){val = p[i].split( "=" )[1];}}return val;}}

//Universal function to Print Page in all browsers including IE 4
var da = (document.all) ? 1 : 0;var pr = (window.print) ? 1 : 0;var mac = (navigator.userAgent.indexOf("Mac") != -1);

// Code for Flash tracking on sites prior to 3.7.05
function flashTracking(lid, pos, argPN){
  var curPN = hbx.pn +"+-+"+argPN;
  var newPN = curPN.replace(/\s/g,"+");
  if (argPN){
    _hbSet('n',newPN);
  }

}

// Flash link tracking code
function flashLinkTracking(argPN, argMLC, argLid, argLpos, argHEC){
  // Sets current page name.  if argPN has a value it will be added to hbx.pn which is set in the .html page.
  var curPN = (argPN=="")?hbx.pn:hbx.pn + "+-+" + argPN;
  // variables curPN | argLid | newLpos - allow only alphanumeric, spaces, "+" and hypens and then it strips out spaces and makes them "+".
  var newPN = curPN.replace(/[^a-zA-Z0-9,\s,+,-]/g,'').replace(/\s+/g,"+");
  var newLid = argLid.replace(/[^a-zA-Z0-9,\s,+,-]/g,'').replace(/\s+/g,"+");
  var newLpos = argLpos.replace(/[^a-zA-Z0-9,\s,+,-]/g,'').replace(/\s+/g,"+");
  var newMLC = (argMLC=="" || argMLC=="undefined")?hbx.mlc:argMLC;
  
  // Gateway variables are being set for WSS and then sent
    _hbSet('n', newPN);
    _hbSet('vcon', newMLC);
    _hbSet('lid', newLid);
    _hbSet('lpos', newLpos);
    _hbSet('hec', argHEC);
    _hbSend();
}

// Flash page view tracking
function flashPageTracking(argPN, argMLC, argGP){
  // Sets current page name.
  var curPN = hbx.pn +"+-+" + argPN;
  // curPN - allows only alphanumeric, spaces, "+" and hypens and then it strips out spaces and makes them "+".
  var newPN = curPN.replace(/[^a-zA-Z0-9,\s,+,-]/g,'').replace(/\s+/g,"+");
  var stem = location.protocol + '\/\/' + location.host + '\/' + argPN.toLowerCase();
  var newGP = argGP.toLowerCase();
  var newMLC = (argMLC=="" || argMLC=="undefined")?hbx.mlc:argMLC;
  
    // Gateway variables are being set for WSS and then sent
    _hbSet('n', newPN);
    _hbSet('vcon', newMLC);
   // custom variables
    _hbSet('cv.c21', stem);
    _hbSet('cv.c22', hbx.hc22);
  // The page is set as a goal page if "y" is passed to argGP
  if (newGP == "y"){
    _hbSet('gp','LAST');
    _hbSet('gn',argPN);
  }
  _hbSend();
}

// enlarge image - shows hidden div and centers div in browser window
function enlargeImg(divID) {
  winW = getW(divID)/2;
  winH = getH(divID)/2;
  
  if (document.documentElement && document.documentElement.scrollTop) {
    scrollX = document.documentElement.scrollLeft;
    scrollY = document.documentElement.scrollTop;
    } else if (document.body){
    scrollX = document.body.scrollLeft;
    scrollY = document.body.scrollTop;
      } else {
      scrollX = window.pageXOffset;
      scrollY = window.pageYOffset;
  }
  
  this.pgX = document.getElementsByTagName('html').item(0).clientWidth||document.getElementsByTagName('html').item(0).offsetWidth||document.body.offsetWidth||innerWidth;
	this.pgY = document.getElementsByTagName('html').item(0).clientHeight||document.getElementsByTagName('html').item(0).offsetHeight||document.body.offsetHeight||innerHeight;
  this.pgX2 = parseInt(this.pgX/2-winW+scrollX)||0;
	this.pgY2 = parseInt(this.pgY/2-winH+scrollY)||0;
  
  if (b.mac && b.safari) {
    setX(divID, pgX2+'px');
    setY(divID, pgY2-scrollY+'px');
    } else {
      setX(divID, pgX2+'px');
      setY(divID, pgY2+'px');
  }
  showE(divID);
}

// Specs Page Functions
var bustcachevar = 1; //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects = "";
var rootdomain = "http://"+window.location.hostname;
var bustcacheparameter = "";

function closeOverlay(div){
	document.getElementById(div).style.display = 'none';
  if (b.mac && b.safari) {
    showMainImage = document.getElementById('mainImage');
    showOpenNav = document.getElementById('open_nav');
    showPromos = document.getElementById('promos_holder');
    showFeatureItemImg = document.getElementById('feature_item_img');
    	if(showMainImage){showE('mainImage');}
      if(showOpenNav){showE('open_nav');}
      if(showPromos){showE('promos_holder');}
      if(showFeatureItemImg){showE('feature_item_img');}
  }
}

function openOverlay(div){
	document.getElementById(div).style.display = 'block';
}

function expandAll(rows){
  totalRows = rows;
	for (var i = 1; i <= totalRows; i++) {
		document.getElementById('row'+i).style.display = 'block';
    document.getElementById('row'+i+'_toggle').innerHTML = '<img src="/img/minus_button.gif" alt="" width="11" height="11" border="0" align="absbottom">';
	}
  document.getElementById('expand_close').innerHTML = '<a href="javascript:closeAll(totalRows);"><img src="/img/minus_button.gif" alt="" width="11" height="11" border="0" align="absbottom">&nbsp;Collapse All</a>';
}

function closeAll(rows){
  totalRows = rows;
	for (var i = 1; i <= totalRows; i++) {
		document.getElementById('row'+i).style.display = 'none';
    document.getElementById('row'+i+'_toggle').innerHTML = '<img src="/img/plus_button.gif" alt="" width="11" height="11" border="0" align="absbottom">';
	}
  document.getElementById('expand_close').innerHTML = '<a href="javascript:expandAll(totalRows);"><img src="/img/plus_button.gif" alt="" width="11" height="11" border="0" align="absbottom">&nbsp;Expand All</a>';
}

function changeTab(path, category){
  closeOverlay('specsPage');
  specs(path, 'specsPage', category); loadobjs('/css/specs.css');
}

//function doToggleAll(isExpand){for(var i=0;i<allGroup.length;i++){doToggle.apply(allGroup[i],[isExpand]);}}

function specs(url, containerid, category){
  openOverlay('specsWrapper');
  openOverlay('specsPage');
  if (category == 'undefined' || category == '' || category == null){
    category = 'cat1';
  }
  var page_request = false;
  if (window.XMLHttpRequest) // if Mozilla, Safari etc
    page_request = new XMLHttpRequest()
    else if (window.ActiveXObject){ // if IE
      try {
        page_request = new ActiveXObject("Msxml2.XMLHTTP")
      } 
      catch (e){
      try{
        page_request = new ActiveXObject("Microsoft.XMLHTTP")
      }
      catch (e){}
      }
    }
  else
  return false
  page_request.onreadystatechange=function(){
    loadpage(page_request, containerid, category);
  }
  
  if (bustcachevar) { //if bust caching of external page
    bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime();
    page_request.open('GET', url+bustcacheparameter, true);
    page_request.send(null);
    }
  }

  function loadpage(page_request, containerid, category){
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) {
    document.getElementById(containerid).innerHTML=page_request.responseText;
    toggle_specsSubCat('row1','row1_toggle');
    toggle_specsCategory(category);
      if (b.mac && b.safari) {
      hideMainImage = document.getElementById('mainImage');
      hideOpenNav = document.getElementById('open_nav');
      hidePromos = document.getElementById('promos_holder');
      hideFeatureItemImg = document.getElementById('feature_item_img');
      	if(hideMainImage){hideE('mainImage');}
        if(hideOpenNav){hideE('open_nav');}
        if(hidePromos){hideE('promos_holder');}
        if(hideFeatureItemImg){hideE('feature_item_img');}
      }
    }
  }

  function loadobjs(){
    if (!document.getElementById)
    return
    for (i=0; i<arguments.length; i++){
    var file=arguments[i]
    var fileref=""
    if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
      if (file.indexOf(".js")!=-1){ //If object is a js file
        fileref=document.createElement('script')
        fileref.setAttribute("type","text/javascript");
        fileref.setAttribute("src", file);
      }
      else if (file.indexOf(".css")!=-1){ //If object is a css file
        fileref=document.createElement("link")
        fileref.setAttribute("rel", "stylesheet");
        fileref.setAttribute("type", "text/css");
        fileref.setAttribute("href", file);
      }
    }
    if (fileref!=""){
      document.getElementsByTagName("head").item(0).appendChild(fileref)
      loadedobjects+=file+" " //Remember this object as being already added to page
    }
  }
}