
// ----------------------------------------------
// StyleSwitcher functions written by Paul Sowden
// http://www.idontsmoke.co.uk/ss/
// - - - - - - - - - - - - - - - - - - - - - - -
// For the details, visit ALA:
// http://www.alistapart.com/stories/alternate/

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

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

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

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

function setVisibility(objectID,state) {
	var object = document.getElementById(objectID);
	object.style.visibility = state;
}



function toggleVisibility(objectID) {
	var object = document.getElementById(objectID);
	state = object.style.visibility;
	if (state == 'hidden')
		object.style.visibility = 'visible';
	else {
		if (state == 'visible')
			object.style.visibility = 'hidden'; 
	else object.style.visibility = 'visible';
	}
}





function popUp(event,objectID) {
         var nx = Number(50);
         var ny = Number(100);
				objPopTrig = document.getElementById(event);
				objPopUp = document.getElementById(objectID);
				xPos = objPopTrig.offsetLeft;
				yPos = objPopTrig.offsetTop + objPopTrig.offsetHeight;
				if (xPos + objPopUp.offsetWidth >  document.body.clientWidth) xPos = xPos - objPopUp.offsetWidth;
				if (yPos + objPopUp.offsetHeight >  document.body.clientHeight) yPos = yPos - objPopUp.offsetHeight - objPopTrig.offsetHeight;
				objPopUp.style.left = xPos + nx + 'px';
				objPopUp.style.top = yPos + ny + 'px';
				objPopUp.style.visibility = 'visible';
			}
			
			function popHide() {
				objPopUp.style.visibility = 'hidden';
				objPopUp = null;
			}

//

   function copyWrite() {
var c = "(c)T-ROC Equipment, L.L.C., All Rights Reserved";
document.write(c);
}

function webWorker() {
var _u = "mike";
var _d = "handuma.com";
var _l = _u + "@" + _d;
var _m = "Web page hand crafted by Michael Morgan";
document.write("<a href='mailto:" + _l + "'>" + _m +"</a>");
}

   function sendEmail() {
var _u = "&nbsp;info";
var _d = "trocequipment.com";
var _l = _u  + "@" + _d;
var _m = " Send us an Email&nbsp;&nbsp;<img src='gfx/mailbox2.gif' alt='Mail Box' width='120px' height='90px' title='Send us an email' />";
document.write("<a href='mailto:'" +  _l  + ">" +  _m  +  "</a>" );
}

   function map() {
var m1 = "<a href='http://maps.google.com/maps?f=q&hl=en&geocode=&q=1024+South+pyle,+Kansas+City,+Wyandotte,+Kansas,+United+States&sll=39.090101,-94.625931&sspn=0.033909,0.058365&num=10&iwstate1=sscorrectthiscard:ssmovemarkercard&iwloc=addr'>";
var m2 = "Find us on a Map &nbsp;&nbsp;";
var m3 = "<img src='gfx/map2.gif' alt='A map to T-ROC' title='T-ROC Equipment 1018 S. 7th St. KCK' width='91px' height='83px' /></a>";
document.write(m1 + m2 + m3);

}
