      function MM_findObj(n, d) { //v4.01
        var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
        if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
        for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
        if(!x && d.getElementById) x=d.getElementById(n); return x;
      }
      function MM_showHideLayers() { //v6.0
        var i,p,v,obj,args=MM_showHideLayers.arguments;
        for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
        if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
        obj.visibility=v; }
      }
      function MM_jumpMenu(targ,selObj,restore){ //v3.0
        eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
        if (restore) selObj.selectedIndex=0;
      }
      // Moved from old site / Creates a pop up
      function newWindow(theURL,winName,features) { //v2.0
        window.open(theURL,winName,features);
      } 

function runSlideShow(runOnce) {
  var slideShowSpeed = 5000;
  var crossFadeDuration = 3;
  var customer_logo = new Array();
  var runOnce = runOnce;

  customer_logo[1] = '/images/testimonials/SEOmoz-testimonial-image.jpg';
  customer_logo[0] = '/images/testimonials/DNS-Stuff-testimonial-image.jpg';
  customer_logo[2] = '/images/testimonials/SourceForge-testimonial-image.jpg';
  customer_logo[3] = '/images/testimonials/CentOS-testimonial-image.jpg';
  customer_logo[4] = '/images/testimonials/student-center-testimonial-image.jpg';

  var t;
  if(!runOnce){
    var j = 0;
  } else {
    var j = runOnce;
  }

  var p = customer_logo.length;
  var preLoad = new Array();
  for (i = 0; i < p; i++) {
    preLoad[i] = new Image();
    preLoad[i].src = customer_logo[i];
  }

  if (document.all) {
    document.images.SlideShow.style.filter="blendTrans(duration=2)";
    document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
    document.images.SlideShow.filters.blendTrans.Apply();
  }
  document.images.SlideShow.src = preLoad[j].src;
  if (document.all) {
    document.images.SlideShow.filters.blendTrans.Play();
  }

  j = j + 1;
  if (j > (p - 1)) j = 0;
  t = setTimeout('runSlideShow(' + j + ')', slideShowSpeed);

}

function swapText(element_id, replacement_text){
  var element_id = element_id;
  var replacement_text = replacement_text;  
  document.getElementById(element_id).innerHTML = replacement_text;
}

function swapImage(originalImage, newImage){
  var originalImage = originalImage;
  var newImage = newImage;
  document.getElementById(originalImage).src=newImage;
}

function setActive(active,section){
  var active = active;
  var section = section;
  var activeTab = section + '-' + active;
  document.getElementById(activeTab).className='submenu-active';
}

function submenuMouseOver(tab,section){
  document.getElementById(section+'-'+tab).style.background='url(/images/submenu-icon-on.jpg) top center no-repeat';
}

function submenuMouseOut(tab,section){
  var tab = tab;
  var section = section;
  var className=document.getElementById(section+'-'+tab).className;
  if(className!='submenu-active'){
    document.getElementById(section+'-'+tab).style.background='url(/images/submenu-icon.jpg) top center no-repeat';
  }
}

function swapTab(active,inactive){
  var activeTab = active;
  var tablist = inactive;
  var inactiveTabs = tablist.split(',');
  
  for(var i=0;i<inactiveTabs.length;i++){
    var x = inactiveTabs[i];
    var y = inactiveTabs[i]+'-tab';
    
    document.getElementById(x).style.visibility='hidden';
    document.getElementById(x).style.position='absolute';
    document.getElementById(x).style.marginTop='-1700px';
    document.getElementById(y).style.width='87px';
    document.getElementById(y).style.color='#036';
  }

  document.getElementById(activeTab).style.visibility='visible';
  document.getElementById(activeTab).style.position='relative';
  document.getElementById(activeTab).style.marginTop='0px';
  document.getElementById(activeTab+'-tab').style.width='130px';
  document.getElementById(activeTab+'-tab').style.color='#A30000';
}

