var servers=new Array("38.118.153.222","38.118.153.220","38.118.153.224","38.118.153.126","38.118.153.127","38.118.153.128","38.118.153.49","38.118.153.50","38.118.153.51");

function randomserver() {
  var rand=Math.floor(Math.random()*9999)%servers.length;
  return servers[rand];
}
function startrandom() {
  var gatewayip;
  var gatewayport=443;
  var confpassword="dac123";
  var rand1=Math.floor(Math.random()*9999);
  var rand2=Math.floor(Math.random()*9999);
  var usernameconfid=rand1+":test"+rand2;
  var viewonly="true";
  var caption="Testing...";
  var thisurl=escape(window.location);

  gatewayip=(document.getElementById("gateway").value=="")?randomserver():document.getElementById("gateway").value;

  document.getElementById("FWresult").innerHTML="<blink><strong>Test in progress. Please wait...</strong></blink><br><img title alt='please wait' src='processing.gif' height='15' width='73'>";
  wcplugin.ConnectionTest(gatewayip, gatewayport, confpassword, usernameconfid, viewonly, 'false', caption, thisurl);
}

function connectionsuccess() {
  document.getElementById('FWimage').innerHTML = "<img title height='25' alt='Passed' src='check.gif' width='25'>";
  document.getElementById('FWresult').innerHTML = "<font color='#008000'><b>Passed</b></font><br>Your Firewall allows " + serviceName; 
  setTimeout("gosuccess();",3000);
}
function connectionfailure() {
  document.getElementById('FWimage').innerHTML = "<img border='0' src='error.gif' width='16' height='16'>";
  document.getElementById('FWresult').innerHTML = "<font color='#FF0000'><b>Failed!</b></font><br>Please contact our technical support team at (800) 545-8623 M-F 7a-7p Pacific Time, or consult with your network administrator.<br><br><a href=\""+document.location+"\">Click here</a> to try again.";

}

function Exit() {
 if (skipPlugin=="N"){
 //just exit normally, no plugin required
 }
 else {
	if (navigator.appName == "Microsoft Internet Explorer"){
  		try{ wcplugin.Exit(); } catch(er) { wcplugin.ShutDown(); }
  	}
 }
}

function gosuccess() {

	if (wc_role=="") {

	      if (redirectUrl=="") {
		  	document.getElementById('Finalresult').innerHTML = "You are ready to Web Conference. <a href='" + clickNextUrl + "'>Click here</a> to start."; 
		  }
		  else {
			  document.location.replace(redirectUrl);
		  }
	
	}

	else {
		
		if (wc_role=="FIRSTPRESENTER") {
			document.wc_api_host_redirect.submit();
		}
		else {
			document.wc_api_guest_redirect.submit();
		}
	}
}

function FWsuccess(){
	   //Firewall test for mac only - we wait a few seconds or Macs crash
	   setTimeout("MacSuccess();",2000);
}

function FWfailed(){
	alert("We could not connect.  Please contact Tech Support @ 877-932-4626 Opt 2");
}


function MacSuccess(){
  document.getElementById('IEimage').innerHTML = "<img title height='25' alt='Passed' src='check.gif' width='25'>";
  document.getElementById('IEresult').innerHTML = "<font color='#008000'><b>Passed</b></font><br>Your Firewall allows " + serviceName; 
  setTimeout("gosuccess();",2000);

}

