function getXMLHttp(){
    if(typeof XMLHttpRequest != 'undefined'){
        var ajax = new XMLHttpRequest();
        return ajax;
    }
    else
    {
        var objects = ["MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
        for(counter = 0 ; counter < objects.length ; counter++ ){
            try{
               var ajax = new ActiveXObject(objects[counter]);
               return ajax;
            } catch(e){
                 // do nothing
            }
        }
    }
    throw new Error("Unable to establish AJAX connection with server");
}

function remove_all_children(el)
{
    if ( el.hasChildNodes() )
    {
        while ( el.childNodes.length >= 1 )
        {
             el.removeChild( el.firstChild );
        }
   }
}

function clearclick(el)
{
    if(el.value=="Enter a search term" || el.value=="Search the site")
    {
        el.value = '';
    }
}


function setOpacity( value ) {
 document.getElementById("login_popup").style.opacity = value / 10;
 document.getElementById("login_popup").style.filter = 'alpha(opacity=' + value * 10 + ')';
}

function fadeInMyPopup() {
 for( var i = 0 ; i <= 100 ; i++ )
   setTimeout( 'setOpacity(' + (i / 10) + ')' , 8 * i );
}

function fadeOutMyPopup() {
 for( var i = 0 ; i <= 100 ; i++ ) {
   setTimeout( 'setOpacity(' + (10 - i / 10) + ')' , 8 * i );
 }

 setTimeout('closeMyPopup()', 800 );
}

function closeMyPopup() {
 document.getElementById("login_popup").style.display = "none"
}

function showlogin() {
 setOpacity( 0 );
 document.getElementById("login_popup").style.display = "block";
 fadeInMyPopup();
}

function bookmarkSite(title,url) { 
if (window.sidebar) { 
  // firefox 
  alert("To bookmark this site: close this box and press Ctrl + D."); 
} else if(window.opera && window.print) { 
  // opera 
  var elem = document.createElement('a'); 
  elem.setAttribute('href',url); 
  elem.setAttribute('title',title); 
  elem.setAttribute('rel','sidebar'); elem.click(); 
} else if(document.all) { 
  // ie 
  window.external.AddFavorite(url, title); 
} 
}