function featureFocus(active,inactive,number){
  var number = number;
  var focusItem = active;
  var normal = inactive;
  var normalItems = normal.split(',');

  for(var i=0;i<normalItems.length;i++){
    var x = normalItems[i];
    var y = normalItems[i]+'-tab';
    
    document.getElementById(y).className='featureTab';
    for(var n=1;n<=number;n++){
      //alert(x+'-'+n);
      document.getElementById(x+'-'+n).style.color='#333';
    }
  }
  document.getElementById(focusItem+'-tab').className='featureTab-active';
  for(var i=1;i<=number;i++){
    document.getElementById(focusItem+'-'+i).style.color='#A30000';
  }
}


function popup(vis,width,height,display,content){
  grayOut(true,{'opacity':'60'});
  var width = width || '400';
  var height = height || '300px';
  var display = display;
  var id = 'popup';
  var left = (document.body.offsetWidth - width)/2;
  var popupWindow = document.getElementById(id);
  var topMargin = (window.pageYOffset + (screen.availHeight/2));
  if(topMargin = "NaN"){topMargin = (document.documentElement.scrollTop + (screen.availHeight/2));}
  if(!popupWindow){
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');
    tnode.style.position='absolute';
    tnode.style.top=topMargin+'px';
    tnode.style.left=left+'px';
    tnode.style.overflow='hidden';
    tnode.id=id;
    tbody.appendChild(tnode);
    popupWindow = document.getElementById(id);
  } else {
    popupWindow.style.top=topMargin+'px';
  }
  if(vis){
    popupWindow.style.display=display;
    popupWindow.style.background='#FFF';
    popupWindow.style.zIndex=75;
    popupWindow.style.margin='0px auto';
    popupWindow.style.marginTop='-'+((height/2)+45)+'px';
    popupWindow.textAlign='center';
    popupWindow.innerHTML = "<div onClick=\"popup(false);\" style='cursor:pointer' />"+content+"<br /><div class='bold-red' style='cursor:pointer;margin:5px 0px;' onClick=\"popup(false);\">click on the image to close window</div></div>";
  } else {
    //popupWindow.style.display='none';
    popupWindow.innerHTML = "";
    grayOut(false);
  }
}

