
function check_all()
{
	
	var max = document.main_frm.elements.length;
	//alert(document.main_frm.elements.length);
	for(j=0;j<max;j++)
	{	
	//document.main_frm.elements[j].checked =!(document.main_frm.elements[j].checked)
		if(document.getElementById('SelectBox').checked == true)
		{
			document.main_frm.elements[j].checked=true;
		}
		else
		{
			document.main_frm.elements[j].checked=false;
		}
	}
}


function submit_frm(page)
{
	
	var check_result=checkselect();
	if(check_result)
	{
		document.main_frm.action=page;
		//alert(document.main_frm.action);
		document.main_frm.submit();
	}
}

function submit_update(page)
{
	//alert(page);
	
		document.main_frm.action=page;
		//alert(document.main_frm.action);
		document.main_frm.submit();
	
}


function checkselect()
{
	var max = document.main_frm.elements.length;
	var count=0;
	for(j=0;j<max;j++)
	{
		if( document.main_frm.elements[j].checked == true)
		{
			count++;
		}
	}
	if(count == 0)
	{
		alert("Please Select at least on record");
		return false;
	}	
	else
	{
		return true;
	}
}



function checkdelete(page)
{
	//alert(page);
	var res=checkselect();
	if(res)
	{
		if(confirm("Are you sure you want to delete all the selected records"))
		{
			document.main_frm.action=page;
			document.main_frm.submit();
		}
		else
		{
			return false;
		}
	}
}

function winPop(pageToLoad, winName, width, height, center, scroll, control)
{
	/*alert(pageToLoad);
	alert(winName);
	alert(center);*/
	xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center))
    {
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
    args = "width=" + width + ","
    + "height=" + height + ","
    + "location=0,"
    + "menubar=0,"
    + "resizable=" + control + ","
    + "scrollbars="+scroll+", "
    + "status=1,"
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only
 
    /*alert(pageToLoad) ;
	alert(args);
	alert(winName);*/
    window.open(pageToLoad, winName, args);
}



//############################### for phone number validation
function check_phone(val) 
{
	var email = val ;
	//alert(email);
	wrongs="/:,#~`!$%^&*()+=|\\{}[]\"'<>?;@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	
	
	if(email == "") 
		a = false;
	for(i=0;i<wrongs.length;i++)
	{
		wrong = wrongs.charAt(i);
		//alert(email.indexOf(wrong,0));
		if(email.indexOf(wrong,0) != -1) 
			return false;
	}
	return true;
}


function check_char(val)
{
	var email = val ;
	wrongs="/:,#~`!$%^&*()+=|\\{}[]\"'<>?;";
	if(email == "") 
		a = false;
	for(i=0;i<wrongs.length;i++)
	{
		wrong = wrongs.charAt(i);
		//alert(email.indexOf(wrong,0));
		if(email.indexOf(wrong,0) != -1) 
			return false;
	}
	return true;
}

function check_numaric(val)
{
	var email = val ;
	wrongs=" /:,#~`!$%^&*()+=|\\{}[]\"'<>?;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	if(email == "") 
		a = false;
	for(i=0;i<wrongs.length;i++)
	{
		wrong = wrongs.charAt(i);
		//alert(email.indexOf(wrong,0));
		if(email.indexOf(wrong,0) != -1) 
			return false;
	}
	return true;
}

function check_email(email)
{
	wrongs=" /:,#~`!$%^&*()+=|\\{}[]\"'<>?;";
	if(email == "") 
		a = false;
	for(i=0;i<wrongs.length;i++)
	{
		wrong = wrongs.charAt(i);
		//alert(email.indexOf(wrong,0));
		if(email.indexOf(wrong,0) != -1) 
			return false;
	}
	monkey_pos = email.indexOf("@",0);
	if(monkey_pos==-1 || monkey_pos==0) 
		return false;
	if(email.indexOf("@",monkey_pos+1)!=-1) 
		return false;
	dot_pos=email.indexOf(".",monkey_pos);
	if(dot_pos==-1 || dot_pos==monkey_pos+1) 
		return false;
	if(dot_pos+3>email.length) 
		return false;
	return true;
}

function isAlphabetic(usrid)
{
	//alert(usrid);
	//return false;
	//This contains A to Z , 0 to 9 and A to B
	if(usrid == null || !usrid.toString().match(/^[-]?\d*\.?\d*$/))
	{
		
		var alphanum=/^[0-9a-zA-Z]+$/; //This contains A to Z , 0 to 9 and A to B
		if(usrid.match(alphanum))
		{
			return true;
		}
		else
		{
			return false;
		}
		
	}
	else
	{
		return false;
		
	}
}


function alphanumeric(alphane)
{
	var numaric = alphane;
	if(!isNaN(numaric))
	{
		return false;
	}
	else
	{
		for(var j=0; j<numaric.length; j++)
			{
			  var alphaa = numaric.charAt(j);
			  var hh = alphaa.charCodeAt(0);
			  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || (hh == 32))
			  {
			  }
			else	{
				 return false;
			  }
			}
	}
 return true;
}


 checked = false;
      function checkedAll () {
        if (checked == false){checked = true}else{checked = false}
	for (var i = 0; i < document.getElementById('main_frm').elements.length; i++) {
	  document.getElementById('main_frm').elements[i].checked = checked;
	}
      }