var curentPage;
var selectedKey;
var curentPage2;
var selected_link;
var interval=null;
var outbound=null;
var help_int=null;
var next_actions= new Array();
var curent_step;
var steps_no;
var reloading=false;
var mouse_x;
var mouse_y;
var seoai_int;
var inter;
var watching;
var site;
var toggle_message = 'Opreste';
var help_timeout=500;
var submit_campaign=false;
var text_lang='ro';
var confirm_change_page=false;
var confirm_test_mail=false;
var chat_window=false;
var current_key=false;
document.getElementsByClassName = function(class_name) {
    var docList = this.all || this.getElementsByTagName('*');
    var matchArray = new Array();

    /*Create a regular expression object for class*/
    var re = new RegExp("(?:^|\\s)"+class_name+"(?:\\s|$)");
    for (var i = 0; i < docList.length; i++) {
        if (re.test(docList[i].className) ) {
            matchArray[matchArray.length] = docList[i];
        }
    }

	return matchArray;}
function put_value(field,id){
		 opts=field.getElementsByTagName('option');
		 for (i=0;i<opts.length;i++)
		     {
			 if (field.value==opts[i].value)
			    {
			    document.getElementById(id).value=opts[i].innerHTML;
			    }
			 }
		 }
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";}
function close_all_charts(){
		charts=document.getElementsByClassName('chart_container');
		for (i=0;i<charts.length;i++)
		    {
		    charts[i].style.display='none';
		    }
		}
function close_all_images(){
		charts=document.getElementsByClassName('images');
		for (i=0;i<charts.length;i++)
		    {
		    charts[i].src='images/open.png';
		    }
		}
function close_all_texts(){
		charts=document.getElementsByClassName('texts');
		for (i=0;i<charts.length;i++)
		    {
		    charts[i].style.fontWeight='normal';
		    }
		}
function close_all_keys_images(){
		charts=document.getElementsByClassName('images');
		for (i=0;i<charts.length;i++)
		    {
		    charts[i].src='images/keys_open.png';
		    }
		}
function close_all_suggestions(){
		charts=document.getElementsByClassName('suggestions_container');
		for (i=0;i<charts.length;i++)
		    {
		    charts[i].style.display='none';
		    }
		icons=document.getElementsByClassName('img_icon');
		for (i=0;i<icons.length;i++)
		    {
		    icons[i].src='images/open.png';
		    }
		}
//functii pentru calendar
function open_close(id,height){
	    if (document.getElementById(id).offsetHeight<height)
		   {
		    if (interval!=null)
		       {
			   interval=clearInterval(interval);
			   }
		   start_from=document.getElementById(id).offsetHeight;
		   if ((id=='seo_container') || (id=='marketing_container') || (id=='traffic_container') || (id=='bills_container'))
		   select_all(id);
		   interval=setInterval("slideup('"+id+"',start_from,"+height+",4);",1);
		   }
		else
		   {
		   if (interval!=null)
		      {
		      interval=clearInterval(interval);
			  }
		   start_from=document.getElementById(id).offsetHeight;
		   if ((id=='seo_container') || (id=='marketing_container') || (id=='traffic_container') || (id=='bills_container'))
		   {deselect_all(id);
		   interval=setInterval("slidedown('"+id+"',start_from,30,4);",1);}
		   else
		      {
		      interval=setInterval("slidedown('"+id+"',start_from,3,4);",1);
			  }
		   }
		}
function calendarAction(param)
        {
	    if (param=='open')
		   {
		   if (interval!=null)
		      {
		      interval=clearInterval(interval);
			  }
		   start_from=document.getElementById('calendar').offsetHeight;
		   interval=setInterval("slideup('calendar',start_from,180,4);",1);
		   }
		else if (param=='close')
		   {
		   if (interval!=null)
		      {
		      interval=clearInterval(interval);
			  }
		   start_from=document.getElementById('calendar').offsetHeight;
		   interval=setInterval("slidedown('calendar',start_from,50,4);",1);
		   }
		}
function slideup(id,start_at,stop_at,step)
        {
	    start_from=start_at;
		if (start_from<=stop_at)
		   {
		   document.getElementById(id).style.height=start_from+'px';
		   start_from=start_from+step;
		   }
		else
		   {
		   interval=window.clearInterval(interval);
		   document.getElementById(id).style.height=stop_at+'px';
		   }
		}
function slidedown(id,start_at,stop_at,step)
        {
	    start_from=start_at;
		if (start_from>=stop_at)
		   {
		   document.getElementById(id).style.height=start_from+'px';
		   start_from=start_from-step;
		   }
		else
		   {
		   interval=window.clearInterval(interval);
		   document.getElementById(id).style.height=stop_at+'px';
		   }
		}
function select_all(id)
        {
	    divs=document.getElementById(id).getElementsByTagName('div');
		inputs=document.getElementById(id).getElementsByTagName('input');
		for (i=0;i<divs.length;i++)
		    {
			if ((divs[i].className=='checkbox') & (divs[i].id!='main'))
			   {
			   divs[i].style.backgroundPosition='0px 0px';
			   }
			}
		for (i=0;i<inputs.length;i++)
		    {
			if ((inputs[i].type=='hidden') & (inputs[i].id!='info') & (inputs[i].id!='bills_'))
			   {
			   inputs[i].value='on';
			   }
			}
	    }
function deselect_all(id)
        {
	    divs=document.getElementById(id).getElementsByTagName('div');
		inputs=document.getElementById(id).getElementsByTagName('input');
		for (i=0;i<divs.length;i++)
		    {
			if ((divs[i].className=='checkbox') & (divs[i].id!='main'))
			   {
			   divs[i].style.backgroundPosition='0px 16px';
			   }
			}
		for (i=0;i<inputs.length;i++)
		    {
			if ((inputs[i].type=='hidden') & (inputs[i].id!='info') & (inputs[i].id!='bills_'))
			   {
			   inputs[i].value='off';
			   }
			}
	    }
//*********************************************************************************************************
function sleep(numberMillis)
       {
       var now = new Date();
       var exitTime = now.getTime() + numberMillis;
       while (true)
             {
             now = new Date();
             if (now.getTime() > exitTime)
             return;
             }
        } 
function hover(buton)
    {
	var cells=null;
    cells = buton.getElementsByTagName('td');
	cells[0].className='left_side_hover';
	cells[1].className='middle_side_hover';
	cells[2].className='right_side_hover';
	}
function normal(buton)
    {
	var cells=null;
    cells = buton.getElementsByTagName('td');
	cells[0].className='left_side_normal';
	cells[1].className='middle_side_normal';
	cells[2].className='right_side_normal';
	}
function pressed(buton)
    {
	var cells=null;
    cells = buton.getElementsByTagName('td');
	cells[0].className='left_side_pressed';
	cells[1].className='middle_side_pressed';
	cells[2].className='right_side_pressed';
	}
function selected(buton)
    {
	var cells=null;
    if (curentPage!=null)
	   {
	   curentPage.onmousemove=function(){hover(this)}
	   curentPage.onmouseout=function(){normal(this)}
	   curentPage.onclick=function(){selected(this)}
	   normal(curentPage);
	   }
    curentPage=buton;
	buton.onmousemove='';
	buton.onmouseout='';
	buton.onclick='';
    cells = buton.getElementsByTagName('td');
	cells[0].className='left_side_selected';
	cells[1].className='middle_side_selected';
	cells[2].className='right_side_selected';
	}
function normal2(buton)
    {
	var cells=null;
    cells = buton.getElementsByTagName('td');
	if (cells[0]!=null)
	   {
	   cells[0].className='left_side_normal2';
	   cells[1].className='middle_side_normal2';
	   cells[2].className='right_side_normal2';
	   }
	}
function selected2(buton)
    {
	var cells=null;
    if (curentPage2!=null)
	   {
	   curentPage2.onclick=function(){selected2(this);}
	   normal2(curentPage2);
	   }
    curentPage2=buton;
	buton.onmousemove='';
	buton.onmouseout='';
	buton.onclick='';
    cells = buton.getElementsByTagName('td');
	cells[0].className='left_side_selected2';
	cells[1].className='middle_side_selected2';
	cells[2].className='right_side_selected2';
	}
function putPreloader(id)
        {
		preloader=" <center><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='160' height='60' id='FlashID' title='preloader'><param name='movie' value='library/swf/preloader_ajax.swf' /><param name='quality' value='high' /><param name='wmode' value='opaque' /><param name='swfversion' value='6.0.65.0' /> <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don't want users to see the prompt. --><param name='expressinstall' value='../../Scripts/expressInstall.swf' /><!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. --><!--[if !IE]>--><object type='application/x-shockwave-flash' data='library/swf/preloader_ajax.swf' width='160' height='60'><!--<![endif]--><param name='quality' value='high' /><param name='wmode' value='opaque' /><param name='swfversion' value='6.0.65.0' /><param name='expressinstall' value='../../Scripts/expressInstall.swf' /><!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. --><div><h4>Content on this page requires a newer version of Adobe Flash Player.</h4><p><a href='http://www.adobe.com/go/getflashplayer'><img src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' width='112' height='33' /></a></p></div><!--[if !IE]>--></object><!--<![endif]--></object></center>";
		if (document.getElementById(id)!=null)document.getElementById(id).innerHTML=preloader;
		}