function grayOut(vis, options) {
  var options = options || {};   
  var zindex = options.zindex || 50;  
  var opacity = options.opacity || 70;  
  var opaque = (opacity / 100);  
  var bgcolor = options.bgcolor || '#000000';  
  var dark=document.getElementById('darkenScreenObject');  
  if (!dark) {    
	var tbody = document.getElementsByTagName("body")[0];    
	var tnode = document.createElement('div');           // Create the layer.        
	    tnode.style.position='absolute';                 // Position absolutely        
		tnode.style.top='0px';                           // In the top        
		tnode.style.left='0px';                          // Left corner of the page        
		tnode.style.overflow='hidden';                   // Try to avoid making scroll bars                    
		tnode.style.display='none';                      // Start out Hidden        
		tnode.id='darkenScreenObject';                   // Name it so we can find it later    
	tbody.appendChild(tnode);                            // Add it to the web page    
	dark=document.getElementById('darkenScreenObject');  // Get the object.  
  }  
  if (vis) {    
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
      var pageWidth = document.body.scrollWidth+'px';        
      var pageHeight = document.body.scrollHeight+'px';    
    } else if( document.body.offsetWidth ) {      
	    var pageWidth = document.body.offsetWidth+'px';      
	    var pageHeight = document.body.offsetHeight+'px';    
	  } else {       
	    var pageWidth='100%';       
	    var pageHeight='100%';    
	  }       
    dark.style.opacity=opaque;                          
    dark.style.MozOpacity=opaque;                       
    dark.style.filter='alpha(opacity='+opacity+')';     
    dark.style.zIndex=zindex;            
    dark.style.backgroundColor=bgcolor;      
    dark.style.width= pageWidth;    
    dark.style.height= pageHeight;    
    dark.style.display='block';
  } else {     
    dark.style.display='none';  
  }
}
//
//For the SLB order form
//
function addServer() {
  var ni = document.getElementById('addServer');
  var numi = document.getElementById('theServer');
  if(document.getElementById("theServer").value < 3){
    var num = (document.getElementById("theServer").value -1)+ 3;
  } else {
    var num = (document.getElementById("theServer").value -1)+ 2;
  }
  numi.value = num;
  var divIdName = "add_server"+num;
  var newdiv = document.createElement('div');
  newdiv.setAttribute("id",divIdName);
  newdiv.innerHTML = "<fieldset class='toggleGroup' style='border:0px solid #FFF;background:transparent;'><div style='padding:10px;'><h2 style='margin:10px;width:580px;'>Cluster Settings</h2><div align='center' style='margin:10px;width:570px;'><div style='float:left;text-align:center;width:100%;line-height:150%;'><div style='border:1px solid white;'><div style='display:inline;float:left;width:175px;text-align:right;padding-right:10px;'>Load Distribution Policy</div><div align='left'><select id='cluster-" + num + "-policy' name='cluster-" + num + "-policy' class='toggleEnable' onChange=\"toggleSections()\"><option value='round_robin'>Round Robin</option><option value='static_weight'>Static Weight</option><option value='fastest_response'>Fastest Response</option><option value='least_connections'>Least Connections</option></select></div></div><div style='border:1px solid #FFF;text-align:left;font-size:11px;color:#666;padding-left:20px;'>How visitors are distributed between servers.</div><div style='height:10px;'>&nbsp;</div><div><div style='postition:absolute;display:inline;float:left;width:175px;text-align:right;padding-right:10px;'>TCP Port Number</div><div align='left'><input type='text' name='cluster-" + num + "-server_port'><br /></div></div><div style='padding:10px 0px;'><div align='left'>Enable Active Content Verification (ACV)? - optional<input onClick=\"toggleACV(document.getElementById('cluster-"+num+"-enableACV').checked, '"+num+"');\" id='cluster-"+num+"-enableACV' name='cluster-"+num+"-enableACV' value='enabled' type='checkbox'></div><div style='border:1px solid #FFF;text-align:left;font-size:11px;color:#666;'>Enables content based health check.</div><div id='cluster-"+num+"-ACV_options'></div></div><div><div style='display:inline;float:left;width:175px;text-align:right;padding-right:10px;'>Type</div><div align='left'><select id='cluster-"+num+"-portType' name='cluster-" + num + "-type' onChange=\"togglePort(getElementById('cluster-"+num+"-portType').value,'"+num+"');\"><option value='TCP'>TCP (Layer 4)</option><option value='HTTP'>HTTP (Layer 7)</option><option value='HTTPS'>HTTPS (SSL offload)</option></select></div><div id='cluster-"+num+"-port_options'><div align='left' style='border:1px solid #FFF;margin:10px;'><div style='border:1px solid #FFF;'>L4 TCP Cluster Options:</div><div style='border:1px solid #FFF;'><div style='display:inline;float:left;width:175px;text-align:right;padding-right:10px;'>Sticky Time</div><div style='border:1px solid #FFF;'><select name='cluster-1-stickyTime'><option value='0sec'>0sec</option><option value='300sec'>300sec</option><option value='600sec'>600sec</option><option value='900sec'>900sec</option><option value='1200sec'>1200sec</option></select></div><div style='border:1px solid #FFF;text-align:left;font-size:11px;color:#666;padding-left:20px;'>How long requests from a given source IP 'stick' to a server.</div></div><div align='left' style='border:1px solid #FFF;text-align:left;'><div style='border:1px solid #FFF;display:inline;float:left;width:175px;text-align:right;padding-right:10px;'>Probe SSL</div><select name='cluster-1-probeSSL'><option value='disabled'>Disabled</option><option value='enabled'>Enabled</option></select></div></div><div style='border:1px solid #FFF;text-align:left;font-size:11px;color:#666;padding-left:20px;'>Must be enabled on SSL protected TCP services or health check will fail.</div></div></div></div><h3 style='margin:10px;width:580px;padding-top:10px;text-align:left;'>Server Connections</h3><div style='margin:10px;'><div style='padding:10px;text-align:right;line-height:145%'><div style='float:left;width:175px;padding-right:10px;'>IP</div><div align='left' style='border:1px solid #FFF;'><input type='text' name='cluster-"+num+"-ip-A'></div><div style='float:left;width:175px;padding-right:10px;'>Port</div><div align='left' style='border:1px solid #FFF;'><input type='text' name='cluster-"+num+"-port-A'></div><div style='float:left;width:175px;padding-right:10px;'>Maximum connections</div><div align='left' style='border:1px solid #FFF;'><input type='text' name='cluster-"+num+"-max_conn-A'></div><div id='cluster-"+num+"-weight' class='toggleField' style='float:left;width:175px;padding-right:10px;'>Weight</div><div align='left' style='border:1px solid #FFF;'><input id='cluster-"+num+"-weight_input' class='toggleField' type='text' name='cluster-"+num+"-weight-A'></div><div style='float:left;width:175px;padding-right:10px;'>Hot spare?</div><div align='left' style='border:1px solid #FFF;'><input type='checkbox' name='cluster-"+num+"-hot_spare-A'></div></div></div><div style='margin:10px;'><div style='padding:10px;text-align:right;line-height:145%'><div style='float:left;width:175px;padding-right:10px;'>IP</div><div align='left' style='border:1px solid #FFF;'><input type='text' name='cluster-"+num+"-ip-B'></div><div style='float:left;width:175px;padding-right:10px;'>Port</div><div align='left' style='border:1px solid #FFF;'><input type='text' name='cluster-"+num+"-port-B'></div><div style='float:left;width:175px;padding-right:10px;'>Maximum connections</div><div align='left' style='border:1px solid #FFF;'><input type='text' name='cluster-"+num+"-max_conn-B'></div><div id='cluster-"+num+"-weightb' class='toggleField' style='float:left;width:175px;padding-right:10px;'>Weight</div><div align='left' style='border:1px solid #FFF;'><input id='cluster-"+num+"-weightb_input' class='toggleField' type='text' name='cluster-"+num+"-weight-B'></div><div style='float:left;width:175px;padding-right:10px;'>Hot spare?</div><div align='left' style='border:1px solid #FFF;'><input type='checkbox' name='cluster-"+num+"-hot_spare-B'></div></div></div><div id='cluster-" + num + "-serverConnection'></div><input type='hidden' value='0' id='cluster-" + num + "-theConnection' /></fieldset><div style='margin:10px;display:block;width:580px;'><div onClick='addServerConnection(" + num + ");toggleSections();' style='color:#FFF;width:180px;height:27px;text-align:center;cursor:pointer;margin:0px 0px 0px 20px;padding:5px;background:transparent url(/images/Superb_SLB_add_server.jpg) top center no-repeat;font-size:10px;font-family:verdana;font-weight:bold;'>Add a server to this cluster</div></div></div><div onclick=\"removeElement(\'"+divIdName+"\', 'addServer')\" style='cursor:pointer;width:180px;height:27px;color:#FFF;background:transparent url(/images/Superb_SLB_remove.jpg) top center no-repeat;text-align:center;padding:5px;margin:-40px 0px 10px 360px;font-size:10px;font-family:verdana;font-weight:bold;'>Remove Cluster</div>";
  ni.appendChild(newdiv);
}

