
function collapseFrame(frameWidth)
{
  if(frameWidth > 2)
  {
    document.getElementById("BottomBar").style.width = frameWidth+'%';
    frameWidth-=4;
    var t=setTimeout("collapseFrame("+frameWidth+")",5);
  }
  else
  {
    document.getElementById("BottomBar").style.width = '12px';
    document.getElementById("BottomBar").innerHTML='\
    <div id="ExpandBtn"><img src="http://images.sleeksearch.com/images/icons/right_arrow.png" onclick="expandFrame(1.5);return false;" ></div>';

    setCookieBB('bbV', -1, 1000);
  }
}


function expandFrame(frameWidth)
{
  if(frameWidth < 100)
  {
    document.getElementById("BottomBar").style.width = frameWidth+'%';
    frameWidth+=4;
    document.getElementById("BottomBar").innerHTML='';
    var t=setTimeout("expandFrame("+frameWidth+")",5);
  }
  else
  {
    document.getElementById("BottomBar").style.width = '100%';
    document.getElementById("BottomBar").innerHTML= '\
    <div id="CollapseBtn">\
    <img src="http://images.sleeksearch.com/images/icons/cross1.png" onclick="collapseFrame(99);return false;" >\
    </div>' +getLinksDivs();
    setCookieBB('bbV', 1, 1000);
  }
}



function getLinksDivs()
{
  var bDivs= new Array()
  bDivs['fb']="http://www.facebook.com";
  bDivs['tw']="http://www.twitter.com";
  bDivs['gm']="http://www.gmail.com";
  bDivs['yh']="http://www.yahoo.com";
  bDivs['ym']="http://mail.yahoo.com";
  bDivs['gn']="http://news.google.com";
  bDivs['am']="http://www.amazon.com";
  bDivs['cn']="http://www.cnn.com";
  bDivs['li']="http://www.linkedin.com";
  bDivs['yt']="http://www.youtube.com";
  bDivs['bb']="http://www.bbc.com";
  bDivs['hm']="http://www.hotmail.com";
  bDivs['ao']="http://www.aol.com";

  var bVals = cookieVal('bottomLinks');
  if(bVals == null)
  {
    bVals = 'fb,tw,yh,gm,cn,am,bb,yt,li,gn,ym';
  }
  var vals = bVals.split(',');
  var divs = '';
  for(var i=0; i<vals.length; ++i)
  {
    divs += "<div class=bottomImgs><a href='"+ bDivs[vals[i]] +"' target='_"+vals[i]+"'><IMG BORDER=0 src='http://images.sleeksearch.com/images/icons/"+vals[i]+".png'></a></div>";
  }


  var flike = '<div style="float:right; width:350px; text-align:right; overflow:hidden;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2Fsleeksearch%2F103929272995752&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=dark&amp;height=21" scrolling="no" frameborder="0" style="border:none; valign:middle; overflow:hidden; width:450px; margin-top:0px; padding-top:0px; height:21px;" allowTransparency="true"></iframe></div>';
  divs += flike;

  var tweet = '<div style="float:right;padding-right:20px;"> <a href="http://twitter.com/share" class="twitter-share-button" data-count="none" data-via="sleeksearch">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> </div>';
  divs += tweet;
  return divs;// + "<a href='#' onclick='fadeOut(); return false;'>Fade</a>";

}

var _tmt;
function fadeDiv(id, op, dimm)
{
  var obj = document.getElementById(id);
  if(dimm == 0) //need to increase opacity
  {
    if(op < 100)
    {
      changeOpacity(obj, op);
      op += 10;
      clearTimeout(_tmt);
      _tmt = setTimeout(function(){fadeDiv(id, op , dimm)}, 20);
    }
  }
  else
  {
    if(op > 10)
    {
      changeOpacity(obj, op);
      op -= 10;
      clearTimeout(_tmt);
      _tmt = setTimeout(function(){fadeDiv(id, op , dimm)}, 100);
    }
  }
}

var fadded = 0;
function fadeOut()
{
  if(!fadded)
  {
    fadeDiv("BottomBar", 100, 1);
  }
  fadded = 1;
}

function fadeIn()
{
  if(fadded)
  {
    fadeDiv("BottomBar", 5, 0);
  }
  fadded = 0;
}

function changeOpacity(obj, op)
{
 if (obj.style.MozOpacity!=null){ obj.style.MozOpacity=(op/100)-.001; }
 else if (obj.style.opacity!=null){ obj.style.opacity=(op/100)-.001; }
 else if (obj.style.filter!=null){ obj.style.filter = 'alpha(opacity='+op+')';  }
}





function setCookieBB(name,value,days)
{
  var expires = "";
  if (days)
  {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    expires = "; expires="+date.toGMTString();
  }
  document.cookie = name+"="+value+expires+"; path=/";
}

function getCookieBB(name)
{
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=ca.length-1; i>=0 ;--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;
}

var _tmt1;
_tmt1 = setTimeout(fadeOut, 5000);
function showBottomBar()
{
  var c = getCookieBB('bbV');
  //alert(c);
  if(c != null && c==-1)
  {
    var bottomBar = "<div class=\"floating-menu\" onmouseout='clearTimeout(_tmt1); _tmt1 = setTimeout(fadeOut, 4000);' onmouseover='clearTimeout(_tmt1); fadeIn();' id =\"BottomBar\"></div>";
    document.write(bottomBar);
    document.getElementById("BottomBar").style.width = '12px';
    document.getElementById("BottomBar").innerHTML='<div id="ExpandBtn"><img src="http://images.sleeksearch.com/images/icons/right_arrow.png" onclick="expandFrame(1.5);return false;" ></div>';
  }
  else
  {
    var bottomBar = "<div class=\"floating-menu\" onmouseout='clearTimeout(_tmt1); _tmt1 = setTimeout(fadeOut, 4000);' onmouseover='clearTimeout(_tmt1); fadeIn();' id =\"BottomBar\">";
    document.write(bottomBar);
    document.write("<div id=\"CollapseBtn\"><img src=\"http://images.sleeksearch.com/images/icons/cross1.png\" onclick=\"collapseFrame(99);return false;\" ></div>");
    document.write(getLinksDivs()) ;
    document.write("</div>");
  }
  //changeOpacity(document.getElementById('BottomBar'), 10);
  //alert(document.cookie);
}



showBottomBar();
