var xmlHttp

function showname(str,str1)
{
if (str.length==0)
  { 
  document.getElementById("txtHint").innerHTML="";
  return;
  }
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="getname.php";
url=url+"?q="+str+"&w="+str1;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
}
}

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;
}




function validatedata(pt)

{


  
 if (!document.f1.st_regno.value.replace(/^\s*|\s*$/g,""))
          {

                 alert ("Enter Register Number");
                 document.f1.st_regno.focus();
                 return false;
        }

         else if (!document.f1.s1.value.replace(/^\s*|\s*$/g,""))
          {
                 alert ("Select Subject");
                 document.f1.s1.focus();
                 return false;

        }
         else if (!document.f1.marks.value.replace(/^\s*|\s*$/g,""))
          {
                 alert ("Enter marks obtained");
                 document.f1.marks.focus();
                 return false;
        } 
			
			
 else
        {
      //document.f1.degree.value 	= 	document.f1.degree.value;
//	  document.f1.scheme.value 	= 	document.f1.scheme.value;
//	  document.f1.year.value 	=	document.f1.year.value; 
//      document.f1.type.value 	= 	document.f1.type.value;
//	  document.f1.ccode.value 	= 	document.f1.ccode.value;	  
	  document.f1.action_value.value="add";
      //document.f1.action = "cvdetuporg.php"&ccode=$ccode&degree=$degree&year=$year&scheme=$scheme;
	  
	  document.f1.action = "cvdetuporg.php";
	
	  document.f1.submit();
        }
}



function validatedata1(pt)
{       
	  if (!document.f1.st_regno.value.replace(/^\s*|\s*$/g,""))
          {
				
                 alert ("Enter Register Number");
                 document.f1.st_regno.focus();
                 return false;
        }

         else if (!document.f1.marks.value.replace(/^\s*|\s*$/g,""))
          {
                 alert ("Enter marks obtained");
				 document.f1.marks.value ="";
                 document.f1.marks.focus();
                 return false;
        } 
		
		
		else if (IsNumeric(document.f1.marks.value) == false) 
        {
                alert("Please check - non numeric value!");
				document.f1.marks.value ="";
                 document.f1.marks.focus();
                 return false;
        } 
         else
        {
                  document.f1.action_value.value="edit";
				  document.f1.action = "cvdetuporg.php";
                  document.f1.submit();
				  return true;
        }

}

function confirmDeletestd()
{
    var agree=confirm("Are you sure to delete this Student?");
    if (agree)
        return true;
    else
        return false;
}


function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }


