
function showbut(num1) 
{
    var el = document.getElementById("button");
    el.innerHTML = (el.innerHTML == '' ? showForm(num1,'') : '');
}

function buzzShowForm(num1, num2) {
    var el = document.getElementById("button");
    el.innerHTML = showForm(num1,num2);
}
    
function showForm(num1,num2) {
    var html;
    //html = "<style type='text/css'> .ad-link { color:red; background-color: #ccffff; } </style>";
    html = "<div id=\"resp_div\" ></div>";  
    html += "<FORM NAME=\"myform\" ACTION=\"\" METHOD=\"GET\">";

    if (!num1) {
	html += "Your Number:<br>";
	html += "<INPUT TYPE=\"text\" NAME=\"num1\" VALUE=\"\"><BR>";
	//	if (!num2) {
	html += "Destination Number:<br>";
	//	    html += "<INPUT TYPE=\"text\" NAME=\"num2\" VALUE=\"\">";
	//}	    
    } else {
	//      html += "Call me at :"+num1+"<BR>";
	html += "<INPUT TYPE=\"hidden\" NAME=\"num1\" VALUE="+num1+">";
	//if (!num2) {
	html += "Number to call you at:<br>";	
	//}	    
	
    }
    html += "<INPUT TYPE=\"text\" NAME=\"num2\" VALUE="+num2+">";    
    //    if (num2) {
    //	html += "<INPUT TYPE=\"hidden\" NAME=\"num2\" VALUE="+num2+">";
    //}
    html += "<INPUT TYPE=\"button\" NAME=\"button\" Value=\"Call\"  onClick=\"call(this.form)\">";
    html += "<br><font size=1><a href=http://spokenbuzz.com/cgi-bin/callmebutton.cgi?nojs=1>Click here if the Call button does not work on your browser</a><br><b>Only U.S.Numbers are supported for now.</b>";
    html += "<br>Your privacy is protected. Your telephone number will not be transmitted to the other party.<br><a href='http://spokenbuzz.com/'>Powered by SpokenBuzz</a></font></FORM>";
    html += "<font size=1>SPONSOR MSG: ";
    html += "<a href='http://www.kqzyfj.com/click-2458744-2484319' target='_top'>Fall In Love For All The Right Reasons</a><img src='http://www.lduhtrp.net/image-2458744-2484319' width='1' height='1' border='0'/>";    
    return(html);
    
}
function call(form) {
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
        {
            alert ("Your browser does not support AJAX!");
            return;
        }
    
    url="/cgi-bin/callmebutton.cgi/?up_num1="+form.num1.value;
    url=url+"&num2="+form.num2.value;
    url=url+"&sid="+Math.random();
    //  alert(url);
    xmlHttp.onreadystatechange=makeCall;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}


function makeCall()
{
      if (xmlHttp.readyState==4)
        {
	    document.getElementById("resp_div").innerHTML=xmlHttp.responseText;
        }
}


/**
 * DHTML phone number validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
	
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function ValidatePhone(Phone){
//	var Phone=document.frmSample.txtPhone
	
	if (checkInternationalPhone(Phone.value)==false){
		alert("Please Enter a Valid Phone Number")
		Phone.value=""
		Phone.focus()
		return false
	}
	
	return true
 }



function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
	{
	    // Firefox, Opera 8.0+, Safari
	    xmlHttp=new XMLHttpRequest();
	}
    catch (e)
	{
	    // Internet Explorer
	    try
		{
		    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	    catch (e)
    {
	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
	}
    return xmlHttp;
}