function addServerConnection(numConnect) {
  if(!numConnect){
    var numberConnections = 1;
  } else {
    var numberConnections = numConnect;
  }
  var ni = document.getElementById('cluster-' + numberConnections + '-serverConnection');
  var numi = document.getElementById('cluster-' + numberConnections + '-theConnection');
  var num = (document.getElementById('cluster-' + numberConnections + '-theConnection').value -1)+ 2;
  numi.value = num;
  var divIdName = "cluster-" + numberConnections + "server_connection" +num;
  var newdiv = document.createElement('div');
  newdiv.setAttribute("id",divIdName);
  newdiv.innerHTML = "<div id='cluster-" + numberConnections + "server_connection" + num + "' style='margin:10px;'><div style='padding:10px;text-align:right;line-height:145%'><div style='float:left;width:175px;padding-right:10px;'>IP</div><div align='left' style='border:1px solid #FFF;'><input type='text' name='cluster-"+numberConnections+"-ip-"+num+"'></div><div style='float:left;width:175px;padding-right:10px;'>Port</div><div align='left' style='border:1px solid #FFF;'><input type='text' name='cluster-"+numberConnections+"-port-"+num+"'></div><div style='float:left;width:175px;padding-right:10px;'>Maximum Connections</div><div align='left' style='border:1px solid #FFF;'><input type='text' name='cluster-"+numberConnections+"-max_conn-"+num+"'></div><div id='cluster-"+numberConnections+"-weight' class='toggleField' style='float:left;width:175px;padding-right:10px;'>Weight</div><div align='left' style='border:1px solid #FFF;'><input id='cluster-"+numberConnections+"-weight_input' class='toggleField' type='text' name='cluster-"+num+"-weight-A'></div><div style='float:left;width:175px;padding-right:10px;'>Hot Spare?</div><div align='left' style='border:1px solid #FFF;'><input type='checkbox' name='cluster-"+num+"-hot_spare-A'></div></div></div><div onclick=\"removeElement(\'"+divIdName+"\', 'cluster-" + numberConnections + "-serverConnection')\" style='cursor:pointer;width:180px;height:27px;color:#FFF;background:transparent url(/images/Superb_SLB_remove.jpg) top center no-repeat;text-align:center;padding:5px;margin:-73px 0px 30px 380px;font-size:10px;font-family:verdana;font-weight:bold;'>Remove Server Connection</div>";
  ni.appendChild(newdiv);
  if(document.getElementById('policy').value == 'static_weight'){
    var showWeight = "cluster-"+numberConnections+"-weight";
    var showWeightInput = "cluster-"+numberConnections+"-weight_input"
    document.getElementById(showWeight).style.visibility = 'visible';
    document.getElementById(showWeightInput).style.visibility = 'visible';
  }
}