function getwidth()
{
	var w = 0;
	var h = 0;

	//IE
	if(!window.innerWidth)
	{
		//strict mode
		if(!(document.documentElement.clientWidth == 0))
		{
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		}
		//quirks mode
		else
		{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	}
	//w3c
	else
	{
		w = window.innerWidth;
		h = window.innerHeight;
	}
	return {width:w,height:h};}
var divObj;
function getMouseCoordinates(e)
{
var posx = 0;
var posy = 0;
if (!e)
e = window.event;
if (e.pageX || e.pageY){
posx = e.pageX;
posy = e.pageY;
}
else if (e.clientX || e.clientY){
posx = e.clientX + document.body.scrollLeft
+ document.documentElement.scrollLeft;
posy = e.clientY + document.body.scrollTop
+ document.documentElement.scrollTop;
}
//alert(mouse_x+" "+mouse_y);
divObj = document.getElementById("panelasd");
//alert(divObj.offsetWidth+posx+15+" - "+docwidth);
if (divObj.offsetWidth+posx+65>getwidth()['width'])
   {
   document.getElementById('left_td_floater').src="images/floater/right_side2.png";
   document.getElementById('right_td_floater').src="images/floater/left_side2.png";
   posx=posx-divObj.offsetWidth-15;
   }
else
   {
   document.getElementById('left_td_floater').src="images/floater/left_side.png";
   document.getElementById('right_td_floater').src="images/floater/right_side.png";
   }
divObj.style.top=(posy-30)+"px";
divObj.style.left=(posx+15)+"px";}
function display(param,id)
       {
		if (param=="show")
	       {
			document.getElementById(id).style.display="block";
		   }
		if (param=="hide")
	       {
			document.getElementById(id).style.display="none";
		   }
	   }
function puttext(text,id)
       {
		document.getElementById(id).innerHTML="<table cellpadding='0' cellspacing='0' border='0'><tr><td><img src='images/floater/left_side.png' id='left_td_floater' alt='' /></td><td style='background-image:url(images/floater/middle_side.png); background-repeat:repeat-x'><span class='text' style='color:#FFFFFF;'> "+text+" </span></td><td><img id='right_td_floater' src='images/floater/right_side.png' alt='' /></td></tr></table>";
	   }
function create(msg)
        {
		 this.floater = document.createElement("div"); 
         this.floater.setAttribute("id","panelasd");
         this.floater.style.zIndex=9999;
		 this.floater.style.position="absolute";
		 this.floater.innerHTML="<table cellpadding='0' cellspacing='0' border='0'><tr><td><img src='images/floater/left_side.png' alt='' id='left_td_floater' /></td><td style='background-image:url(images/floater/middle_side.png); background-repeat:repeat-x'><span class='text' style='color:#FFFFFF;'> "+msg+" </span></td><td><img id='right_td_floater' src='images/floater/right_side.png' alt='' /></td></tr></table>";
		 createin=document.getElementsByTagName('body')[0];
		 createin.appendChild(this.floater);
		}
function change_bg(title)
       {
	   var cells=null;
	   tr = document.getElementsByTagName('tr');
	   for (i=0;i<tr.length;i++)
	       {
		   if (tr[i].title=='group')
		      {
              cells = tr[i].getElementsByTagName('td');
	          cells[0].className='first_cell';
	          cells[1].className='middle_cell';
	          cells[2].className='middle_cell';
			  cells[2].innerHTML='';
	          cells[3].className='left_cell';
			  }
		   }
       cells = title.getElementsByTagName('td');
	   cells[0].className='first_cell1';
	   cells[1].className='middle_cell1';
	   cells[2].className='middle_cell1';
	   cells[2].innerHTML='Inclus in raport';
	   cells[3].className='left_cell1';
	   }
function createSortable()
        {
	    Sortable.create('mainlist',{elements:$$('#mainlist li'),
									handles:$$('#mainlist .main_handle'),
								    onUpdate:function()
									         {
		                                     var myRegExp = new RegExp("&", "g");
						                     myString = Sortable.serialize('mainlist').replace(myRegExp,"|");
											 ajaxFunction('change_overview_order','',myString);
											 }
									});
	    }
function calculate(url,key,mail)
        {
		ajaxFunction('seo_iq','content',url+''+key+''+mail);
		}
var int_online=null;
function ajaxFunction(act,id,value,alt_id)
        {
	    if ((confirm_change_page) && (act!='newsletter_get_layout') && (act!='sidepanel'))
		   {
	       if (text_lang=='ro')
		      confirm_text='Doriti sa salvati modificarile campaniei curente?';
		   else
		      confirm_text='Do you wish to save the changes?';
		   if (confirm(confirm_text))
		      {
			  submit_campaign=true;
			  document.getElementById('start_campaign').value='save';
			  document.getElementById('goto_after').value=act;
			  document.getElementById('submit_newsletter_form').click();
			  confirm_change_page=false;
		      tinyMCE.execCommand('mceRemoveControl', false, 'newsletter_content');
			  }
		   else
		      {
		      tinyMCE.execCommand('mceRemoveControl', false, 'newsletter_content');
			  confirm_change_page=false;
			  }
		   }
	    if ((document.getElementById('newsletter_content')!=null) && (act.indexOf('newsletter')!=-1))
		   {
		   if (act!='newsletter_get_layout')
		      {
		      tinyMCE.execCommand('mceRemoveControl', false, 'newsletter_content');
			  }
		   }
	    if ((act!='newsletter_add') && (act!='newsletter_edit') && (act!='newsletter_get_layout') && (act.indexOf('newsletter')!=-1))
		   {
		   if (document.getElementById('newsletter_steps')!=null)
		      {
			  if (text_lang=='ro')
			  btn_value='Campanie noua';
			  else
			  btn_value='New campaign';
		      document.getElementById('newsletter_steps').innerHTML="<span style=\"position:relative; height:28px; display:inline-block; vertical-align:middle; background-image:url(images/button/middle_side.png); cursor:pointer;\"><img src=\"images/button/left_side.png\" alt=\"\" style=\"position:absolute; left:0px; top:0px;\" /><input type=\"button\" value=\" + "+btn_value+"\" class=\"text\" style=\"border:none; background-color:transparent; position:relative; top:5px; color:#FFF; font-size:12px; cursor:pointer;\" onclick=\"document.getElementById('newsletter_steps').innerHTML=' <img class=\\'news_ball\\' src=\\'images/newsletter_step_green.png\\' alt=\\'\\' /> <img class=\\'news_ball\\' src=\\'images/newsletter_step_grey.png\\' alt=\\'\\' /> <img class=\\'news_ball\\' src=\\'images/newsletter_step_grey.png\\' alt=\\'\\' />';ajaxFunction('newsletter_add','marketing_content','');\" /><img src=\"images/button/right_side.png\" alt=\"\" style=\"position:absolute; right:0px; top:0px;\" /></span>";
			  }
		   }
	    if (act=='validation')
		   {
		   previous=document.getElementById(alt_id).innerHTML;
		   document.getElementById(alt_id).innerHTML="<img src='images/reload.gif' style='position:relative; right:7px; top:12px;' alt='' />";
		   }
	    if (act=='reload_keyword')
		   {
		   if (reloading)
		      {
			  if (text_lang=='ro')
			     {
			     alert('Un alt proces ruleaza in acest moment, va rugam asteptati.');
				 }
			  else
			     {
			     alert('There is another process running. Please wait.');
				 }
			  }
		   else
		      {
		      reloading=true;
		      document.getElementById(alt_id).src="images/reload.gif";
			  }
		   }
	    if (act=='rescan_site')
		   {
		   document.getElementById(alt_id).src="images/reload.gif";
		   }
		if ((int_online!=null) & (act!='online_visitors_content') & (id!='sidepanel'))
		   {
		   int_online=window.clearInterval(int_online);
		   }
		if ((int_online!=null) & (act!='newsletter_content') & (id!='sidepanel'))
		   {
		   int_online=window.clearInterval(int_online);
		   }
	    if ((id!='') && (id!='sidepanel') && (act!='validation') && (act!='notifications_forms') && (id!='submenu') && (act!='online_visitors_content') && (act!='refresh_chat') && (act!='empty'))
		   {
		   putPreloader(id);
		   }
        var xmlHttp;
        try
          {
          // Firefox, Opera 8.0+, Safari
          xmlHttp=new XMLHttpRequest();
          }
        catch (e)
              {
              // Internet Explorer
              try
                {
                xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
                }
              catch (e)
                    {
                    try
                      {
                      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                      }
                    catch (e)
                          {
                          alert("Your browser does not support AJAX!");
                          return false;
                          }
                    }
              }
        xmlHttp.onreadystatechange=function()
              {
              if(xmlHttp.readyState==4)
                {
			    if (xmlHttp.responseText.indexOf('<!--logout-->')!=-1)
				   {
				   window.location='logout.php';
				   }
			    if (xmlHttp.responseText.indexOf('<!--site=')!=-1)
				   {
				   pos1=xmlHttp.responseText.indexOf('<!--site=');
				   pos2=xmlHttp.responseText.indexOf('-->',pos1);
				   in_use=xmlHttp.responseText.substr(pos1+9,pos2-(pos1+9));
				   if (in_use!=site)
				      {
				      window.location='/';
					  }
				   }
			    if ((id!='') && (document.getElementById(id)!=null))
				   {
				   if ((act!='newsletter_get_layout'))
				      {
                      document.getElementById(id).innerHTML=xmlHttp.responseText;
					  }
				   else
				      {
						  //document.getElementById('content').innerHTML=xmlHttp.responseText
					  tinyMCE.get(id).setContent(xmlHttp.responseText);
					  }
				   }
				if (act=='reload_keyword')
				   {
		           document.getElementById(alt_id).src='images/reload.png';
				   ajaxFunction('sidepanel','sidepanel','');
				   reloading=false;
				   }
				if (act=='change_date')
				   {
				   reloadPage(alt_id);
				   }
				if (act=='rescan_site')
				   {	
		           document.getElementById(alt_id).src='images/reload.png';
				   if (xmlHttp.responseText.indexOf('<!--done-->')!=-1)
				      {
				      ajaxFunction('sidepanel','sidepanel','');
					  }
				   else
				      {
					  alert(xmlHttp.responseText);
					  }
				   }
				if (act=='validation')
				   {
		           document.getElementById(alt_id).innerHTML=previous;
				   }
				if (act=='last_page')
				   {
				   document.getElementById('next_button').style.visibility='hidden';
				   }
				if (act=='change_site')
				   {
				   location.reload(true);
				   }
				if (act=='admin_change_site')
				   {
				   window.location.reload();
				   }
				if (act=='check_image')
				   {
				   if (xmlHttp.responseText.indexOf('<!--found-->')!=-1)
				      {
					   if (curent_step+1<=steps_no)
						  {
						  curent_step+=1;
						  if (next_actions[curent_step]=='map_overlay_countries')
						     {
						     ajaxFunction('map_overlay','content','reports_countries');
							 }
					      else
						     {
						     ajaxFunction(next_actions[curent_step],'content','reports');
							 }
						  change_submenu_btn(curent_step,'text_submenu');
						  window.scroll(0,0);
						  }
					  }
				   else
				      {
					  if (text_lang=='ro')
					     {
					     alert('Pentru a continua trebuie sa salvati toate graficele.\nFolositi butonul "Save" din coltul dreapta-sus al fiecarui grafic');
						 }
					  else
					     {
					     alert('To continue you must save all the graphs.\nUse the "Save" button from the upper right corner of each graph');
						 }
					  }
				   }
				if ((xmlHttp.responseText.indexOf('<!--exit-->')!=-1) & (act!='login') & (act!='lost_pass'))
				   {
				   window.location='login.php';
				   }
				if ((xmlHttp.responseText.indexOf('<!--unpaid_bills-->')!=-1) & (act!='bills') & (act!='empty'))
				   {
				   if (xmlHttp.responseText.indexOf('<!--refresh-->')!=-1)
				      {
					  window.location='index.php';
					  }
				   }
				 if (xmlHttp.responseText.indexOf('<!--refresh-->')!=-1)
				    {
				    window.location='index.php';
					}
				if ((act=='info_sec_menu') || (act=='support_sec_menu') || (act=='utilites_sec_menu') || (act=='bills_sec_menu') || (act=='marketing_sec_menu'))
				   {
				   selected_link='link1';
				   }
				if (act=='get_alert')
				   {
				   text=xmlHttp.responseText.split('');
				   if (text[1] === undefined)
				      {
				      destroy_alert();
					  }
				   else
				      {
				      create_alert(text[1]);
					  }
				   if (value=='traffic_overview')
				      {
				      ajaxFunction('get_tip','','');
					  }
				   }
				if ((act=='hide_tip') || (act=='close_tip'))
				   {
				   destroy_tip();
				   }
				if (act=='get_tip')
				   {
				   //alert(xmlHttp.responseText);
				   text=xmlHttp.responseText.split('');
				   if (text[1] === undefined)
				      {
				      destroy_tip();
					  }
				   else
				      {
				      create_tip(text[1]);
					  }
				   }
				if (act=='refresh_chat')
				   {
	               obj=document.getElementById('chat_content');
				   obj.scrollTop = obj.scrollHeight;
				   }
				if (act=='check_chat_activity')
				   {
				   if (parseInt(readCookie('chat_line')*1)<parseInt(xmlHttp.responseText*1))
				      {
					  for (k=parseInt(readCookie('chat_line')*1)+1;k<=parseInt(xmlHttp.responseText*1);k++)
					      {
					      var div=document.createElement('div');
					      div.id=k;
					      document.getElementById('chat_content').appendChild(div);
					      ajaxFunction('refresh_chat',k,k);
						  }
	                  obj=document.getElementById('chat_content');
				      setTimeout("obj.scrollTop = obj.scrollHeight;",500);
					  }
				   }
				if (act=='delete_invoice')
				   {
				   if (xmlHttp.responseText.indexOf('<!--done-->')==-1)
				      {
					  alert(xmlHttp.responseText);
					  }
				   else
				      {
					  goto('invoices');
					  }
				   }
				// These are the actions that happen when user changes the page
				// These are the actions from SEO tab
				if (act=="keys")
				   {
				   ajaxFunction('keys_content','seo_content',value);
				   if (value!='reports')
				      {
				      setTimeout("ajaxFunction('put_calendar','calendar','seo_content');",50);
					  }
				   }
				if (act=="keys_content")
				   {
				   if (value!='reports')
				      {
				      if ((value!='') && (!isNaN(value)))
				         {
					     close_all_charts();
					     close_all_texts();
					     close_all_keys_images();
				         document.getElementById('chart'+value).style.display='inline-block';
				         document.getElementById('text'+value).style.fontWeight='bold';
				         document.getElementById('image'+value).src='images/keys_opened.png';
					     }
				      ajaxFunction('get_alert','','');
				      setTimeout("ajaxFunction('put_calendar','calendar','keys_content');",50);
					  }
				   }
				if (act=="uptime")
				   {
				   ajaxFunction('uptime_content','seo_content',value);
				   if (value!='reports')
				      {
				      setTimeout("ajaxFunction('put_calendar','calendar','uptime_content');ajaxFunction('get_alert','','');",50);
					  }
				   }
				if (act=="links")
				   {
				   ajaxFunction('links_content','seo_content','inbound');
				   setTimeout("ajaxFunction('put_calendar','calendar','links_content');ajaxFunction('get_alert','','');",50);
				   }
				if (act=="link_monitor")
				   {
				   ajaxFunction('link_monitor_content','seo_content','');
				   setTimeout("ajaxFunction('put_calendar','calendar','link_monitor_content');ajaxFunction('get_alert','','');",50);
				   }
				if (act=="link_monitor_add")
				   {
				   ajaxFunction('link_monitor_content','seo_content','');
				   }
				if (act=="link_monitor_delete")
				   {
				   ajaxFunction('link_monitor_content','seo_content','');
				   }
				if (act=="links_content")
				   {
				   if (value=='history')
				      {
					  ajaxFunction('links_history','links_content','');
					  }
				   else
				      {
				      ajaxFunction('links_detailed','links_content',value);
					  }
				   }
				if (act=="bot_activity")
				   {
				   ajaxFunction('bot_activity_content','seo_content',value);
				   if (value!='reports')
				      {
				      setTimeout("ajaxFunction('put_calendar','calendar','bot_activity_content');ajaxFunction('get_alert','','');",50);
					  }
				   }
				if (act=="suggestions")
				   {
				   ajaxFunction('suggestions_content','seo_content',value);
				   if (value!='reports')
				      {
				      ajaxFunction('get_alert','','');
				      //setTimeout("ajaxFunction('put_calendar','calendar','suggestions_content');",50);
					  }
				   }
				if (act=="competition")
				   {
				   if (value!='reports')
				      {
				      ajaxFunction('competition_content','seo_content',value);
					  }
				   else
				      {
				      ajaxFunction('reports_competition_content','seo_content',value);
					  }
				   if (value!='reports')
				      {
				      setTimeout("ajaxFunction('put_calendar','calendar','competition_content');ajaxFunction('get_alert','','');",50);
					  }
				   }
				if (act=="daily_cache")
				   {
				   ajaxFunction('daily_cache_content','seo_content','');
				   setTimeout("ajaxFunction('put_calendar','calendar','daily_cache_content');ajaxFunction('get_alert','','');",50);
				   }
				if (act=="indexed_pages")
				   {
				   ajaxFunction('indexed_pages_content','seo_content','');
				   setTimeout("ajaxFunction('put_calendar','calendar','indexed_pages_content');ajaxFunction('get_alert','','');",50);
				   }
				if (act=="indexed_images")
				   {
				   ajaxFunction('indexed_images_content','seo_content','');
				   Shadowbox.init;
				   setTimeout("ajaxFunction('put_calendar','calendar','indexed_images_content');ajaxFunction('get_alert','','');",50);
				   }
				if (act=="indexed_images_content")
				   {
				   //setTimeout("Shadowbox.init;",5000);
				   }
				if (act=="seo_ai")
				   {
				   ajaxFunction('seo_ai_content','seo_content','');
				   setTimeout("ajaxFunction('get_alert','','');",50);
				   }
				if (act=="seo_iq_form")
				   {
				   setTimeout("ajaxFunction('put_calendar','calendar','seo_iq_form');",50);
				   }
				if (act=="antivirus")
				   {
				   ajaxFunction('antivirus_content','seo_content','');
				   setTimeout("ajaxFunction('get_alert','','');",50);
				   }
				// These are the actions from MARKETING tab
				if (act=='newsletter_update')
				   {
				   //alert(xmlHttp.responseText);
				   }
				if (act=="newsletter")
				   {
				   if (value=='')
				      {
				      ajaxFunction('newsletter_update','','');
				      ajaxFunction('newsletter_top_menu','calendar','');
				      setTimeout("ajaxFunction('get_alert','','');",50);
					  }
				   else
				      {
				      ajaxFunction(value,'marketing_content','');
				      ajaxFunction('newsletter_top_menu','calendar','');
				      setTimeout("ajaxFunction('get_alert','','');",50);
					  }
				   }
				if ((act=='newsletter_add') || (act=='newsletter_edit'))
				   {
				   if (xmlHttp.responseText.indexOf('<!--no_smtp-->')==-1)
				      {
				      confirm_change_page=true;
				      submit_campaign=false;
				      tinyMCE.execCommand('mceAddControl', false, 'newsletter_content');
				      if (act=='newsletter_edit')
				         {
					     ajaxFunction('newsletter_get_layout','newsletter_content',value);
					     }
				      document.getElementById('newsletter_overview').style.textDecoration='none';
				      document.getElementById('newsletter_lists').style.textDecoration='none';
					  }
				   else
				      {
					  ajaxFunction('newsletter_content',id,'');
				      alert(xmlHttp.responseText.replace('<!--no_smtp-->',''));
					  }
				   }
				if (act=='newsletter_remove_mail')
				   {
				   var opts = value.split('||');
				   ajaxFunction('newsletter_list_detailed','newsletter_lists_'+opts[1],opts[1]);
				   }
				if (act=='newsletter_lists')
				   {
				   if (xmlHttp.responseText.indexOf('<!--go_to_add-->')!=-1)
				      {
					  ajaxFunction('newsletter_add_list','marketing_content','List name');
					  }
				   document.getElementById('newsletter_overview').style.textDecoration='none';
				   document.getElementById('newsletter_lists').style.textDecoration='underline';
				   }
				if ((act=='newsletter_add_list_submit') || (act=='newsletter_edit_list_submit') || (act=='newsletter_delete_list'))
				   {
				   ajaxFunction('newsletter_lists','marketing_content','');
				   }
				if ((act=='newsletter_delete_campaign') || (act=='newsletter_update'))
				   {
				   ajaxFunction('newsletter_content','marketing_content','');
		           int_online=window.clearInterval(int_online);
				   int_online=window.setInterval("ajaxFunction('newsletter_update','','');",600000);
				   }
				if (act=='newsletter_detailed')
				   {
				   if (xmlHttp.responseText.indexOf('<!--reload-->')!=-1)
				      {
					  document.getElementById('campaign_status_toggler').style.display='inline-block';
				      setTimeout("ajaxFunction('newsletter_detailed','newsletter_details_"+value+"',"+value+");",60000);
					  }
				   }
				if (act=='newsletter_content')
				   {
				   //ajaxFunction('newsletter_update','','');
				   counterFile = 1;
				   counterFileLimit = 10;
				   pos = xmlHttp.responseText.indexOf('<!--');
				   pos1 = xmlHttp.responseText.indexOf('-->');
				   str = xmlHttp.responseText.substr(pos,pos1-pos);
				   str = str.split('||');
				   document.getElementById('newsletter_overview').style.textDecoration='underline';
				   document.getElementById('newsletter_lists').style.textDecoration='none';
				   if (document.getElementById('newsletter_details_'+str[1]))
				      {
				      ajaxFunction('newsletter_detailed','newsletter_details_'+str[1],str[1]);
					  }
				   }
				// These are the actions from TRAFFIC tab
				if (act=="overview")
				   {
				   ajaxFunction('get_alert','','traffic_overview');
				   ajaxFunction('traffic_overview','traffic_content',10);
				   setTimeout("ajaxFunction('put_calendar','calendar','traffic_overview');",50);
				   }
				if (act=="overview_traffic")
				   {
				   ajaxFunction('traffic_overview_content','traffic_content',10);
				   setTimeout("ajaxFunction('put_calendar','calendar','traffic_overview_content');ajaxFunction('get_alert','','');",50);
				   }
				if (act=="traffic_overview" || act=="traffic_overview_content")
				   {
				   createSortable();
				   }
				if (act=="map_overlay")
				   {
				   if ((value=='') || (value=='reports'))
				      {
				      ajaxFunction('map_overlay_cities','traffic_content',value);
					  if (value!='reports')
					     {
				         setTimeout("ajaxFunction('put_calendar','calendar','map_overlay_cities');ajaxFunction('get_alert','','');;",50);
						 }
					  }
				   else
				      {
					  if (value=='reports_countries')value='reports';
				      ajaxFunction('map_overlay_countries','traffic_content',value);
					  if (value!='reports')
					     {
				         setTimeout("ajaxFunction('put_calendar','calendar','map_overlay_countries');ajaxFunction('get_alert','','');",50);
						 }
					  }
				   }
				if (act=="map_overlay_cities")
				   {
				   if (value!='reports')
					  {
				      //ajaxFunction('traffic_table','traffic_table',10);
				      setTimeout("ajaxFunction('put_calendar','calendar','map_overlay_cities');ajaxFunction('get_alert','','');",50);
					  }
				   }
				if (act=="map_overlay_countries")
				   {
				   if (value!='reports')
					  {
				      //ajaxFunction('traffic_table_countries','traffic_table',10);
				      setTimeout("ajaxFunction('put_calendar','calendar','map_overlay_countries');ajaxFunction('get_alert','','');",50);
					  }
				   }
				if (act=="content")
				   {
				   ajaxFunction('content_content','traffic_content',value);
				   if (value!='reports')
				      {
				      setTimeout("ajaxFunction('put_calendar','calendar','content_content');ajaxFunction('get_alert','','');",50);
					  }
				   }
				if (act=="sources")
				   {
				   ajaxFunction('sources_content','traffic_content',value)
				   if (value!='reports')
				      {
				      setTimeout("ajaxFunction('put_calendar','calendar','sources_content');ajaxFunction('get_alert','','');",50);
					  }
				   }
				if (act=="conversions")
				   {
				   ajaxFunction('conversions_content','marketing_content','');
				   setTimeout("ajaxFunction('put_calendar','calendar','conversions_content');ajaxFunction('get_alert','','');",50);
				   }
				if (act=="bounces")
				   {
				   ajaxFunction('bounces_content','marketing_content','');
				   setTimeout("ajaxFunction('put_calendar','calendar','bounces_content');ajaxFunction('get_alert','','');",50);
				   }
				if (act=="discussions")
				   {
				   ajaxFunction('discussions_content','marketing_content','');
				   setTimeout("ajaxFunction('put_calendar','calendar','discussions_content');ajaxFunction('get_alert','','');",50);
				   }
				if (act=="clickheat")
				   {
				   setTimeout("ajaxFunction('get_alert','','');",50);
				   }
				if (act=="new_old")
				   {
				   ajaxFunction('new_old_content','traffic_content',value);
				   if (value!='reports')
				      {
				      setTimeout("ajaxFunction('put_calendar','calendar','new_old_content');ajaxFunction('get_alert','','');",50);
					  }
				   }
				if (act=="traffic_keys")
				   {
				   ajaxFunction('traffic_keys_content','traffic_content',value);
				   if (value!='reports')
				      {
				      setTimeout("ajaxFunction('put_calendar','calendar','traffic_keys_content');ajaxFunction('get_alert','','');",50);
					  }
				   }
				if (act=="search_engines")
				   {
				   ajaxFunction('search_engines_content','traffic_content',value);
				   if (value!='reports')
				      {
				      setTimeout("ajaxFunction('put_calendar','calendar','search_engines_content');ajaxFunction('get_alert','','');",50);
					  }
				   }
				if (act=="adwords")
				   {
				   ajaxFunction('adwords_content','traffic_content',value);
				   if (value!='reports')
				      {
				      setTimeout("ajaxFunction('put_calendar','calendar','adwords_content');ajaxFunction('get_alert','','');",50);
					  }
				   }
				if (act=="browsers")
				   {
				   ajaxFunction('browsers_content','traffic_content',value);
				   if (value!='reports')
				      {
				      setTimeout("ajaxFunction('put_calendar','calendar','browsers_content');ajaxFunction('get_alert','','');",50);
					  }
				   }
				if (act=="addon_sites")
				   {
				   ajaxFunction('addon_sites_content','traffic_content',value);
				   if (value!='reports')
				      {
				      setTimeout("ajaxFunction('put_calendar','calendar','addon_sites_content');ajaxFunction('get_alert','','');",50);
					  }
				   }
				if (act=="visits_on_hours")
				   {
				   ajaxFunction('visits_on_hours_content','traffic_content',value);
				   if (value!='reports')
				      {
				      setTimeout("ajaxFunction('put_calendar','calendar','visits_on_hours_content');ajaxFunction('get_alert','','');",50);
					  }
				   }
				if (act=="time_on_page")
				   {
				   ajaxFunction('time_on_page_content','traffic_content',value);
				   if (value!='reports')
				      {
				      setTimeout("ajaxFunction('put_calendar','calendar','time_on_page_content');ajaxFunction('get_alert','','');",50);
					  }
				   }
				if (act=="add_new_message")
				   {
				   if (xmlHttp.responseText.indexOf('<!--limited-->')!=-1)
				      {
					  alert('Conturile gratuite sunt limitate la o singura conversatie pe zi.');
					  }
				   else
				      {
				      var token = xmlHttp.responseText.split('||');
				      if (token[1]!==undefine && token[1].length==32)
				         {
						 if ((chat_window===false) || (chat_window.new_tab===undefined))
						    {
				            chat_window=window.open('http://b.seomonitor.ro/chat/test.php?token='+token[1],'chat','toolbar=0,titlebar=0,status=0,scrollbars=0,resizable=0,menubar=0,location=0,directories=0,width=375,height=440,title=SEO monitor Chat');
							}
					     else
						    {
						    chat_window.new_tab(token[1]);
							}
					     }
					  }
				   }
				if (act=="online_visitors")
				   {
				   ajaxFunction('online_visitors_content','seo_content','');
				   ajaxFunction('get_alert','','');
				   }
				if (act=="online_visitors_content")
				   {
		           int_online=window.clearInterval(int_online);
				   int_online = setInterval("ajaxFunction('online_visitors_content','seo_content','');",60000);
				   }
				if (act=="visits_log")
				   {
				   if (value=='today_visits_log')
				      {
				      ajaxFunction('today_visits_log_content','traffic_content','');
					  setTimeout("ajaxFunction('put_calendar','calendar','today_visits_log_content');ajaxFunction('get_alert','','');",50);
					  }
				   else
				      {
				      ajaxFunction('visits_log_content','traffic_content','');
					  setTimeout("ajaxFunction('put_calendar','calendar','visits_log_content');ajaxFunction('get_alert','','');",50);
					  }
				   }
				// These are the actions from UTILITES tab
				
				// These are the actions from RAPORTS tab
				if (act=='add_remove_key')
				   {
				   //alert(xmlHttp.responseText);
				   }
				if (act=="raports")
				   {
				   setTimeout("ajaxFunction('put_calendar','calendar','raports');",50);
				   }
				// These are the actions from BILLS tab
				// These are the actions from sub menus
				if ((act=="traffic_sec_menu") || (act=="content_sec_menu") ||(act=="utilites_sec_menu") || (act=="seo_sec_menu") || (act=="bills_sec_menu") || (act=="marketing_sec_menu"))
				   {
				   if (value!='')
				      {
					  selected_link='link'+value;
					  change_submenu_btn(value,'text_submenu');
				      }
				   else
				      {
					  selected_link='link1';
					  change_submenu_btn(1,'text_submenu');
					  }
				   }
				// These are the actions from various places
				if ((act=="wishlist") || (act=="add_wish") || (act=="vote_wish") || (act=="approve_wish"))
				   {
				   ajaxFunction('wishlist_content','traffic_content','');
				   }
				if (act=="set_search_string")
				   {
				   ajaxFunction('links_content','seo_content','inbound');
				   }
				if (act=="set_search_keyword")
				   {
				   if (value.indexOf('reports'))
				      {
				      ajaxFunction('traffic_keys_content','traffic_content','reports');
					  }
				   else
				      {
				      ajaxFunction('traffic_keys_content','traffic_content','');
					  }
				   }
				if (act=="add_keyword")
				   {
				   document.getElementsByTagName('body')[0].removeChild(document.getElementById('preloader'));
				   }
				if (act=="compare")
				   {
				   ajaxFunction('daily_cache_content','seo_content','');
				   }
				if (act=="erase_daily_page")
				   {
				   document.getElementsByTagName('body')[0].removeChild(document.getElementById('preloader'));
				   ajaxFunction('daily_cache_content','seo_content','');
				   }
				if (act=="erase_compare")
				   {
				   ajaxFunction('daily_cache_content','seo_content','');
				   }
				if (act=="notifications_delete")
				   {
				   ajaxFunction('notifications','content','');
				   }
				if ((act=="empty") && (id='content'))
				   {
				   ajaxFunction('get_alert','','');
				   }
                }
              }
	    if (developer)
		   {
           xmlHttp.open("GET","actions_.php?action="+act+"&values="+value,true);
		   }
		else
		   {
           xmlHttp.open("GET","actions.php?action="+act+"&values="+value,true);
		   }
        xmlHttp.send(null);
        }
function goto(dest)
       {
	   if ((dest=='sources') || (dest=='sources_table') || (dest=='sources_content'))
	      {
	      change_btn(5,'main_menu');
	      ajaxFunction('traffic_sec_menu','submenu','4');
	      ajaxFunction('sources','content','');
		  }
       else if (dest=='invoices')
	      {
	      change_btn(10,'main_menu');
	      ajaxFunction('bills_sec_menu','submenu','1');
	      ajaxFunction('invoices','content','');
		  }
       else if (dest=='bills')
	      {
	      change_btn(10,'main_menu');
	      ajaxFunction('bills_sec_menu','submenu','2');
	      ajaxFunction('bills','content','');
		  }
       else if (dest=='contact')
	      {
	      change_btn(11,'main_menu');
	      ajaxFunction('empty','submenu','');
	      ajaxFunction('contact','content','');
		  }
       else if ((dest=='keywords') || (dest=='keys'))
	      {
	      change_btn(3,'main_menu');
	      ajaxFunction('seo_sec_menu','submenu','2');
	      ajaxFunction('keys','content','');
		  }
       else if ((dest!='traffic_keys') && (dest.indexOf('key_')!=-1))
	      {
		  params=dest.split('_');
		  if (params[1]=='1')
		     {
			 params[1]='1';
			 }
	      change_btn(3,'main_menu');
	      ajaxFunction('seo_sec_menu','submenu','2');
	      ajaxFunction('keys','content',params[1]);
		  }
       else if (dest=='uptime')
	      {
	      change_btn(3,'main_menu');
	      ajaxFunction('seo_sec_menu','submenu','3');
	      ajaxFunction('uptime','content','');
		  }
       else if (dest=='links')
	      {
	      change_btn(3,'main_menu');
	      ajaxFunction('seo_sec_menu','submenu','4');
	      ajaxFunction('links','content','');
		  }
       else if (dest=='link_analytics')
	      {
	      change_btn(3,'main_menu');
	      ajaxFunction('seo_sec_menu','submenu','5');
	      ajaxFunction('link_analytics','content','');
		  }
       else if (dest=='link_monitor')
	      {
	      change_btn(3,'main_menu');
	      ajaxFunction('seo_sec_menu','submenu','6');
	      ajaxFunction('link_monitor','content','');
		  }
       else if ((dest=='search_bot') || (dest=='bot_activity') || (dest=='bot_activity_content'))
	      {
	      change_btn(3,'main_menu');
	      ajaxFunction('seo_sec_menu','submenu','7');
	      ajaxFunction('bot_activity','content','');
		  }
       else if (dest=='suggestions')
	      {
	      change_btn(3,'main_menu');
	      ajaxFunction('seo_sec_menu','submenu','8');
	      ajaxFunction('suggestions','content','');
		  }
       else if (dest=='competition')
	      {
	      change_btn(3,'main_menu');
	      ajaxFunction('seo_sec_menu','submenu','8');
	      ajaxFunction('competition','content','');
		  }
       else if (dest=='daily_cache')
	      {
	      change_btn(3,'main_menu');
	      ajaxFunction('seo_sec_menu','submenu','9');
	      ajaxFunction('daily_cache','content','');
		  }
       else if (dest=='indexed_pages')
	      {
	      change_btn(3,'main_menu');
	      ajaxFunction('seo_sec_menu','submenu','10');
	      ajaxFunction('indexed_pages','content','');
		  }
       else if (dest=='indexed_images')
	      {
	      change_btn(3,'main_menu');
	      ajaxFunction('seo_sec_menu','submenu','11');
	      ajaxFunction('indexed_images','content','');
		  }
       else if (dest=='seo_ai_content')
	      {
	      change_btn(3,'main_menu');
	      ajaxFunction('seo_sec_menu','submenu','12');
	      ajaxFunction('seo_ai','content','');
		  }
       else if (dest=='antivirus')
	      {
	      change_btn(3,'main_menu');
	      ajaxFunction('seo_sec_menu','submenu','');
	      ajaxFunction('antivirus','content','');
		  }
       else if (dest=='position_form')
	      {
	      change_btn(3,'main_menu');
	      ajaxFunction('seo_sec_menu','submenu','15');
	      ajaxFunction('position_form','content','');
		  }
       else if (dest=='seo_iq_form')
	      {
	      change_btn(3,'main_menu');
	      ajaxFunction('seo_sec_menu','submenu','16');
	      ajaxFunction('seo_iq_form','content','1');
		  }
       else if (dest=='newsletter_content')
	      {
	      change_btn(4,'main_menu');
	      ajaxFunction('marketing_sec_menu','submenu','2');
	      ajaxFunction('newsletter','content','');
		  }
       else if (dest=='newsletter_lists')
	      {
	      change_btn(4,'main_menu');
	      ajaxFunction('marketing_sec_menu','submenu','2');
	      ajaxFunction('newsletter','content','newsletter_lists');
		  }
       else if (dest=='newsletter_add_list')
	      {
	      change_btn(4,'main_menu');
	      ajaxFunction('marketing_sec_menu','submenu','2');
	      ajaxFunction('newsletter','content','newsletter_add_list');
		  }
       else if (dest=='clickheat')
	      {
	      change_btn(4,'main_menu');
	      ajaxFunction('marketing_sec_menu','submenu','5');
	      ajaxFunction('clickheat','content','');
		  }
       else if (dest=='raports')
	      {
	      change_btn(8,'main_menu');
	      ajaxFunction('empty','submenu','');
	      ajaxFunction('raports','content','');
		  }
       else if (dest=='notifications')
	      {
	      change_btn(9,'main_menu');
	      ajaxFunction('empty','submenu','');
	      ajaxFunction('notifications','content','');
		  }
       else if (dest=='overview')
	      {
	      change_btn(1,'main_menu');
	      ajaxFunction('empty','submenu','');
	      ajaxFunction('overview','content','');
		  }
       else if (dest=='traffic_overview_content')
	      {
	      change_btn(5,'main_menu');
	      ajaxFunction('traffic_sec_menu','submenu','1');
	      ajaxFunction('overview_traffic','content','');
		  }
       else if ((dest=='map') || (dest=='map_overlay_cities'))
	      {
	      change_btn(5,'main_menu');
	      ajaxFunction('traffic_sec_menu','submenu','2');
	      ajaxFunction('map_overlay','content','');
		  }
       else if (dest=='map_overlay_countries')
	      {
	      change_btn(5,'main_menu');
	      ajaxFunction('traffic_sec_menu','submenu','2');
	      ajaxFunction('map_overlay','content','countries');
		  }
       else if ((dest=='content_content') || (dest=='content'))
	      {
	      change_btn(5,'main_menu');
	      ajaxFunction('traffic_sec_menu','submenu','3');
	      ajaxFunction('content','content','');
		  }
       else if (dest=='conversions')
	      {
	      change_btn(4,'main_menu');
	      ajaxFunction('marketing_sec_menu','submenu','3');
	      ajaxFunction('conversions','content','');
		  }
       else if (dest=='bounces')
	      {
	      change_btn(4,'main_menu');
	      ajaxFunction('marketing_sec_menu','submenu','4');
	      ajaxFunction('bounces','content','');
		  }
       else if (dest=='discussions')
	      {
	      change_btn(4,'main_menu');
	      ajaxFunction('marketing_sec_menu','submenu','5');
	      ajaxFunction('discussions','content','');
		  }
       else if (dest=='new_old')
	      {
	      change_btn(5,'main_menu');
	      ajaxFunction('traffic_sec_menu','submenu','5');
	      ajaxFunction('new_old','content','');
		  }
       else if (dest=='traffic_keys')
	      {
	      change_btn(5,'main_menu');
	      ajaxFunction('traffic_sec_menu','submenu','6');
	      ajaxFunction('traffic_keys','content','');
		  }
       else if (dest=='search_engines')
	      {
	      change_btn(5,'main_menu');
	      ajaxFunction('traffic_sec_menu','submenu','7');
	      ajaxFunction('search_engines','content','');
		  }
       else if (dest=='adwords_content')
	      {
	      change_btn(5,'main_menu');
	      ajaxFunction('traffic_sec_menu','submenu','8');
	      ajaxFunction('adwords','content','');
		  }
       else if (dest=='adwords')
	      {
	      change_btn(5,'main_menu');
	      ajaxFunction('traffic_sec_menu','submenu','8');
	      ajaxFunction('adwords','content','');
		  }
       else if (dest=='browsers')
	      {
	      change_btn(5,'main_menu');
	      ajaxFunction('traffic_sec_menu','submenu','9');
	      ajaxFunction('browsers','content','');
		  }
       else if (dest=='addon_sites')
	      {
	      change_btn(5,'main_menu');
	      ajaxFunction('traffic_sec_menu','submenu','10');
	      ajaxFunction('addon_sites','content','');
		  }
       else if (dest=='visits_on_hours')
	      {
	      change_btn(5,'main_menu');
	      ajaxFunction('traffic_sec_menu','submenu','11');
	      ajaxFunction('visits_on_hours','content','');
		  }
       else if (dest=='time_on_page')
	      {
	      change_btn(5,'main_menu');
	      ajaxFunction('traffic_sec_menu','submenu','12');
	      ajaxFunction('time_on_page','content','');
		  }
       else if ((dest=='online_visitors_content') || (dest=='online'))
	      {
	      change_btn(4,'main_menu');
	      ajaxFunction('marketing_sec_menu','submenu','1');
	      ajaxFunction('online_visitors','content','');
		  }
       else if (dest=='visits_log')
	      {
	      change_btn(5,'main_menu');
	      ajaxFunction('traffic_sec_menu','submenu','13');
	      ajaxFunction('visits_log','content','visits_log');
		  }
       else if (dest=='today_visits_log')
	      {
	      change_btn(5,'main_menu');
	      ajaxFunction('traffic_sec_menu','submenu','13');
	      ajaxFunction('visits_log','content','today_visits_log');
		  }
	   else
	      {
		  //alert(dest);
	      change_btn(1,'main_menu');
	      ajaxFunction('empty','submenu','');
	      ajaxFunction('overview','content','');
		  }
	   scroll(0,0);
	   }
function changeDate(param,startd,startm,starty,stopd,stopm,stopy)
        {
	    ajaxFunction('change_date','',''+'|'+startd+'|'+startm+'|'+starty+'|'+stopd+'|'+stopm+'|'+stopy+'|custom_date',param);
		}
function reloadPage(param)
        {
		if ((param=='overview') || (param=='traffic_overview'))
		   {
		   ajaxFunction('traffic_overview','traffic_content','');
		   }
		else if (param=='traffic_overview_content')
		   {
		   ajaxFunction('overview_traffic','traffic_content','');
		   }
		else if (param=='map_overlay_cities')
		   {
		   ajaxFunction('map_overlay_cities','traffic_content','0');
		   }
		else if (param=='map_overlay_countries')
		   {
		   ajaxFunction('map_overlay_countries','traffic_content','0');
		   }
		else if (param=='sources_content')
		   {
		   ajaxFunction('sources_content','traffic_content','0');
		   }
		else if (param=='content_content')
		   {
		   ajaxFunction('content_content','traffic_content','0');
		   }
		else if (param=='uptime_content')
		   {
		   ajaxFunction('uptime_content','seo_content','0');
		   }
		else if (param=='keys_content')
		   {
		   ajaxFunction('keys_content','seo_content','');
		   }
		else if (param=='bills')
		   {
		   ajaxFunction('bills','content','');
		   }
		else if (param=='invoices')
		   {
		   ajaxFunction('invoices','content','');
		   }
		else if (param=='bot_activity_content')
		   {
		   ajaxFunction('bot_activity_content','seo_content','');
		   }
		else if (param=='traffic_keys_content')
		   {
		   ajaxFunction('traffic_keys_content','traffic_content','10');
		   }
		else if (param=='time_on_page_content')
		   {
		   ajaxFunction('time_on_page_content','traffic_content','');
		   }
		else if (param=='visits_on_hours_content')
		   {
		   ajaxFunction('visits_on_hours_content','traffic_content','');
		   }
		else if (param=='visits_log_content')
		   {
		   ajaxFunction('visits_log_content','traffic_content','');
		   }
		else if (param=='competition_content')
		   {
		   ajaxFunction('competition_content','seo_content','');
		   }
		else if (param=='daily_cache_content')
		   {
		   ajaxFunction('daily_cache_content','seo_content','');
		   }
		else if (param=='indexed_pages_content')
		   {
		   ajaxFunction('indexed_pages_content','seo_content','');
		   }
		else if (param=='indexed_images_content')
		   {
		   ajaxFunction('indexed_images_content','seo_content','');
		   }
		else if (param=='conversions_content')
		   {
		   ajaxFunction('conversions_content','marketing_content','');
		   }
		else if (param=='bounces_content')
		   {
		   ajaxFunction('bounces_content','marketing_content','');
		   }
		else if (param=='discussions_content')
		   {
		   ajaxFunction('discussions_content','marketing_content','');
		   }
		else if (param=='new_old_content')
		   {
		   ajaxFunction('new_old_content','traffic_content','');
		   }
		else if (param=='search_engines_content')
		   {
		   ajaxFunction('search_engines_content','traffic_content','');
		   }
		else if (param=='adwords_content')
		   {
		   ajaxFunction('adwords_content','traffic_content','');
		   }
		else if (param=='browsers_content')
		   {
		   ajaxFunction('browsers_content','traffic_content','');
		   }
		else if (param=='addon_sites_content')
		   {
		   ajaxFunction('addon_sites_content','traffic_content','');
		   }
		else if (param=='links_content')
		   {
		   ajaxFunction('links_content','seo_content','');
		   }
		else if (param=='seo_iq_form')
		   {
		   ajaxFunction('seo_iq_form','content','');
		   }
		else if (param=='raports')
		   {
		   }
		else
		   {
		   alert('Err code:0 - Unknow action '+param);
		   }
		}
function change_btn(nr,clas)
        {
	    butons=document.getElementsByTagName('table');
	    j=0;
	    for (i=0;i<butons.length;i++)
	        {
		    if (butons[i].className==clas)
		       {
			   j++;
			   if (j==nr)
			      {
			      selected(butons[i]);
				  }
			   else
			      {
			      normal(butons[i]);
			      }
		       }
		    }
		}
function change_info_btn(nr,clas)
        {
	    butons=document.getElementsByTagName('table');
	    j=0;
	    for (i=0;i<butons.length;i++)
	        {
		    if (butons[i].className==clas)
		       {
			   j++;
			   if (j==nr)
			      {
			      selected2(butons[i]);
				  }
			   else
			      {
			      normal2(butons[i]);
			      }
		       }
		    }
		}
function change_submenu_btn(nr,clas)
        {
	    butons=document.getElementsByTagName('div');
	    j=0;
	    for (i=0;i<butons.length;i++)
	        {
		    if (butons[i].className==clas)
		       {
			   j++;
			   if (j==nr)
			      {
			      butons[i].style.color='#478f2a';
				  id=butons[i].id;
				  document.getElementById(id+'1').style.visibility='visible';
				  selected_link=id;
				  }
			   else
			      {
			      butons[i].style.color='#000000';
				  id=butons[i].id;
				  document.getElementById(id+'1').style.visibility='hidden';
			      }
		       }
		    }
		}
// functii login
function login_open_close(id,height,stop_at)
        {
	    if (document.getElementById(id).offsetHeight<height)
		   {
	       if (id='login_form')
		      {
		      document.getElementById('form_login').style.display='none';
		      }
		    if (interval!=null)
		       {
			   interval=clearInterval(interval);
			   }
		   start_from=document.getElementById(id).offsetHeight;
		   interval=setInterval("login_slideup('"+id+"',start_from,"+height+",4);",1);
		   }
		else
		   {
	       if (id='login_form')
		      {
		      document.getElementById('login_new_user').style.display='none';
		      }
		   if (interval!=null)
		      {
		      interval=clearInterval(interval);
			  }
		   start_from=document.getElementById(id).offsetHeight;
		   interval=setInterval("login_slidedown('"+id+"',start_from,"+stop_at+",4);",1);
		   }
		}
function login_slideup(id,start_at,stop_at,step)
        {
	    start_from=start_at;
		if (start_from<=stop_at)
		   {
		   document.getElementById(id).style.height=start_from+'px';
		   start_from=start_from+step;
		   }
		else
		   {
		   interval=window.clearInterval(interval);
		   document.getElementById(id).style.height=stop_at+'px';
		   if (id=='login_form')
		      {
			  document.getElementById('login_new_user').style.display='block';
			  }
		   }
		}
function login_slidedown(id,start_at,stop_at,step)
        {
	    start_from=start_at;
		if (start_from>=stop_at)
		   {
		   document.getElementById(id).style.height=start_from+'px';
		   start_from=start_from-step;
		   }
		else
		   {
		   interval=window.clearInterval(interval);
		   document.getElementById(id).style.height=stop_at+'px';
		   if (id=='login_form')
		      {
			  document.getElementById('form_login').style.display='block';
			  }
		   }
		}
// functii
function hit_open_close(id,height,stop_at,keyword,div)
        {
	    if (document.getElementById(id).offsetHeight<height)
		   {
		    if (interval!=null)
		       {
			   interval=clearInterval(interval);
			   }
		   start_from=document.getElementById(id).offsetHeight;
		   interval=setInterval("hit_slideup('"+id+"',start_from,"+height+",4);",1);
		   imgs=document.getElementsByClassName('img_icon');
		   for (i=0;i<imgs.length;i++)
		       {
		       imgs[i].src='images/open.png';
			   }
		   div.getElementsByTagName('img')[1].src='images/opened.png';
		   var panels=document.getElementsByClassName('hits_panel');
		   for (i=0;i<panels.length;i++)
		       {
			   if (panels[i].offsetHeight>5)
			      {
				  panels[i].style.height='5px';
				  }
			   }
		   ajaxFunction('one_hit',id,keyword);
		   }
		else
		   {
		   if (interval!=null)
		      {
		      interval=clearInterval(interval);
			  }
		   start_from=document.getElementById(id).offsetHeight;
		   interval=setInterval("hit_slidedown('"+id+"',start_from,"+stop_at+",4);",1);
		   div.getElementsByTagName('img')[1].src='images/open.png';
		   }
		}
function hit_slideup(id,start_at,stop_at,step)
        {
	    start_from=start_at;
		if (start_from<=stop_at)
		   {
		   document.getElementById(id).style.height=start_from+'px';
		   start_from=start_from+step;
		   }
		else
		   {
		   interval=window.clearInterval(interval);
		   document.getElementById(id).style.height=stop_at+'px';
		   }
		}
function hit_slidedown(id,start_at,stop_at,step)
        {
	    start_from=start_at;
		if (start_from>=stop_at)
		   {
		   document.getElementById(id).style.height=start_from+'px';
		   start_from=start_from-step;
		   }
		else
		   {
		   interval=window.clearInterval(interval);
		   document.getElementById(id).style.height=stop_at+'px';
		   }
		}
function check_all(sel)
        {
		checks=sel.parentNode.parentNode.parentNode.getElementsByTagName('input');
		for (i=0;i<checks.length;i++)
		    {
			if (checks[i].type=='checkbox')
			   {
			   checks[i].checked=true;
			   }
			}
		}
function uncheck_all(sel)
        {
		checks=sel.parentNode.parentNode.parentNode.getElementsByTagName('input');
		for (i=0;i<checks.length;i++)
		    {
			if (checks[i].type=='checkbox')
			   {
			   checks[i].checked=false;
			   }
			}
		}
function erase_sel(sel)
        {
		checks=sel.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('input');
		for (i=0;i<checks.length;i++)
		    {
			if ((checks[i].type=='checkbox') & (checks[i].name!='all'))
			   {
			   if (checks[i].checked)
			      {
			      ajaxFunction('notifications_delete','',checks[i].name)
				  }
			   }
			}
		ajaxFunction('notifications','content','')
		}
function stop_sel(sel)
        {
		checks=sel.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('input');
		for (i=0;i<checks.length;i++)
		    {
			if ((checks[i].type=='checkbox') & (checks[i].name!='all'))
			   {
			   if (checks[i].checked)
			      {
			      ajaxFunction('notifications_set_state','','status_'+checks[i].name+'_0')
				  }
			   }
			}
		ajaxFunction('notifications','content','')
		}
function start_sel(sel)
        {
		checks=sel.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('input');
		for (i=0;i<checks.length;i++)
		    {
			if ((checks[i].type=='checkbox') & (checks[i].name!='all'))
			   {
			   if (checks[i].checked)
			      {
			      ajaxFunction('notifications_set_state','','status_'+checks[i].name+'_1');
				  }
			   }
			}
		ajaxFunction('notifications','content','')
		}
function open_keyword(id)
        {
		imgs=document.getElementsByClassName('position_opener');
		keys=document.getElementsByClassName('position_holder');
		for (i=0;i<imgs.length;i++)
		    {
			imgs[i].src="images/keys_open.png";
			}
		for (i=0;i<keys.length;i++)
		    {
			keys[i].style.display="none";	
			}
	    document.getElementById('opener_for_'+id).src='images/opened.png';
	    document.getElementById('container_for_'+id).style.display='block';
		ajaxFunction('set_active_keyword','',id);
		}
var interval_ip=null;
function floater(element,ip)
        {
	    if (document.getElementById('floater_ip')==null)
		   {
		   var img=document.createElement('img');
		   img.src='images/save.png';
		   img.style.position="absolute";
		   img.style.right="-10px";
		   img.style.top='-15px';
		   img.style.cursor='pointer';
		   img.alt=ip;
		   img.id='floater_ip';
		   img.onmousedown=function(){Shadowbox.open({player:'iframe',title:'Contul meu',content:'clientaccount.php?=contacts&add_contact=true&ip='+ip,height:500,width:600});};
		   img.onmouseout=destroy_floater;
		   element.appendChild(img);
		   }
		else
		   {
		   document.getElementById('floater_ip').parentNode.removeChild(document.getElementById('floater_ip'));
		   interval_ip=clearInterval(interval_ip);
		   floater(element,ip);
		   }
		}
function destroy_floater()
        {
		interval_ip=setInterval("if (document.getElementById('floater_ip')!=null){document.getElementById('floater_ip').parentNode.removeChild(document.getElementById('floater_ip'));}interval_ip=clearInterval(interval_ip);",3000);
	    }
function float_preloader()
        {
	    var div=document.createElement('div');
		div.style.width='100%';
		div.style.height='100%';
		div.style.position='absolute';
		div.style.top='0px';
		div.style.left='0px';
		div.style.zIndex=999999;
		div.innerHTML='<table width="100%" style="height:100%;"><tr valign="middle"><td align="center"><img src="images/please_wait.png" alt="" /></td></tr></table>';
		div.id='preloader';
		document.getElementsByTagName('body')[0].appendChild(div);
	    }
/* ----------------------------RAPORTS FUNCTIONS-------------------------------------- */
function next_step()
       {
	   inputs=document.getElementById('content').getElementsByTagName('input');
	   var ids = new Array();
	   j=0;
	   for (i=0;i<inputs.length;i++)
	       {
		   if ((inputs[i].value=='on') && (inputs[i].id!='all_seo') && (inputs[i].id!='all_traffic') && (inputs[i].id!='bills_'))
		      {
			  ids[j]=inputs[i].id;
			  j++;
			  }
		   }
	   menu='<br /><table border="0" cellpadding="0" cellspacing="0" style="position:relative; top:-15px;" align="right"><tr>';
	   menu+='<td align="center"><img src="images/down.png" id="link11" /></td>';
	   for (i=0;i<ids.length;i++)
	       {
		   if ((ids[i]!='newsletter_general') && (ids[i]!='newsletter_pe_ore'))
		   menu+='<td align="center"><img src="images/down.png" style="visibility:hidden;" id="link'+(i+2)+'1" /></td>';
		   }
	   menu+='<td align="center"><img src="images/down.png" style="visibility:hidden;" id="link'+(i+2)+'1" /></td>';
	   menu+='</tr><tr>';
	   menu+='<td style="padding-left:4px; padding-right:4px;"><div class="text_submenu" style="font-weight:bold; color:#478f2a; cursor:pointer;" id="link1" onclick="if (confirm(\'Schimband astfel paginile, unele grafice pot ramane nesalvate si nu vor aparea in raport. Sunteti sigur ca doriti sa continuati?\')){ajaxFunction(\'raports_first_page\',\'content\',\'reports\');change_submenu_btn(1,\'text_submenu\');}">1</div></td>';
	   values='';
	   next_actions[1]='raports_first_page';
	   curent_step=1;
	   j=1;
	   for (i=0;i<ids.length;i++)
	       {
		   values+=ids[i]+'|';
		   found = false;
		   if (ids[i]=='sumar')
		      {
			  curent_step++;
			  next_actions[curent_step]='reports_overview';
			  found = true;
		      }
		   else if (ids[i]=='suggestions')
		           {
			       curent_step++;
			       next_actions[curent_step]='suggestions';
			       found = true;
				   }
		   else if (ids[i]=='competition')
		           {
			       curent_step++;
			       next_actions[curent_step]='competition';
			       found = true;
				   }
		   else if (ids[i]=='keys')
		           {
			       curent_step++;
			       next_actions[curent_step]='keys';
			       found = true;
				   }
		   else if (ids[i]=='uptime')
		           {
			       curent_step++;
			       next_actions[curent_step]='uptime';
			       found = true;
				   }
		   else if (ids[i]=='newsletter')
		           {
			       curent_step++;
			       next_actions[curent_step]='reports_newsletter';
			       found = true;
				   }
		   else if (ids[i]=='cities')
		           {
			       curent_step++;
			       next_actions[curent_step]='map_overlay';
			       found = true;
				   }
		   else if (ids[i]=='countries')
		           {
			       curent_step++;
			       next_actions[curent_step]='map_overlay_countries';
			       found = true;
				   }
		   else if (ids[i]=='sources')
		           {
			       curent_step++;
			       next_actions[curent_step]='sources';
			       found = true;
				   }
		   else if (ids[i]=='new_old')
		           {
			       curent_step++;
			       next_actions[curent_step]='new_old';
			       found = true;
				   }
		   else if (ids[i]=='search_engines')
		           {
			       curent_step++;
			       next_actions[curent_step]='search_engines';
			       found = true;
				   }
		   else if (ids[i]=='browsers')
		           {
			       curent_step++;
			       next_actions[curent_step]='browsers';
			       found = true;
				   }
		   else if (ids[i]=='contents')
		           {
			       curent_step++;
			       next_actions[curent_step]='content';
			       found = true;
				   }
		   else if (ids[i]=='all_hits')
		           {
			       curent_step++;
			       next_actions[curent_step]='traffic_keys';
			       found = true;
				   }
		   else if (ids[i]=='addon_sites')
		           {
			       curent_step++;
			       next_actions[curent_step]='addon_sites';
			       found = true;
				   }
		   else if (ids[i]=='visits_on_hours')
		           {
			       curent_step++;
			       next_actions[curent_step]='visits_on_hours';
			       found = true;
				   }
		   else if (ids[i]=='time_on_page')
		           {
			       curent_step++;
			       next_actions[curent_step]='time_on_page';
			       found = true;
				   }
		   else if (ids[i]=='search_bot')
		           {
			       curent_step++;
			       next_actions[curent_step]='bot_activity';
			       found = true;
				   }
		   else if (ids[i]=='bills')
		           {
			       curent_step++;
			       next_actions[curent_step]='bills';
			       found = true;
				   }
		   else if (ids[i]=='invoices')
		           {
			       curent_step++;
			       next_actions[curent_step]='invoices';
			       found = true;
				   }
		   else if (ids[i]=='adwords')
		           {
			       curent_step++;
			       next_actions[curent_step]='adwords';
			       found = true;
				   }
		   if (found)
		      {
		      menu+='<td style=" padding-left:4px; padding-right:4px;"><div class="text_submenu" style="font-weight:bold; color:#000000; cursor:pointer;" id="link'+(j+1)+'" onclick="if (confirm(\'Schimband astfel paginile, unele grafice pot ramane nesalvate si nu vor aparea in raport. Sunteti sigur ca doriti sa continuati?\')){ajaxFunction(\'';
			  if (next_actions[curent_step]=='map_overlay_countries')
			     {
			     menu=menu+'map_overlay';
				 }
			  else
			     {
			     menu=menu+next_actions[curent_step];
				 }
			   menu=menu+'\',\'content\',\'';
			  if (next_actions[curent_step]=='map_overlay_countries')
			     {
			     menu=menu+'reports_countries';
				 }
			  else
			     {
			     menu=menu+'reports';
				 }
			  menu=menu+'\');change_submenu_btn('+(j+1)+',\'text_submenu\');curent_step='+(j+1)+';}">'+(j+1)+'</div></td>';
			  j++;
			  }
		   }
	   menu+='</tr></table>';
	   selected_link='link1';
	   values=values.substr(0,(values.length-1));
	   //alert(values);
	   ajaxFunction('raports_first_page','content',values);
	   ajaxFunction('raports_menu','buttons','');
	   document.getElementById('submenu').innerHTML=menu;
	   curent_step++;
	   next_actions[curent_step]='last_page';
	   steps_no=curent_step;
	   curent_step=1;
	   }
function next_action()
       {
	   ajaxFunction('check_image','',next_actions[curent_step]);
	   }
function previous_action()
       {
	   if (curent_step-1>=1)
	      {
	      curent_step-=1;
	      ajaxFunction(next_actions[curent_step],'content','reports');
		  change_submenu_btn(curent_step,'text_submenu');
		  }
	   document.getElementById('next_button').style.visibility='visible';
	   }
function give_up()
       {
	   ajaxFunction('erase_raports','','');ajaxFunction('raports','content','');
	   document.getElementById('buttons').innerHTML='';
	   }
/* ----------------------------DAILY CACHE FUNCTIONS-------------------------------------- */
function hover_row(tr)
       {
	   $tds=tr.getElementsByTagName('td');
	   $tds[0].style.backgroundColor='#f9f8f8';
	   $tds[1].style.backgroundColor='#f9f8f8';
	   $tds[2].style.backgroundColor='#f9f8f8';
	   $tds[3].style.backgroundColor='#f9f8f8';
	   $tds[1].getElementsByTagName('img')[0].src='images/daily_plus_green.png';
	   }
function normal_row(tr)
       {
	   $tds=tr.getElementsByTagName('td');
	   $tds[0].style.backgroundColor='#ebffea';
	   $tds[1].style.backgroundColor='#ebffea';
	   $tds[2].style.backgroundColor='#ebffea';
	   $tds[3].style.backgroundColor='#ebffea';
	   $tds[1].getElementsByTagName('img')[0].src='images/daily_plus_grey.png';
	   }
function check_selected()
       {
	   sel=document.getElementById('cache_container').getElementsByTagName('input');
	   inc=0;
	   for (i=0;i<sel.length;i++)
	       {
		   if (sel[i].checked)
		      {
			  inc++;
			  }
		   }
	   if (inc<=2)
	      {
		  return true;
		  }
	   else
	      {
		  alert('Puteti compara doar doua zile.');
		  return false;
		  }
	   }
function compare_selected()
       {
	   sel=document.getElementById('cache_container').getElementsByTagName('input');
	   inc=0;
	   j=0;
	   files= new Object();
	   for (i=0;i<sel.length;i++)
	       {
		   if (sel[i].checked)
		      {
			  files[j]=sel[i].value;
			  j++;
			  }
		   }
	   if ((files[0]!='') & (files[1]!=''))
	      {
		  ajaxFunction('compare','',files[0]+'|'+files[1]+'|'+document.getElementById('compare_type').value);
		  }
	   else
	      {
		  alert('Aveti nevoie de 2 fisiere pentru a compara!');
		  }
	   }
/* ----------------------------CHAT FUNCTIONS-------------------------------------- */
var chat_cookie;
var curent_cookie;
var nr='';
for (i=1;i<=10;i++)
    {
    if (readCookie(i)==null)
	   {
	   nr=i;
	   break;
	   }
	}
if (nr!='')
   {
   chat_cookie=nr;
   curent_cookie=nr;
   }
else
   {
   chat_cookie=11;
   curent_cookie=11;
   }
createCookie(curent_cookie,'',1);
function submit_form(e)
{
var keynum=-1;
var KeyID = (window.event) ? event.keyCode : e.keyCode;
if(window.event) // IE
{
keynum = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
}
if (keynum==-1)
   {
   }
else if (keynum==13)
   {
   createCookie(curent_cookie,'',-1);
   create_chat_history(document.getElementById('chat_line').value);
   createCookie(curent_cookie,'',1);
   document.layer1_form.submit_btn.click();
   return false;
   }
   return true;
}
function create_history(e)
{
var keynum=-1;
var KeyID = (window.event) ? event.keyCode : e.keyCode;
if(window.event) // IE
{
keynum = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
}
if (keynum==-1)
   {
   }
else
   {
   if (KeyID==38)
      {
	  cookie=readCookie(chat_cookie-1);
	  if (cookie!=null)
	     {
 	     chat_cookie=chat_cookie-1;
		 document.getElementById('chat_line').value=cookie;
		 }
	  }
   else if (KeyID==40)
      {
	  cookie=readCookie(chat_cookie+1);
	  if (cookie!=null)
	     {
 	     chat_cookie=chat_cookie+1;
		 document.getElementById('chat_line').value=cookie;
		 }
      }
   else
      {
	  createCookie(curent_cookie,document.getElementById('chat_line').value,1);
	  }
   }
   return true;
}
function create_chat_history(txt)
         {
	     var nr='';
	     for (i=1;i<=10;i++)
		     {
			 if (readCookie(i)==null)
			    {
			    nr=i;
				break;
			    }
			 }
		 if (nr!='')
		    {
			createCookie(nr,txt,1);
			chat_cookie=nr+1;
			curent_cookie=nr+1;
			createCookie(curent_cookie,'',1);
			}
		 else
		    {
			for (i=2;i<=11;i++)
			    {
				createCookie((i-1),readCookie(i),1);
				}
			createCookie(10,txt,1);
			chat_cookie=11;
			curent_cookie=11;
			createCookie(11,'',1);
			}
	     }
/* -------------------------------------------SEO AI--------------------------------------------------- */
function destroy_seoai()
         {
		 if (document.getElementById('seoai')!=null)
		    {
			document.getElementById('seoai').parentNode.removeChild(document.getElementById('seoai'));
			}
		 }
function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}
function create_seoai(content)
         {
		 if (document.getElementById('seoai')==null)
		    {
			 seoai_int=clearInterval(seoai_int);
			 var div=document.createElement('div');
			 div.style.width='279px';
			 div.style.position='absolute';
			 //alert(getDocHeight()-mouse_y);
			 div.style.bottom=(getDocHeight()-mouse_y)+"px";
			 div.style.left=(mouse_x-15)+"px";
			 div.style.verticalAlign="baseline";
			 div.id='seoai';
			 div.style.zIndex=999999;
			 div.innerHTML='<table cellpadding="0" cellspacing="0"><tr><td><div class="seoai_head"><div class="close_ai" onclick="destroy_seoai();">x</div><div class="seoai_beta">SEO AI versiune beta</div></div></td></tr><tr><td valign="bottom"><div id="seoai_body" class="seoai_body"></div></td></tr><tr><td><div class="seoai_foot"></div></td></tr></table>';
			 document.getElementById('content_holder').appendChild(div);
			 ajaxFunction('seoai','seoai_body',content);
			}
	     else
		    {
			 seoai_int=clearInterval(seoai_int);
	        }
	     }
