 function check_for_blank(txtvalue)
{
	if (txtvalue.value=="")
	{
		//alert('Invalid Value');
		txtvalue.focus();
		return false;
	}	
	
}
function check_email(EMAIL)
 {
  var FLG = false;
  var FLG1 = false;
  var FLG2 = true;
  if (EMAIL.value.substring(0,1)=="@")
   {
   // alert('Email should not start with @');
//    EMAIL.value="";
    EMAIL.focus();
    return false;
   }
   else if (EMAIL.value.substring((EMAIL.value.length-1),EMAIL.value.length)==".")
    {
    //alert('Email should not end with .');
//    EMAIL.value="";
    EMAIL.focus();
	return false;
    }
   else
    {
    for (i=1;i<=EMAIL.value.length;i++)
     { 
      if (EMAIL.value.substring((i-1),i)=="@"){
         FLG=true;}
      if (EMAIL.value.substring((i-1),i)=="."){
         FLG1=true;}
      if (EMAIL.value.substring((i-1),i)=="@" && EMAIL.value.substring(i,(i+1))==".")
         {FLG2=false;}
     }
    if (FLG==false)
     {
      // alert('@ missing in the E-mail ');
       // EMAIL.value="";
       EMAIL.focus();
       return false;
     }
    if (FLG1==false)
     {
       //alert('. missing');
       //EMAIL.value="";
       EMAIL.focus();
       return false;
     }
    if (FLG2==false)
     {
      //alert('There should be characters between @ and .');
      EMAIL.focus();
      return false;  
     } 
   }
  return true;
 }
 
 function check_for_NaN(TextValue)
 {
	if (isNaN(TextValue.value))
	{	alert('This field must be numeric.');
		TextValue.value="";
		TextValue.focus();
		return true;
	}
 }
 

 function chk_selectAll(frm,check)
  {
   var i;
   var cnt=frm.elements.length;
   for (i=0;i<cnt;i++)
    {
      if (frm.elements[i].name=check+i)
       {
        frm.elements[i].checked=true;
       }                 
    }
  }
 
 function f_update()
 {
  if (confirm("Do you want to update?"))
   return true;
  else
   return false;
 }
 
 function f_delete()
  {
   if (confirm("Are you sure, you want to delete?"))
     return true;
   else 
     return false;
 }
 
 //name validation
 function f_name(name) 
  {
   var flg;
   if (name.value.charAt(0)>='0' && name.value.charAt(0)<='9')
    {
     alert('First character should not be a number');
     name.focus();
     return false;
    } 
   for (i=0;i<name.value.length;i++)
    {
     if ((name.value.charAt(i)=="_") || ((name.value.charAt(i)>='0') && (name.value.charAt(i)<='9')) || ((name.value.charAt(i)>='a')&&(name.value.charAt(i)<='z')) || ((name.value.charAt(i)>='A')&&(name.value.charAt(i)<='Z')))
      {}
     else 
      {
        alert("Invalid Character \""+name.value.substring(i,i+1)+"\"");
        name.focus();
        return false;      
      }   
     }
      
   return true;  
  } 
  
  
 //for selecting all the items in the list box
