//draw point tags
function drawPointTags(placeholder, flot, meteo_data, fconfig){
	
        var products = select_products(meteo_data.product_data,fconfig.products);
	var index;
	
	
	var start_epoch = meteo_data.options.start_epoch;
	var finish_epoch = meteo_data.options.finish_epoch;
		
	var freq, pos, yoffset, xoffset, xaxis, yaxis, mult, inv, type,style;
	
	var product_config;
	
	
	for (var i=0;i<products.length;i++){
		
		index = find_product_config_index(products[i].p_raw_id,products[i].p_hv,fconfig);
		p_config = fconfig.products[index];
		
		if(p_config.pointTag != null){
		
			//frequency
			freq = (typeof(p_config.pointTag.freq) != 'undefined') ? 
				p_config.pointTag.freq : _PRODUCT_POINT_TAG_FREQ;
			
			//position
			if(p_config.bars != null){
			
				if(p_config.inverse)
					yoffset = _POINT_TAG_UNDER_MARGIN;
				
				else
					yoffset = _POINT_TAG_OVER_MARGIN;
				
				xoffset = _POINT_TAG_X_POSITION;
			}
			
			
			else{
                            
                            pos = (typeof(p_config.pointTag.position) != 'undefined') ?
                                    p_config.pointTag.position : _PRODUCT_POINT_TAG_POS;

                            switch(pos){

                                    case "over" :
                                            yoffset = _POINT_TAG_OVER_MARGIN;
                                            break;

                                    case "under":
                                            yoffset = _POINT_TAG_UNDER_MARGIN;
                                            break;

                                    default:
                                            break;
                            }

                            xoffset = _POINT_TAG_X_POSITION;
			}
			
			//axis
			xaxis = 1;
			
			switch(p_config.y_axis){
		
				case "yaxis_left":
					yaxis = 1;
					break;
					
				case "yaxis_right":
					yaxis = 2;
					break;		
			
				default:
					break;
			}
			
			//multiplier
			inv= (typeof(p_config.inverse) != 'undefined') ? 
			p_config.inverse : false;
			
			mult = (inv) ? -1 : 1;
					
			//type
			type= (typeof(p_config.pointTag.type) != 'undefined') ? 
				p_config.pointTag.type : _PRODUCT_POINT_TAG_TYPE;	
						
			switch(type){
			
                                case "mouseover" :
                                        style = _POINT_TAG_MOUSEOVER_STYLE;
                                        break;

                                case "visible":
                                        style = _POINT_TAG_VISIBLE_STYLE;
                                        break;

                                default:
                                        break;
			}
				
			generatePointTag(placeholder,flot,products[i].p_data,start_epoch,finish_epoch,freq,yoffset,xoffset, xaxis, yaxis, mult,p_config.product_ID,style);
		}
	}
}




/**
 * Draw numbers in graph points with lots of parameters
 *
 *
 * @param <placeholder>     Div where the graph is placed
 * @param <plot>            Flot graph Object
 * @param <data>            Data array [[epoch,data],...]
 * @param <epoch_start>     Initial epoch
 * @param <epoch_end>       Final epoch
 * @param <ijmp>            Iteration offset
 * @param <yoffset>         Y offset
 * @param <xoffset>         X offset
 * @param <sxaxis>          Xaxis to reference from (flot numbering)
 * @param <syaxis>          Yaxis to reference from (flot numbering)
 * @param <multiplier>      Visual Data Multiplier. Miltiplies all the data by this number
 * @param <id>              Div ID prefix. (for example r_, will generate divs with id's r_1,r_2...)
 * @param <css_class>       CSS class name
 **/
function generatePointTag(placeholder,plot,data,epoch_start,epoch_end,ijmp,yoffset,xoffset,sxaxis,syaxis,multiplier,id,css_class){
    var i,ln,mepoch,value,visible_value,o;
	
    ln = data.length;
	
    for(i=0; i<ln; i+=ijmp){
	
        mepoch = data[i][0];
				
		
		if(mepoch >= epoch_start && mepoch < epoch_end){
			
			value = data[i][1];
			visible_value = value * multiplier;

			o = plot.pointOffset({ x: mepoch, y: value, xaxis:sxaxis,yaxis: syaxis});		
			
			placeholder.append('<div id="'+id+i+'" class="'+css_class+'" style="left:' + (o.left + xoffset) + 'px;top:' + (o.top + yoffset) + 'px;">'+Math.round(visible_value*10)/10+'</div>');
		}
    }
}
