  // selection of laptops:
  
  // how it works:
  // add to each tablecell: id="cell_x_y"
  // with x as column-number
  // with y as row-number
  //
  // each product needs a checkbox with name: check_x
  // with x as the column-number
  //
  // set 2 variables (numProd / numRow) on family & serie page
  //
  // set numFeatures-variable on feature ranking page


  var isIE    = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;

  // selecting products
  
  function selectProd(cnt,isFeature) {
   numOfCheck = 0;
   isSelected = null
   
   // check if a product is selected
   for(x=0;x<numProd;x++) {
    if(document.prodTable.elements["check_"+x].checked) {
     isSelected = true
    }   
   } 
   
   // show selected products
   if(isSelected==true) {
    for(x=0;x<numProd;x++) {
     if(!document.prodTable.elements["check_"+x].checked) {
      for(y=0;y<numRow;y++) {
		var cell = document.getElementById("cell_"+x+"_"+y);
		//alert(bosh);
		if (cell)
		{
       		document.getElementById("cell_"+x+"_"+y).style.display = "none";
		}
      }
     } else {
      if(isFeature) {
       numOfCheck++
      }
     }
    }
    toggleButtons("showCell","selectCell",cnt,isFeature,numOfCheck);
   }
  }
  
  //used for selecting products on series print page
  function getSelectedProdParam(){
	
    var result = "";
    var oidList = "";
    for(x=0;x<numProd;x++) {
      if(document.prodTable.elements["check_"+x].checked) {
        var prodIdInput = document.getElementById("hiddenProdId_"+x);
        if( prodIdInput!=null ){
          oidList += prodIdInput.value+"-";
        }
      }
    }
		
    if( oidList != "" ){
      result = "selectedProd/-" + oidList;
    }
    return result;
  }

  /*
  function getSelectedProdParam(){
    var result = "";
    var oidList = "";
    for(x=0;x<numProd;x++) {
      if(document.prodTable.elements["check_"+x].checked) {
        var prodIdInput = document.getElementById("hiddenProdId_"+x);
        if( prodIdInput!=null ){
          oidList += prodIdInput.value+"|";
        }
      }
    }
    if( oidList != "" ){
      result = "&selectedProd=|" + oidList;
    }
    return result;
  }

*/
  
  // show all products
  
  function showAll(cnt,isFeature) {
   for(x=0;x<numProd;x++) {
    for(y=0;y<numRow;y++) {
     if(!document.prodTable.elements["check_"+x].checked) {
		var cell = document.getElementById("cell_"+x+"_"+y);
		if(cell)
		{
      		if(isIE) {
       			cell.style.display = "block";
      		} else {
       			cell.style.display = "table-cell";
      		}
		}
     }
    }
    document.prodTable.elements["check_"+x].checked = false;
   }
   toggleButtons("selectCell","showCell",cnt,isFeature,0);
  }
  
  
  // toggle select & show all buttons
  // +
  // on feature ranking page: show/hide right featuretitle
  
  function toggleButtons (showC,hideC,cnt,isFeature,numOfCheck) {

   for(x=0;x<cnt;x++) {
    document.getElementById(hideC+"_"+x).style.display = "none";

    if(isIE) {
     document.getElementById(showC+"_"+x).style.display = "block";
    } else {
     document.getElementById(showC+"_"+x).style.display = "table-cell";
    }
   }
   
   
   // on feature rank page, when less then 4 products selected, hide title
   if(isFeature) {
    if(showC=="showCell") {
     if(numOfCheck<4) {
      for(y=0;y<numFeatures;y++) {
       document.getElementById("featureTitle_"+y).style.display = "none";
      }
     } 
    } else {
     for(y=0;y<numFeatures;y++) {
      document.getElementById("featureTitle_"+y).style.display = "block";
     }
    }
   }
   
  }



// show optionsserie

// how it works:
//
// add to each serie-block: id="serie_x"
// add to each "plus"-icon: id="show_x"

// compatible option page:
//
// add to each product-block: id="prod_x_y_z"
// add to each title-block: id="titleRow_x"
//
// for print, set numSerie = null

