function $(ElId) {
	return document.getElementById(ElId);
}
function fill(ElId) {
  $(ElId).style.backgroundColor='#fff';
  $(ElId).disabled='';
  $(ElId).focus();
}
function fill2(ElId) {
  if($(ElId).disabled){
    fill(ElId);
  } else {
    disable(ElId);
  }
}
function disable(ElId, label) {
  if ($(ElId+'_label') == null) return;
  var label = label || false;
  if(label) {
    $(ElId+'_label').style.color='#666';
  } else {
    $(ElId).style.backgroundColor='#cecece';
  }
  $(ElId).disabled='1';
/*  $(ElId).value='';*/
}
function enable(ElId, label) {
  if ($(ElId+'_label') == null) return;
  $(ElId).disabled='';
  if(label) {
    $(ElId+'_label').style.color='#000';
  }
}
function clearForm() {
    if (confirm("Are you sure you want to clear form?")) {
        disable('citizenship_Others_text');
        disable('purpose_Others_text');
        disable('area_Others_text');
        disable('visitarea_Others_text');
        disable('purpose_Others_text');
	    enable('by_Email',1);enable('by_Post',1);enable('by_Both',1);
        document.questions.reset();
        $('first_name').focus();
    }
}
function check(){
    var frm = document.forms['questions'];

    if ( $('Friends_Yes').checked ) { // if selected contacts for "Friends Network"
        var is_any_name_filled = false;
        for(var i=1;i<=5;i++){
            if(frm.elements['friend['+i+'][name]'].value){
                is_any_name_filled = true;    
                if(!frm.elements['friend['+i+'][email]'].value){
                    alert('Please enter email #' + i);
                    return false;
                }
            }
        }
    
        if ( !is_any_name_filled ) {
            alert('Please enter name #1');
            return false;
        }    
    }

    return true;
}