function getMouse(e)
		 {
		 var posx = 0;
		 var posy = 0;
		 if (!e)
		 e = window.event;
		 if (e.pageX || e.pageY){
		 posx = e.pageX;
		 posy = e.pageY;
		 }
		 else if (e.clientX || e.clientY){
		 posx = e.clientX + document.body.scrollLeft
		 + document.documentElement.scrollLeft;
		 posy = e.clientY + document.body.scrollTop
		 + document.documentElement.scrollTop;
		 }
		 mouse_x=posx;
		 mouse_y=posy;
		}
/* -------------------------------------------SEOMONITOR TOOLTIP--------------------------------------------------- */
function getScroll()
   {
	  var scrollX, scrollY;
	  
	  if (document.all)
	  {
		 if (!document.documentElement.scrollLeft)
			scrollX = document.body.scrollLeft;
		 else
			scrollX = document.documentElement.scrollLeft;
			   
		 if (!document.documentElement.scrollTop)
			scrollY = document.body.scrollTop;
		 else
			scrollY = document.documentElement.scrollTop;
	  }   
	  else
	  {
		 scrollX = window.pageXOffset;
		 scrollY = window.pageYOffset;
	  }
   
	  return scrollY;
   }
function destroy_seo_help()
         {
	     help_int = clearInterval(help_int);
		 if (document.getElementById('seo_help')!=null)
		    {
			document.getElementById('seo_help').parentNode.removeChild(document.getElementById('seo_help'));
			}
		 }
