function filecheck(check){
   var input=check.value;
   str=String(input);
   if( str == ""){
      alert("Please upload a photo");
	  return false;
   }
   else{
	   idx=str.indexOf(".",0);
	   fileext=str.substr((idx+1),str.length);
	   if(fileext == "gif" ){  
	     if(confirm("Your Gif Image may appear distorted , it is advisable to upload jpg image.\n\tAre you sure you want to upload Gif Image?")){ 		 
		    return true;
		 }	
	     else
		    return false;		
	   }
    }
}	

function selectlistindex(check)
{   
   var checknull=1;
   for(i=0;i<check.options.length;i++){
     if (check.options[i].selected){
	    checknull=0;
        idx=i;	 
		break;
     }
   }	
   if (checknull!= 0) 
	  return 0;     		
   else
     return idx;
}

function listcheck(check,err_msg){
   var checknull=0; 
   for(i=0;i<check.options.length;i++){
     if (check.options[i].selected){
	   if( i == 0 ){
	      checknull=1;
	      break;
	   }	  
	 }
   }    
   if (checknull==1){
      alert(err_msg);
	  check.focus();
	  return false;
   }
}

function validfield(check,int_no,err_msg){
   str=new String(check.value)
   if(str.length < int_no || isNaN(str) == true ){
      alert(err_msg);
	  check.focus();
	  return false;
   }
}
 
function validNum(check){
   str=new String(check.value)
   if(isNaN(str) == true ){
      alert("Please Fill in numbers only");
	  check.focus();
	  return false;
   }
 }

function emptyfield(check,err_msg){
   if (check.value == ""){
      alert(err_msg);
	  check.focus();
	  return false;
   }
}

function checkEmail(check,err){
   errmsg=err;
   email = new String(check.value);   
     if (email.indexOf("@") == -1){
	    alert(errmsg);
		check.focus();
		return false;
	 }
	 else
	 {
	   idx1=email.indexOf("@");
	 }
	 if(email.indexOf(".") == -1){
	    alert(errmsg);
		check.focus();
		return false;
	 }
	 else{
	    idx2=email.indexOf(".");
	 }
	 str1=email.substring(0,idx1);
	 if(str1.length < 2){
	    alert(errmsg);
		check.focus();
		return false;
	 }
	 str2=email.substring(idx1,idx2);
	 if(str2.length < 2){
	    alert(errmsg);
		check.focus();
		return false;
	 }
	 str3=email.substring(idx2,email.length-1);
	 if(str3.length < 2){
		alert(errmsg);
		check.focus();
		return false;
	 } 
}

function checkBox(check,err_msg){
   var counter=0;
   for(var i=0;i<check.length;i++)
   {
     if(check[i].checked)
	 {
	   counter=counter+1;
	 }
   }
   if(counter < 1 )
   {
     alert(err_msg);
	 check[0].focus();
	 return false;
   }
}

function rbcheck(check,err_msg){         
   var value=null;
   for (var i=0;i<check.length;i++){
      if(check[i].checked){
	     value=check[i].value;
		 break;
	   }
	}
   if(value == null){
      alert(err_msg);
	  check[0].focus();
	  return false;
   } 
}

