// function switchDiv()
//  this function takes the id of a div
//  and calls the other functions required
//  to show that div
//


function switchDiv(div_id)
{
  var style_sheet = getStyleObject(div_id);
  if (style_sheet)
  {
    hideAll();
    changeObjectVisibility(div_id,"visible");
  }
  else 
  {
    alert("sorry, this only works in browsers that do Dynamic HTML");
  }
}

// function hideAll()
//  hides a bunch of divs
//
function hideAll()
{
   changeObjectVisibility("Driver","hidden");
   changeObjectVisibility("SerDes","hidden");
  
}

// function getStyleObject(string) -> returns style object
//  given a string containing the id of an object
//  the function returns the stylesheet of that object
//  or false if it can't find a stylesheet.  Handles
//  cross-browser compatibility issues.
//
function getStyleObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  //
  if (objectId != 'SerDes'){
	  objectId = 'Driver'
}
	  
	  
	  
  if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
   }
   else if (document.all && document.all(objectId)) {  
	return document.all(objectId).style;
   } 
   else if (document.layers && document.layers[objectId]) { 
	return document.layers[objectId];
   } else {
	return false;
   }
}

function changeObjectVisibility(objectId, newVisibility) {
    // first get a reference to the cross-browser style object 
    // and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
}

function interfacerecommendedparts() {

   // Input Parameters for non SerDes
   
      DeviceFunction	 	= document.the_form.DeviceFunction.value;
      DataRate        	 	= document.the_form.DataRate.value;
      InputType       	 	= document.the_form.InputType.value;
      NumberofInputs     	= document.the_form.NumberofInputs.value;
      OutputType      	 	= document.the_form.OutputType.value;
	  NumberofOutputs    	= document.the_form.NumberofOutputs.value;
  	  
	  for (i = 0; i < document.the_form.Power_Supply.length; i++) {
         if (document.the_form.Power_Supply[i].checked) {
            Power_Supply = document.the_form.Power_Supply[i].value;
         }
      }
	     
		  
  	   
      
   // Input Parameters for SerDes
   
   	  DeviceFunction	 	= document.the_form.DeviceFunction.value;
   	  DataRateSerDes	 	= document.the_form.DataRateSerDes.value;
   	  MuxRatio 			 	= document.the_form.MuxRatio.value;
   	    	  
   	  for (i = 0; i < document.the_form.Power_Supply_SerDes.length; i++) {
         if (document.the_form.Power_Supply_SerDes[i].checked) {
            Power_Supply_SerDes = document.the_form.Power_Supply_SerDes[i].value;
         }
	  }

      if (DeviceFunction != "SerDes") {
         dest = '/appinfo/webench/interface/recommended_parts.cgi';
      
      new_location  = dest + '?';
      new_location += 'DeviceFunction=' +DeviceFunction;
      new_location += '&DataRate=' + DataRate;
      new_location += '&InputType=' + InputType;
      new_location += '&NumberofInputs=' + NumberofInputs;
      new_location += '&OutputType=' + OutputType;
      new_location += '&NumberofOutputs=' + NumberofOutputs;
      new_location += '&Power_Supply=' + Power_Supply;   
      new_location += '&flow=interface';   
      new_location += '&step=1B'; 
      new_location += '&Topology=Interface+Selection'; 
     //window.open(new_location,"Interface");  
     window.location = new_location;
      }
         
      else if (DeviceFunction == 'SerDes'){
	       dest = '/appinfo/webench/interface/recommended_parts.cgi';
      
      new_location  = dest + '?';
      new_location += 'DeviceFunction=' +DeviceFunction;
      new_location += '&DataRateSerDes=' + DataRateSerDes;
      new_location += '&MuxRatio=' + MuxRatio;
      new_location += '&Power_Supply_SerDes=' + Power_Supply_SerDes;   
      new_location += '&flow=interface';   
      new_location += '&step=1B'; 
      new_location += '&Topology=Interface+Selection';   
     //window.open(new_location,"Interface");     
     window.location = new_location
	      
	   
	      
      }
      
         
         
      

   } // interfacerecommendedparts()


//Display a new window on the screen
   function new_window(dest,h_size,w_size) {

    random = Math.round(Math.random() * 100000);

     popWindow = window.open(dest,random,'toolbar=yes,history=no,location=no,scrollbars=yes,resizable=yes,width=' + h_size + ', height=' + w_size);
      if (navigator.appName.indexOf("Microsoft") == -1) {
         if (navigator.appVersion.charAt(0) >= '3') {
            popWindow.focus();
         }
      }

     if (popWindow.opener == null) {
         popWindow.opener = self;
      }

   } // new_window()