// 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();

}

function checkall(theForm)
{
 for(i=0; i<theForm.elements.length; i++)
 {
	 if(theForm.elements[i].type == "checkbox")
	 {
		theForm.elements[i].checked = theForm.SelectAll.checked;
	 }
 }
}

function CheckRequiredFields(theForm)
{
//   theForm.requiredhiddenfield.value="";
   for(i=1; i<CheckRequiredFields.arguments.length; i++)
    {
      if(theForm.elements[CheckRequiredFields.arguments[i]].value=="" || theForm.elements[CheckRequiredFields.arguments[i]].value=="null")
        {
            alert(theForm.elements[CheckRequiredFields.arguments[i]].name + " is required");
            theForm.elements[CheckRequiredFields.arguments[i]].focus();
            return false;
        }
//        theForm.requiredhiddenfield.value=theForm.requiredhiddenfield.value + theForm.elements[CheckRequiredFields.arguments[i]].name + "|";
    }
   return true;
}

function CheckDateFields(theForm)

{

   for(i=1; i<CheckDateFields.arguments.length; i++)

        if(theForm.elements[CheckDateFields.arguments[i]].value=="-")

        {

            alert("Please select the date fields");

            theForm.elements[CheckDateFields.arguments[i]].focus();

            return false;

        }

   return true;

}



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 == "@"))

           {

             return false;

        theForm.elements[eCheckNum.arguments[i]].focus();

             //(ch >= "0" && ch <= "9") || (ch == ".") || (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 CheckDeleted(name,value, alertmessage)

{

 if(alertmessage == undefined) alertmessage = "";



 if(value=="" || value==null)

 {

  alert("Please select the record you want to delete.");

  return false;

 }

 conf=confirm("Are you sure!! You want to delete record of this "+name+". "+alertmessage);

 if(!conf)



  return false;

 else

  return true;

}



function CheckModified(name, value, actionname)

{

 if(value=="" || value==null)

 {

  alert("Please select the record you want to "+actionname+".");

  return false;

 }

 else

 {

  return true;

 }

}