// JavaScript Document
function Ajax(url,method,callbackfunction) 
{
  var xmlhttp = false;
  if (window.XMLHttpRequest)
    xmlhttp = new XMLHttpRequest();
  else if (window.ActiveXObject)// code for IE
  {
    try
    {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try
      {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp=false;
      }
    }
  }
  if(xmlhttp)
  {
  	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp && xmlhttp.readyState==4)
		{
			if (xmlhttp.status==200)
			{
				callbackfunction(xmlhttp.responseText);
			}
			else
			{
			}
		}
		else
		{
			//alert(xmlhttp.readyState);
		}
	}
  	xmlhttp.open(method,url,true);
  	xmlhttp.send(null);
  }
  else
  {
  	alert("Unable to creat Ajax Object for this browser.\n Contact Ajax Programmer info@shantiwebsolution.com");
  }
}
/* Processing display Code */
var utila = {}

utila.getElementWidth = function(obj){
	return obj.offsetWidth;
};
utila.getElementHeight = function(obj){
	return obj.offsetHeight;
};
// page offset
utila.getPageXScroll = function(){
	return (window.pageXOffset ? window.pageXOffset : document.body.scrollLeft)||0;
};
utila.getPageYScroll = function(){
	return (window.pageYOffset ? window.pageYOffset : document.body.scrollTop)||0;
};
// inner dimentions
utila.getInnerWidth = function(){
	return (window.innerWidth ? window.innerWidth : document.body ? document.body.clientWidth : 0)||0;
};
utila.getInnerHeight = function(){
	return (window.innerHeight ? window.innerHeight : document.body ? document.body.clientHeight : 0)||0;
};

function Hide(txt,subcat)
{
	var loading = document.getElementById('loading');
	var overlaydiv = document.getElementById('overlaydiv');
	overlaydiv.style.top = 0;
	overlaydiv.style.left = 0;

	overlaydiv.style.display = "block";
	loading.style.display = "block";

	window.onresize = UpdateMessage;
	window.onscroll = UpdateMessage;
	UpdateMessage();
	if(subcat == 1)
		loading.innerHTML = '<img src="../images/ajax_icon.gif" align="absmiddle"/> &nbsp; ' + txt + ' &nbsp; ';
	else
		loading.innerHTML = '<img src="images/ajax_icon.gif" align="absmiddle"/> &nbsp; ' + txt + ' &nbsp; ';
}
function UpdateMessage(){
	var overlaydiv = document.getElementById('overlaydiv');
	var loading = document.getElementById('loading');
	loading.style.left = (utila.getPageXScroll()+(utila.getInnerWidth()-utila.getElementWidth(loading))/2)+"px";
	loading.style.top = (utila.getPageYScroll()+(utila.getInnerHeight()-utila.getElementHeight(loading))/2)+"px";
	overlaydiv.style.width = (utila.getInnerWidth()-20)+"px";
	overlaydiv.style.height = (utila.getInnerHeight()-20)+"px";
	overlaydiv.style.left = utila.getPageXScroll()+"px";
	overlaydiv.style.top = utila.getPageYScroll()+"px";
}
function Show()
{
	var loading = document.getElementById('loading');
	var overlaydiv = document.getElementById('overlaydiv');
	overlaydiv.style.display = "none";
	loading.style.display = "none";
}
function echeck(obj)
{
	var str=obj.value;
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid E-mail ID")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid E-mail ID")
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		alert("Invalid E-mail ID")
		return false
	 }
	 return true;
}
