// **************** START FUNCTION check ***************************


validname="abcdefghijklmnopqrstuvwxyz' ";
validnum="0123456789";

function check(){

pass1 = "yes";
pass2="no";

if (document.form.name.value==0){
pass1="no";
alert("Please enter your name");
document.form.name.focus();
return false;
}

if(document.form.address.value==0){
pass1="no";
alert("Please mention your address");
document.form.address.focus();
return false;
}

if(document.form.state.value==0){
pass1="no";
alert("Please mention your state");
document.form.state.focus();
return false;
}

if(document.form.country.selectedIndex < 0){
pass1="no";
alert("Please mention your country");
document.form.country.focus();
return false;
}

if(document.form.postalcode.value==0){
pass1="no";
alert("Please enter your postal code");
document.form.postalcode.focus();
return false;
}

if(document.form.email.value==0){
pass1="no";
alert("Please mention your e-mail");
document.form.email.focus();
return false;
}

if(document.form.query.value==0){
pass1="no";
alert("No query has been submitted");
document.form.query.focus();
return false;
}


if(pass1=="yes"){

pass2="yes";

name=(document.form.name.value).toLowerCase();

for(i=0;i<name.length;i++){
if(validname.indexOf(name.charAt(i)) == -1){
pass2="no";
alert("invalid character in name");
return false;
}
}

pcode=document.form.postalcode.value;
for(i=0;i<document.form.postalcode.value.length;i++){
if(validnum.indexOf(pcode.charAt(i)) == -1){
pass2="no";
alert("invalid postal code");
return false;
}
}

phone=document.form.phone.value;
if(phone != ""){
if(phone.length < 5){
pass2="no";
alert("invalid phone number");
return false;
}
else{
for(i=0;i<phone.length;i++){
if(validnum.indexOf(phone.charAt(i)) == -1){
pass2="no";
alert("invalid phone number");
return false;
}
}
}

if ((document.form.email.value.indexOf("@") == -1) || 
         (document.form.email.value.indexOf(".") == -1) || (document.form.email.value.indexOf(",") > -1 )){
pass2="no";
alert("invalid e-mail ID");
return false;
}

if(document.form.email.value.length < 7){
pass2="no";
alert("invalid e-mail ID");
return false;
}

}
}
if(pass2=="yes"){
document.form.key.value="done";
document.form.submit();
}
}


// **************** START FUNCTION getdetails ***************************

function getdetails(VID){
document.f1.selectID.value = VID;
// alert(document.f1.selectID.value);
document.f1.submit();
}


// **************** START FUNCTION showdetails ***************************

function showdetails(){
if(document.f1.viruslist.options.selectedIndex < 0){
alert("No option selected");
return false;
}
else{
document.f1.selectID.value = document.f1.viruslist.options[document.f1.viruslist.options.selectedIndex].value;
document.f1.submit();
}
}

// **************** START FUNCTION popdef ***************************

function popdef(catname){
filename = "/virus-categories/" + catname.toLowerCase() + ".html";
window.open(filename, "Virus_Definitions", "width=550,height=200,left=100,top=200,scrollbars=yes");
}

// **************** START FUNCTION download ***************************


	function download()

	{
		if(document.f1.name.value == 0)
		{
			alert("Please enter your name");
			document.f1.name.focus();
			return false;
		}
		if(document.f1.email.value == 0)
		{
			alert("Please enter your email");
			document.f1.email.focus();
			return false;
		}
		
		name = (document.f1.name.value).toLowerCase();
		
		for(i=0;i<name.length;i++)
		{
			if(validname.indexOf(name.charAt(i)) == -1)
			{
				alert("Invalid character in name");
				document.f1.name.select();
				return false;			
			}	
		}		
		
		if ((document.f1.email.value.indexOf("@") == -1) || (document.f1.email.value.indexOf(".") == -1) || (document.f1.email.value.indexOf(",") > -1 ))
		{
			alert("invalid e-mail ID");
			return false;
		}

		if(document.f1.email.value.length < 7){
		alert("invalid e-mail ID");
		return false;
		}
		
		window.location.href="/update/sscan.zip";

	}
// ********************    Start function chk    *****************************************

function chk(txt)
{
	if (txt == 'current')
	{
		document.form_current.submit;
	}
	else if (txt == 'hash')
	{
		document.form_hash.submit;
	}
	else if (txt == 'A')
	{
		document.form_a.submit;
	}
	else if (txt == 'B')
	{
		document.form_b.submit;
	}
	else if (txt == 'C')
	{
		document.form_c.submit;
	}
	else if (txt == 'D')
	{
		document.form_d.submit;
	}
	else if (txt == 'E')
	{
		document.form_e.submit;
	}
	else if (txt == 'F')
	{
		document.form_f.submit;
	}
	else if (txt == 'G')
	{
		document.form_g.submit;
	}
	else if (txt == 'H')
	{
		document.form_h.submit;
	}
	else if (txt == 'I')
	{
		document.form_i.submit;
	}
	else if (txt == 'J')
	{
		document.form_j.submit;
	}
	else if (txt == 'K')
	{
		document.form_k.submit;
	}
	else if (txt == 'L')
	{
		document.form_l.submit;
	}
	else if (txt == 'M')
	{
		document.form_m.submit;
	}
	else if (txt == 'N')
	{
		document.form_n.submit;
	}
	else if (txt == 'O')
	{
		document.form_o.submit;
	}
	else if (txt == 'P')
	{
		document.form_p.submit;
	}
	else if (txt == 'Q')
	{
		document.form_q.submit;
	}
	else if (txt == 'R')
	{
		document.form_r.submit;
	}
	else if (txt == 'S')
	{
		document.form_s.submit;
	}
	else if (txt == 'T')
	{
		document.form_t.submit;
	}
	else if (txt == 'U')
	{
		document.form_u.submit;
	}
	else if (txt == 'V')
	{
		document.form_v.submit;
	}
	else if (txt == 'W')
	{
		document.form_w.submit;
	}
	else if (txt == 'X')
	{
		document.form_x.submit;
	}
	else if (txt == 'Y')
	{
		document.form_y.submit;
	}
	else if (txt == 'Z')
	{
		document.form_z.submit;
	}
//return true 
}

// ********************    remove_space    *****************************************

function remove_white_space(item)
{
  var tmp = "";
  var item_length = item.value.length;
  var item_length_minus_1 = item.value.length - 1;
  for (index = 0; index < item_length; index++)
  {
    if (item.value.charAt(index) != ' ')
    {
      tmp += item.value.charAt(index);
    }
    else
    {
      if (tmp.length > 0)
      {
        if (item.value.charAt(index+1) != ' ' && index != item_length_minus_1)
        {
          tmp += item.value.charAt(index);
        }
      }
    }
  }
  item.value = tmp;
}