// JavaScript Document
/// show hide edit field
function show_edit(rowid)
{
var x;
var rowid=rowid;
// table-row or none
if(document.getElementById(rowid).style.display=="none")
{
   try
   {
   document.getElementById(rowid).style.display="table-row";
   }
   catch(e)
   {
      document.getElementById(rowid).style.display="block";
   }
}
else
{
document.getElementById(rowid).style.display="none";
}
}

/// delete confir
function create() {
 var go = confirm("Are you sure to DELETE this record?");
 if (go == true) {
   return true;
 }
 else {
  return false;
 }
}


/// check is it blank
function ISBLANK(xx)
{ 
        var cc=0,tt;
		for(tt=0; tt<xx.length; tt++)
		{
		     if (xx.charAt(tt)==' ')
			 {
			 	cc=cc+1; // count blank character
			 }
		}
		if (cc==xx.length)
		{
			return true;  //// means it is BLANK
		}
	     return false;	//// means it is NOT BLANK
}

// is valid image file jpg/jpeg/gif
function IsValidimage(xx) 
	{   
	    var str=xx;
		
		var dotpos=str.lastIndexOf('.');
		var rr=(str.charAt(dotpos+1)+str.charAt(dotpos+2)+str.charAt(dotpos+3)+str.charAt(dotpos+4));
		
		if (rr.toLowerCase()=="jpg" || rr.toLowerCase()=="gif" || rr.toLowerCase()=="jpeg")
		{
			return true;
		}
		else
		{
			return false;
		}
    }
	
///////// RADIO BUTTON VALIDATION ////////

/*
/// how to call in main function
function CheckAll(x)
{
if(!is_radio_button_selected(x.radiobutton_name))
{
  alert ("Please select radio button !!");
  return false;
}
}
*///

function is_radio_button_selected(fieldnm)
{
// set var radio_choice to false
var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections
for (counter = 0; counter < fieldnm.length; counter++)
{
// If a radio button has been selected it will return true
// (If not it will return false)
if (fieldnm[counter].checked)
radio_choice = true; 
}

if (!radio_choice)
{
return (false); /// means not selected
}
return (true); /// means selected
}

///
function is_checkbox_button_selected(fieldnm)
{
// set var radio_choice to false
var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections
for (counter = 0; counter < fieldnm.length; counter++)
{
// If a radio button has been selected it will return true
// (If not it will return false)
if (fieldnm[counter].checked)
radio_choice = true; 
}

if (!radio_choice)
{
return (false); /// means not selected
}
return (true); /// means selected
}

///

function checkemail(myemail)
{
var str=myemail;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
{
testresults=true
}
else
{
testresults=false
}
return (testresults)
}