// JavaScript Document
function getXMLHttp()
{
        var xmlhttp;

        /* Special IE only code ... */
              try
              {
                  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
              }
              catch (e)
              {
                  try
                  {
                      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                  }
                  catch (E)
                  {
                      xmlhttp = false;
                  }
             }
          /** Every other browser on the planet */
        if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
        {
            try
            {
                xmlhttp = new XMLHttpRequest();
            }
            catch (e)
            {
                xmlhttp = false;
            }
        }

        return xmlhttp;
}
function Requestimage()
{	
 var xmlHttp = getXMLHttp();
   xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponse(xmlHttp.responseText);
    }
  }

      xmlHttp.open("GET", "getsecuritycode.php", true);
	  xmlHttp.send(null);
	
}
function HandleResponse(response)
{
	document.getElementById('code').src="images/"+response;
	
}
function getimage()
{	
 var xmlHttp = getXMLHttp();
   xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      Responseimage(xmlHttp.responseText);
    }
  }
		
      xmlHttp.open("GET", "getsecuritycode.php", true);
	  xmlHttp.send(null);
	
}
function Responseimage(response)
{
// document.getElementById('code').innerHTML=response;
// document.getElementById('code').style.backgroundImage="url("+response+")";
 document.getElementById('scode').src="images/"+response;
}
function fieldchk()
{	
	var me=document.frmfeedback;
  	var invalid = " "; // Invalid character is a space	
   var space1= ",/<>?!~`';:#$%^&*()=|[]{}" + '"' +"\n\t";

	if(me.fname.value == "")
	{
	alert("Please enter your Name.");
	me.fname.focus();
	return false;
	}
	if(me.email.value == "")
	{
		alert("Please enter your E-mail ID.");
		me.email.focus();
		return false;
	}
 mymail = me.email.value;
	if((mymail.indexOf("@") == -1) || (mymail.indexOf(".") == -1))
	{
      // DISPLAY ERROR MESSAGE
      alert ("Sorry, the E-mail ID you\nentered is not in the correct\nformat.");
      me.email.focus();
		  return false;
    }
	if(me.enquiry.value == "")
	{
		alert("Please enter your Message.");
		me.enquiry.focus();
		return false;
	}
	if(me.code.value == "")
	{
		alert("Please the capcha code.");
		me.code.focus();
		return false;
	}
	return true;
	
}

function frmvalidate()
{
	var a=document.frmfeedback;
	if(a.txtName.value=="")
	{
		alert("Enter the Name.");
		a.txtName.focus();
		return false;
	}
	if(a.email.value=="")
	{
		alert("Enter the E-mail.");
		a.email.focus();
		return false;
	}
	if((a.email.value.indexOf(".")==-1)||(a.email.value.indexOf("@")==-1))
	{
		alert("Enter the valid E-mail.");
		a.email.focus();
		return false;
	}
	if(a.txtMessage.value=="")
	{
		alert("Enter the Message.");
		a.txtMessage.focus();
		return false;
	}
	if(a.code.value=="")
	{
		alert("Enter the capcha code.");
		a.code.focus();
		return false;
	}
	
	return true;
}
function reloadimage()
{	
var val=frmvalidate();
	if(val==true)

	{

		var code1=document.frmfeedback.code.value;

		if((code1!="m9fd6b")&&(code1!="sap")&&(code1!="cf5fdk")&&(code1!="uaonl")&&(code1!="jzs2s4")&&(code1!="fvw83x")&&(code1!="ubas")&&(code1!="7r5v2x")&&(code1!="4qx499")&&(code1!="kdxk2p"))

		{	

			alert("Check Security Code.");

			document.frmfeedback.code.focus();

			getimage();

			return false;

		}

		else

		{

		return true;

		}

	}

	else

	{

	return false;

	}

}
function reloadsmall()
{	
var val=fieldchk();
	if(val==true)

	{

		var code1=document.frmfeedback.code.value;

		if((code1!="m9fd6b")&&(code1!="sap")&&(code1!="cf5fdk")&&(code1!="uaonl")&&(code1!="jzs2s4")&&(code1!="fvw83x")&&(code1!="ubas")&&(code1!="7r5v2x")&&(code1!="4qx499")&&(code1!="kdxk2p"))

		{	

			alert("Check Security Code.");

			document.frmfeedback.code.focus();

			Requestimage();

			return false;

		}

		else

		{

		return true;

		}

	}

	else

	{

	return false;

	}

}
