var blogxmlhttp;

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function startup()
{
    startChartLoop();
    searchstr.focus();
}

function startChartLoop()
{
    getChart();
    setTimeout('startChartLoop()', 8000);
}

function showSearchOptions()
{
    Effect.Appear(searchoptions, {duration: 0});
    Effect.Appear(hidesearchoptionsbar, {duration: 0});      
    Effect.Fade(showsearchoptionsbar, {duration: 0});
    Effect.Fade(xtoolbar, {duration: 0});      
}

function hideSearchOptions()
{
    Effect.Fade(searchoptions, {duration: 0});
    Effect.Fade(hidesearchoptionsbar, {duration: 0});    
    Effect.Appear(showsearchoptionsbar, {duration: 0});      
    Effect.Appear(xtoolbar, {duration: 0});      
}

function getBlog()
{
    //document.getElementById("searchdata").innerHTML="<iframe src=\http://localhost:8888/blogs/></iframe>";
    document.getElementById("searchdata").innerHTML="<object class=blog id=foo name=foo type=text/html data=http://kissmarrykill.com/blogs/jessica-simpson><\/object>";
}

function postComment(id,kisstype,kissnamestr,str)
{
    blogxmlhttp=GetBlogXmlHttpObject();
    if (blogxmlhttp==null)
    {
        alert ("Browser does not support HTTP Request");
    return;
    }
    var posturl="/updateblog.php";
    posturl=posturl+"?id="+id+"&comment="+str+"&kisstype="+kisstype+"&kissnamestr="+kissnamestr;
    window.location = posturl;
    exit();
    
    //posturl=posturl+"&sid="+Math.random();
    blogxmlhttp.onreadystatechange=commentstateChanged;
    blogxmlhttp.open("POST",posturl,true);
    blogxmlhttp.send(null);
    
}

function commentstateChanged()
{
    if (kissxmlhttp.readyState==4)
    {
        //window.location = "search.php";
        //document.getElementById("kissid1").innerHTML=blogxmlhttp.responseText;
        //document.getElementById("instructions"+instructidu).innerHTML=kissinstruction;
        //setTimeout('document.getElementById("instructiontextbox1").Focus();', 3000);
    }
}

function GetBlogXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

function encode_cookie(cookie_value) {
  var coded_string = ""
  for (var counter = 0; counter < cookie_value.length; counter++) {
    coded_string += cookie_value.charCodeAt(counter)
    if (counter < cookie_value.length - 1) {
      coded_string += "+"
    }
  }
  return coded_string
}

function decode_cookie(coded_string) {
  var cookie_value = ""
  var code_array = coded_string.split("+")
  for (var counter = 0; counter < code_array.length; counter++) {
    cookie_value += String.fromCharCode(code_array[counter])
  }
  return cookie_value
}

function hpShowHide(whichdiv) {
    //alert (whichdiv);
    document.getElementById('hpbio').style.display = 'none';
    document.getElementById('hpcomments').style.display = 'none';
    document.getElementById('hpnews').style.display = 'none';
    document.getElementById('hpphotos').style.display = 'none';
    document.getElementById('hpvideos').style.display = 'none';
    document.getElementById(whichdiv).style.display = 'block';
    document.getElementById('hpb').style.backgroundColor = 'white';
    document.getElementById('hpc').style.backgroundColor = 'white';
    document.getElementById('hpn').style.backgroundColor = 'white';
    document.getElementById('hpp').style.backgroundColor = 'white';
    document.getElementById('hpv').style.backgroundColor = 'white';
    if (whichdiv=='hpbio') document.getElementById('hpb').style.backgroundColor = '#ffbac8';
    if (whichdiv=='hpcomments') document.getElementById('hpc').style.backgroundColor = '#ffbac8';
    if (whichdiv=='hpnews') document.getElementById('hpn').style.backgroundColor = '#ffbac8';
    if (whichdiv=='hpphotos') document.getElementById('hpp').style.backgroundColor = '#ffbac8';
    if (whichdiv=='hpvideos') document.getElementById('hpv').style.backgroundColor = '#ffbac8';
}

function getCheckAttr()
{
    //echo $TSTS;
    return "hello";
}

var hWidth, bWidth;

function setBgPos(v) {
    var off = v * hWidth;
    var pos = -bWidth + (v * bWidth);
    $('slider').setStyle({backgroundPosition: Math.round(pos - off) + 'px'});
}

function setSlideOutput(v) {
    $('percent').innerHTML = Math.round(v * 100) + '%';
}

function insertNavigation () {
    document.write('hello');
}