// numSerie   : numbers of serie
// serie      : serie which has to be shown
// isShow     : show serie or close serie
// isCompOpt  : compatible options page or not
// highNum    : num of elements in row which has to be highlighted
// highLight  : highlight product (compatible optionpage)


  var printSerie = null;
  
  function showSerie(numSerie,serie,isCompOpt,highNum,highLight) {
   // check if serie is shown or not
   var isOpen = 0;
   if ((serie!=null) && (serie!='null')) 
   isOpen = (document.getElementById("serie_"+serie).style.display != "none") ? 1 : 0;
 
   // for printpage numSerie = null, we dont have to hide all layer
   if (numSerie!=null) {
    for(x=0;x<numSerie;x++) {
     document.getElementById("serie_"+x).style.display = "none";
     if(!isCompOpt) {
      document.getElementById("show_"+x).src = "/images/icon_plus.gif";
     }
    }
    if(!isCompOpt) {
     document.getElementById("show_"+serie).src = "/images/icon_minus.gif";
    } else {
     for(x=0;x<numSerie;x++) {
      if(isIE) {
       document.getElementById("titleRow_"+x).style.display = "block";
      } else {
       document.getElementById("titleRow_"+x).style.display = "table-row";
      }
     }
     document.getElementById("titleRow_"+serie).style.display = "none";
    }
   } else if ((serie!=null) && (serie!='null')) {
    //if((!isCompOpt) || (isCompOpt == '1')) 
    //document.getElementById("show_"+serie).src = "/images/icon_minus.gif";
   }
	   
   
   if(!isOpen) {
    printSerie = serie;
    if ((serie!=null) && (serie!='null')) {
    if(isIE) {
     document.getElementById("serie_"+serie).style.display = "block";
    } else {
     if(!isCompOpt) {
      document.getElementById("serie_"+serie).style.display = "table-row";
     } else {
      document.getElementById("serie_"+serie).style.display = "table-row-group";
     }
    }
    }
   } else {
    printSerie = null;
    if ((serie!=null) && (serie!='null')) {
	    if(isCompOpt) {
	     if(isIE) {
	      document.getElementById("titleRow_"+serie).style.display = "block";
	     } else {
	      document.getElementById("titleRow_"+serie).style.display = "table-row";
	     }
	    } else {
	     document.getElementById("show_"+serie).src = "/images/icon_plus.gif";
	    }
    }
   }
   if ((serie!=null) && (serie!='null')) {
	   if(highLight!=null) {
	    for(h=0;h<highNum;h++) {
	     document.getElementById("prod_" +serie+ "_" +highLight+ "_" +h).style.backgroundColor = "#ffd9d9";
	    }
	   }
   }
  }
  
  // shows optionsserie but doesn't hide series that have been opened before
  // params as in showSerie()
  function showOneSerie(numSerie,serie,isCompOpt,highNum,highLight) {
   // check if serie is shown or not
   var isSerieToOpen = 0;
   
   if ( (serie!=null) && (serie!='null') ) {
    isSerieToOpen = (document.getElementById("serie_"+serie).style.display != "none") ? 0 : 1;
   
    if( isSerieToOpen ) { // details to open, title to hide
      if( isCompOpt ){
        // hide title row if not print page
        if( numSerie != null ){
          document.getElementById("titleRow_"+serie).style.display = "none";
        }
        // display selected details
        if( isIE ){ document.getElementById("serie_"+serie).style.display = "block"; }
        else{      document.getElementById("serie_"+serie).style.display = "table-row-group"; }
      }else{
        if( numSerie != null ){
          // hide title row
          document.getElementById("show_"+serie).src = "/images/icon_minus.gif";
          // display selected details
          if( isIE ){ document.getElementById("serie_"+serie).style.display = "block"; }
          else{      document.getElementById("serie_"+serie).style.display = "table-row"; }
        }
      }      
    }else{               // details to hide, title to show
      if( numSerie != null ){  // functionality not for print page
        // hide details
        document.getElementById("serie_"+serie).style.display = "none";
        // show title row
        if( !isCompOpt ) {
          document.getElementById("show_"+serie).src = "/images/icon_plus.gif";
        }else{ // isCompOpt
          if( isIE ){ document.getElementById("titleRow_"+serie).style.display = "block"; }
          else{      document.getElementById("titleRow_"+serie).style.display = "table-row"; }
        }
      }
    }

    // set variable printSerie = serie (for all opened series);
    if( numSerie!=null ){
      printSerie = "";
      isEmptyPrintSerie = 1;
      for( x=0; x<numSerie; x++ ) {
        if( document.getElementById("serie_"+x).style.display != "none" ){
          if( isEmptyPrintSerie==1 ){
            printSerie = x;
            isEmptyPrintSerie = 0;
          }else{
            printSerie = printSerie + '&printSerie=' + x;
          }
        }
      }
    }

   }
 
   // for printpage numSerie = null, we dont have to hide all layer
   if (numSerie!=null) {
     // highlight selected prod_serie
     if( (serie!=null) && (serie!='null') ){
	   if( highLight != null ){
	     for( h=0; h<highNum; h++ ) {
	       document.getElementById("prod_" +serie+ "_" +highLight+ "_" +h).style.backgroundColor = "#ffd9d9";
	     }
	   }
     }
   }

  }

  
  function showPrint() {
   
   var comOpt;
   var allValOfUrlParams;
   var printSerie;
   
   if (typeof friendlyUrls != 'undefined' && friendlyUrls == true) {
	  comOpt = friendlyArgItems("comOpt");
	  allValOfUrlParams = friendlyAllValuesOfUrlParam("printSerie");
	  printSerie = friendlyArgItems("printSerie");
   } else {
	  comOpt = argItems("comOpt");
	  allValOfUrlParams = allValuesOfUrlParam("printSerie");
	  printSerie = argItems("printSerie");
   }
    
   if( allValOfUrlParams && allValOfUrlParams.length > 1 ){
     for( var idx=0; idx<allValOfUrlParams.length; idx++ ){
       showOneSerie( null, allValOfUrlParams[idx], comOpt );
     }
   }else{
     if( printSerie!=null && printSerie!="" ){
       showSerie(null,printSerie,comOpt)
     }
   }

} 
  
  
  // function to get var from url

  function argItems (theArgName) {
  	sArgs = location.search.slice(1).split('&');
      r = '';
      for (var i = 0; i < sArgs.length; i++) {
          if (sArgs[i].slice(0,sArgs[i].indexOf('=')) == theArgName) {
              r = sArgs[i].slice(sArgs[i].indexOf('=')+1);
              break;
          }
      }
      return (r.length > 0 ? unescape(r).split(',') : '')
  }
  
  function friendlyArgItems(theArgName) {
	var re = new RegExp("/"+theArgName+"/([^/]*)/?");
	var match = re.exec(location);
	if (match != null && match.length>1) {
		return unescape(match[1]);
	} else {
	    return null;
	}
  }
  
  
  // function returns array of url parameter values (name of param as func. argument)
  function allValuesOfUrlParam( paramName ){
    var resTab = new Array();
    var tabIdx = 0;
  	sArgs = location.search.slice(1).split('&');
    
	for( var i = 0; i < sArgs.length; i++ ){
      if( sArgs[i].slice(0,sArgs[i].indexOf('=')) == paramName ){
        var paramVal = sArgs[i].slice(sArgs[i].indexOf('=')+1);
        if( paramVal!=null && paramVal!="" ){
          resTab[tabIdx] = paramVal;
          tabIdx++;
        }
      }
    }
    return resTab;
  }
  
