function initPage() {
   fixFrameRail();
   fixFloor();
   fixFramePadding();
   fixRip();
   fixFloormarkTop();
   setFloorMark('Home');
   fixLogo();
   fixValidated();
   fixDev();
}

function fixDev() {
   totalHeight = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
   totalHeight = parseInt(totalHeight);
   
   left = 20;
   topz = totalHeight - (110+48+122-2-60);
   topp = topz+"px";
   
   $('#dev').css({'left' : '20px'});
   $('#dev').css({'top' : topp});
}

function fixFrameRail() {
   floorHeight = 110+48;
   
   totalHeight = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
   totalHeight = parseInt(totalHeight);
   
   frameHeight = 437;
   
   offsetFrame = ((totalHeight-floorHeight)/2)-(frameHeight/2);
   
   document.getElementById("main").style.paddingTop = offsetFrame+"px";
}

function fixFloor() {
   floorHeight = 110+48;
   
   totalHeight = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
   totalHeight = parseInt(totalHeight);
   
   offsetFloor = totalHeight - floorHeight;
   offsetFloor = offsetFloor+"px";
   
   document.getElementById("floor").style.top = offsetFloor;
}

function fixFramePadding() {
   frameWidth = 654;
   newX = getWindowCenter() - (frameWidth/2);
   newX = newX+"px";
   document.getElementById("frameHomeNull").style.marginLeft = newX;
   document.getElementById("frameSitesNull").style.marginLeft = newX;
   document.getElementById("frameAppsNull").style.marginLeft = newX;
   document.getElementById("frameContactNull").style.marginLeft = newX;
}

function fixFloormarkTop() {
   totalHeight = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
   totalHeight = parseInt(totalHeight);
   hi = totalHeight - 151 - 14;
   
   document.getElementById("floormark").style.top = hi+"px";
}

function fixRip() {
   totalHeight = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
   totalHeight = parseInt(totalHeight);
   
   left = 200;
   topz = totalHeight - (110+48+122-2);
   topp = topz+"px";
   
   $('#rip').css({'left' : '200px'});
   $('#rip').css({'top' : topp});
}

function fixLogo() {
   xpos = (getWindowCenter()*2)-732;
   xpos = xpos+"px";
   $("#logo").css({'left' : xpos});
}

function fixValidated() {
   w = (typeof window.innerWidth != 'undefined' ? window.innerWidth : document.body.offsetWidth);
   w = parseInt(w);
   
   h = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
   h = parseInt(h);
   
   xpos = w-204-36; xpos = xpos+"px";
   ypos = h-72; ypos = ypos+"px";
   $("#validated").css({'top':ypos});
   $("#validated").css({'left':xpos});
}

function getWindowCenter() {
   w = (typeof window.innerWidth != 'undefined' ? window.innerWidth : document.body.offsetWidth);
   w = parseInt(w/2);
   return w;
}

function btnHov(btn) {
   btnObj = document.getElementById("btn"+btn);
   getPath = btnObj.src;
   finalPath = getPath.match(/[-_\w]+[.][\w]+$/i)[0];
   if (finalPath == "btn"+btn+".png") finalPathStr = "btn"+btn+"H.png";
   if (finalPath == "btn"+btn+"H.png") finalPathStr = "btn"+btn+".png";
   document.getElementById("btn"+btn).src = "images/"+finalPathStr;
}

function goFr(fra) {
   $.scrollTo('#frame'+fra,1500);
   setFloorMark(fra);
}

function setFloorMark(frame) {
   switch(frame) {
      case 'Home':
         lo = getWindowCenter() - 164;
         break;
      case 'Sites':
         lo = getWindowCenter() - 57;
         break;
      case 'Apps':
         lo = getWindowCenter() + 41;
         break;
      case 'Contact':
         lo = getWindowCenter() + 149;
         break;
   }

   $("#floormark").animate({"left": lo}, 500);
   fixFloormarkTop();
}

function checkBrowser() {
   if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))
      nullllll = 0;
   else
      location.href="nope.htm";
}

function launchResume(ext) {
   location.href = "resume."+ext;
}

function openWin(wnd) {
   $('#'+wnd).dialog('open');
}

function contactSendHover(which) {
   if (which == 1) {
      document.getElementById("contactSendBtn").src = "images/sendH.png";
   } else {
      document.getElementById("contactSendBtn").src = "images/send.png";
   }
}

function sendContactMsg() {
   get1 = encodeURIComponent(document.getElementById('contactName').value);
   get2 = encodeURIComponent(document.getElementById('contactMsg').value);
   
   if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }
      else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
   xmlhttp.open("GET","msg.php?yourname="+get1+"&msg="+get2,false);
   xmlhttp.send(null);
   text = xmlhttp.responseText;
   
   document.getElementById('contactResult').style.display = "none";
   document.getElementById('contactResult').innerHTML = text;
   $('#contactResult').fadeIn(500);
   
   document.getElementById('contactName').value = "";
   document.getElementById('contactMsg').value = "";
}
