$(document).ready(function() {	

	// function for ajax load	
	var load_action = function(act, master) {	
		$('div[@cc_log=div],img[@cc_log=div]').each(function(){
			var cc_extlink = $(this).attr('cc_extlink');
			var cc_target = $(this).attr('cc_target');
			var cc_col = $(this).attr('cc_col');
			var cc_type = $(this).attr('cc_type');
			if (!cc_target || cc_target==undefined){
				cc_target = '';
			}
			else
				cc_target='target="'+cc_target+'"';
								
			if (cc_extlink!=undefined){				
				if ($(this).attr('src')) // case it it img tag
					$(this).wrap('<a class="ya-ads-a" '+cc_target+' href="'+cc_extlink+'" cc_log="a" cc_type="'+cc_type+'" cc_col="'+cc_col+'"></a>');
				else
					$(this).wrap('<a class="ya-ads-a" '+cc_target+' href="'+cc_extlink+'" cc_log="a" cc_type="'+cc_type+'" cc_col="'+cc_col+'"></a>');
			}
		});
		
		$('a[@cc_log=a]').click(function(){
			var link = $(this).attr('href')
			var cc_col = $(this).attr('cc_col');
			var cc_type = $(this).attr('cc_type');
			clicks_counter('href', link, location.href, cc_type, cc_col, 0);
		});		
	};		
		
	$.post("/_sys_app/page_type/",
		{ page_type: 'home_page'},
		function(data){		
			//alert(data);			
			load_action();
	  	}
	);	

});

function flmap_click(id){
//	alert(id);
	$('#fm-data, #fm-default').hide();
	$('#fm-load').show();
	$.post("/",
		{ ajax: 'on', tl_id: id},
		function(data){		
			$('#fm-title-all').hide();
			$('#fm-title-one').show();
			var arr = data.split('|[-*-]|');
			$('#fm-title-one').html(arr[0]);

			$('#fm-load, #fm-default').hide();			
			$('#fm-data').show();
			$('#fm-data').html(arr[1]);

			$('div[@cc_log=div],img[@cc_log=div]').each(function(){
				var cc_extlink = $(this).attr('cc_extlink');
				var cc_target = $(this).attr('cc_target');
				var cc_col = $(this).attr('cc_col');
				var cc_type = $(this).attr('cc_type');
				if (!cc_target || cc_target==undefined){
					cc_target = '';
				}
				else
					cc_target='target="'+cc_target+'"';
									
				if (cc_extlink!=undefined){				
					if ($(this).attr('src')) // case it it img tag
						$(this).wrap('<a class="ya-ads-a" '+cc_target+' href="'+cc_extlink+'" cc_log="a" cc_type="'+cc_type+'" cc_col="'+cc_col+'"></a>');
					else
						$(this).wrap('<a class="ya-ads-a" '+cc_target+' href="'+cc_extlink+'" cc_log="a" cc_type="'+cc_type+'" cc_col="'+cc_col+'"></a>');
				}
			});
			$('a[@cc_log=a]').click(function(){
				var link = $(this).attr('href')
				var cc_col = $(this).attr('cc_col');
				var cc_type = $(this).attr('cc_type');
				clicks_counter('href', link, location.href, cc_type, cc_col, 0);
			});					

	  	}
	);	
	
}