function removeElement(divNum, divName) {
  var d = document.getElementById(divName);
  var olddiv = document.getElementById(divNum);
  d.removeChild(olddiv);
}

function togglePort(portType, clusterNum) {
  var togglePort = portType;
  if(!clusterNum){
    clusterNum = "1";
    var cluster = "port_options";
  } else {
    var cluster = "cluster-" + clusterNum + "-port_options";
  }
  if (togglePort == "default"){
    var selectPort = document.getElementById(cluster).innerHTML = "";
  } else if (togglePort == "TCP"){
    document.getElementById(cluster).innerHTML = "<div align='left' style='border:1px solid #FFF;margin:10px;'><div style='border:1px solid #FFF;'>L4 TCP Cluster Options:</div><div style='border:1px solid #FFF;'><div style='display:inline;float:left;width:175px;text-align:right;padding-right:10px;'>Sticky Time</div><div style='border:1px solid #FFF;'><select name='cluster-"+clusterNum+"-stickyTime'><option value='0sec'>0sec</option><option value='300sec'>300sec</option><option value='600sec'>600sec</option><option value='900sec'>900sec</option><option value='1200sec'>1200sec</option></select></div><div style='border:1px solid #FFF;text-align:left;font-size:11px;color:#666;padding-left:20px;'>How long requests from a given source IP 'stick' to a server.</div></div><div align='left' style='border:1px solid #FFF;text-align:left;'><div style='border:1px solid #FFF;display:inline;float:left;width:175px;text-align:right;padding-right:10px;'>Probe SSL</div><div style='border:1px solid #FFF;'><select name='cluster-"+clusterNum+"probeSSL'><option value='disabled'>Disabled</option><option value='enabled'>Enabled</option></select></div></div><div style='border:1px solid #FFF;text-align:left;font-size:11px;color:#666;padding-left:20px;'>Must be enabled on SSL protected TCP services or health check will fail.</div></div>";
  } else if (togglePort == "HTTP") {
    var selectPort = document.getElementById(cluster).innerHTML = "<div align='left' style='border:1px solid #FFF;margin:10px;w'><div style='border:1px solid #FFF;'>L7 HTTP Cluster Options:</div><div style='border:1px solid #FFF;'><div style='display:inline;float:left;width:175px;text-align:right;padding-right:10px;'>Cookie Age</div><input type='text' name='cluster-"+clusterNum+"-cookieAge' /><div style='font-size:11px;border:1px solid #FFF;color:#666;'>Seconds (600 - 3600). Should match web server's session expiration.</div></div><div style='border:1px solid #FFF;'><div style='display:inline;float:left;width:175px;text-align:right;padding-right:10px;'>Cookie domain</div><input type='text' name='cluster-"+clusterNum+"-cookieDomain' /><div style='font-size:11px;border:1px solid #FFF;color:#666;'>Domain name for the cookie. Must match web server configuration.</div></div></div>";
  } else if (togglePort == "HTTPS") {
    var selectPort = document.getElementById(cluster).innerHTML = "<div align='left' style='border:1px solid #FFF;margin:10px;'><div style='border:1px solid #FFF;'>L7 HTTPS Cluster Options:</div><div style='border:1px solid #FFF;'><div style='display:inline;float:left;width:175px;text-align:right;padding-right:10px;'>Cookie Age</div><input type='text' name='cluster-"+clusterNum+"-HTTPS-cookieAge' /><div style='font-size:11px;border:1px solid #FFF;color:#666;'>Seconds (600 - 3600). Should match web server's session expiration.</div></div><div style='border:1px solid #FFF;'><div style='display:inline;float:left;width:175px;text-align:right;padding-right:10px;'>Cookie domain</div><input type='text' name='cluster-"+clusterNum+"-HTTPS-cookieDomain' /><div style='font-size:11px;border:1px solid #FFF;color:#666;'>Domain name for the cookie. Must match web server configuration.</div></div></div><div style='font-size:11px;text-align:left;padding:0px 10px 10px 10px;width:420px;'><span style='color:#A30000;font-weight:bold'>NOTE: </span>Customer is responsible for generating the SSL Certificate and E-mailing it to our Technical Team to be applied.</div></div>";
  }
}