function getMouseHelp(e)
		 {
		 var posx = 0;
		 var posy = 0;
		 if (!e)
		 e = window.event;
		 if (e.pageX || e.pageY){
		 posx = e.pageX;
		 posy = e.pageY;
		 var ie=false;
		 }
		 else if (e.clientX || e.clientY){
		 var ie=true;
		 posx = e.clientX + document.body.scrollLeft
		 + document.documentElement.scrollLeft;
		 posy = e.clientY + document.body.scrollTop
		 + document.documentElement.scrollTop;
		 }
		 mouse_x=posx;
		 mouse_y=posy;
		 var div = document.getElementById('seo_help');
		 if (div!=null)
		    {
			 if (mouse_x+279>getwidth()['width'])
				{
				div.style.left=(mouse_x-270)+"px";
				document.getElementById('seo_help_foot').setAttribute('class','seoai_foot2');
		        if (mouse_y-getScroll()<=div.offsetHeight+10)
		           {
				   if (ie)
					  {
					  var offset=25;
					  }
				   else
					  {
					  var offset=15;
					  }
			       div.style.bottom=(getDocHeight()-mouse_y-offset-div.offsetHeight)+"px";
				   document.getElementById('seo_help_beta').setAttribute('class','seoai_beta1');
				   document.getElementById('seo_help_head').setAttribute('class','seoai_head2');
				   document.getElementById('seo_help_foot').setAttribute('class','seoai_foot1');
		           }
			    else
			       {
			       div.style.bottom=(getDocHeight()-mouse_y+5)+"px";
				   document.getElementById('seo_help_beta').setAttribute('class','seoai_beta');
				   document.getElementById('seo_help_head').setAttribute('class','seoai_head');
				   document.getElementById('seo_help_foot').setAttribute('class','seoai_foot2');
			       }
				}
			 else
				{
				div.style.left=(mouse_x-15)+"px";
				document.getElementById('seo_help_foot').setAttribute('class','seoai_foot');
		        if (mouse_y-getScroll()<=div.offsetHeight+10)
		           {
				   if (ie)
					  {
					  var offset=25;
					  }
				   else
					  {
					  var offset=15;
					  }
			       div.style.bottom=(getDocHeight()-mouse_y-offset-div.offsetHeight)+"px";
				   document.getElementById('seo_help_beta').setAttribute('class','seoai_beta1');
				   document.getElementById('seo_help_head').setAttribute('class','seoai_head1');
				   document.getElementById('seo_help_foot').setAttribute('class','seoai_foot1');
		           }
			    else
			       {
			       div.style.bottom=(getDocHeight()-mouse_y+5)+"px";
				   document.getElementById('seo_help_beta').setAttribute('class','seoai_beta');
				   document.getElementById('seo_help_head').setAttribute('class','seoai_head');
				   document.getElementById('seo_help_foot').setAttribute('class','seoai_foot');
			       }
				}
			}
		}
