function showhideGroup(id) {
	if (document.getElementById("hid_con_"+id).innerHTML == "Yes") {
		document.getElementById("div_con_"+id).style.display = "block";
		document.getElementById("hid_con_"+id).innerHTML = "No";
		//$("div_con_"+id).slideDown();
		ajaxGroup(id);
	} else {
		document.getElementById("div_con_"+id).style.display = "none";
		document.getElementById("hid_con_"+id).innerHTML = "Yes";
		//$("div_con_"+id).slideUp();
	}
}

function showhideDelivery(id, ref) {
	if (document.getElementById("hid_con_"+id).innerHTML == "Yes") {
		document.getElementById("div_con_"+id).style.display = "block";
		document.getElementById("hid_con_"+id).innerHTML = "No";
		ajaxDeliveryReport(id, ref);
	} else {
		document.getElementById("div_con_"+id).style.display = "none";
		document.getElementById("hid_con_"+id).innerHTML = "Yes";
	}
}

function updown(id) {
	if (document.getElementById("hid_con_"+id).innerHTML == "Yes") {
		document.getElementById("table_"+id).style.display = "block";
		document.getElementById("hid_con_"+id).innerHTML = "No";
	} else {
		document.getElementById("table_"+id).style.display = "none";
		document.getElementById("hid_con_"+id).innerHTML = "Yes";
	}
}

var xmlhttp;

function GetXmlHttpObject() {
	if (window.XMLHttpRequest) {
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject) {
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}

/*------------------------------------------------------------------------------*/

function ajaxGroup(id) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url="ajax-groups.php";
	url=url+"?groupid="+id;
	url=url+"&sid="+Math.random();
	document.getElementById("div_con_"+id).innerHTML="<img src='sms-pix/loading.gif' width='47' height='39'/>";
	xmlhttp.onreadystatechange = function (){
		if (xmlhttp.readyState==4) {
			document.getElementById("div_con_"+id).innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

/*------------------------------------------------------------------------------*/

function ajaxDeliveryReport(id, ref) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url="ajax-delivery.php";
	url=url+"?ref="+ref;
	url=url+"&sid="+Math.random();
	document.getElementById("div_con_"+id).innerHTML="<img src='sms-pix/loading.gif' width='47' height='39'/>";
	xmlhttp.onreadystatechange = function (){
		if (xmlhttp.readyState==4) {
			document.getElementById("div_con_"+id).innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

/*------------------------------------------------------------------------------*/

function ajaxSearch(filter_to, filter_sentby, filter_datefrom, filter_dateto) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url="sms-history-search.php";
	url=url+"?filter_to="+filter_to;
	url=url+"&filter_sentby="+filter_sentby;
	url=url+"&filter_datefrom="+filter_datefrom;
	url=url+"&filter_dateto="+filter_dateto;
	url=url+"&sid="+Math.random();
	document.getElementById("txtHist").innerHTML="<img src='sms-pix/loading.gif' width='47' height='39'/>";
	xmlhttp.onreadystatechange=stateChangedSearch;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateChangedSearch() {
	if (xmlhttp.readyState==4) {
		document.getElementById("txtHist").innerHTML=xmlhttp.responseText;
	}
}

/*------------------------------------------------------------------------------*/

function ajaxContacts(letter) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url="sms-contacts-ajax.php";
	url=url+"?letter="+letter;
	url=url+"&sid="+Math.random();
	document.getElementById("txtHist").innerHTML="<img src='sms-pix/loading.gif' width='47' height='39'/>";
	xmlhttp.onreadystatechange=stateChangedSearch;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

/*------------------------------------------------------------------------------*/

function ajaxSched(filter_to, filter_sentby, filter_datefrom, filter_dateto) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url="sms-schedule-search.php";
	url=url+"?filter_to="+filter_to;
	url=url+"&filter_sentby="+filter_sentby;
	url=url+"&filter_datefrom="+filter_datefrom;
	url=url+"&filter_dateto="+filter_dateto;
	url=url+"&sid="+Math.random();
	document.getElementById("txtHist").innerHTML="<img src='sms-pix/loading.gif' width='47' height='39'/>";
	xmlhttp.onreadystatechange=stateChangedSearch;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

/*------------------------------------------------------------------------------*/
