// This function is used to open a new window
function OpenWin(url,windowname,width,height)
{
 if (!url)
 {
 alert ("Please specify a URL to open");
 return false;
 }
 if (!windowname) windowname = 'newwin';
 if (!width) width = 300;
 if (!height) height = 350;
  var properties = "menubar=yes,toolbars=no,directory=no,scrolling=yes,status=yes,scrollbars=yes,resizable=yes,maximize=yes,width="+width+",height="+height;
  var newWin = window.open(url,windowname,properties);
  newWin.focus();
  return newWin;
}
function eCheckNum(sn){
    s= sn.value;
    for (var i = 0; i < s.length; i++) {
        ch = s.substring(i, i + 1)
        if (((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z") || (ch == " ")  || (ch == ".")  || (ch == ";")  || (ch == "&")  ||  (ch == ",")  ||  (ch == "_")  ||  (ch == "(")  ||  (ch == ")")  ||  ch == "@"))
           {
             return false;
        theForm.elements[eCheckNum.arguments[i]].focus();
             //(ch >= "0" && ch <= "9") (ch == "-")   ||
                                }
        }
   return true;
}

function CheckNum(theForm){
   for(var i=1; i<CheckNum.arguments.length; i++)
         if (!eCheckNum(theForm.elements[CheckNum.arguments[i]])){
            alert("Field entry is not valid");
            theForm.elements[CheckNum.arguments[i]].focus();
            return false;
        }
   return true;
}


function eCheckAlphaNum(sn){
    s= sn.value;
    for (var i = 0; i < s.length; i++) {
        ch = s.substring(i, i + 1)
        if (!((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z") || (ch == " ")  || (ch == ".")  || (ch == "-")   || (ch == "&")  ||  (ch == ",")  ||  (ch == "_")  ||  (ch == "(")  ||  (ch == ")")  || (ch >= "0" && ch <= "9") || ch == "@"))
           {
             return false;
        theForm.elements[eCheckAlphaNum.arguments[i]].focus();

                                }
        }
   return true;
}

function CheckAlphaNum(theForm){
   for(var i=1; i<CheckAlphaNum.arguments.length; i++)
         if (!eCheckAlphaNum(theForm.elements[CheckAlphaNum.arguments[i]])){
            alert("Field entry is not valid");
            theForm.elements[CheckAlphaNum.arguments[i]].focus();
            return false;
        }
   return true;
}

function CheckRequiredFields(theForm)
{
   for(i=1; i<CheckRequiredFields.arguments.length; i++)
        if(theForm.elements[CheckRequiredFields.arguments[i]].value=="")
        {
            alert("This field is required");
            theForm.elements[CheckRequiredFields.arguments[i]].focus();
            return false;
        }
   return true;
}

function deleterow(form,formobj)
{
var end=eval("document."+form+".end.value");
var count=0;
var i=0;
  for(i=1;i<=end;i++)
  {
     box=eval("document."+formobj+i);
        if(box.checked==true)
        {
                count=i;
        }
  }
             if(count < 1)
                  {
                alert("You have to select atleast one checkbox");
          return false;
                  }
      else if(!delrecord())
            {
       return false;
            }

//return mess;
 return true;
}

function delrecord(record)
{
var label="Are you sure you want to delete selected "+record+" ?\nClick on OK to delete.";

  if(!confirm(label))
  {
    return false;
  }

return true;
}

function email(formobj)
{
   var em=formobj.value;
   var len=em.length;
   var fm=em.indexOf("@");
   var fm1=em.indexOf(".");
   var fm3=em.indexOf(" ");
   var m=0 ;
   var check=false;
   var messg="";

   if(fm==-1 || fm3!=-1 || fm1==-1)
   {
      check=true;
      messg+="This is not valid email address\n";
   }
   if(em.substring(0,1)=="@" || em.substring(0,1)==".")
   {
      check=true;
      messg+="Email address should be start from a valid character or number\n";
   }
   for(i=0;i<len;i++)
   {
      if(em.substring(i,i+1)=="@")
      {
         m=m+1;
      }
      if((em.substring(i,i+1)=="@") && (em.substring(i+1,i+2)=="."))
      {
         check=true;
         messg+="after '@' character should be present\n";
      }
      if((em.substring(i,i+1)==".") && ((em.substring(i+1,i+2)=="@" ||em.substring(i+1,i+2)=="") || (em.substring(i+2,i+3)=="")))
      {
         check=true;
         messg+="After '.' atleast two character should be present\n";
      }
   }
   if(check==true)
   {
      return messg;
   }
   else if(m > 1)
   {
      return messg+="Not more then one '@' is allowed\n";
   }
   else
   {
      return messg="";
   }

}

function init()
{
	theObjects = document.getElementsByTagName("object"); 
	for (var i = 0; i < theObjects.length; i++) 
	{ 
		theObjects[i].outerHTML = theObjects[i].outerHTML; 
	}
}

window.setTimeout("init()", 0);