﻿// global constants
var _MAX_KEYWORDS = 100;
var _MIN_POPULARITY_CHANGE = 2;
var _MAX_LATEST_PHOTOS = 3;
var _MAX_LATEST_TOTAL_POSTS = 65;
var _MAX_LATEST_INTIAL_POSTS = 8;
var _HOT_KEYWORDS_COUNT = 8;
var _CURRENT_MESSAGE_ID = 1;

// globals
var _arLatestPhotos = new Array(_MAX_LATEST_PHOTOS);
var _arPhotoUrl = new Array(_MAX_LATEST_PHOTOS);
var _arPhotoStoryUrl = new Array(_MAX_LATEST_PHOTOS);
var _arPhotoSource = new Array(_MAX_LATEST_PHOTOS);
var _arPhotoTitle = new Array(_MAX_LATEST_PHOTOS);
var _arPhotoClip = new Array(_MAX_LATEST_PHOTOS);
var _arPhotoDateTime = new Array(_MAX_LATEST_PHOTOS);

var _arLatestPosts = new Array(_MAX_LATEST_TOTAL_POSTS); // array of latest post ids
var _arHotTimers = new Array(_HOT_KEYWORDS_COUNT+1); // array of timers
var _previousOption = 'hide'; // options are always hidden by default (no need for a cookie)
var _activeSortView = 'tabsSortView1'; // default sort tab
var _activeKeywordsView = 'tabsKeywordsView1'; // default keyword tab
var _activeFilterKey = ''; // previous filter key used by showRows function
var _tipobj = ''
var _enabletip = false;  

// option value globals
var _arIdsColor = new Array(3); // array of color ids
_arIdsColor[0] = 'styleColorWhite';
_arIdsColor[1] = 'styleColorBlue';
_arIdsColor[2] = 'styleColorGray';

var _arColor = new Array(3); // array of colors
_arColor[0] = 'w';
_arColor[1] = 'b';
_arColor[2] = 'g';


var _arIdsTextSize = new Array(3); // array of text size ids
_arIdsTextSize[0] = 'styleTextSizeNormal';
_arIdsTextSize[1] = 'styleTextSizeSmall';
_arIdsTextSize[2] = 'styleTextSizeBig';
var _arTextSize = new Array(3); // array of text size
_arTextSize[0] = 'n'
_arTextSize[1] = 's'
_arTextSize[2] = 'b'


// -----------------------------------------------------------------------------
// cookie defs.

function Get_Cookie(name)
{var start=document.cookie.indexOf(name);
var len=start+name.length+1;
if((!start)&&(name!=document.cookie.substring(0,name.length)))
{return null;}

if(start==-1)return null;
var end=document.cookie.indexOf(";",len);

if(end==-1)end=document.cookie.length;
return unescape(document.cookie.substring(len,end));
};

function Set_Cookie(name,value,expires,path,domain,secure)
{
var today=new Date();
today.setTime(today.getTime());
if(expires){expires=expires*1000*60*60*24;}
var expires_date=new Date(today.getTime()+(expires));
document.cookie=name+"="+escape(value)+((expires)?";expires="+expires_date.toGMTString():"")+((path)?";path="+path:"")+((domain)?";domain="+domain:"")+((secure)?";secure":"");
};

function Delete_Cookie(name,path,domain)
{
if(Get_Cookie(name))
{document.cookie=name+"="+((path)?";path="+path:"")+((domain)?";domain="+domain:"")+";expires=Thu, 01-Jan-1970 00:00:01 GMT";}
};

// -----------------------------------------------------------------------------
// toggles horizontal scrollbar for low res
function toggleXScroll()
{
     if (screen.width < 1024)
     {    
        var oS = document.getElementById('x-overflow');
        oS.style.overflowX = "auto";
     }
     else
     {
        var oS = document.getElementById('x-overflow');
        oS.style.overflowX = "hidden";
     } 
}

// show options
function showOptions(origin)
{  
    // 'toggle' OR 'close'
    if ( origin == 'toggle' )
    {
        if ( _previousOption == 'hide' )
        {
            document.getElementById('optionsDropBox').style.display = ""; 
            document.getElementById('linkOptions').innerHTML = "- options"; 
            _previousOption = 'show';
        }
        else
        {
            document.getElementById('optionsDropBox').style.display = "none";
            document.getElementById('linkOptions').innerHTML = "+ options"; 
            _previousOption = 'hide';
        }
    }
    else // 'close'
    {
        document.getElementById('optionsDropBox').style.display = "none";
        document.getElementById('linkOptions').innerHTML = "+ options"; 
        _previousOption = 'hide';  
    }
    
    stopAnimation();  
}

// -----------------------------------------------------------------------------
// e.g. switchToggle('cbFeedTimeSwitch','expandedFeedStyle','defaultFeedStyle','ckView','user')
// e.g. switchToggle('cbSimilar','','','ckSim','user')
// e.g. switchToggle('cbMarkTopicsSwitch','','','ckMark','user')

function switchToggle( idSelector,idOn,idOff,nameCookie,callOriginator )
{
    var cookie = Get_Cookie(nameCookie)
    
    // call from onclick
    if ( callOriginator == 'user' )
    {
        // reverse value
        if ((cookie == '1') || (cookie == '') || (cookie == null))
            return(switchToggleElements(idOn,idOff,nameCookie,'0'));       
        else
            return(switchToggleElements(idOn,idOff,nameCookie,'1'));
    }
    else // call from onload
    {        
        // set value
        if ( cookie == '1' )
        {
            document.getElementById(idSelector).checked = true;
            return(switchToggleElements(idOn,idOff,nameCookie,'1'));           
        }
        else // default
        {
            if(document.getElementById(idSelector))
                document.getElementById(idSelector).checked = false;
                
            return(switchToggleElements(idOn,idOff,nameCookie,'0'));           
        }
    }  
}

function switchToggleElements( idOn,idOff,nameCookie,valueCurrent )
{
    if ((idOn != '') && (idOff != ''))
    {
        if ( valueCurrent == '1' )
        {
            document.getElementById(idOn).disabled = false;        
            document.getElementById(idOff).disabled = true;            
        }
        else
        {    
            document.getElementById(idOn).disabled = true;
            document.getElementById(idOff).disabled = false;
        }
    }
    // set cookie to match current value
    Set_Cookie(nameCookie,valueCurrent,30000,'/','',false);  
    return(valueCurrent);        
}