function friendlyAllValuesOfUrlParam( paramName ){
    var resTab = new Array();
    var tabIdx = 0;
	var re = new RegExp("/"+paramName+"/([^/]*)/?", "g");
	var vars = location.toString().match(re);
	var length = (vars != null) ? vars.length : 0;	
	for (var i=0; i<length; i++) {
		var param = vars[i];
		var re2 = new RegExp("/"+paramName+"/([^/]*)/?", "g");
		var match = re2.exec(param);		
		if (match != null && match.length>1) {
			resTab[tabIdx] = match[1];
			tabIdx++;
		}
	}	
    return resTab;
}

 function printPageSelection (num,url) {
  var showSel = "";
  for(x=0;x<num;x++) {
   if(document.prodTable.elements["check_"+x].checked) {
    showSel += document.prodTable.elements["hidden_"+x].value + "|";
   }
  }
  if(showSel==""){
   for(x=0;x<num;x++) {
     showSel += document.prodTable.elements["hidden_"+x].value + "|";
   }
  }
  window.open(url+"?showSel="+showSel,'print_page','menubar=yes,toolbar=no,status=no,width=850,height=450,scrollbars=yes,resizable=yes')
 }

 
 function showTable (num) {
  
  //showSel = argItems("showSel");
  showSel = friendlyArgItems("showSel");
  
  var showSelStr = String(showSel); 
  var showSelArr = showSelStr.split("-");
  showSelArr.pop();
  
  for(x=0;x<showSelArr.length;x++) {
   for(y=0;y<numNotebookItems;y++) {
    document.getElementById("cell_"+x+"_"+y).innerHTML  = notebook[showSelArr[x]][y];
    if(isIE) {
     document.getElementById("cell_"+x+"_"+y).style.display = "block";
    } else {
     document.getElementById("cell_"+x+"_"+y).style.display = "table-cell";
    }
   }
  }
  
 }
 
function setHeaderTableSize() {
 setSizeIe = document.documentElement.clientWidth - 50;
  if(isIE && numProd > 4) {
   document.getElementById("wrapNaviBg").style.width= setSizeIe+"px";
   document.getElementById("headerTab").style.width=setSizeIe+"px";
  }
} 


