var CountingFlag = true;

// Webservice connection
var initCount = 0;
var LookupCount = 0;
var Lookupfunc;
var initfunc = setTimeout('initWebservices()',1000);


function initWebservices() 
{
	try
	{
    	document.getElementById('myService').useService("http://www.laomu.com:500/usermanager/usermanager.asmx?WSDL","Service1");
		Lookupfunc = setTimeout('DoMyLookup("' + document.location.href + '")',3000);
    }
	catch(e)
    {
		if(initCount < 15)
		{
			initCount++;
			clearTimeout(initfunc );
			clearTimeout(Lookupfunc );
			setTimeout('initWebservices()',1000);
		}
		else
		{
			window.status = 'INIT WS error:' + e.message ;
		}
    }
}
function DoMyLookup(value) {
	if(!CountingFlag)
	{
		window.status = 'Status: 020';
		return;
	}
	try
	{
		var callerID = document.getElementById('myService').Service1.callService(mycallback,'AddHitCount',value);
    }
    catch(e)
    {
		if(LookupCount < 15)
		{
			LookupCount++;
			clearTimeout(Lookupfunc );
			Lookupfunc = setTimeout('DoMyLookup("' + document.location.href + '")',1000);
		}
		else
		{
			window.status = 'Add Count error:' + e.message ;
		}
    }
}
function mycallback(result)
{
     //if an error then get error details
      if(result.error)
      {
         //Pull error info from event.result.errorDetail properties
         var xfaultcode   = result.errorDetail.code;
         var xfaultstring = result.errorDetail.string;
         var xfaultsoap   = result.errorDetail.raw;
         // Add code to handle specific error codes here
         window.status = "Error: " + xfaultcode + " ; " + xfaultstring + " ; " + xfaultsoap;
      }
      else
      {
			window.status = 'Site Statistics: ' + result.value;
			CountingFlag = false;
      }
}

//		<SCRIPT language="javascript" src="ws.js">	</SCRIPT>
//      <DIV ID="myService" STYLE="behavior:url(webservice.htc)"></DIV>


