// JavaScript Document

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++){

        var c = s.charAt(i);

        if (bag.indexOf(c) == -1) returnString += c;

    }

    return returnString;

}


var type_rec=""

function sendMe(num){

	if(!isInteger(num))return
	cc=document.getElementById("cc").value
	if(cc=="0"){
		alert("You must select a country code")
		return
	}
	pn=Trim(document.getElementById("mobnum").value)
	nn=""
	reg=/^[0-9 ]+$/
	if(!reg.test(pn)){
		alert("Please enter a valid phone number (numbers and spaces only)")
		return
	}
    	for (i = 0; i < pn.length; i++){

        	var c = pn.charAt(i);
		if(i==0 && c=="0")continue
		if(c==" ")continue
		nn += c
   	 }
	if(nn.length<8){
		alert("Please enter a valid phone number (your entry was too short)")
		return
	}
	msi=cc + nn
	if(lockxml){return;}

	lockxml=true;

	localxml=true;

	

	if(type_rec=="smsM")return


	

	type_rec="smsM"

	//create url for deleting or modifying	

	url="scripts/xmlmaker.php?type=smsM&value="+msi+"&num="+num



	urlload()// send the url off to be processed

	document.getElementById("smsme").innerHTML="Thank you, you should receive an SMS shortly"

}





function smsM_lxml(){


	//alert(xmlhttp.responseText)
	type_rec=""

	localxml=false;

	lockxml=false;

	return

}



<!--

// set of javascript functions for xmlhttp

var notWhitespace = /\S/

var xmlDoc

var url

var xmlhttp

var moztime=0

var kcount=0

var type_rec=""

var agt = navigator.userAgent.toLowerCase();

var is_ie = (agt.indexOf("msie") != -1);

var is_ie5 = (agt.indexOf("msie 5") != -1);

var is_opera = (agt.indexOf("opera") != -1);

var is_mac = (agt.indexOf("mac") != -1);

var is_gecko = (agt.indexOf("gecko") != -1);

var is_safari = (agt.indexOf("safari") != -1);

var localxml=false;

var lockxml=false;



function removeTxt(){
	if(document.getElementById("mobnum").value=="Enter your mobile number")document.getElementById("mobnum").value=""
	return
}

function lockwarn(){

	alert("another process is running, you must wait")

	return;

}



function urlload(){

	if(document.implementation && document.implementation.createDocument){



		Document.prototype.loadXML = function (s) {

      

   			// parse the string to a new doc   

   			var doc2 = (new DOMParser()).parseFromString(s, "text/xml");

      

   			// remove all initial children

   			while (this.hasChildNodes())

      			this.removeChild(this.lastChild);

         

   				// insert and import nodes

   				for (var i = 0; i < doc2.childNodes.length; i++) {

      			this.appendChild(this.importNode(doc2.childNodes[i], true));

   			}

		};



    	xmlDoc = document.implementation.createDocument("", "", null);



		if(localxml)strLoad=type_rec + "_lxml"

		else strLoad="loadxml"

		//eval("xmlDoc.onload = "+strLoad)

		

		//xmlDoc.onload = loadxml;

		 

		xmlhttp = null;

    	xmlhttp = new XMLHttpRequest();



	}

	else{

    	// Guaranteed to be ie5 or ie6

   		var control = (is_ie5) ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP";



   		try {

      		xmlhttp = new ActiveXObject(control);

 	//     xmlhttp.onreadystatechange = handler;

    	} catch (ex) {

      // TODO: better help message

     		alert("You need to enable active scripting and activeX controls");  

    	}

		

		xmlDoc=new ActiveXObject("Microsoft.XMLDOM")

		xmlDoc.async="false"

		//docload()

	}

	

	xmlhttp.onreadystatechange=function (){

		if(xmlhttp.readyState==4)docload()

	}

	

	try {

   		xmlhttp.open("GET", url+"&rannum="+(Math.round(Math.random()*1000)), true);

 //  		xmlhttp.open("GET", url, true);

		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1")

   		xmlhttp.send(null);

		



	} catch (ex) {

   		 alert("Your browser has javascript disbaled or does not support this function")

	}

}



function docload(){



	try {



		xmlDoc=xmlhttp.responseXML

		

	}catch (ex) {

		alert("och well")

	}



	if(localxml)eval(type_rec + "_lxml();")

	else loadxml()

}



function httpload(dts){



	if(document.implementation && document.implementation.createDocument){



		Document.prototype.loadXML = function (s) {

      

   			// parse the string to a new doc   

   			var doc2 = (new DOMParser()).parseFromString(s, "text/xml");

      

   			// remove all initial children

   			while (this.hasChildNodes())

      			this.removeChild(this.lastChild);

         

   				// insert and import nodes

   				for (var i = 0; i < doc2.childNodes.length; i++) {

      			this.appendChild(this.importNode(doc2.childNodes[i], true));

   			}

		};



    	xmlDoc = document.implementation.createDocument("", "", null);

		if(localxml)xmlDoc.onload = eval(type_rec + "_lxml;")
		else xmlDoc.onload = loadxml;

		 

		xmlhttp = null;

    	xmlhttp = new XMLHttpRequest();



	}

	else{

    	// Guaranteed to be ie5 or ie6

   		var control = (is_ie5) ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP";



   		try {

      		xmlhttp = new ActiveXObject(control);

 	//     xmlhttp.onreadystatechange = handler;

    	} catch (ex) {

      // TODO: better help message

     		alert("You need to enable active scripting and activeX controls");  

    	}

		

		xmlDoc=new ActiveXObject("Microsoft.XMLDOM")

		xmlDoc.async="false"

		//docload()

	}

	



  	try {

   		xmlhttp.open("POST", url, false);	

		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

		readys=setInterval(function (){if(xmlhttp.readyState!=4 && moztime<200){moztime++;return};clearInterval(readys);docload();}, 100)

   		xmlhttp.send(dts);



  	} catch (ex) {

  	 // do nothing

  	}

}



function Trim(s) 

{

	// Remove leading spaces and carriage returns

	

	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))

	{

	s = s.substring(1,s.length);

	}

	

	// Remove trailing spaces and carriage returns

	

	while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))

	{


	s = s.substring(0,s.length-1);

	}

	return s;

}


function removeTxt(){
	if(document.getElementById("mobnum").value=="your mobile number")document.getElementById("mobnum").value=""
	return
}