function f_select(sel,txthide)
{
	var strhidvalue = "";	
	var i=0;
	for (i=0;i<sel.length;i++)
	{
		if (strhidvalue != "")
		{	
			sel.options[i].selected=true;
			strhidvalue = strhidvalue + "," + sel.options[i].value;	
		}
		else
		{	
			sel.options[i].selected=true;
			//alert("dd");
			strhidvalue = sel.options[i].value;	
		}
	}
  	txthide.value = strhidvalue;	
}

 //To remove the selected items
  function f_remove(sel)
   {
    var i=0;
    for (i=sel.length-1;i>=0;i--)
     {
      if (sel.options[i].selected==true)
       {
    	if(navigator.appName == "Microsoft Internet Explorer")
    	{
	  	sel.remove(i);
	    }
       else
	    {
//		  alert(sel.options[i].value);
		  sel.options[i].text = "";
		  sel.options[i].value = "";
//		  alert("Once Selected Can Not Removed");
	    }
	   }
      } 
      sel.focus();
   }
   
       
 // attach with months to the third box
 function f_attach(sel1,sel2,ifother,sel3,text)
   {
   var flg = 0,flg2 = 0,flg1=0,j=0,i=0;
    len = sel3.length;
    str_mon="";
    str1= "";
    str_value="";
    str_other="";
    //
    for (j=0;j<sel2.length;j++)
      {
       if (sel2.options[j].selected==true)
        {
           str_mon = " | " + sel2.options[j].text + " Months";
           str_value=" |" + sel2.options[j].value;
           sel2.options[j].selected=false;
         }
      }

    for (i=0;i<sel1.length;i++)
     {           
      if (sel1.options[i].selected == true)
        {
         if (sel1.options[i].text != "")
          {
	   flg2 = 0;
           for (x=0;x<sel3.length;x++)
              {
               sel3.options[x].selected=false;
               if (sel1.options[i].text==sel3.options[x].text.substring(0,sel1.options[i].text.length))
                {
                  flg2=1;
                }
              } 
            if (flg2==0)  
             {
              sel3.options[len] = new Option(sel1.options[i].text + str_mon,sel1.options[i].value + str_value);
              sel1.options[i].selected=false;
             }
          }
          } 
     }   

    if (ifother.value.length>0 && ifother.value!="If Other")  
       {
          flg1 = 0;
          for (k=1;k<len;k++) 
          {
           if ((ifother.value)==sel3.options[k].text.substring(0,(ifother.value.length)))
             {
              flg1 = 1;
              sel3.options[k].text=ifother.value + str_mon;
             }
           }   

	    if(flg1==0)   
	       {
	         sel3.options[len]=new Option(ifother.value + str_mon,ifother.value + str_mon);
	         ifother.value="If Other";
	       }  
   }
   sel1.options[0].selected = true;
   sel2.options[0].selected = true;
  }
  //function is called when month is selected
 function f_attachmon(sel1,sel2,ifother,sel3)
  {
    var flg = 0,flg2 = 0,flg1=0;
    len = sel3.length;
    str="";
    str_value="";
    str_other="";
    for (j=0;j<sel2.length;j++)
      {
       if (sel2.options[j].selected==true)
        {
          str =  sel2.options[j].text + " Months";
          str_value=sel2.options[j].value;
          sel2.options[j].selected=false;
         }
      }
    for (x=0;x<sel3.length;x++)
         {
          if (sel3.options[x].selected == true)
           {
            for (j=0;j<sel3.options[x].text.length;j++)
                 {
                  str_other+=sel3.options[x].text.charAt(j); 
                  if (sel3.options[x].text.charAt(j)=="|")
                   {
                    sel3.options[x].text=str_other + " " + str;
					sel3.options[x].value=str_other + " " + str_value;   
					break;
                   }                     
                 } 
            }
          }       
 } 
  
  //attachment to Qual 
  function f_attachqual(sel1,sel2,ifother,ifother2,sel3)
   {
    var flg = 0;
    len = sel3.length;
    str="";
    strval = "";
    for (j=0;j<sel2.length;j++)
     {           
      if (sel2.options[j].selected==true)
       {
        str = " | " + sel2.options[j].text;
        strval = " | " + sel2.options[j].value;
        sel2.options[j].selected=false;
       }
       else
       {
        if (ifother2.value.length>0 && ifother2.value!=="If Other")
         {str= " | " + ifother2.value;}
        }
       }     
     for (i=0;i<sel1.length;i++)
      {
       if (sel1.options[i].selected == true)
       {
        flg = 0;
        for (j=0;j<len;j++)
          {
           if ((sel1.options[i].text)==sel3.options[j].text.substring(0,(sel1.options[i].text.length)))
             {
              flg = 1;
              sel3.options[j].text=sel1.options[i].text + str;
             } 
           }
         if (flg==0)  
         {
          sel3.options[len] = new Option(sel1.options[i].text + str,sel1.options[i].value + strval);
          sel1.options[i].selected=false;
          sel3.options[len].selected=true;
         } 
       }
      }
     if (ifother.value.length>0)  
       {
          flg1 = 0;
          for (k=1;k<len;k++) 
          {
           if ((ifother.value)==sel3.options[k].text.substring(0,(ifother.value.length)))
             {
              flg1 = 1;
              sel3.options[k].text=ifother.value + str;
             }
           }   
          if (ifother.value=="If Other")  
           {return false;}
          if(flg1==0)   
           {
             sel3.options[len]=new Option(ifother.value + str,ifother.value + str);
             ifother.value="";
           }  
       }
      }  
