// JavaScript Document
var tickerText = "";  

//----------------------------------------------------------------------------------------------------------------------------------------
//functie refresh block last updated
//----------------------------------------------------------------------------------------------------------------------------------------
function refreshLastUpdated(relative_path){
	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;        
            }      
        }
    }
    
    //refresh last updated block
    xmlHttp.onreadystatechange=function(){
      if(xmlHttp.readyState==4){
        document.getElementById('updates').innerHTML = xmlHttp.responseText;
        
      }
    }
	
	xmlHttp.open("GET","server?mode=1&relative_path="+relative_path, true);
    xmlHttp.send(null);
}

//----------------------------------------------------------------------------------------------------------------------------------------
//functie refresh block last created
//----------------------------------------------------------------------------------------------------------------------------------------
function refreshLastCreated(relative_path){
	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;        
            }      
        }
    }
    
    //refresh last updated block
    xmlHttp.onreadystatechange=function(){
      if(xmlHttp.readyState==4){
        document.getElementById('creation').innerHTML = xmlHttp.responseText;
        
      }
    }
	
	xmlHttp.open("GET","server?mode=2&relative_path="+relative_path,true);
    xmlHttp.send(null);
}

//----------------------------------------------------------------------------------------------------------------------------------------
//functie refrtesh ticker
//----------------------------------------------------------------------------------------------------------------------------------------
function refreshTickerText(relative_path){
    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;        
            }      
        }
    }
    
    
    //refresh text ticker
    xmlHttp.onreadystatechange=function(){
      if(xmlHttp.readyState==4){
	    tickerText = xmlHttp.responseText;
            //alert(tickerText);
	  }
    }
	
    xmlHttp.open("GET","server?mode=3&relative_path="+relative_path,true);
    xmlHttp.send(null);
	
  }
  
//----------------------------------------------------------------------------------------------------------------------------------------//Functii nitializare si pornire timer  
//----------------------------------------------------------------------------------------------------------------------------------------
var timerID = null;
var timerIDLogin = null;
var delay = 30*1000;

function InitializeTimer(relative_path)
{
    // Set the length of the timer, in seconds
    StartTheTimer(relative_path);
}

function InitializeTimerLogin(relative_path)
{
    // Set the length of the timer, in seconds
    StartTheTimerLogin(relative_path);
}

function StartTheTimer(relative_path)
{
    refreshLastUpdated(relative_path);
    refreshLastCreated(relative_path);
    refreshTicker(relative_path);
    timerID = self.setTimeout("StartTheTimer("+relative_path+")", delay)
}

function StartTheTimerLogin(relative_path)
{
    refreshLastUpdated(relative_path);
    refreshTickerText(relative_path);
    refreshLastCreated(relative_path);
    timerIDLogin = self.setTimeout("StartTheTimerLogin("+relative_path+")", delay)
}

//----------------------------------------------------------------------------------------------------------------------------------------
//Functii pentru sms ticker
//----------------------------------------------------------------------------------------------------------------------------------------
function highlightLink(obj)
{
    obj.style.color='OrangeRed';
    obj.style.fontWeight='bold';
    obj.style.fontSize='0.95em';
}

function normalLink(obj)
{
    obj.style.color='black';
    obj.style.fontWeight='normal';
    obj.style.fontSize='1em';
}

function refreshTicker()
{
    document.getElementById('smsticker').innerHTML = tickerText;
}
