window.onload = function(){
  tgt = document.getElementsByTagName("a");
  for(var i = 0; i <tgt.length;i++){
  tgt[i].onfocus = function(){this.blur();}
	}
}

$(function() {
  offSetX = 15;
  offSetY = 10;
  $(".toptip").hover(function(e) {
		topTip = '#' + $(this).attr('class').split(' ').slice(-1);

		height = $(window).height();
		width = $(window).width();
		scrTop = $(window).scrollTop();
		scrLeft = $(window).scrollLeft();
		tipWidth = $(topTip).outerWidth();
		tipHeight = $(topTip).outerHeight();
		tipLeft = e.pageX + offSetX;
		tipTop = e.pageY + offSetY;
		
		if ((e.pageX - scrLeft + offSetX + tipWidth) > width) { tipLeft = e.pageX - offSetX - tipWidth; }
		if ((e.pageY - scrTop + offSetY + tipHeight) > height) { tipTop = e.pageY - offSetY - tipHeight; }
		
		$(topTip)			
			.css("top", tipTop + "px")			
			.css("left", tipLeft + "px")			
			.show();
		}, function() {	
			$(topTip).hide();	
			});

	$(".toptip").mousemove(function(e) {
		topTip = '#' + $(this).attr('class').split(' ').slice(-1);
		
		height = $(window).height();
		width = $(window).width();
		scrTop = $(window).scrollTop();
		scrLeft = $(window).scrollLeft();
		tipWidth = $(topTip).outerWidth();
		tipHeight = $(topTip).outerHeight();
		tipLeft = e.pageX + offSetX;
		tipTop = e.pageY + offSetY;

		if ((e.pageX - scrLeft + offSetX + tipWidth) > width) { tipLeft = e.pageX - offSetX - tipWidth; }
		if ((e.pageY - scrTop + offSetY + tipHeight) > height) { tipTop = e.pageY - offSetY - tipHeight; }

		$(topTip)			
			.css("top", tipTop + "px")			
			.css("left", tipLeft + "px");
	});
});

function slideSwitch() {
    var $active = $('#slideshow a.active');

    if ( $active.length == 0 ) $active = $('#slideshow a:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow a:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}
$(function() {
    setInterval( "slideSwitch()", 8000 );
});

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_openBrWindow(theURL,winName,popupwidth,popupheight) { //v2.0
  if (navigator.userAgent.indexOf('Safari') >= 0) {
    window.open(theURL,winName,'width=' + (popupwidth + 1) + ',height=' + (popupheight + 1) + ',resizable=yes');
  } else {
    window.open(theURL,winName,'width=' + popupwidth + ',height=' + popupheight + ',resizable=yes');
  }
}


