	
	function CloseOverlayWindow(){
		var sendEmailToMom = document.getElementById('sendEmailToMom');
		var dark = document.getElementById('darkLayer');
		var homeMakerMom = document.getElementById('homeMakerMom');
		var religiousMom = document.getElementById('religiousMom');
		var trendyMom = document.getElementById('trendyMom');
		var workingMom = document.getElementById('workingMom');
		hideMonChar(homeMakerMom);
		hideMonChar(religiousMom);
		hideMonChar(trendyMom);
		hideMonChar(workingMom);
		hideMonChar(sendEmailToMom);
		hideMonChar(dark);
		
	}

	function showMonChar(obj){
		obj.style.visibility="visible";
		obj.style.display="";
	}
	
	function showDarkDiv(obj){
		obj.style.visibility="visible";
		obj.style.display="";
		obj.style.width="1000px";
    	obj.style.height="1025px";
    	obj.style.overflow="scroll";
	}
	
	function hideMonChar(obj){
		obj.style.visibility="hidden";
		obj.style.display="none";
	}
	
	function common(obj){
		obj.style.visibility="visible";
		obj.style.display="";
		var dark = document.getElementById("darkLayer");
		showDarkDiv(dark);
		/*document.getElementById("darkLayer").style.display = "";
		document.getElementById("darkLayer").style.visibility="visible";
	    document.getElementById("darkLayer").style.width="1000px";
    	document.getElementById("darkLayer").style.height="1025px";
    	document.getElementById("darkLayer").style.overflow="scroll";*/
	}

	function homeMakerOverLay(){

		var homeMakerMom = document.getElementById('homeMakerMom');
		var sendEmailToMom = document.getElementById('sendEmailToMom');
		common(sendEmailToMom);
		showMonChar(homeMakerMom);
	}
	
	function religiousMom(){
	var sendEmailToMom = document.getElementById('sendEmailToMom');
		common(sendEmailToMom);
	var religiousMom = document.getElementById('religiousMom');
	showMonChar(religiousMom);
	}
	
	function trendyMom(){
	var sendEmailToMom = document.getElementById('sendEmailToMom');
		common(sendEmailToMom);
	var trendyMom = document.getElementById('trendyMom');
		showMonChar(trendyMom);
	}
	
	function workingMom(){
	var sendEmailToMom = document.getElementById('sendEmailToMom');
		common(sendEmailToMom);
	var workingMom = document.getElementById('workingMom');
		showMonChar(workingMom);
	}

		function notValidEmail( str ){
    mailRE = new RegExp( );
    mailRE.compile( '^[\._a-z0-9-]+@[\.a-z0-9-]+[\.]{1}[a-z]{2,4}$', 'gi' );
    return !(mailRE.test( str ));
	} 
	
function removeLeadingSpaces(str)
{
   var whitespace = new String(" \\t\\n\\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1)
    {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)  j++;
      s = s.substring(j, i);
    }
   return s;
}
//######################################################################################################
// This method is used to remove Trailing spaces.
// It takes argument of the string which Trailing Spaces has to removed.
function removeTrailingSpaces(str)
{
   var whitespace = new String(" \\t\\n\\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1)
   {
      var i = s.length - 1;       // Get length of string
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) i--;
      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }
   return s;
}
//######################################################################################################
// Removes both Leading and Trailing blanks.
//
function removeAllSpaces(str)
{
   str = removeLeadingSpaces(str); //Remove Leading Spaces
   str = removeTrailingSpaces(str); //Remove Trailing Spaces
   return str;
}

	function mailToMother(){
		//alert("inside ");
		var to = document.motherday.to;
		var emailto = document.motherday.emailto;
		var from = document.motherday.from;
		var emailfrom = document.motherday.emailfrom;
		var content = document.motherday.content;
		
		
		if(removeAllSpaces(to.value) == ''){
			alert("Please enter name.");
			to.focus();
			return false;
		}
		
		if(removeAllSpaces(emailto.value) == ''){
			alert("Please enter email id.");
			emailto.focus();
			return false;			
		}
		
		if(notValidEmail(emailto.value)){
        alert( "Please enter correct email address");
		emailto.focus();
        return false;
    	}
    	
		if(removeAllSpaces(from.value) == ''){
			alert("Please enter name.");
			from.focus();
			return false;
		}
		
		if(removeAllSpaces(emailfrom.value) == ''){
			alert("Please enter email id.");
			emailfrom.focus();
			return false;			
		}
		if(notValidEmail(emailfrom.value)){
        alert( "Please enter correct email address");
		emailfrom.focus();
        return false;
    	}
		if(removeAllSpaces(content.value) == ''){
			alert("Please enter you message.");
			content.focus();
			return false;			
		}
		
		
		var temp = content.value;
		var text="";
		for(var i=0; i<temp.length; i++){
			text += temp.charAt(i).replace("\n", "<br/>");
		}
		//alert(text);
		var url="/mothersday.do?from="+from.value+"&emailfrom="+emailfrom.value+"&to="+to.value+"&emailto="+emailto.value+"&content="+text;
		
		 //alert(url);
		 
		var req = getAjexRequest();
		req.open("POST", url, true);
		//alert(req.readyState);
		req.onreadystatechange = responseT;
		req.send(null);
  } 
  
  function responseT(){
  	if (req.readyState == 4) {
			if (req.status == 200) {
				//alert(req.responseText)
				if(req.responseText == 'true'){
					to = document.motherday.to.value="";
					emailto = document.motherday.emailto.value="";
					from = document.motherday.from.value="";
					emailfrom = document.motherday.emailfrom.value="";
					content = document.motherday.content.value="";
					CloseOverlayWindow();
				}
			}
		}
  } 
function getAjexRequest(){
			if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
		return req;
	}
	