/* This function checks the browser window on page load, if its less that 950px then switches to the */
/* stylesheet to the 800px version */
function GetWindowSize() {
	if (!document.getElementById) return false;
  	var myWidth = 0, myHeight = 0;
	
  	if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    //myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    //myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    //myHeight = document.body.clientHeight;
  }
	if (myWidth < 948) {
		
		//alert(myWidth);
		preparePlaceholder();
		
	}
}


/* Yet another little hack to stop IE6 background images flicker on hover .. I hate IE6 */
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

function insertAfter(newElement,targetElement) {
  var parent = targetElement.parentNode;
  if (parent.lastChild == targetElement) {
    parent.appendChild(newElement);
  } else {
    parent.insertBefore(newElement,targetElement.nextSibling);
  }
}
function preparePlaceholder() {
  if (!document.createElement) return false;
  if (!document.createTextNode) return false;
  if (!document.getElementById) return false;
  if (!document.getElementById("findme")) return false;
  var placeholder = document.createElement("link");
  placeholder.setAttribute("rel","stylesheet");
  placeholder.setAttribute("type","text/css");
  placeholder.setAttribute("media","screen");
  placeholder.setAttribute("href","/styles/800.css");
  var gallery = document.getElementById("findme");
  insertAfter(placeholder,gallery);
}

/* Sucker fish for shitty IE6 - Makes it understand the PSEUDO :hover class */
function startList() {
		if (!document.getElementById("nav")) return false;
		if (document.all&&document.getElementById) {
			navRoot = document.getElementById("nav");
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
					}
					node.onmouseout=function() {
						this.className=this.className.replace(" over", "");
					}
				}
			}
		}
	}



/* -------- Start Custom MooTools Functions ----------- */

function CreateTips() {
	var myTips = new Tips($$('.rssfeed'), {
	maxTitleChars: 50, 
	maxOpacity: .9, 
	timeOut: 500
	});
};

function CreateSearchSlider() {
var mySlide = new Fx.Slide('hpaccommsearch');
mySlide.toggle();

$('toggle').addEvent('click', function(e){
	e = new Event(e);
	mySlide.toggle();
	e.stop();
});

};

/* --------------- End MooTools functions ---------------- */

/* ############## CLEAR SEARCH BOX ############################ */
function doClear(theText) {
	if (theText.value == theText.defaultValue) {
         theText.value = ""
     }
 }


/* ------------------ CUSTOM ON PAGE LOAD ---------------------------------- */

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}


addLoadEvent(startList);
//addLoadEvent(GetWindowSize);