function trim1(inputString)
{
    if (typeof inputString != "string")
    {
        return inputString;
    }
    var retValue = inputString;
    var ch = retValue.substring(0, 1);
    while (ch == " ")
    { // Check for spaces at the beginning of the string
        retValue = retValue.substring(1, retValue.length);
        ch = retValue.substring(0, 1);
    }
    ch = retValue.substring(retValue.length-1, retValue.length);
    while (ch == " ")
    { // Check for spaces at the end of the string
        retValue = retValue.substring(0, retValue.length-1);
        ch = retValue.substring(retValue.length-1, retValue.length);
    }
    //while (retValue.indexOf(" ") != -1) { // Note that there are two 
 //spaces in the string - look for multiple spaces within the string
    //retValue = retVal
//}
return retValue;
}
    var vld_Email =  
/^(([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,5}|[0-9]{1,3})(\]?))?$/;
 
function temp(){
}
function reSet()
{
	document.getElementById('email').value=''
		document.getElementById('email').style.background='#FFFFFF'
		document.getElementById('email').style.color=''
	document.getElementById('comments').value=''
		document.getElementById('comments').style.background='#FFFFFF'
		document.getElementById('comments').style.color=''
}
function validate(frmName) {
	flag=0;	
	 
	if((trim1(frmName.email.value)=="")) {
		flag=0;
		document.getElementById('email').value='Please enter your e-mail address'
		document.getElementById('email').style.background='#7bac00'
		document.getElementById('email').style.color='#ffffff'
        frmName.email.focus();
		return false;
  	}else{
		flag=1;	
		}
	 if((eval(vld_Email).test(frmName.email.value)==false) && flag){
		flag=0;
		document.getElementById('email').value='Please enter a valid e-mail address'
		document.getElementById('email').style.background='#7bac00'
		document.getElementById('email').style.color='#ffffff'
        frmName.email.focus();
        return (false);
    }
	else{
   		flag=1;	
			
	}
	if((trim1(frmName.comments.value)=="")) {
		flag=0;
		document.getElementById('comments').value='Kindly Send Us Your Query'
		document.getElementById('comments').style.background='#7bac00'
		document.getElementById('comments').style.color='#ffffff'
        frmName.email.focus();
		return false;
  	}else{
		flag=1;	
		show();
		addComments();
		}
}

function addComments()
{	
	var email1=document.getElementById('email').value;
	var comment1=document.getElementById('comments').value;
	var target='refresh';
	var url="http://ashisha.info/process.php?&email="+email1+"&comment="+comment1;
	//alert(url);
	new Ajax.Updater(target,url);
	
}
function show(){
document.getElementById('form_container').style.display="none";
document.getElementById('thanks_section').style.display="";
setTimeout("subFunction()", 3000);
 
}
function subFunction(){
document.getElementById('form_container').style.display="none";
document.getElementById('thanks_section').style.display="none";
document.getElementById('sub_form').style.display="";
setTimeout("myFunction()", 4500);
}
function myFunction(){
document.getElementById('thanks_section').style.display="none";
document.getElementById('sub_form').style.display="none";
document.getElementById('form_container').style.display="";
document.getElementById('email').value='';
document.getElementById('comments').value='';
}
function cleartext()
{
        if (document.getElementById('email').value=='Please enter your e-mail address' || document.getElementById('email').value=='Please enter a valid e-mail address')
		{
        document.getElementById('email').value=''
		document.getElementById('email').style.background='#FFFFFF'
		document.getElementById('email').style.color=''
		}
}
function cleartext1()
{
       if (document.getElementById('comments').value=='Kindly Send Us Your Query')
        document.getElementById('comments').value=''
		document.getElementById('comments').style.background='#FFFFFF'
		document.getElementById('comments').style.color=''
}

function winPop(url)
{
	window.open(url);
	return false;
}






var http_request = false;
   function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('fname').value = '';
            document.getElementById('email').value = '';
            document.getElementById('phone').value = '';
            document.getElementById('comments').value = '';			
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function get(obj) {
      var poststr = "fname=" + encodeURI( document.getElementById("fname").value ) +
                    "&email=" + encodeURI( document.getElementById("email").value ) +
                    "&phone=" + encodeURI( document.getElementById("phone").value ) +
					"&comments=" + encodeURI( document.getElementById("comments").value );
      makePOSTRequest('process.php', poststr);
   }