function create_help(content)
         {
	     help_int = clearInterval(help_int);
		 if (document.getElementById('seo_help')==null)
		    {
			 seoai_int=clearInterval(seoai_int);
			 var div=document.createElement('div');
			 div.style.width='279px';
			 div.style.overflow='hidden';
			 div.style.position='absolute';
		      if (mouse_x+279>getwidth()['width'])
				{
				div.style.left=(mouse_x-270)+"px";
		        if (mouse_y-getScroll()<=80)
		           {
			       div.style.bottom=(getDocHeight()-mouse_y-25-80)+"px";
				   var beta_class = 'seoai_beta1';
				   var head_class = 'seoai_head2';
				   var foot_class = 'seoai_foot1';
		           }
			    else
			       {
			       div.style.bottom=(getDocHeight()-mouse_y+5)+"px";
				   var beta_class = 'seoai_beta';
				   var head_class = 'seoai_head';
				   var foot_class = 'seoai_foot2';
			       }
				}
			 else
				{
				div.style.left=(mouse_x-15)+"px";
		        if (mouse_y-getScroll()<=80)
		           {
			       div.style.bottom=(getDocHeight()-mouse_y-25-80)+"px";
				   var beta_class = 'seoai_beta1';
				   var head_class = 'seoai_head1';
				   var foot_class = 'seoai_foot1';
		           }
			    else
			       {
			       div.style.bottom=(getDocHeight()-mouse_y+5)+"px";
				   var beta_class = 'seoai_beta';
				   var head_class = 'seoai_head';
				   var foot_class = 'seoai_foot';
			       }
				}
			 div.style.verticalAlign="baseline";
			 div.id='seo_help';
			 div.style.zIndex=999999;
			 div.innerHTML='<table cellpadding="0" cellspacing="0"><tr><td><div id="seo_help_head" class="'+head_class+'"><div id="seo_help_beta" class="'+beta_class+'">SEO monitor help</div></div></td></tr><tr><td valign="bottom"><div id="seoai_body" class="seoai_body"><div style="padding:8px;">'+content+'</div></div></td></tr><tr><td><div id="seo_help_foot" class="'+foot_class+'"></div></td></tr></table>';
		      if (mouse_x+279>getwidth()['width'])
				{
				div.style.left=(mouse_x-270)+"px";
		        if (mouse_y-getScroll()<=80)
		           {
			       div.style.bottom=(getDocHeight()-mouse_y-25-80)+"px";
		           }
			    else
			       {
			       div.style.bottom=(getDocHeight()-mouse_y+5)+"px";
			       }
				}
			 else
				{
				div.style.left=(mouse_x-15)+"px";
		        if (mouse_y-getScroll()<=80)
		           {
			       div.style.bottom=(getDocHeight()-mouse_y-25-80)+"px";
		           }
			    else
			       {
			       div.style.bottom=(getDocHeight()-mouse_y+5)+"px";
			       }
				}
			 document.getElementById('content_holder').appendChild(div);
			}
	     }
