function toogle_div(div_id){
  if (document.getElementById(div_id).style.visibility == 'hidden'){
      document.getElementById(div_id).style.visibility ='visible';
      document.getElementById(div_id).style.display ='block';
  }
  else {
      document.getElementById(div_id).style.visibility ='hidden';
      document.getElementById(div_id).style.display ='none';
  }
}

function showdiv(vector_divs,id_active_div){
   for (ids in vector_divs){
       document.getElementById(vector_divs[ids]).style.display ='none';
   }
   document.getElementById(id_active_div).style.display ='';
}

//pentru a selecta, deselecta toate checkbox-urile
function checkAll(camp, min, max, param){
  for(i = min; i < max; i++){
	  if(param=='all')
        document.getElementById(camp+i).checked = true;
	  else
	    document.getElementById(camp+i).checked = false;
  }
}

function set_records_on_page(form_id,records_on_page) {
	var x=document.getElementById(form_id);
	x.page.value = '0';
	x.records_on_page.value = records_on_page;
	x.move_order.value = '';
	x.move_direction.value = '';
	form_submit(form_id);
}

function set_position(form_id,position) {
	var x=document.getElementById(form_id);
	x.page.value = '0';
	x.position.value = position;
	x.move_order.value = '';
	x.move_direction.value = '';
	form_submit(form_id);
}

function sort_form(form_id,column) {
	var x=document.getElementById(form_id);
	x.sortfield.value = column;
	x.sortdirection.value = x.sortdirection.value == 'asc' ? 'desc' : 'asc';
	x.move_order.value = '';
	x.move_direction.value = '';
	form_submit(form_id);
}

function form_change_order(form_id,move_order, move_direction) {
	var x=document.getElementById(form_id);
	x.move_order.value = move_order;
	x.move_direction.value = move_direction;
	form_submit(form_id);
}

function form_pagination(form_id,page) {
	var x=document.getElementById(form_id);
	x.page.value = page;
	x.move_order.value = '';
	x.move_direction.value = '';
	form_submit(form_id);
}

function form_action(form_id,checkbox_id,action){
	
	var x=document.getElementById(form_id);
	var y=document.getElementById(checkbox_id);
	y.checked = true;
	x.action.value = action;
	form_submit(form_id);
}

/*pentru select cu mai multe optiuni*/
function form_action1(form_id,checkbox_id,action){
	
	var x=document.getElementById(action);
	var y=document.getElementById(checkbox_id);
	x.selected = true;
	y.checked = true;
	form_submit(form_id);
}


jQuery(document).ready(function(){
	jQuery("#frmSearch").submit(function() {
	   var param = jQuery('#search_term').val();
	   var action = '/search/index/' + param ;
	   jQuery('#frmSearch').attr('action', action);
		//form_submit('frmSearch');   
	});
});
function form_submit(form_id) {
	var x=document.getElementById(form_id);
	x.submit();
}

function do_search()
{
	var param = jQuery('#search_term').val();
	var action = '/search/index/' + param ;
	jQuery('#frmSearch').attr('action', action);
	form_submit('frmSearch');
}



