// JavaScript Document
		var noticeTimer, nextOffer = -1;
		function $(id)
		{
			return document.getElementById(id)
		};
		function switchDataView(a)
		{
			var t = ($('flashy_visitors').className == 'dn') ? false : true;
			$('flashy_visitors').className = (t) ? 'dn' : ' ';
			$('flashy_visitors').parentNode.getElementsByTagName('table')[0].className = (t) ? ' ' : 'dn';
			a.innerHTML = (t) ? 'показать графиком' : 'показать таблицей';
		};
		function showPopup(n)
		{
			$(n).style.display='block'
		};
		function hidePopup(n)
		{
			$(n).style.display='none'
		};
		function removePopup(n)
		{
		    $(n).parentNode.removeChild($(n));
		    
		    if(window.opera){         // Force Opera redraw.
    		    if(document.body.style.position == "relative"){    		    	document.body.style.position = "static";	
    	        }else{    	            document.body.style.position = "relative";
    	        }
    	    }

		};

		function error(text)
		{
			if(noticeTimer) clearTimeout(noticeTimer);
			$('notice').className = 'error';
			$('notice').getElementsByTagName('p')[0].innerHTML = text;
			$('notice').style.display = 'block';
			noticeTimer = setTimeout(function(){
				$('notice').style.display = 'none';
			}, 2500);
		};
		function info(text)
		{
			if(noticeTimer) clearTimeout(noticeTimer);
			$('notice').className = 'info';
			$('notice').getElementsByTagName('p')[0].innerHTML = text;
			$('notice').style.display = 'block';
			noticeTimer = setTimeout(function(){
				$('notice').style.display = 'none';
			}, 2500);
		};
		function help(a)
		{
			//a.parentNode.className = (a.parentNode.className != 'show') ? 'show' : ' ';
		};
		function showMenu(i)
		{
			$('header').getElementsByTagName('ol')[0].getElementsByTagName('li')[0].className = (i == 0) ? 'active' : ' ';
			$('header').getElementsByTagName('ol')[0].getElementsByTagName('li')[1].className = (i == 1) ? 'active' : ' ';
			$('header').getElementsByTagName('ul')[0].style.display = (i == 0) ? 'block' : 'none';
			$('header').getElementsByTagName('ul')[1].style.display = (i == 1) ? 'block' : 'none';
			$('user').getElementsByTagName('p')[0].style.display = (i == 0) ? 'block' : 'none';
			$('user').getElementsByTagName('p')[1].style.display = (i == 1) ? 'block' : 'none';
		};


		function addLegend(el)
		{
			if(el.parentNode.parentNode.getElementsByTagName('p').length > 5)
			{
				error('Возможно добавить до пяти блогов или кампаний!<br />Вы можете удалить один и добавить новый');
			}
			else {
				var tf = el.parentNode.getElementsByTagName('input')[0],
					txt = tf.value,
					p = document.createElement('p');
					blno = el.parentNode.parentNode.getElementsByTagName('p').length;
					mes = "'Применяется фильтр к графику популярности...'";
					p.innerHTML = '<input type="checkbox" id="blog'+blno+'" onclick="info('+mes+')" /><label for="blog'+blno+'" class="bl'+blno+'" onclick="info('+mes+')">'+txt+'</label><a href="#" onclick="delTheme(this)" class="DeleteP"><small>&#215;</small></a>';
					el.parentNode.parentNode.appendChild(p, el.parentNode);
			}
		};
		function selectTheme(el,limit)
		{
		    if(el.parentNode.parentNode.getElementsByTagName('p').length > limit + 1) // must count the tooltip 'p'
			{
			    create_errormsg('Некорректные данные','Возможно выбрать до '+limit+' тематик!<br />Вы можете удалить одну и добавить новую');
			}
			else {				var tf = el.parentNode.getElementsByTagName('select')[0],
					selNum = tf.selectedIndex,
					txt = tf.options[selNum].text,
					p = document.createElement('p');
				p.innerHTML = '<input type="hidden" name="theme_index" value="'+tf.value+'"><a href="#" onclick="delTheme(this)" class="DeleteP"><small>&#215;</small></a>'+txt;
				el.parentNode.parentNode.appendChild(p, el.parentNode);
			}
			el.selectedIndex = 0;
		};
		function selectPlatform(el,limit)
		{
			if(el.parentNode.parentNode.getElementsByTagName('p').length > limit)
			{
			    create_errormsg('Некорректные данные','Возможно выбрать до '+limit+' площадок!<br />Вы можете удалить одну и добавить новую');
			}
			else {
				var tf = el.parentNode.getElementsByTagName('select')[0],
					selNum = tf.selectedIndex,
					txt = tf.options[selNum].text,
					p = document.createElement('p');
				p.innerHTML = '<input type="hidden" name="platform_index" value="'+tf.value+'"><a href="#" onclick="delTheme(this)" class="DeleteP"><small>&#215;</small></a>'+txt;
				el.parentNode.parentNode.appendChild(p, el.parentNode);
			}
		};
		function delTheme(el)
		{
			if(el.parentNode.parentNode.getElementsByTagName('p').length == 1)
			{
				document.getElementById('anyTheme').style.display = 'inline';
			}
			el.parentNode.parentNode.removeChild(el.parentNode);
		};

		function mouse_on(el){			tooltip.show(document.getElementById(el.getAttribute('tiptitle')).innerHTML, document.getElementById(el.getAttribute('tiptitle')).getAttribute("offsX") || 0, document.getElementById(el.getAttribute('tiptitle')).getAttribute("offsY") || 0, el);
		}

		function mouse_out(el){		    tooltip.hide(el);
		}

		 function tooltip_show (text, offsX, offsY, el) {
        	if (!el.tip) return;
        	el.tip.innerHTML = text;

                el.offsetX = parseInt(offsX);
                el.offsetY = parseInt(offsY);

        	el.tip.style.display = "block";
        }

         function tooltip_hide (el) {
        	if (!el.tip) return;
        	el.tip.innerHTML = "";
        	el.tip.style.display = "none";
        }

        function get_ajax_fb_code(id){            return '<img class="ajaxfb" src="files/img/ajaxfb.gif" id="'+id+'" style="margin-bottom:0px;padding:2px 30px 3px 30px;vertical-align:middle;display:inline;" />';
        }

        function ajax_show_preloader(el_id, id){        	var el = $(el_id);
        	el.style.display='none';

        	var code = get_ajax_fb_code(id);
            el.parentNode.innerHTML=code+el.parentNode.innerHTML;
        }

        function ajax_hide_preloader(el_id, ajax_fb_id){            $(el_id).style.display='';
        	removePopup(ajax_fb_id);

         }

