function open_modal(){
	$('#modal').slideDown();
}

function close_modal(){
	$('#modal').slideUp();
}

function set_focus(my_element){
	if(document.getElementById(my_element))
		document.getElementById(my_element).focus();
}

function get_value(my_id){
	if(document.getElementById(my_id))
		return document.getElementById(my_id).value;
	return null;
}

function get_html(my_id){
	if(document.getElementById(my_id))
		return document.getElementById(my_id).innerHTML;
	return null;
}

function div_hide(div){
	$('#'+div).hide();
}

function in_array(haystack,needle){
	for(i=0;i<haystack.length;i++){
		if(haystack[i]==needle)
			return true;
	}
	return false;
}

function delete_from_array(haystack,needle){
	found 	= false;
	i 		= -1;
	while(!found && i<haystack.length){
		i++;
		if(haystack[i]==needle)
			found = true;
	}
	if(found)
		haystack.splice(i,1);
	return haystack;
}

function make_suggest(table, row, value_id, div){	
	$.ajax({			
			type: 'POST',
			url: './ajax/common.php',
			data: {
						method:'make_suggest',
						table: table,
						row: row,
						value_id: value_id,						
						value : $('#'+value_id).val()
					},
			success: function(result) {								
				$('#'+div).html(result);
				$('#'+div).show();
			}			
		});
}

function set_suggest(div,value){
	var str_val = "";
	ar_val = $('#'+div).val().split(",");	
	for(i=0;i<(ar_val.length-1);i++){
		str_val+=ar_val[i]+",";
	}
	str_val+=value;
	$('#'+div).val(str_val);
	$('#'+div+'_suggest').hide();
}

function toggle(div){
	$('#'+div).slideToggle('slow');
}

function show_div(div){	
	if(document.getElementById(div)){
		if(document.getElementById(div).style.display == "none")
			$('#'+div).slideDown('slow');
	}
}

function hide_div(div){	
	if(document.getElementById(div)){
		if(document.getElementById(div).style.display != "none")
			$('#'+div).slideUp('slow');
	}
}

function show_tooltip(div){
	show_div(div);
	//timer
	//hide_div
}
