

function checkAll(frm,checked)
{
	//alert(checked);
	//alert(frm['items'].length);
	 for(var i=0;i<frm['items'].length;i++)
	  {  
		 	var e = frm.items[i];
			if(e.type == "checkbox") e.checked = checked;
	  } 
}
function deleteAlert(theForm)
{
	 var records = theForm.records.value;
     var total = 0;
     var msg = "";
     if(records>0)
     {
          for(i=0; i<theForm.length; i++)
          {
               e=theForm.elements[i];
               name = e.name;
               name = name.substr(0,4);
               if (e.type=='checkbox' && name == "item")
                    if(eval('e.checked') == true)
                         total= total+1;
          }
          if(total >0)
               msg = msg + 'Do You Like to remove ' + total +' records ?';
          else
          {
               alert("Please check the items to remove !");
               return false;
          }
          if(msg.length >0)
          {
               var flag;
               flag = confirm(msg + " If Yes Press \"OK\" else Press \"Cancel\".");
               if(flag == true)
               return true;
          }
     }
	 //alert("You can not delete items");
     return false;
	 
}
/* Email validation function*/
function isValidEmail(emailid){		
		var l=emailid.length;
		if(l==0)
		{
				return false;	
		}
		if(l!=0)
		{
				var a=emailid.indexOf('@');
				var d=emailid.lastIndexOf('.');
				var str1=emailid.substr(0,a);
				var str2=emailid.substr(a+1,d-a-1);
				var str3=emailid.substr(d+1,l);
				var len1=str1.length;
				var len2=str2.length;
				var len3=str3.length;
				if(a<0 || d<2)
				{
						//alert ("Check for missing '@' or '.' ");
						return false;
				}
				else if (a>d)
				{
						//alert ("Invalid email. Please enter correct email address");
						return false;
				}				
				if (len1<=1 || len2<=1 || len3 <=1)
				{
						//alert ("Invalid email. Please enter correct email address");
						return false;
				}				
		}
		return true;
}


	function chkphone(alphane)
	{
		var numaric = alphane;
		var isNumeric=''; 
		for(var j=0; j<numaric.length; j++)
			{
			  var alpha = numaric.charAt(j);
			  if(alpha!='-' && alpha!='+')
			  {  
				 if(isNaN(alpha))
				 {
					isNumeric=false;
					break;
				 }
				 else
					isNumeric=true;
			  }
			  else
				isNumeric=true;
			 
		   }
		   return isNumeric;
	   }

//popup window
/*var pop='';
function openwin(nm,width,height) {
	var name=nm;
	if (pop && !pop.closed) {
		pop.close();
	}
	pop=eval("window.open('"+name+"','NewWIN','chrome[4],toolbar=no,left=5,top=5,width="+width+",height="+height+",directories=no,menubar=no,SCROLLBARS=yes,left=2,right=2')");
	if (!pop.opener) popUpWin.opener = self;
} */


var pop='';
function openwin(nm,width,height,w_per,h_per) {
	var name=nm;
	var screen_h=window.screen.height;
	var screen_w=window.screen.width;
	var x_cor=parseInt((w_per/100)*screen_w);
	var y_cor=parseInt((h_per/100)*screen_h);
	if (pop && !pop.closed) {
		pop.close();
	}
	pop=eval("window.open('"+name+"','NewWIN','chrome[4],toolbar=no,left=5,top=5,width="+width+",height="+height+",directories=no,menubar=no,SCROLLBARS=yes,left='+x_cor+',top='+y_cor+'')");
	pop.moveTo(x_cor,y_cor);

	if (!pop.opener) popUpWin.opener = self;
}


/*************Validate the forms--------------------------------------*/

function check(frm, fld_arr)
{
  
	
	var msg=Array();
    var count=0;

	for (var word in fld_arr)
    {
	   
	   	//alert(frm);
	
		 if(frm[word].value=="")
		 {
			 msg[count] = fld_arr[word];		
    		 count++;
          } 	
	} 

	return msg;
	

	//alert(test);
}
function display_message(arr_msg)
{	
	var msg='Please review the following error message before continue:<br>';
	for (var word in arr_msg)
    {
		msg+="&bull; "+arr_msg[word]+'<br>';
	}
	msg+="<br>";
	return msg;
}