function addWeight(value, clusterNum){
  if(!clusterNum){
    var clusterNum = 1;
  }
    var cluster = "cluster-"+clusterNum+"-weight";
    var cluster_input = "cluster-"+clusterNum+"-weight_input";
    var clusterb = "cluster-"+clusterNum+"-weightb";
    var clusterb_input = "cluster-"+clusterNum+"-weightb_input";
    
  if((value == "static_weight")){
    document.getElementById(cluster).style.visibility = 'visible';
    document.getElementById(cluster_input).style.visibility = 'visible';
    document.getElementById(clusterb).style.visibility = 'visible';
    document.getElementById(clusterb_input).style.visibility = 'visible';
  } else {
    document.getElementById(cluster).style.visibility = 'hidden';
    document.getElementById(cluster_input).style.visibility = 'hidden';
    document.getElementById(clusterb).style.visibility = 'hidden';
    document.getElementById(clusterb_input).style.visibility = 'hidden';
  }
}

function toggleACV(state, clusterNum) {
  if(!clusterNum){
    var cluster = "ACV_options";
    var clusterNum = 1;
  } else {
    var cluster = "cluster-"+clusterNum+"-ACV_options";
  }
  if((!state)) {
    document.getElementById(cluster).innerHTML = "";
  } else {
    document.getElementById(cluster).innerHTML = "<div><div style='display:inline;float:left;width:175px;text-align:right;padding-right:10px;'>ACV Probe</div><div align='left'><input type='text' name='cluster-"+clusterNum+"-ACVprobe'><div style='padding-left:185px;font-size:11px;color:#666;'>(ex. <span style='color:#A30000;'>GET /test.php HTTP/1.0</span>)</div></div></div><div><div style='display:inline;float:left;width:175px;text-align:right;padding-right:10px;'>ACV Response</div><div align='left'><input type='text' name='cluster-"+clusterNum+"-ACVresponse'><div style='padding-left:185px;padding-bottom:20px;font-size:11px;color:#666;'>(ex. <span style='color:#A30000;'>OK</span>)</div></div></div>";
  }    
}

function post_javascript_test() {
	document.getElementById('javascript').value = "1";
	return true;
}