// -----------------------------------------------------------------------------
function Select_Value_Set(SelectName, Value) {
  var SelectObject = document.getElementById(SelectName);
    
  if(SelectObject != null)
  {
      var len = SelectObject.options.length;
      for(var i = 0; i < len; i++) 
      {
         //the Value of the cookie is only 1 letter (i.e 'b') as opposed to option value (i.e. 'big')
         if(SelectObject[i].value.substring(0,1) == Value) 
             SelectObject.selectedIndex = i;
      }
  }
}

// -----------------------------------------------------------------------------
// e.g. switchMultiSelected('ckCol',_arIdsColor,_arColor,'w')
// e.g. switchMultiSelected('ckText',_arIdsTextSize,_arTextSize,'s')
function switchMultiSelected( nameCookie,valueIdsArray,valueArray,valueCurrent )
{       
    var cookie = Get_Cookie(nameCookie);

    if (( cookie == '' ) || ( cookie == null )) // no cookie exists, set default value to valueArray[0]
    {
        switchMultiElements( nameCookie,valueIdsArray,valueArray,valueArray[0] );
    }
    else if ( valueCurrent == 'onload' ) // onload, set cookie value
    {
        switchMultiElements( nameCookie,valueIdsArray,valueArray,cookie );
        
        // onload needs to also set the selector value
        if ( nameCookie == 'ckText' )
        {
            Select_Value_Set('selectTextSize',cookie);  
        }
    }
    else // switch selected, set switch value
    {
        var i = 0;
        while (valueArray[i] && (i<999))
        {
            if (valueArray[i] == valueCurrent)
            {
                switchMultiElements( nameCookie,valueIdsArray,valueArray,valueCurrent );
            }
            i++;
        }
    }        
}

function switchMultiElements( nameCookie,valueIdsArray,valueArray,valueCurrent )
{
    var i = 0;
    var bSuccess = 0;
    while (valueIdsArray[i] && (i<999))
    {
        var vi = document.getElementById(valueIdsArray[i]);
        vi.disabled = true;
        if ( valueCurrent == valueArray[i])
        {
            vi.disabled = false;
            bSuccess = 1;
        }
        i++;
    }
       
    if ( bSuccess == 0 )
        document.getElementById(valueIdsArray[0]).disabled = false; // set default value to first element

    if (( valueCurrent != '' ) && ( valueCurrent != 'onload' ))
        Set_Cookie(nameCookie,valueCurrent,30000,'/','',false);          
}

function doMarkTopicsSwitch()
{
    switchToggle('cbMarkTopicsSwitch','','','ckMark','user');
    highlightKeywords('t_' + _activeFilterKey);  
    document.getElementById('idWebSearchKeyword').innerHTML = _activeFilterKey.replace(eval('/_/gi'),'&nbsp;');    
}

// -----------------------------------------------------------------------------
function Querystring(qs) 
{ 
// optionally pass a querystring to parse
	this.params = new Object();
	this.get=f_qs;
	
	if (qs == null)
		qs=location.search.substring(1,location.search.length);

	if (qs.length == 0) return;

    // Turn <plus> back to <space>
    // See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1

	qs = qs.replace(/\+/g, ' ');
	
	// parse out name/value pairs separated via &
	var args = qs.split('&'); 
	
    // split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=');
		var name = unescape(pair[0]);

		if (pair.length == 2)
			value = unescape(pair[1]);
		else
			value = name;
		
		this.params[name] = value;
	}
}

function f_qs(key, default_) {
	// This silly looking line changes UNDEFINED to NULL
	if (default_ == null) default_ = null;
	
	var value=this.params[key]
	if (value==null) value=default_;
	
	return value
}

// -----------------------------------------------------------------------------

function setTextSize(size)
{
    var sizeLetter = 'n'; // normal is default size
    if (size == 'small')
        sizeLetter = 's';
    else if (size == 'big')
        sizeLetter = 'b';        
        
    switchMultiSelected('ckText',_arIdsTextSize,_arTextSize, sizeLetter)
}
    
// -----------------------------------------------------------------------------
// time difference since the post 
    
    function timeDiff(utcstamp)
    {
        if ( utcstamp == "" )
            return "";
            
        var customstamp = false;
        if (document.location.href.indexOf('?1') > 0)
            customstamp = true;
        
        var oDate = new Date();
        var sUTCTime2 = utcstamp; //"7/21/2007 2:00:00 PM";
        var sUTCTime = (customstamp ? Get_Cookie("ct") : (oDate.getUTCMonth()+1) + "/" + oDate.getUTCDate() + "/" + oDate.getUTCFullYear() + " " +  oDate.getUTCHours() + ":" + oDate.getUTCMinutes() + ":" + oDate.getUTCSeconds());
        //alert("Subtract: " + sUTCTime + "-" + sUTCTime2);
        var date1 = new Date(sUTCTime2);
	    var date2 = new Date(sUTCTime);
	    var msec = Math.abs(date2.getTime() - date1.getTime());         
        var sec = msec/1000;
        
        var mf = Math.floor
        var min = mf(sec/60);
        sec = mf(sec%60);            
        var hrs = mf(min/60);
        min = mf(min%60);
        var days = mf(hrs/24);
        var sAgo = (hrs == 0 ? min + " min" + (min > 1 ? "s" : "") : (days == 0 ? hrs + ":" + (min < 10 ? "0" : "" ) + min + " hrs" : days + " day" + (days > 1 ? "s" : ""))) + " ago";   
        var sOut = "<span>" + sAgo + "<\/span>";      
	    return sOut; //hrs + " hrs. " + min + " min." + sec + " sec. ago";  
    }

//------------------------------------------------------------------------------
// auto generated feed stamp

    function doAutoGenStamp() 
    {          
        var utcstamp = document.getElementById('autoGenTime').innerHTML;                                 
        var sLocalStamp = (new Date(utcstamp)).toLocaleString();            
        utcstamp = utcstamp.replace("+0000","");     
        var sTimeDiff = timeDiff(utcstamp);
          
	    if ((sTimeDiff != 'Nan') && (sTimeDiff != null))
	    {
            document.getElementById('autoGenStamp').innerHTML = sTimeDiff;
	    }
    }
    
