basePath="http://www.voipgate.com/webphone";
version="2.3.1";
Webphone=function(checkFlash)
{
	//Builder
	/* **********************************************************************************************************************
	********************************************************************************************************************** */
	this._activeFlash="false";

	document.write("<div id=\"appletview\"></div>"+
		"<div id=\"WaitBG\" style=\"position:absolute;top:0;left:0;width:0%;height:0%;margin:0;background-color:black;filter:alpha(opacity=85);-moz-opacity:.85;opacity:.85;z-index:1000;display:none;\">"+
		"<div id=\"TextDesc\" style=\"position:absolute;left:50%;top:50%;width:200px; height:50px;margin-top:-25px;margin-left:-100px;color:white;\">This is the first time you are running the version "+ version+" of the VoipGATE webphone, if nothing happened make sure that you enable Java applets in your browser and that <a href=\"https://sdlc1b.sun.com/ECom/EComActionServlet/DownloadPage:~:com.sun.sunit.sdlc.content.DownloadPageInfo;jsessionid=B7D1776AEF1D8D57117F23981B908F83;jsessionid=B7D1776AEF1D8D57117F23981B908F83\">Java</a> is correctly installed on your computer..<br />Loading java Applet : <span id=\"pctg\"></span> %</div>"+
		"</div>");

	if(checkFlash=="true")
		document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"0\" height=\"0\" id=\"checkPort\" align=\"middle\">"+
		"<param name=\"allowScriptAccess\" value=\"sameDomain\" />"+
		"<param name=\"movie\" value=\""+basePath+"/checkPort.swf\" />"+
		"<param name=\"quality\" value=\"high\" />"+
		"<param name=\"bgcolor\" value=\"#ffffff\" />"+
		"<embed src=\""+basePath+"/checkPort.swf\" quality=\"high\" bgcolor=\"#ffffff\" width=\"0\" height=\"0\" name=\"checkPort\" align=\"left\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />"+
		"</object>");

	document.write("<iframe name=\"HiddenFrameWebphone\" width=\"0\" height=\"0\" style=\"border:0px;\"></iframe>");

	var aPrm = new Array();    /* Pour stock. le nom des param?tres*/
	var aVal = new Array();    /* Pour stock. la valeur des param?tres*/
	var objQS = new Object();  /* Objet pour stock. le nom des param?tres*/

	/* R?cup?ration de la requ?te contenue dans l'URL (sans le ?)*/
	var req = window.location.search.substr(1,window.location.search.length);

	/* R?cup?ration des paires param?tre=valeur*/
	var dbl = req.split('&');

	for (i=0;i < dbl.length;i++)
	{
		/* Recup. le nom des parametres (Attention : elem.1 du tab. = param.1)*/
		aPrm[i+1] = dbl[i].substring(0,dbl[i].indexOf('='));
		/* Recup. la valeur des parametres (Attention : elem.1 du tab. = val.param.1)*/
		aVal[i+1] = unescape(dbl[i].substring(dbl[i].indexOf('=')+1,dbl[i].length));
		/* Stock la valeur des param?tres sous forme de propri?t?*/
		objQS[aPrm[i+1]] = aVal[i+1];
	}
	/* **********************************************************************************************************************
	*********************************************************************************************************************** */

	this.Online = function ()
	{
		this._activeFlash="true";
	}

	this.chgMask = function()
	{
		document.getElementById("WaitBG").style.width="100%";
		document.getElementById("WaitBG").style.height="100%";
		document.getElementById("WaitBG").style.zindex="1000";
		document.getElementById("WaitBG").style.display="block";
	}
	
	/* Renvoie la valeur d'un parametre par son nom*/
	this.getQueryStringByName = function(pname)
	{
	  return eval("objQS." + pname);
	}

	this.LoadApplet= function(user, pass, callnumber, server)
	{
		if (navigator.javaEnabled()) 
		{
			this.chgMask();
			document.getElementById('appletview').innerHTML="<APPLET code=\"VGWebphone.class\" width=\"0\" height=\"0\" align=\"left\" MAYSCRIPT>"+
						"<PARAM NAME = \"ARCHIVE\" VALUE=\""+basePath+"/VGWebphone.jar\">"+
						"<PARAM NAME = \"user\" VALUE=\""+user+"\">"+
						"<PARAM NAME = \"pass\" VALUE=\""+pass+"\">"+
						"<PARAM NAME = \"callnumber\" VALUE=\""+callnumber+"\">"+
						"<PARAM NAME = \"server\" VALUE=\""+server+"\">"+
						"<PARAM NAME = \"version\" VALUE=\""+version+"\">"+
						"<PARAM NAME = \"path\" VALUE=\""+basePath+"/software\">"+
						"Your browser don't support Java or the Java plug in is not installed of obsolete..."+
						"</APPLET>";
		}
		else
			this.noJava();
	}
	
	this.noJava =function()
	{
		document.getElementById('TextDesc').innerHTML="You can download java on http://java.sun.com";
	}
	
	var i=0;
	this.statusDisplay = function (res)
	{
		if(res<100)
		{
			i=i+1;
			document.getElementById('pctg').innerHTML=res;
		}
		else
		{
			document.getElementById("WaitBG").style.width="0%";
			document.getElementById("WaitBG").style.height="0%";
			document.getElementById("WaitBG").style.display="none";
		}
			
	}

	this.displayInfo = function()
	{
		document.getElementById('user').value=this.getQueryStringByName("user");
		document.getElementById('callnumber').value=this.getQueryStringByName("callnumber");
	}

	this.Call=function(user,pass,callnumber,server)
	{
		if(user==null && pass==null && callnumber==null)
		{
			user=this.getQueryStringByName("user");
			pass=this.getQueryStringByName("pass");
			callnumber=this.getQueryStringByName("callnumber");
		}
		//alert(this._activeFlash);
		if(this._activeFlash=="false")
			this.LoadApplet(user, pass, callnumber, server);// parent.frames["HiddenFrameWebphone"].location.href = basePath+"/hiddenCallPage.html?user="+user+"&pass="+pass+"&callnumber="+callnumber+"&server="+server+"&action=Call&";
		else
			parent.frames["HiddenFrameWebphone"].location.href = "http://127.0.0.1:53419?user="+user+"&pass="+pass+"&callnumber="+callnumber+"&server="+server+"&action=Call&";
	}
	
	this.SendDTMF=function(user,pass,DTMF,server)
	{
		parent.frames["HiddenFrameWebphone"].location.href = "http://127.0.0.1:53419?user="+user+"&pass="+pass+"&callnumber="+DTMF+"&server="+server+"&action=DTMF&";
	}
	
	this.Hangup=function()
	{
		parent.frames["HiddenFrameWebphone"].location.href = "http://127.0.0.1:53419?callnumber=hangup&action=DTMF&";
	}
}

	var i=0;
	function statusDisplay (res)
	{
		if(res<100)
		{
			i=i+1;
			document.getElementById('pctg').innerHTML=res;
		}
		else
		{
			document.getElementById("WaitBG").style.width="0%";
			document.getElementById("WaitBG").style.height="0%";
		}
			
	}