/* -------------------------------------------REPLAY--------------------------------------------------- */
function check_replay_window(param,win)
        {
		//alert(win);
	    if (win.closed)
		   {
		   //alert('closed');
		   ajaxFunction('remove_from_watch','',param);
		   inter=clearInterval(inter);
		   watching=false;
		   }
		}
/* -------------------------------------------ALERTS--------------------------------------------------- */
function create_alert(text)
        {
	    values=text.split('');
		color=values[0];
		border=values[1];
		image=values[2];
		title=values[3];
		content=values[4];
		document.getElementById('main_table_alert').style.display='table';
		document.getElementById('main_cell_alert').style.backgroundColor='#'+color;
		document.getElementById('main_cell_alert').style.borderLeftColor='#'+border;
		document.getElementById('main_cell_alert').style.borderTopColor='#'+border;
		document.getElementById('alerts').style.backgroundColor='#'+color;
		document.getElementById('alert_image').src='images/alert/'+image;
		
		if ((title!='') && (title !== undefined) && (title!=' '))
		   {
		document.getElementById('alert_title').innerHTML=title;
		document.getElementById('alert_title').style.display='block';
		   }
		else
		{
		document.getElementById('alert_title').innerHTML='';
		document.getElementById('alert_title').style.display='none';
		}
		
		if ((content!='') && (content !== undefined))
		document.getElementById('alert_content').innerHTML=content;
		else
		document.getElementById('alert_content').innerHTML='';
		}
