// JavaScript Document
function ShowHide(elementId)
{
	var element = document.getElementById(elementId);
	if(element.style.display != "block")
	{
		element.style.display = "block";
	}
	else
	{
		element.style.display = "none";
	}
}
function UpdateText(element, textMesg)
{
	if(element.innerHTML.indexOf("Show") != -1)
	{
		element.innerHTML = "Hide&nbsp;"+textMesg;
	}
	else
	{
		element.innerHTML = "Show&nbsp;"+textMesg;
	}
}

var xmlHttp

function showHint(actionword)
{ //alert(actionword);
	
	
  	 if(document.getElementById("gr_name").value==''){
			 alert ("No Group Selected");
			 actionword.checked= false;;
			 return false;
		 }
		 
		 if(document.getElementById("gr_name").value!=''){
			 var url="<?php echo CONTROLLER_URL_PATH; ?>" + "index_controller.php?action=fetch_group_type";
			var http;
			http = GetXmlHttpObject();
			var params = "action=fetch_group_type&tname="+document.getElementById("gr_name").text;
			//alert(params);
			http.open("POST", url, true);	
			http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			http.setRequestHeader("Content-length", params.length);
			http.setRequestHeader("Connection", "close");
	
			http.onreadystatechange = function() {//Call a function when the state changes.
				if(http.readyState == 4 && http.status == 200) {				
					if(http.responseText == 's'){
					   alert("No invitation can be send for self type of group.")
					   return false;
					}
					
				}
			}
			http.send(params);
		 }
		 
		 actionword = actionword.value;
		 document.getElementById("actionword").value = actionword;
		 xmlHttp=GetXmlHttpObject()
		 this.createAJAX = function() {
			try {
				this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e1) {
				try {
					this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e2) {
					this.xmlhttp = null;
				}
			}
	
			if (! this.xmlhttp) {
				if (typeof XMLHttpRequest != "undefined") {
					this.xmlhttp = new XMLHttpRequest();
				} else {
					this.failed = true;
				}
			}
		}; 
		var url="<?php echo CONTROLLER_URL_PATH; ?>" + "index_controller.php?action=template";
		var http;
		http = GetXmlHttpObject();
		var params = "action=template&actionword="+actionword;
		http.open("POST", url, true);	
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", params.length);
		http.setRequestHeader("Connection", "close");

		http.onreadystatechange = function() {//Call a function when the state changes.
			if(http.readyState == 4 && http.status == 200) {				
				document.getElementById("show_ajax_data").innerHTML=http.responseText;
				document.getElementById("sel_group_name").innerHTML = document.getElementById("gr_name").value;
				
			}
		}
		http.send(params);
} 

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;
}
 