function resetvalue()
 {
	document.frmCandInfo.selExpertiseMonths.value =""; 
	document.frmCandInfo.selDesignationMonths.value="";
	document.frmCandInfo.selIndustryMonths.value="";
	document.frmCandInfo.selExpertiseAdd.value="";
	document.frmCandInfo.selDesignation.value="";
	document.frmCandInfo.selIndustry.value="";
	document.frmCandInfo.areaselected1.value="";
	document.frmCandInfo.areadisplay1.value="";
	document.frmCandInfo.txtuniversity.value="";
	document.frmCandInfo.selExpertiseAdd.value="";
	document.frmCandInfo.selDesignationAdd.value="";
	document.frmCandInfo.selIndustryAdd.value="";
	document.frmCandInfo.areaselected.value="";
	
	
	var i=0;
	for (i = document.frmCandInfo.selExpertiseAdd.length-1;i>=0;i--)
     {
      if(document.frmCandInfo.selExpertiseAdd.length >= 1)
       {
        if(navigator.appName == "Microsoft Internet Explorer")
    	 {
    	  document.frmCandInfo.selExpertiseAdd.remove(i);
	     }
       else
	    {
    	//alert(document.frmCandInfo.selExpertiseAdd.options[i].value);
		  document.frmCandInfo.selExpertiseAdd.options[i].text = "";
		  document.frmCandInfo.selExpertiseMonths.options[i].value = "";
    	//alert("Once Selected Can Not Removed");
	    }
	   }
      }
          
for (i = document.frmCandInfo.selDesignationAdd.length-1;i>=0;i--)
     {
      if(document.frmCandInfo.selDesignationAdd.length >= 1)
       {
        if(navigator.appName == "Microsoft Internet Explorer")
    	 {
    	  document.frmCandInfo.selDesignationAdd.remove(i);
	     }
       else
	    {
    	//alert(document.frmCandInfo.selExpertiseAdd.options[i].value);
		  document.frmCandInfo.selDesignationAdd.options[i].text= "";
		  document.frmCandInfo.selDesignationAdd.options[i].value= "";
    	//alert("Once Selected Can Not Removed");
	    }
	   }
      }
          
for (i = document.frmCandInfo.selIndustryAdd.length-1;i>=0;i--)
     {
      if(document.frmCandInfo.selIndustryAdd.length >= 1)
       {
        if(navigator.appName == "Microsoft Internet Explorer")
    	 {
    	  document.frmCandInfo.selIndustryAdd.remove(i);
	     }
       else
	    {
    	//alert(document.frmCandInfo.selIndustryAdd.options[i].value);
		  document.frmCandInfo.selIndustryAdd.options[i].text = "";
		  document.frmCandInfo.selIndustryAdd.options[i].value = "";
    	//alert("Once Selected Can Not Removed");
	    }
	   }
      }
     for (i = document.frmCandInfo.areaselected.length-1;i>=0;i--)
     {
      if(document.frmCandInfo.areaselected.length >= 1)
       {
        if(navigator.appName == "Microsoft Internet Explorer")
    	 {
    	  document.frmCandInfo.areaselected.remove(i);
	     }
       else
	    {
    	//alert(document.frmCandInfo.areaselected.options[i].value);
		  document.frmCandInfo.areaselected.options[i].text = "";
		  document.frmCandInfo.areaselected.options[i].value = "";
    	//alert("Once Selected Can Not Removed");
	    }
	   }
      }
               

	
 }
	