function destroy_alert()
        {
		document.getElementById('main_table_alert').style.display='none';
		document.getElementById('alert_image').src='';
		document.getElementById('alert_title').innerHTML='';
		document.getElementById('alert_content').innerHTML='';
		}
/* -------------------------------------------TIPS--------------------------------------------------- */
function create_tip(text)
        {
		document.getElementById('main_table_tip').style.display='table';
		document.getElementById('tip_image').src='images/alert/daily_tips.png';
		document.getElementById('tip_title').innerHTML=text;
		}
function destroy_tip()
        {
		document.getElementById('main_table_tip').style.display='none';
		document.getElementById('tip_image').src='';
		document.getElementById('tip_title').innerHTML='';
		document.getElementById('tip_content').innerHTML='';
		}
/* -------------------------------------------WHAT'S NEW TIP--------------------------------------------------- */
function moveTooltip(e) {
	var posx = 0;
	var posy = 0;
	var divObj;
	if (!e)
	e = window.event;
	if (e.pageX || e.pageY){
	posx = e.pageX;
	posy = e.pageY;
	}
	else if (e.clientX || e.clientY){
	posx = e.clientX + document.body.scrollLeft
	+ document.documentElement.scrollLeft;
	posy = e.clientY + document.body.scrollTop
	+ document.documentElement.scrollTop;
	}
	//alert(mouse_x+" "+mouse_y);
	divObj = document.getElementById("tooltip_body");
	divObj.style.top=(posy+10)+"px";
	divObj.style.left=(posx+0)+"px";
	}
