/**********************************************************************/
/*GLOBLIB.JS                                                          */
/*(C) 2009, JESSE JAMES HELFRICH                                      */
/*                                                                    */
/*This is the master javascript library for JesseHelfrich.net.        */
/*If you are poking around in my javascript, it must mean you want    */
/*to know how something works or are looking for inspriation.         */
/*                                                                    */
/*Feel free to draw inspiration from this, but directly copying my    */
/*code without attributing it to me will be a clear violation of my   */
/*copyright and Terms of Use. For more information, use my contact    */
/*form at http://www.jessehelfrich.net/contact.php.                   */
/*                                                                    */
/*This is my first major javascript application and, as such, much    */
/*of my inpiration is drawn from the book "Learning Javascript" by    */
/*Shelley Powers. I recommend it for novice developers.               */
/*                                                                    */
/**********************************************************************/

supLeft = 30;
globOpen = 0;

function openSup() {
   if(supLeft!=-370 && globOpen!=1) {
      supLeft-=50;
   }
   sup = document.getElementById("supp_box");
   sup.style.visibility = "visible";
   sup.style.left = supLeft + "px";
   if(supLeft>-370) {
      setTimeout("openSup()",30);
   } else {
      globOpen = 1;
   }
}

function closeSup() {
   supLeft+=50;
   sup = document.getElementById("supp_box");
   sup.innerHTML = "";
   sup.style.left = supLeft + "px";
   if(supLeft<30) {
      setTimeout("closeSup()",30);
   } else {
      sup.style.visibility="hidden";
      globOpen = 0;
   }
}

var xmlhttp = false;
if(window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
   //xmlhttp.overrideMimeType('text/xml');
} else if (window.ActiveXObject) {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} else {
   alert("Ajax not supported!");
}

function setAjax() {
var xmlhttp = false;
if(window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
} else if (window.ActiveXObject) {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} else {
   alert("Ajax not supported!");
}
   alert("HEY MAN!");
}

function whatSup(show) {
   var url = 'supp_display.php?show=' + show;
   xmlhttp.open('GET',url,true);
   xmlhttp.onreadystatechange = holdSup;
   xmlhttp.send(null);
}

function portfolioSup(item) {
   var url = 'portfolio_view.php?item=' + item;
   xmlhttp.open('GET',url,true);
   xmlhttp.onreadystatechange = holdSup;
   xmlhttp.send(null);
}

function iLike(id) {
   var url = 'supp_links.php?id=' + id;
   xmlhttp.open('GET',url,true);
   xmlhttp.onreadystatechange = holdSup;
   xmlhttp.send(null);
}

function flashSup(id) {
   var url = 'supp_flash.php?id=' + id;
   xmlhttp.open('GET',url,true);
   xmlhttp.onreadystatechange = holdSup;
   xmlhttp.send(null);
}

function showComs(id) {
   var url = 'supp_comments.php?do=show&id=' + id;
   xmlhttp.open('GET',url,true);
   xmlhttp.onreadystatechange = holdSup;
   xmlhttp.send(null);
}

function addComs(id) {
   var url = 'supp_comments.php?do=add&id=' + id;
   xmlhttp.open('GET',url,true);
   xmlhttp.onreadystatechange = holdSup;
   xmlhttp.send(null);
}

function holdSup() {
   openSup();
   if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      document.getElementById("supp_box").innerHTML = "<h1>Loading ...</h1>";
      setTimeout("dispSup()",900);
   }
}

function dispSup() {
   if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      document.getElementById("supp_box").innerHTML = xmlhttp.responseText;
      checkreCaptcha();
      checkForForms();
   }
}


function checkreCaptcha() {
   var theDiv = document.getElementById("recaptcha_div");
   if(theDiv) {
      Recaptcha.create("6LdAcgQAAAAAAMJqX610hKLijdolZ4HcTB98P9fv","recaptcha_div",{theme:"white"});
   }
}

function checkForForms() {
   if(document.forms[0]) {
      document.forms[0].elements[0].focus();
   } else {
      //do nothing
   }
}

function point_it(event){
   var theEvnt = event? event: window.event;
   var posX = theEvnt.screenX;
   var posY = theEvnt.screenY;
   document.getElementById("hm").style.top = posY + "px";
   document.getElementById("hm").style.left = posX + "px";
}

function hm(e) {
   var posx = 0;
   var posy = 0;
   if (!e) var e = window.event;
   if (e.pageX || e.pageY) 	{
      posX = e.pageX;
      posY = e.pageY;
   } else if (e.clientX || e.clientY) 	{
      posX = e.clientX + document.body.scrollLeft
             + document.documentElement.scrollLeft;
      posY = e.clientY + document.body.scrollTop
             + document.documentElement.scrollTop;
   }
 
   //SET DISPLAY
   var hmDiv = document.getElementById("hm");
   hmDiv.style.display = "block";
   hmDiv.style.top = (posY-70) + "px";
   hmDiv.style.left = (posX-158) + "px";
   ahm((posY-70),(posY-165));

   //SET CONTENT
   globOpen = 1;
   var url = 'hm.php?show=form';
   xmlhttp.open('GET',url,true);
   xmlhttp.onreadystatechange = function() {
				   if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      				      hmDiv.innerHTML = xmlhttp.responseText;
   				   }
   				}   				   
   xmlhttp.send(null);
}

function ahm(n,f) {
   var topn = n-10;
   document.getElementById("hm").style.top = topn + "px";
   if(topn>f) {
      setTimeout("ahm(" + topn + "," + f + ")",30);
   }
}

function chm() {
   document.getElementById("hm").style.display = "none";
}

//NEW STUFFffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

function blogSign() {
   blogSign = document.getElementById("subscribe_box");
   if(blogSign) {
      blogSignPos = -300;
      blogSign.style.left = blogSignPos + "px";
      blogSign.style.display = "block";
      blogSignMove();
   }
}

function blogSignMove() {
   if(blogSignPos<100) {
      blogSignPos+=10;
   }
   blogSign.style.left = blogSignPos + "px";
   if(blogSignPos<100) {
      setTimeout("blogSignMove()",30);
   } else {
      //do nothing;
   }
}

function setUp() {
   setWords();
   blogSign();
}

window.onload = setUp;
   

  
   