// -----------------------------------------------------------------------------
// tooltip

    function ietruebody(){
    if (document.compatMode && document.compatMode!="BackCompat")
        return document.documentElement;
    else 
        return document.body;
    }

    function tip(thetext,tstamp)
    {    
        var b_ie=document.all;
        var b_ns6=document.getElementById && !document.all;

        var thecolor = '#EEEEF9';
        var thewidth = 525;

        if (!_tipobj)
        {
            _enabletip=false;
            return;
        }
        
        
        if (b_ns6||b_ie)
        {
            if (typeof thewidth!="undefined") _tipobj.style.width=thewidth+"px";
            if (typeof thecolor!="undefined" && thecolor!="") _tipobj.style.backgroundColor=thecolor;
            _tipobj.innerHTML = thetext;
            
            if (tstamp)
            {
                var d = new Date(tstamp);
                _tipobj.innerHTML += " (" + (d != null ? d.toLocaleString() + ' EST' : "") + ")";
            }
            
            _tipobj.innerHTML;
            _enabletip=true;
            return true;
        }
    }

    function f_pn(e)
    {
        var offsetxpoint=0 //Customize x offset of tooltip
        var offsetypoint=24 //Customize y offset of tooltip
        
        var b_ie=document.all
        var b_ns6=document.getElementById && !document.all
        
        if (!_tipobj)
        {
            _enabletip=false;
            return;
        }
        

        if (_enabletip){
            _tipobj.style.display = '';
            var curX=(b_ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
            var curY=(b_ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
            //Find out how close the mouse is to the corner of the window
            var rightedge=b_ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
            var bottomedge=b_ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

            var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

            //if the horizontal distance isn't enough to accomodate the width of the context menu
            if (rightedge<_tipobj.offsetWidth)
            //move the horizontal position of the menu to the left by it's width
            _tipobj.style.left=b_ie? ietruebody().scrollLeft+event.clientX-_tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-_tipobj.offsetWidth+"px";
            else if (curX<leftedge)
            _tipobj.style.left="5px";
            else
            //position the horizontal position of the menu where the mouse is positioned
            _tipobj.style.left=curX+offsetxpoint+"px"


            //same concept with the vertical position
            if (bottomedge<_tipobj.offsetHeight)
            _tipobj.style.top=b_ie? ietruebody().scrollTop+event.clientY-_tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-_tipobj.offsetHeight-offsetypoint+"px";
            else
            _tipobj.style.top=curY+offsetypoint+"px"
            _tipobj.style.visibility="visible"
        }
        else
        {
            if (_tipobj)
                _tipobj.style.display = 'none';
        }
    }

    function htip()
    {  
        var b_ie=document.all
        var b_ns6=document.getElementById && !document.all
        
        if (!_tipobj)
        {
            _enabletip=false;
            return;
        }
        
       
        if (b_ns6||b_ie){
            _enabletip=false
            _tipobj.style.visibility="hidden"

            _tipobj.style.backgroundColor=''
            _tipobj.style.width=''
        }
    }

    document.onmousemove=f_pn
    

// -----------------------------------------------------------------------------
function stopAnimation()
{  
    // clear timers
    for ( var i=0; i < _HOT_KEYWORDS_COUNT+1; i++ )
    {
        if ( _arHotTimers[i] ) 
            clearTimeout( _arHotTimers[i] );
    }      
    
    if (document.getElementById('idPlayKeywords'))
        document.getElementById('idPlayKeywords').innerHTML = 'play';                                         
}

// -----------------------------------------------------------------------------
// show rows
function showRows(filter)
{
    if (_activeFilterKey == '')
        return;
      
    updatedFilter = outputRows(filter);
    if ( updatedFilter != '' )
    {
        highlightKeywords(updatedFilter);
        document.getElementById('idWebSearchKeyword').innerHTML = _activeFilterKey.replace(eval('/_/gi'),'&nbsp;'); 
    }
} 

function outputRows(filter)
{   
    document.getElementById('rL_more').style.display = 'none'; 
    document.getElementById('latestOpenMessage').style.display = 'none'; 
    document.getElementById('latestAll').style.display = '';
   
    var LEN_KEY_PREFIX = 2; // 'a_' OR 't_'
    var updatedFilter = filter;

    // tab clicked
    switch(filter)
    {        
        case 'selectedTimeTab':
              updatedFilter = 't_' + _activeFilterKey;
              break;    
        case 'selectedAlexaTab':
              updatedFilter = 'a_' + _activeFilterKey;
              break;
        default: // keyword in the cloud clicked             
              var lenKey = updatedFilter.length; // most popular key 
              _activeFilterKey = updatedFilter.substring(LEN_KEY_PREFIX,lenKey);                
              
              if ( _activeSortView == 'tabsSortView1' ) // by rank
              {  
                 updatedFilter = 't_' + _activeFilterKey;
              }
              else // ( _activeSortView == 'tabsSortView2' ) // by time
              {  
                 updatedFilter = 'a_' + _activeFilterKey;
              }                
              break;
    }                          
    
    // fill the latest row id values based on the filter key
    var idFilter = document.getElementById(updatedFilter);
    if (idFilter)
    {
        _arLatestPosts = (idFilter.innerHTML).split(',');
    }
    else
    {
        return ('');   
    }  
 
    // reset and fill output rows
    var i = 1;
    while (document.getElementById( "rL_" + i ) && (i <= _MAX_LATEST_TOTAL_POSTS ))
    {
        document.getElementById("rL_" + i).style.display = "none";  
        i++;
    }
    
    // display rows (-1 due to comma at the end)
    var k = 1;
    var len = _arLatestPosts.length - 1; 
    
    if (len > _MAX_LATEST_TOTAL_POSTS)
        len = _MAX_LATEST_TOTAL_POSTS;
     
    for (var i=0; i < len; i++)
    { 
        var ri = document.getElementById("rC_" + _arLatestPosts[i]);       
        
        if ( ri != null )
        {
            var rt = document.getElementById("rL_" + k);
            rt.innerHTML = ri.innerHTML; 
            rt.style.display = '';                
            k++;
        }    
    }
    
    // remaining rows are empty
    if (len < _MAX_LATEST_INTIAL_POSTS)
    {
        var lenEmpty = _MAX_LATEST_INTIAL_POSTS - len;
        for (var i=1; i <= lenEmpty; i++)
        { 
            var rt = document.getElementById("rL_" + k);
            rt.innerHTML = ''
            rt.style.display = '';                
            k++;
        }
    }
  
    return(updatedFilter);
}

function displayKeywordPhotos()
{
    // fill the latest photo values based on the filter key
    var photoFilter = "ph_" + _activeFilterKey;
    var idPhotoFilter = document.getElementById(photoFilter);
    if (idPhotoFilter)
    {
        _arLatestPhotos = (idPhotoFilter.innerHTML).split(',');
        _arPhotoUrl = (document.getElementById('photoUrl').innerHTML).split(',');
        _arPhotoStoryUrl = (document.getElementById('photoStoryUrl').innerHTML).split(',');
        _arPhotoSource = (document.getElementById('photoSource').innerHTML).split(',');
        _arPhotoTitle = (document.getElementById('photoTitle').innerHTML).split(',');
        _arPhotoClip = (document.getElementById('photoClip').innerHTML).split(',');
        _arPhotoDateTime = (document.getElementById('photoDateTime').innerHTML).split(',');     
    }
    else
    {
        return ('');   
    } 
    
    var i = 1;
    while (i <= _MAX_LATEST_PHOTOS )
    {
        var idPhoto = 'photo' + i;    
    
        if (_arLatestPhotos[i-1])
        {
            document.getElementById(idPhoto).style.display = '';
            
            var photoUrl = _arPhotoUrl[_arLatestPhotos[i-1]];
            var photoStoryUrl = _arPhotoStoryUrl[_arLatestPhotos[i-1]];  
            var photoSource = _arPhotoSource[_arLatestPhotos[i-1]]; 
            var photoTitle = _arPhotoTitle[_arLatestPhotos[i-1]];  
            var photoClip = _arPhotoClip[_arLatestPhotos[i-1]]; 
            var photoDateTime = _arPhotoDateTime[_arLatestPhotos[i-1]]; 
                     
            var idPhotoHtml = "<a target='_blank' href='" + photoStoryUrl + "'><img style='max-width: 125px; width: expression(this.width > 125 ? 127: true); border: solid 1px #CCCCFF; padding:0.5em;' src='" + photoUrl + "' alt=''/> <\/a> <br/> <\/td> <td align='left' valign='middle'>" + "<a href='" + photoStoryUrl + "' alt='' target='_blank'>" + "<span id='phTitle" + i + "'>" + photoTitle + "<\/span>" + "<\/a>" + ":&nbsp;" + "<br/><span id='phClip" + i + "'>" + photoClip + "<\/span>" + " [" + photoSource + ", " + photoDateTime + "]";
            
            if (( photoStoryUrl!= '' ) && ( photoTitle != '' ))
                document.getElementById(idPhoto).innerHTML = idPhotoHtml; 
            else
                document.getElementById(idPhoto).style.display = 'none';                           
        }
        else
        {
            document.getElementById(idPhoto).style.display = 'none';
        }
        
        i++;
    }
}


function highlightKwLatest(filter)
{ 
        var sTitle = '';
        var arTitle = new Array(3); 
        var j = 1;              
        
        // latest section
        // ---------------
        while ( (_arLatestPosts[j-1]) && ( j <= _MAX_LATEST_TOTAL_POSTS ))
        {      
            var idElementTitle = 'rL_' + j; 
            
            // process latest title for keyword highlights  
            sTitle = document.getElementById(idElementTitle).innerHTML;
            arTitle = processLatestTitle(sTitle)      
                  
            // keywords in latest section       
            resetAndApplyHighlights(idElementTitle, arTitle, filter);
            
            j++;
        } 

}

function highlightKwPhotos(filter)
{ 
        var sTitle = '';
        var arPhotoTitle = new Array(3);
        var arClipTitle = new Array(3);
        var j = 1; 
        
        var sPhotoTitle = '';
        var sPhotoClip = '';       
                   
        while ( (_arLatestPhotos[j-1]) && ( j <= _MAX_LATEST_PHOTOS ))
        {      
            var idPhotoTitle = 'phTitle' + j; 
            var idPhotoClip = 'phClip' + j; 
            
            // process latest title for keyword highlights                          
            sPhotoTitle = document.getElementById(idPhotoTitle).innerHTML;
            sPhotoClip = document.getElementById(idPhotoClip).innerHTML;
            
            arPhotoTitle[0] = sPhotoTitle;
            arClipTitle[0] = sPhotoClip;                    
 
            resetAndApplyHighlights(idPhotoTitle, arPhotoTitle, filter);
            resetAndApplyHighlights(idPhotoClip, arClipTitle, filter);                 
                     
            j++;
        }     
}

function highlightKwCloud(filter)
{ 
    var arTitle = new Array(3); 
    
    arTitle[0] = document.getElementById('idTagCloud').innerHTML;
    resetAndApplyHighlights('idTagCloud', arTitle, filter);      
}


//function highlightHotTopic(filter)
//{
//    var arTitle = new Array(3); 
//
//   arTitle[0] = document.getElementById('rL_0').innerHTML;
//  resetAndApplyHighlights('rL_0', arTitle, filter);   
//}


function highlightKeywords(filter)
{        
    displayKeywordPhotos();   
    
    if (document.getElementById('cbMarkTopicsSwitch').checked)
    {
        highlightKwLatest('');        
        highlightKwPhotos('');
    }
    else
    {
        highlightKwLatest(filter);         
        highlightKwPhotos(filter);
    }
       
    highlightKwCloud(filter); 
    //highlightHotTopic(filter); 
}   

function colorFreshKeywords(id, hours)
{
    Set_Cookie("ckFresh",hours,30000,'/','',false);

    var divFresh = document.getElementById('kwTime' + hours).innerHTML;
    var arSplit = divFresh.split(','); 

    // loop
    var i = 1;
    while(i <= _MAX_KEYWORDS) 
    {

    
        if (document.getElementById(id + i))
        {
            if ( arSplit[i-1] >= (_MIN_POPULARITY_CHANGE + 1) )
            {
                document.getElementById(id + i).className = 'cColorKeywordVeryFresh';
            }
            else if ( arSplit[i-1] >= _MIN_POPULARITY_CHANGE )
            {
                document.getElementById(id + i).className = 'cColorKeywordFresh';
            }
            else
            {
                document.getElementById(id + i).className = '';
            } 
        }      
        
        i++;       
    }      
}    

function processLatestTitle(sTitle)
{      
        var arTitle = new Array(3); 
        var iRtStart = 0;
        
        iRtStart = sTitle.indexOf("<SPAN id=rt"); // ie
        if ( iRtStart == -1 )
            iRtStart = sTitle.indexOf("<span id=\"rt"); // ff                 
        
                    
        var sTitlePre0 = sTitle.substring(0, iRtStart);
        sTitle = sTitle.substring(iRtStart,sTitle.length);       
        
        var iTitleSpanPre = sTitle.indexOf(">"); 
        var sTitleSpanPre = sTitle.substring(0,iTitleSpanPre+1);
        var sTitlePre = sTitlePre0 + sTitleSpanPre;
        
        var iRtEnd = sTitle.indexOf("<\/SPAN>"); // ie
        if ( iRtEnd == -1 )
            iRtEnd = sTitle.indexOf("<\/span>"); // ff
            
        var sTitleSuf = sTitle.substring(iRtEnd,sTitle.length); 
        sTitle = sTitle.substring(0,iRtEnd); 
        
        
        var iRtStart2 = sTitle.indexOf("\">");
        if ( iRtStart2 == -1 )
        {
            iRtStart2 = sTitle.indexOf(">");
            sTitle = sTitle.substring((iRtStart2+1),sTitle.length);
        }
        else
        { 
            sTitle = sTitle.substring((iRtStart2+2),sTitle.length);
        } 
        
        arTitle[0] = sTitle.replace(eval('/-/gi'),'');
        arTitle[1] = sTitlePre;
        arTitle[2] = sTitleSuf;
        
        return(arTitle)
}

function resetAndApplyHighlights(idElement, arContent, filter)
{ 
    var HIGHLIGHT_COLOR = '#03FFFF';
    var MATCH_START = "<span style=\'background-color: " + HIGHLIGHT_COLOR + "'>";
    var MATCH_END = "<\/span>";  

    var sContent = arContent[0];
    var sContentPre = arContent[1];
    var sContentSuf = arContent[2]; 
    
    var arSplit = filter.split('_'); 
    
    var KW_POS = 1;
    var sOld = arSplit[KW_POS]; // first word is at position 1    
    
    // check if keyword is a pair or triplet
    for ( var i=(KW_POS+1); i<=(KW_POS+2); i++ )
    {    
        if ( arSplit[i] )  
        {     
            if ( idElement == "idTagCloud" ) 
                sOld += '&nbsp;' + arSplit[i];
            else
                sOld += ' ' + arSplit[i];
        }
    }

    var reg = new RegExp(sOld,'gi');                                  
    var regExec = reg.exec(sContent);  
    
    if (( regExec == null ) || ( regExec == '' ))
    {   
         //clean up the previous highlights
        //sContent = sContent.replace(/<span(.*?)>/gi,"")
        //sContent = sContent.replace(MATCH_END, "");
          
        if (( idElement == "idTagCloud") || (idElement.indexOf("ph") == 0 ))                    
            document.getElementById(idElement).innerHTML = sContent;    
        else // rL_ 
            document.getElementById(idElement).innerHTML = sContentPre + sContent + sContentSuf;                                            
    }
    else
    {                                       
        // reset previous matches     
        sNew = MATCH_START + regExec + MATCH_END;  
        
        var iPos = sContent.toLowerCase().indexOf(sOld);
        if (( iPos != -1 ) && (( filter.substring(0,(KW_POS+1)) == "a_" ) || ( filter.substring(0,(KW_POS+1)) == "t_" )))
        {
            var sOriginalContent = sContent.substring(iPos,iPos + sOld.length);

            //clean up the previous highlights         
            sContent = sContent.replace(/<span(.*?)>/gi,"");  
            sContent = sContent.replace(MATCH_END, "");                                                        
                      
            // apply the new highlights                          
            if ( idElement == "idTagCloud")
            {               
                var sRep = ">" + sOriginalContent + "<";
                var sNewCloud =  ">" + sNew + "<";
                // NOTE: don't highlight global strings in the cloud: use i not gi
                document.getElementById(idElement).innerHTML = sContent.replace(new RegExp( sRep, "i" ), sNewCloud);  
            }
            else if (idElement.indexOf("ph") == 0)
            {
                document.getElementById(idElement).innerHTML = sContent.replace(sOriginalContent,sNew,'gi'); 
            }
            else 
            {
                if (!sContentPre)
                    sContentPre = '';
                    
                if (!sContentSuf)
                    sContentSuf = '';
                               
                document.getElementById(idElement).innerHTML = sContentPre + sContent.replace(sOriginalContent,sNew,'gi') + sContentSuf; 
            } 
        }
    }  
}

// -----------------------------------------------------------------------------
// active tabs

function activateSortView(idTabs,idActive) 
{
    _activeSortView = idTabs + idActive;
    activateTab(idTabs,idActive);
    
    if ( idActive == '1' )
    {
        showRows('selectedTimeTab');
        Set_Cookie("ckSort","1",30000,'/','',false);
    }
    else if ( idActive == '2' )
    {    
        showRows('selectedAlexaTab');
        Set_Cookie("ckSort","2",30000,'/','',false);
    }      
}

function activateKeywordsView(idTabs,idActive) 
{
    _activeKeywordsView = idTabs + idActive;
    activateTab(idTabs,idActive); 

    if ( idActive == '1' )
        colorFreshKeywords('kwr',sliderKw.getValue())  
    
    stopAnimation();
}

function activateTab(idTabs,idActive) 
{
    var i = 1;
    while (document.getElementById(idTabs + i)  && (i<999))
    {
        document.getElementById(idTabs + i).className = 'cNonActiveSpan'; 
        document.getElementById(idTabs + 'A' + i).className = 'cNonActiveA';  
        i++;
    }
    
    document.getElementById(idTabs + idActive).className = 'cActiveSpan';  
    document.getElementById(idTabs + 'A' + idActive).className = 'cActiveA';  
}

function activateAboutDiv(idTab) 
{
    var i = 1;
    while (document.getElementById('about' + i)  && (i<999))
    {
        if ( i != idTab )
            document.getElementById('about' + i).style.display = 'none';
        else
              document.getElementById('about' + i).style.display = '';          
            
        i++;
    }
}

//-----------------------------------------------------------------------------

function playKeywords()
{
    // play animation
    if (document.getElementById('idPlayKeywords').innerHTML == 'play')
    {
        document.getElementById('idPlayKeywords').innerHTML = 'stop';  
        
        var arKw = document.getElementById('kwTime').innerHTML.split(','); 
        _activeFilterKey = arKw[0];      
        showRows('t_' + _activeFilterKey);
        
        var i = 2;
        while( i <= _HOT_KEYWORDS_COUNT+1) 
        {
            nextHotLightBuild(i); 
            i++;       
        }   
    }
    // stop keyword animation
    else
    {
        stopAnimation();          
    }
}
// ------------------------------------------------------------

function nextHotLightBuild(idHot1)
{
    var HOT_DELAY = 7000;//msec     
 
    var action1 = "";
    var action2 = ""; 
    action1 += "id1 = " + idHot1 + "; nextHotLightAction('action1',id1);";

    var idHot2 = idHot1 + 1;
    if (idHot2 <= _HOT_KEYWORDS_COUNT+1)   
    { 
        action2 += "id2 = " + idHot2 + "; nextHotLightAction('action2_1',id2);";
    }
    else // _HOT_KEYWORDS_COUNT (need to automate action2 AND switch below)
    {
        idHot2 = 1;
        action2 += "id2 = " + idHot2 + "; nextHotLightAction('action2_2',id2);";
    }  
    
    var actionTotal = action1 + action2;
    if (actionTotal != '' )
    {  
        _arHotTimers[idHot1-1] = setTimeout(actionTotal, (HOT_DELAY * (idHot1-1)));
    }  
}

// hot keywords
function nextHotLightAction(type,id)
{
    if (type == 'action1') // switch previous action off
    {                   
        var activeKeyword = document.getElementById('hot_' + id).innerHTML.replace(eval('/&nbsp;/gi'),'_')
        showRows('t_' + activeKeyword);        
    }
    else if ((type == 'action2_1') || (type == 'action2_2')) // always do this if action needs to be switched on
    {    
        _activeFilterKey = document.getElementById('hot_' + id).innerHTML.replace(eval('/&nbsp;/gi'),'_')      
    }
    
    if (type == 'action2_2') // switch final action on
    {    
        _activeFilterKey = document.getElementById('hot_1').innerHTML.replace(eval('/&nbsp;/gi'),'_')
        showRows('t_' + _activeFilterKey);
        stopAnimation(); 
    }   
}

function showSimilarInCloud(i,filterKey)
{
    document.getElementById('sj' + i).style.display = 'none';
    document.getElementById('sk' + i).style.display = '';
        
    _activeFilterKey = filterKey;
    showRows('t_' + _activeFilterKey);
    stopAnimation(); 
}

function showSimilarTopics()
{
    switchToggle('cbSimilar','','','ckSim','user');
    showSimilarAllTopics();
}
    
function showSimilarAllTopics()
{    

    // show/hide similar keywords 
    var i = 1;
    while(i <= _MAX_KEYWORDS) 
    {
        if (document.getElementById('sk' + i))
        { 
           if (document.getElementById('cbSimilar').checked)
           {
                document.getElementById('sk' + i).style.display = '';
                document.getElementById('sj' + i).style.display = 'none';
           }
           else
           {
                document.getElementById('sk' + i).style.display = 'none';
                document.getElementById('sj' + i).style.display = '';
           }           
        }
        i++;
    }
}

function showOpeningMessage()
{
    document.getElementById('latestAll').style.display = 'none'; 
    document.getElementById('latestOpenMessage').style.display = '';
}

function showFirstTimeMessage()
{
    //document.getElementById('latestAll').style.display = 'none'; 
    document.getElementById('latestOpenMessage').style.display = 'none';
}

// -----------------------------------------------------------------------------
// search related functions
function finalizeBuildSearchProcess()
{
    return;
    
    window.open('','_self','');
    window.opener = self; 
    window.close();
}

function handleEnter(e,cat) {
 var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
 if (keyCode == 13)
   DoSearch(cat);
}


//-----------------------------------------------------------------------------
function toggleDropDown(id)
{
    if (!document.getElementById(id))
        return;
    
    document.getElementById(id).style.display = '';
       
    if (id == 'dropdown_alpha_sort')
    {
        document.getElementById('dropdown_rank_sort').style.display = 'none';    
    } 
    else if (id == 'dropdown_rank_sort')
    {
        document.getElementById('dropdown_alpha_sort').style.display = 'none';        
    }
    
    document.getElementById('alpha_blog_selection').options[0].selected = true; 
    document.getElementById('rank_blog_selection').options[0].selected = true; 
}

// selectBlog
function selectBlog(id)
{
    x = document.getElementById(id).value;
    highlightBlog(x);
    setTimeout("document.getElementById(x).style.background = 'none';", 3000);  
}

function highlightBlog(x)
{
    if (document.getElementById(x))
    { 
        document.location.href = "#" + x;    
        document.getElementById(x).style.background = 'aqua';    
    }
}

function switchNewsSortingTab()
{
    var ckSort = Get_Cookie("ckSort");
    
    if (ckSort == '2') //by rank
    {
        activateSortView('tabsSortView','2')
    }
    else
    {
        activateSortView('tabsSortView','1')
        ckSort = '1';
    }
    
    return(ckSort)
}

function repChar(str,oldc,newc)
{
    var out = oldc;
    var add = newc;
    var temp = "" + str;

    while (temp.indexOf(out)>-1) 
	{
        pos= temp.indexOf(out);
        temp = "" + (temp.substring(0, pos) + add + temp.substring((pos + out.length), temp.length));    
    }
    
    return temp;
}

function InternetCustomEscape(str)
{
    str = repChar(str,".","@1");
    str = repChar(str,"/","");
    str = repChar(str,"\\","");
	str = repChar(str,";","");
  
    return str;
}

var _SEARCH_DIRECTORY = "search";

function validateEntry(ctl,val)
{    
    var re = /[\s,/,%,_,-,!,@,#,$,@,&,*,\\,.]+/;
    val = repChar(val,".","");
    val = repChar(val,"/","");
    val = repChar(val,"\\","");
    val = repChar(val,"_","");
    val = repChar(val,"-","");
    val = repChar(val,"!","");
    val = repChar(val,"@","");
    val = repChar(val,"#","");
    val = repChar(val,"$","");
    val = repChar(val,"&","");
    val = repChar(val,"*","");        
        
    var bInvalidChars = (val.indexOf('%') > -1);
    
    if (val.length == 0 || bInvalidChars)
    {                                         
        $('#inputErrors').show(1000);
                
        return false;       
    }    
    
    return true;
}

function DoSearch() {
    
    $('#inputErrors').hide();
    //var sCat = document.getElementById("categories").value;         
    var sKey = document.getElementById("inputSearchBox").value;
    if (validateEntry("inputSearchBox",sKey))
        window.location.replace("/" + _SEARCH_DIRECTORY + "/" + escape(InternetCustomEscape(sKey)));        
}

function rssFeed(sources)
{
    $('#inputErrors').hide();
    //var sCat = document.getElementById("categories").value;         
    var sKey = document.getElementById("inputSearchBox").value;
    if (validateEntry("inputSearchBox",sKey))
        window.open("../AAA/Scr/SearchFeeds.aspx?t=" + htParams["key"] + "&rss=true&sources=" + sources);
}
   
     
// -----------------------------------------------------------------------------
function switchMultiSelectDelay()
{
    // options 
    switchMultiSelected('ckCol', _arIdsColor, _arColor,'onload');
    switchMultiSelected('ckText',_arIdsTextSize,_arTextSize,'onload'); 

    switchToggle('cbMarkTopicsSwitch','','','ckMark','onload');
    switchToggle('cbSimilar','','','ckSim','onload');
}

// initialize 
function init(type)
{     
    // initiate _tipobj
    if (document.getElementById("dhtmltooltip"))
        _tipobj = document.getElementById("dhtmltooltip");
         
    // options 
    setTimeout("switchMultiSelectDelay()",500);
    
    toggleXScroll();
    
    //safari
    document.getElementById('safariFeedStyle').disabled = true;
    if (navigator.userAgent.toLowerCase().indexOf("safari") > -1)
    {
        document.getElementById('idColorOptions').style.display='none';
    
        if ((type == 'search') || (type == 'feeds'))      
        {
               document.getElementById('safariFeedStyle').disabled = false;
               
               if (type == 'search')
                    document.getElementById('searchSelectTimeStamps').style.display='none';                              
        }
    }
    
    //search
    if (document.getElementById('inputSearchBox'))
    {
        var keyId = document.getElementById('inputSearchBox');
        keyId.focus();
    }
   
    if (type == 'search')
    {
		var DEFAULT_HEADLINES_PER_BOX = 5;
        var iHeadlineCount = ((Get_Cookie('cbNewsCount') == '' || Get_Cookie('cbNewsCount') == null) ? DEFAULT_HEADLINES_PER_BOX : Get_Cookie('cbNewsCount'));
        Set_Cookie('cbNewsCount',iHeadlineCount,30000,'/','',false);
        document.getElementById('headlineCountSelection').value = iHeadlineCount; 
        switchToggle('cbSearchTimeSwitch','defaultFeedStyle','expandedFeedStyle','ckSearchView','onload');
        
        loadResults();
    }
    else if (type == 'about')
    {
        var qs = new Querystring();
        var aboutId = qs.get("a");
        if (aboutId)
        {
            activateTab('tabsAboutView',aboutId);
            activateAboutDiv(aboutId)
        }
    }  
    else if (type == 'home-a1')
    {
        setTimeout("doAutoGenStamp()",500);
    }
    else if (type == 'time')
    {
        setTimeout("doAutoGenStamp()",500);
    }
    else if (type == 'feeds') 
    {  
        switchToggle('cbFeedTimeSwitch','defaultFeedStyle','expandedFeedStyle','ckView','onload');
        toggleDropDown('dropdown_alpha_sort');
        
        setTimeout("doAutoGenStamp()",500);
        
        if (window.location.href.indexOf('#') > 0)
        {
            var a = window.location.href.substring(0,window.location.href.indexOf('#')+1);
            var x = window.location.href.replace(a,'').replace('%20',' '); 
            highlightBlog(x); 
            setTimeout("var a = window.location.href.substring(0,window.location.href.indexOf('#')+1); var x = window.location.href.replace(a,'').replace('%20',' '); document.getElementById(x).style.background = 'none';", 3000);  
        }
    } 
    else if (type == 'topics')
    {
		// cookies
        //switchToggle('cbMarkTopicsSwitch','','','ckMark','onload');
        //switchToggle('cbSimilar','','','ckSim','onload')    
        var sortOrder = switchNewsSortingTab(); 
    
        // time stamp
        setTimeout("doAutoGenStamp()",500);
                   
        // if no querystring in url then do default animation
        var qs = new Querystring();
        var topic = qs.get("t");
        
        if (topic)
        {
            _activeFilterKey = topic.replace(eval('/ /gi'),'_');;
            //showRows('t_' + _activeFilterKey);
            setTimeout("showRows('t_" + _activeFilterKey + "')",500);
        }
        else if (document.getElementById('cbMarkTopicsSwitch').checked)
        {
 	    _activeFilterKey = document.getElementById('hot_1').innerHTML.replace(eval('/&nbsp;/gi'),'_')
            setTimeout("showRows('t_" + _activeFilterKey + "')",500);
        }
        else
        {
            // showRows takes cpu time and so it is not called here 
            // the first keyword's headlines have already been filled in on the server side
	   _activeFilterKey = document.getElementById('hot_1').innerHTML.replace(eval('/&nbsp;/gi'),'_')           
	   highlightKeywords('t_' + _activeFilterKey); 
        } 
          
        if (sortOrder=='2')
        {
           setTimeout("activateSortView('tabsSortView'," + sortOrder + ")",500); // also sets _activeSortView
        }
       
        // fresh keywords
        var ckF = Get_Cookie('ckFresh'); 
        if ((ckF == null) || (ckF == ''))
            ckF = '2'; 
            
        sliderKw.setValue(ckF);
        //colorFreshKeywords('kwr',ckF);
		setTimeout("colorFreshKeywords('kwr'," + ckF + ")",500);
        
        // similar topics
        var ckS = Get_Cookie('ckSim'); 
        if ((ckS == null) || (ckS == '')) 
            ckS = '1'; 
            
        //showSimilarAllTopics();
		setTimeout("showSimilarAllTopics()",500);
           
        // opening message
        var ckO = Get_Cookie('ckOpen');  
        if ((ckO == null) || (ckO == ''))
        {
            Set_Cookie("ckOpen",_CURRENT_MESSAGE_ID,30000,'/','',false);
            setTimeout("showFirstTimeMessage()",500);
        }
        else if (ckO != _CURRENT_MESSAGE_ID)
        {
            Set_Cookie("ckOpen",_CURRENT_MESSAGE_ID,30000,'/','',false);
            setTimeout("showOpeningMessage()",500);
        }
    }
    
    if (document.getElementById('divButtonA1'))
        document.getElementById('divButtonA1').style.display ='';
        
} 

function validateSearchToken(str)
{    
    return unescape(str);
}

function parseQuery(url,bParseSearch)
{
    var htParams = {};
    
    if (bParseSearch)
    {
        var arrParams = url.split('/');
        if (arrParams.length > 2 && arrParams[arrParams.length - 2] == _SEARCH_DIRECTORY)
        {
            htParams["key"] = validateSearchToken(arrParams[arrParams.length - 1]);
        }               
    }
    else
    {
        var arrParams = url.split('?');
        if (arrParams.length  < 2)
            return htParams;
        
        var sQS = arrParams[1];
        var arrTokens = sQS.split('&');
        for(var i=0; i < arrTokens.length; i++)
        {
            var arrKeyValue = arrTokens[i].split('=');
            if (arrKeyValue.length != 2)
                continue;
            htParams[arrKeyValue[0]] = arrKeyValue[1];
        }
    }
        
    return htParams;
}

function selectHeadlineCount(val)
{
    //Set Cookie
    Set_Cookie('cbNewsCount',val,30000,'/','',false);    
    DoSearch();    
}

function getAjaxUrl(name,token)
{
    var url = "../aaa/scr/SearchFeeds.aspx?";              
    url += "s=" + name + "&t=" + escape(token) + "&c=" + Get_Cookie('cbNewsCount');
    return(url);
}

//drop-down
var verticalOffsetIE=-1;var verticalOffsetFF=-1;
var cssdropdown={disappeardelay:100,dropmenuobj:null,ie:document.all,firefox:document.getElementById&&!document.all,getposOffset:function(what,offsettype){ var totaloffset=(offsettype=="left")?what.offsetLeft:what.offsetTop;
var parentEl=what.offsetParent;while(parentEl!=null){totaloffset=(offsettype=="left")?totaloffset+parentEl.offsetLeft:totaloffset+parentEl.offsetTop;parentEl=parentEl.offsetParent;}return totaloffset;},showhide:function(obj,e,visible,hidden){if(this.ie||this.firefox)this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px";
if(e.type=="click"&&obj.visibility==hidden||e.type=="mouseover")obj.visibility=visible;else if(e.type=="click")obj.visibility=hidden},iecompattest:function(){return(document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body},clearbrowseredge:function(obj,whichedge){var edgeoffset=0;if(whichedge=="rightedge"){var windowedge=this.ie&&!window.opera?this.iecompattest().scrollLeft+this.iecompattest().clientWidth-15:window.pageXOffset+window.innerWidth-15;this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth;if(windowedge-this.dropmenuobj.x<this.dropmenuobj.contentmeasure)edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth}else{var topedge=this.ie&&!window.opera?this.iecompattest().scrollTop:window.pageYOffset;
var windowedge=this.ie&&!window.opera?this.iecompattest().scrollTop+this.iecompattest().clientHeight-15:window.pageYOffset+window.innerHeight-18;this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight;if(windowedge-this.dropmenuobj.y<this.dropmenuobj.contentmeasure){edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight;if((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure)edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge}}return edgeoffset},dropit:function(obj,e,dropmenuID){if(this.dropmenuobj!=null)this.dropmenuobj.style.visibility="hidden";this.clearhidemenu();if(this.ie||this.firefox){obj.onmouseout=function(){cssdropdown.delayhidemenu()};this.dropmenuobj=document.getElementById(dropmenuID);this.dropmenuobj.onmouseover=function(){cssdropdown.clearhidemenu()};
this.dropmenuobj.onmouseout=function(){cssdropdown.dynamichide(e)};this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()};this.showhide(this.dropmenuobj.style,e,"visible","hidden");this.dropmenuobj.x=this.getposOffset(obj,"left");this.dropmenuobj.y=this.getposOffset(obj,"top");this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj,"rightedge")+"px";if(this.firefox)this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj,"bottomedge")+obj.offsetHeight+verticalOffsetFF+"px";else this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj,"bottomedge")+obj.offsetHeight+verticalOffsetIE+"px"}},contains_firefox:function(a,b){while(b.parentNode)if((b=b.parentNode)==a)return true;return false;},dynamichide:function(e){var evtobj=window.event?window.event:e;
this.delayhidemenu();},delayhidemenu:function(){this.delayhide=setTimeout("cssdropdown.dropmenuobj.style.visibility='hidden'",this.disappeardelay)},clearhidemenu:function(){if(this.delayhide!="undefined")clearTimeout(this.delayhide)}} 


