function PhoneCheck(phoneCheckStat_CtlID, phoneCheckAttemps_CtlID, phoneCheckPassed_CtlID)
{
	this.CreateHTTPObject = function()
	{        
		try
		{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				xmlhttp = false;
			}
		}
	    
		if (!xmlhttp && typeof XMLHttpRequest!='undefined')
		{
			try
			{
				xmlhttp = new XMLHttpRequest();
			}
			catch (e)
			{
				xmlhttp=false;
			}
		}
	    
		if (!xmlhttp && window.createRequest)
		{
			try
			{
				xmlhttp = window.createRequest();
			}
			catch (e)
			{
				xmlhttp=false;
			}
		}        
		return xmlhttp;
	}
	this.CurrentTimes=0;
	//this.URL = "http://localhost/Bullseye.PublicSite.ValidateTelNOViaWTN.Pages/ValidatePage.aspx";
	this.URL="ValidatePage.aspx";
	this.GetValue=function (str_content,str_name)
	{
		var li_start;
		var li_len;
		var li_pos;
		var ls_temp;
		var ls_value;
		str_name=str_name +"=";
		li_pos = str_content.indexOf(str_name);
		if (li_pos==-1)
		{
			ls_value="";
		}
		else
		{
			ls_temp = str_content.substring(li_pos ,str_content.length );
			li_pos = ls_temp.indexOf("&");
			if (li_pos==-1)
			{
				ls_value =ls_temp.substring(str_name.length,ls_temp.length );		
			}
			else
			{
				ls_value = ls_temp.substring(str_name.length,li_pos );
			}			
		}
		return ls_value;
	}
	//this.PhoneCheckStat=phoneCheckstat;
	this.Check=function(PhoneNumber)
	{
		var result = '0';
		
		
		this.CurrentTimes++;
	    //alert( this.CurrentTimes );
	    var xmlhttp = this.CreateHTTPObject();
	    if (xmlhttp)
	    {
	       var s= this.URL + "?TelNO=" + PhoneNumber + "&SumbitTimes=" + this.CurrentTimes;
	       xmlhttp.open("GET", s, false);
           xmlhttp.send(null);
		   //if(xmlHttp.readyState == 4)
		   {
			    var responseValue=xmlhttp.responseText;
			    
			    document.getElementById(phoneCheckStat_CtlID).value=this.GetValue( responseValue, "PHONECHK_STAT" );
				document.getElementById(phoneCheckAttemps_CtlID).value=this.GetValue( responseValue, "PHONECHK_ATTEMPTS" );
				
				var tempResult = this.GetValue( responseValue, "PHONECHK_PASSED" );
				if( tempResult != '' )
				{
					result = tempResult;
				}
				document.getElementById(phoneCheckPassed_CtlID).value=result;
		   }
	    }
	    	return result;
	}

	this.Check_new=function(PhoneNumber,itemID)
	{
		var result = '0';		
		
		this.CurrentTimes++;
	    //alert( this.CurrentTimes );
	    var xmlhttp = this.CreateHTTPObject();
	    if (xmlhttp)
	    {
	       var s= this.URL + "?TelNO=" + PhoneNumber + "&SumbitTimes=" + this.CurrentTimes + "&itemID=" + itemID;
	       xmlhttp.open("GET", s, false);
           xmlhttp.send(null);
		   //if(xmlHttp.readyState == 4)
		   {
			    var responseValue=xmlhttp.responseText;
			    
			    document.getElementById(phoneCheckStat_CtlID).value=this.GetValue( responseValue, "PHONECHK_STAT" );
				document.getElementById(phoneCheckAttemps_CtlID).value=this.GetValue( responseValue, "PHONECHK_ATTEMPTS" );
				
				var tempResult = this.GetValue( responseValue, "PHONECHK_PASSED" );
				if( tempResult != '' )
				{
					result = tempResult;
				}
				document.getElementById(phoneCheckPassed_CtlID).value=result;
		   }
	    }
	    return result;
	}

this.Check_new_rejectUnknown=function(PhoneNumber,itemID)
	{
		var result = '0';		
		
		this.CurrentTimes++;
	    //alert( this.CurrentTimes );
	    var xmlhttp = this.CreateHTTPObject();
	    if (xmlhttp)
	    {
	       var s= this.URL + "?TelNO=" + PhoneNumber + "&SumbitTimes=" + this.CurrentTimes + "&itemID=" + itemID+"&rejectUnknown=1";
	       xmlhttp.open("GET", s, false);
           xmlhttp.send(null);
		   //if(xmlHttp.readyState == 4)
		   {
			    var responseValue=xmlhttp.responseText;
			    
			    document.getElementById(phoneCheckStat_CtlID).value=this.GetValue( responseValue, "PHONECHK_STAT" );
				document.getElementById(phoneCheckAttemps_CtlID).value=this.GetValue( responseValue, "PHONECHK_ATTEMPTS" );
				
				var tempResult = this.GetValue( responseValue, "PHONECHK_PASSED" );
				if( tempResult != '' )
				{
					result = tempResult;
				}
				document.getElementById(phoneCheckPassed_CtlID).value=result;
		   }
	    }
	    return result;
	}
}

 