$(document).ready(function() 
{
$('#morange').bt({ ajaxPath: ["$(this).attr('bt-xtitle')", 'div#content'],spikeLength: 10, spikeGirth: 20,cornerRadius: 10,fill: 'rgba(247, 148, 30, .9)',strokeWidth: 0,centerPointX:.2,padding:'10px'});
$('#mblue').bt({ ajaxPath: ["$(this).attr('bt-xtitle')", 'div#content'],spikeLength: 10, spikeGirth: 20,cornerRadius: 10,fill: 'rgba(204, 219, 232, .9)',strokeWidth: 0,centerPointX:.2,padding:'10px'});
$('#myellow').bt({ ajaxPath: ["$(this).attr('bt-xtitle')", 'div#content'],spikeLength: 10, spikeGirth: 20,cornerRadius: 10,fill: 'rgba(255, 241,161, .9)',strokeWidth: 0,centerPointX:.2,padding:'10px'});
$('#msand').bt({ ajaxPath: ["$(this).attr('bt-xtitle')", 'div#content'],spikeLength: 10, spikeGirth: 20,cornerRadius: 10,fill: 'rgba(227, 219,179, .9)',strokeWidth: 0,centerPointX:.2,padding:'10px'});

});

jQuery.bt.defaults.closeWhenOthersOpen = true;
//jQuery.bt.defaults.hoverIntentOpts = {interval: 200,timeout: 1200};
//jQuery.bt.defaults.trigger = 'focus';
jQuery.bt.defaults.trigger = ['mouseover', 'focus'];
jQuery.bt.defaults.overlap = 5;
jQuery.bt.defaults.windowMargin = 100;




//Hiding menu by checking the mouse position
jQuery(document).ready(function(){
   $(document).mousemove(function(e){

	var mouseX=parseInt(e.pageX);
	var mouseY=parseInt(e.pageY);

	//Compares the mouse X position to and closes all menu pop-ups if outside of their range.
	var xPositionOfMenu=jQuery('#Left_Menu').offset().left;
	var menuWidth=420;

	if (mouseX > xPositionOfMenu+menuWidth || mouseX<xPositionOfMenu)
		closeAlltips();

	//Compares the yposition of the mouse to the location of the menu pop-ups
	

	if ($("#msand").length > 0){
		var yPositionOfSand=jQuery('#msand').offset().top;

		var sandHeight=document.getElementById('msand').offsetHeight;
		if (mouseY+35 < yPositionOfSand || mouseY > yPositionOfSand+sandHeight+35)
			$('#msand').btOff();
	}

	if ($("#myellow").length > 0){
		var yPositionOfYellow=jQuery('#myellow').offset().top;
		var yellowHeight=document.getElementById('myellow').offsetHeight;
		if (mouseY+35 < yPositionOfYellow || mouseY > yPositionOfYellow+yellowHeight+35)
			$('#myellow').btOff();
	}

	if ($("#mblue").length > 0){
		var yPositionOfBlue=jQuery('#mblue').offset().top;
		var blueHeight=document.getElementById('mblue').offsetHeight;
		if (mouseY+35 < yPositionOfBlue || mouseY > yPositionOfBlue+blueHeight+35)
			$('#mblue').btOff();
	}

	if ($("#morange").length > 0){
		var yPositionOfOrange=jQuery('#morange').offset().top;
		var orangeHeight=document.getElementById('morange').offsetHeight;
		if (mouseY+35 < yPositionOfOrange || mouseY > yPositionOfOrange+orangeHeight+95)
			$('#morange').btOff();
	}
   }); 

})


function closeAlltips()
{
	$('#msand').btOff();
	$('#myellow').btOff();
	$('#mblue').btOff();
	$('#morange').btOff();
}


function initLinks() {
  for (i in document.links) {
    link = document.links[i];
    if (link.rel && link.rel.indexOf('external')!=-1) {
      link.onclick = onExternalLinkActivate;
      link.onkeypress = onExternalLinkActivate;
    }
  }
}

function onExternalLinkActivate() {
  window.open(this.href);
  return false;
}

window.onload = initLinks;
