function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   
   var IsNumber=true;
   var Char;
 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
function chk_num(val,field)
{
	
	var num= IsNumeric(val);
	//alert(num);
	if(num==false)
	{
		alert("Please Insert Numeric Values");
		document.getElementById(field).value="";
	}
}
//-----------------------------------------------
function clr_txt(field_id,CurVal)
{
	var NewVal=document.getElementById(field_id).value;
	if(NewVal==CurVal)
		document.getElementById(field_id).value="";
}
function clr_and_type(field_id,typeNmae)
{
	document.getElementById(field_id).value="";
	document.getElementById(field_id).type=typeNmae;
}
function chk_empty(field_id,SetVal)
{
	var vals=document.getElementById(field_id).value;
	if(vals=="")
		document.getElementById(field_id).value=SetVal;
}

function chk_empty_type(field_id,SetVal,typeNmae)
{
	
	var vals=document.getElementById(field_id).value;
	if(vals=="")
	{
		document.getElementById(field_id).type=typeNmae;
		document.getElementById(field_id).value=SetVal;		
	}
}

//-----------------------------------------------
function matchpass(formId)
{
	if (document.getElementById(formId).ConfirmPassword.value  != document.getElementById(formId).Password.value) 
	{
		alert("Password and Confirm password are not the same");
		document.getElementById(formId).ConfirmPassword.focus();
		return false; 
	}
}
//------------- Password Generator --------
function CreatePassword()
{
  var minsize, maxsize, count, actualsize;
  minsize = parseInt(document.forms[0].minpw.value);
  if (minsize <= 0)
  {
    window.alert("Minimum Password Size must be at least 1!");
    return;
  }
  document.forms[0].minpw.value = minsize;
  maxsize = parseInt(document.forms[0].maxpw.value);
  if (maxsize < minsize)
  {
    window.alert("Maximum Password Size cannot be smaller than Minimum!");
    return;
  }
  document.forms[0].maxpw.value = maxsize;
  if (document.forms[0].pwout.size < maxsize)
    document.forms[0].pwout.size = maxsize;
  var validchars = "";
  var startvalid = "";

  for (count = 0; count < document.forms[0].length; count++)
    if (document.forms[0].elements[count].checked)
      if (document.forms[0].elements[count].name == "middle")
        validchars = validchars.concat(document.forms[0].elements[count].value);
      else if (document.forms[0].elements[count].name == "start")
        startvalid = startvalid.concat(document.forms[0].elements[count].value);
 
  actualsize = Math.floor(Math.random() * (maxsize - minsize + 1)) + minsize;
  document.forms[0].pwout.value = startvalid.charAt(Math.floor(Math.random()
    * startvalid.length));
  for (count = 1; count < actualsize; count++)
    document.forms[0].pwout.value += validchars.charAt(Math.floor(Math.random()
      * validchars.length));
}

//-------------------------
function validate()
{
   var NAME=document.form1.Name.value;
   var EMAIL=document.form1.Email.value;
   var COMMENTS=document.form1.Comments.value;
   
   if(NAME=="")
   {
   alert('Name field cannot be blank!');
   document.form1.Name.focus();
   return false;
   }
  if(EMAIL=="")
   {
   alert('Email field cannot be blank!');
   document.form1.Email.focus();
   return false;
   }
   if(COMMENTS=="")
   {
   alert('Comments Field cannot be blank!');
   document.form1.Comments.focus();
   return false;
   }
//else return window.confirm ("Are you ready to Submit?");
return true;
}
//-------------------Function Check Empty-------------------------------
function Empty_field(formId,fields,action)
{	
	//alert('Form Name : '+formId);
	var action=action;	
	var fields=fields;
	var fn= fields.split(",");
	
	for(i=0;i<fn.length;i++)
	{
		//alert("Waow!");
		var a= fn[i];
		var ef=document.getElementById(a).value;
		
		if(ef=="")
		{
			alert("Please fill the Blank Field");
			document.getElementById(a).focus();
			//document.getElementById(a).style.backgroundColor='#FFFFCC';
			document.getElementById(a).style.borderColor='#FF0000';
			return false;
		}
	}
	document.getElementById(formId).action=action;
}
//-------------------cHECKING eMAIL-------------------------------------
var testresults
function checkemail(formId,EmailFld)
{
	var str=document.getElementById(formId).getElementById(EmailFld).value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str)) {
		testresults=true;
		 //return window.confirm ("Are you ready to Submit?");
	}
	else {
		alert("Please input a valid email address!");
		document.getElementById(formId).getElementById(EmailFld).focus();
		testresults=false;
	}
	return (testresults);
}

function validemail(formId,EmailFld){
if (document.layers||document.getElementById||document.all)
	return checkemail(formId,EmailFld);
else
	return true;
}
//--------- Focus first form element -----------------
function formfocus() {
    if(document.forms.length > 0)
    {
		var formElements = ["text", "checkbox", "radio", "select-one", "select-multiple", "textarea", "password"];
		var form = document.forms[document.forms.length-1];
		for (var j = 0; j < form.elements.length; j++)
		{
			var field = form.elements[j];
			for(var x = 0; x < formElements.length; x++)
			{
				if (field.getAttribute("type") == formElements[x])
				{
					field.focus();
					return false;
				}
			}
		}
    }
}
//-----------------------------Test Function------------------------------
function test()
{
	alert('Dekhai na...');
	
}

//-----------------------Status Bar Time---------------------------------
<!-- Hide from old browsers 
var hour=0;
var min =0;
var sec =0;

function timer() {
  var _status = "You have been on this page for: ";
  if (++sec>59) {
    if (++min>59) {
      hour++;
      min=0;
    }
   sec=0;
  }
  var _min=min>9?min:"0"+min;
  var _sec=sec>9?sec:"0"+sec;
  var _hour=hour>9?hour:"0"+hour;
  _status += _hour+":"+_min+":"+_sec;
  defaultStatus = _status;
}

var myTimer=null;
var ONE_SECOND = 1000;
function startTimer() {
  endTimer();
  myTimer = setInterval("timer()",ONE_SECOND);
}
function endTimer() {
  if (myTimer != null) {
    clearInterval(myTimer);
	myTimer = null;
  }
}
//---------"Accept terms" form submission--------------------------------------
var checkobj

function agreesubmit(el)
{
	checkobj=el;
	if (document.all||document.getElementById)
	{
		for (i=0; i<checkobj.form.length; i++)
		{  //hunt down submit button
			var tempobj=checkobj.form.elements[i]
			if(tempobj.type.toLowerCase()=="submit")
				tempobj.disabled=!checkobj.checked;
		}
	}
}

function defaultagree(el)
{
	if (!document.all&&!document.getElementById)
	{
		if (window.checkobj&&checkobj.checked)
			return true;
		else
		{
			alert("Please read/accept terms to submit form")
			return false;
		}
	}
}

function chk_Browser()
{
	var msg='';
	var StrDummy = navigator.appVersion;
	strVersion = StrDummy.substring(0,4);
	if(navigator.appName == "Microsoft Internet Explorer") {
	msg+='Best Viewed in Mozilla FireFox or Google Chrome! ';
	}
	if(strVersion < 5) {
	msg+='\n\nAnd Please Update Your Browser to Latest Version!';
	}
	if(msg!=''){
		alert(msg);
	}
}
