/*
 * Title: Brian Lock Racing Site Common Javascript
 * Author: Rubeun S. Tan
 * Updated: July 27st, 2009
 *
 */

// init the $racing namespace. All functions should be part of this namespace
var $racing = window.$racing || {};  

//
// createLink(): Given a jQuery selector and a URL, add an onclick event that 
// lets you click on a div to go to a new page 
//
$racing.createLink = function(cssSelector, url) {
	$(cssSelector).click(function() { 
		if ($(this).hasClass('external')) {
			window.open( url );
        	return false;
		} else {
			location.href=url;
		}
	});
}


$racing.initScrollable = function() {
    // initialize scrollable  
    $("div.scrollable").scrollable({ 
             
        // items are auto-scrolled in 2 secnod interval 
        interval: 2000, 
         
        // when last item is encountered go back to first item 
        loop: true,  
         
        // make animation a little slower than the default 
        speed: 600, 
         
        // when seek starts make items little transparent 
        onBeforeSeek: function() { 
            this.getItems().fadeTo(300, 0.2);         
        }, 
         
        // when seek ends resume items to full transparency 
        onSeek: function() { 
            this.getItems().fadeTo(300, 1); 
        } 
    });     

}


$(document).ready( function() {
   
    $('A[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });

	droplinemenu.buildmenu("droplinetabs1");    
        
    // insert a tooltip span that tells you that you're leaving the site
    // class='warning' can be applied to anything other than a link
    // class='warningLink' should only be applied to <a> tags, as it is needed to keep IE6 happy
    $('.warning, a.warningLink').append("<span>You are now exiting this web site.  Brian Lock Racing is not responsible for the content or data collection of the website you are about to go to.</span>");
    $('.warning span').addClass('externalTooltip');	// only add externalTooltip class to the 'warning' objects (not the 'warningLink' objects)
    												// because IE6 has a hissy fit if the span inside the warningLink object has a class
});