function createTooltip(txt) {
	var div = document.createElement('div');
	div.style.position="absolute";
	div.style.top="0px";
	div.style.left="0px";
	div.style.width="279px";
	div.style.height="auto";
	div.style.overflow="hidden";
	div.id='tooltip_body';
	div.style.zIndex='999999';
	document.getElementsByTagName('body')[0].appendChild(div);
	
	var top = document.createElement('div');
	top.style.position="relative";
	top.style.top="0px";
	top.style.left="0px";
	top.style.backgroundImage="url(images/tooltip/top.png)";
	top.style.width="279px";
	top.style.height="25px";
	document.getElementById('tooltip_body').appendChild(top);
	
	var content = document.createElement('div');
	content.style.position="relative";
	content.style.left="0px";
	content.style.width="279px";
	content.style.height="auto";
	content.style.backgroundColor="#FFFFFF";
	content.style.padding="5px";
	content.innerHTML=txt;
	content.id='tooltip_content';
	content.setAttribute('class','text');
	document.getElementById('tooltip_body').appendChild(content);
	
	var bottom = document.createElement('div');
	bottom.style.position="absolute";
	bottom.style.bottom="0px";
	bottom.style.left="0px";
	bottom.style.backgroundImage="url(images/tooltip/bottom.png)";
	bottom.style.width="279px";
	bottom.style.height="7px";
	bottom.style.overflow="hidden";
	document.getElementById('tooltip_body').appendChild(bottom);
	
	var side = document.createElement('div');
	side.style.position="absolute";
	side.style.top="0px";
	side.style.left="0px";
	side.style.backgroundImage="url(images/tooltip/side.png)";
	side.style.backgroundColor="#4b810c";
	side.style.backgroundRepeat="repeat-y";
	side.style.width="2px";
	side.style.height="100%";
	side.style.overflow="hidden";
	document.getElementById('tooltip_content').appendChild(side);
	
	var side = document.createElement('div');
	side.style.position="absolute";
	side.style.top="0px";
	side.style.right="10px";
	side.style.backgroundImage="url(images/tooltip/side.png)";
	side.style.backgroundColor="#4b810c";
	side.style.backgroundRepeat="repeat-y";
	side.style.width="2px";
	side.style.height="100%";
	side.style.overflow="hidden";
	document.getElementById('tooltip_content').appendChild(side);
	}
function destroyTooltip() {
	var div = document.getElementById('tooltip_body');
	if (div != null)
	   {
	   div.parentNode.removeChild(div);
	   }
	}
/* -------------------------------------------NEWSLETTER--------------------------------------------------- */
var counterFile = 1;
var counterFileLimit = 10;
function lists_check() {
	if (document.getElementById('old_list').checked)
	   {
	   var lists = document.getElementsByName('lists[]');
	   var all_ok = false;
	   for (i = 0; i<lists.length; i++)
		   {
		   if (lists[i].checked)
			  {
			  all_ok = true;
			  break;
			  }
		   }
	   return all_ok;
	   }
	else
	   {
	   return false;
	   }
	}
function add_name_field(text) {
	document.getElementById('name_field_here').innerHTML='<div class="field_container" style="width:461px;"><div class="left_side_field"></div><div class="right_side_field"></div><input type="text" name="newsletter_new_list_name" id="newsletter_new_list_name" class="field" style="width:441px; color:#CCC;" value="'+text+'" onfocus="if (this.value==\''+text+'\') {this.value=\'\';this.style.color=\'#000\'}" onblur="if (this.value==\'\') {this.value=\''+text+'\';this.style.color=\'#CCC\'}" /></div><br /><br />';
	document.getElementById('newsletter_new_list').style.height = '156px';
	document.getElementById('newsletter_new_list_field').style.height = '152px';
	}
function remove_name_field() {
	document.getElementById('name_field_here').innerHTML='';
	document.getElementById('newsletter_new_list').style.height = '200px';
	document.getElementById('newsletter_new_list_field').style.height = '196px';
	}
function removeInput(id,confirm_text){
	if (confirm(confirm_text))
	   {
	   document.getElementById('fileNamesHolder').removeChild(document.getElementById('filename'+id));
	   document.getElementById('fileHolder').removeChild(document.getElementById('file'+id));
	   counterFileLimit++;
	   }
	}
function addInputs(delete_text,confirm_text){
   if (counterFile<counterFileLimit)
      {
	  document.getElementById('file'+(counterFile)).style.display='none';
      var newdiv = document.createElement('input');
      newdiv.setAttribute('id', 'file'+(counterFile + 1));
      newdiv.setAttribute('name', 'file'+(counterFile + 1));
      newdiv.setAttribute('type', 'file');
      document.getElementById('fileHolder').appendChild(newdiv);
      document.getElementById('file'+(counterFile + 1)).onchange=function(){addInputs(delete_text,confirm_text);};
	  document.getElementById('fileNamesHolder').innerHTML+="<div id='filename"+counterFile+"'><span style='display:inline-block; width:157px; overflow:hidden;'><img src='images/newsletter_attachement.png' style='position:relative; top:3px;' alt='' /><span style='position:relative; top:-2px; left:3px;'>"+document.getElementById('file'+(counterFile)).value+"</span></span><span onclick=\"removeInput("+(counterFile)+",'"+confirm_text+"');\" class='text newsletter_remove_att'>"+delete_text+"</span></div>";
      counterFile++;
	  }
   if (counterFile==counterFileLimit)
      {
	  alert('Puteti atasa maxim 10 fisiere.');
	  }}
function removeThisPicture(id) {
      var d = document.getElementById('PictureContainer');
      var olddiv = document.getElementById(id);
      d.removeChild(olddiv);
	  counterFile--;
      document.getElementById('pictureCounter').value= ""+counterFile;
	  return false;
   }
function toogle_campaign(div,id) {
	if (div.style.backgroundPosition=='0px 0px')
	   {
	   div.style.backgroundPosition="16px 16px";
	   ajaxFunction('newsletter_set_status','',id+'||'+0);
	   if (document.getElementById('whaiting_img')!=null)
	      {
		  toggle_message = 'Opreste';
		  document.getElementById('whaiting_img').src="images/whaiting.gif";
		  document.getElementById('newsletter_status').innerHTML="Se trimit email-uri ...";
		  }
	   }
	else
	   {
	   div.style.backgroundPosition="0px 0px";
	   ajaxFunction('newsletter_set_status','',id+'||'+1);
	   if (document.getElementById('whaiting_img')!=null)
	      {
		  toggle_message = 'Porneste';
		  document.getElementById('whaiting_img').src="images/whaiting.png";
		  document.getElementById('newsletter_status').innerHTML="Campanie intrerupta.";
		  }
	   }
	}
function toogle_campaign_details(img,div,id) {
	if (document.getElementById(div).innerHTML=='')
	   {
	   ajaxFunction('newsletter_detailed',div,id);
	   img.src='images/opened.png';
	   }
	else
	   {
	   document.getElementById(div).innerHTML='';
	   img.src='images/open.png';
	   }
    }
function toogle_report_campaign_details(img,div,id) {
	if (document.getElementById(div).innerHTML=='')
	   {
	   ajaxFunction('reports_newsletter_content',div,id);
	   ajaxFunction('add_remove_key','','add|'+id+'|newsletter');
	   img.src='images/opened.png';
	   }
	else
	   {
	   ajaxFunction('add_remove_key','','remove|'+id+'|newsletter');
	   document.getElementById(div).innerHTML='';
	   img.src='images/open.png';
	   }
    }
function toogle_campaign_lists(img,div,id) {
	if (document.getElementById(div).innerHTML=='')
	   {
	   ajaxFunction('newsletter_list_detailed',div,id);
	   img.src='images/opened.png';
	   }
	else
	   {
	   document.getElementById(div).innerHTML='';
	   img.src='images/open.png';
	   }
    }
/* -------------------------------------------DORU's TOOLTIP--------------------------------------------------- */
var divObj;
var contentObj;
function setTipContent(content) {

	contentObj = document.getElementById("tooltip_content");
	contentObj.innerHTML = content;}
function setToolTip(e) {
	var posx = 0;
	var posy = 0;
	if (!e)
	e = window.event;
	if (e.pageX || e.pageY){
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY){
		posx = e.clientX + document.body.scrollLeft
		+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
		+ document.documentElement.scrollTop;
	}
	divObj = document.getElementById("tooltip");
	divObj.style.display = 'block';
	divObj.style.top=(posy-6)+"px";
	divObj.style.left=(posx+23)+"px";}
function hideTooltip() {
	divObj = document.getElementById("tooltip");
	divObj.style.display = 'none';}
function toogle_competition(id,tr) {
	if (document.getElementById('chart'+id).style.display=='none')
	   {
	   close_all_charts();
	   document.getElementById('chart'+id).style.display='block';
	   trs=tr.parentNode.getElementsByTagName('tr');
	   for (i=0;i<trs.length;i++)
	       {
		   if (trs[i].getAttribute('class')=='comp_row')
		      {
		      trs[i].style.backgroundColor='#fff';
		      trs[i].onmouseover=function(){this.style.backgroundColor='#EEE';}
		      trs[i].onmouseout=function(){this.style.backgroundColor='#FFF';}
			  }
		   }
	   tr.style.backgroundColor='#E8F6D6';
	   tr.onmouseover=function(){}
	   tr.onmouseout=function(){}
	   }
	else
	   {
	   close_all_charts();
	   trs=tr.parentNode.getElementsByTagName('tr');
	   for (i=0;i<trs.length;i++)
	       {
		   if (trs[i].getAttribute('class')=='comp_row')
		      {
		      trs[i].style.backgroundColor='#fff';
		      trs[i].onmouseover=function(){this.style.backgroundColor='#EEE';}
		      trs[i].onmouseout=function(){this.style.backgroundColor='#FFF';}
			  }
		   }
	   }
	}
function toogle_competition_raport(id) {
	if (document.getElementById('chart'+id).style.display=='none')
	   {
	   document.getElementById('chart'+id).style.display='block';
	   ajaxFunction('add_remove_key','','add|'+id+'|competition');
	   }
	else
	   {
	   document.getElementById('chart'+id).style.display='none';
	   ajaxFunction('add_remove_key','','remove|'+id+'|competition');
	   }
	}
function toogle_keys(id) {
	if (document.getElementById('chart'+id).style.display=='none')
	   {
	   close_all_charts();
	   close_all_keys_images();
	   close_all_texts();
	   document.getElementById('chart'+id).style.display='inline-block';
	   document.getElementById('image'+id).src='images/keys_opened.png';
	   document.getElementById('text'+id).style.fontWeight='bold';
	   }
	else
	   {
	   close_all_keys_images();
	   close_all_texts();
	   close_all_charts();
	   }
	}
function toogle_keys_report(id) {
	if (document.getElementById('chart'+id).style.display=='none')
	   {
	   ajaxFunction('add_remove_key','','add|'+id);
	   document.getElementById('chart'+id).style.display='inline-block';
	   document.getElementById('image'+id).src='images/keys_opened.png';
	   document.getElementById('text'+id).style.fontWeight='bold';
	   ajaxFunction('add_remove_key','','add|'+id+'|keywords');
	   }
	else
	   {
	   ajaxFunction('add_remove_key','','remove|'+id);
	   document.getElementById('chart'+id).style.display='none';
	   document.getElementById('image'+id).src='images/keys_open.png';
	   document.getElementById('text'+id).style.fontWeight='normal';
	   ajaxFunction('add_remove_key','','remove|'+id+'|keywords');
	   }
	}
function filterLinking() {
	linking_section=document.getElementById('linking_section').value;
	linking_month=document.getElementById('linking_month').value;
	linking_show=document.getElementById('linking_show').value;
	
	ajaxFunction('link_analytics','content','{"req":"history","linking_section":"'+linking_section+'","linking_month":"'+linking_month+'","linking_show":"'+linking_show+'"}');
	}
function changeAvailableShows(sel) {
	if (sel.value!='anchor_text_distribution')
	   {
	   document.getElementById('linking_show').innerHTML='<option value="old">Deleted</option><option value="new">New</option><option value="linking_more">More Autoritive</option><option value="linking_less">Less Autoritive</option><option value="linking_same">No changes</option>';
	   }
	else
	   {
	   document.getElementById('linking_show').innerHTML='<option value="old">Deleted</option><option value="new">New</option><option value="linking_more">Number increased</option><option value="linking_less">Number decreased</option><option value="linking_same">No changes</option>';
	   }
	}
function filterLinks() {
	linking_section=document.getElementById('linking_section').value;
	linking_show=document.getElementById('linking_show').value;
	
	ajaxFunction('links_history','links_content','{"linking_section":"'+linking_section+'","linking_show":"'+linking_show+'"}');
	}
function gotoPage(linking_section,linking_show,start_with) {
	ajaxFunction('links_history','links_content','{"linking_section":"'+linking_section+'","linking_show":"'+linking_show+'","start_with":"'+start_with+'"}');
	}