/**
*	Author: Jarrett M. Barnett
*	E-mail: jarrett@mc2design.com
*	Company: MC2 Design Group, Inc.
*	Copyright (c) 2010
*	Last Modified: 2010-01-27
*/

/** NOTES:
 *      initCustomFuctions() initiates custom functions that extend jQuery's library.
 *      initSearch() makes search input field clear onfocus, only when search hasn't been performed.
 *      initExtlinks() initiates external linking rules, such as rel="external", and class="noclick".
 *   BUILT FOR JQUERY v1.3.2
 */


// jquery ready
$(function () {
//    initCustomFunctions();
//    initSearch();
    initExtlinks();
//    initLightbox();
});

function initCustomFunctions(){
    $.fn.delay = function(duration) {
        $(this).animate({ dummy: 1 }, duration);
        return this;
    };
}

function initSearch(){
    var _search = $('input#search');
    var _defaultvalue = "enter keywords";

    // On focus of search field, clear it unless user keywords exist
    _search.focus(function()
    {
        _searchvalue = $(this).val('');
        // only erase if user hasnt already performed a search
        if(_searchvalue == 'enter keywords') $(this).val('');
    });
}

function initExtlinks()
{
    var _extlinkclass = $('a:external');
    var _extlink = $('a[rel*="external"]');
    var _noclick = $('a.noclick');
    var _pdf = $("a[href*=.pdf]");

    // Creating custom :external selector
    $.expr[':'].external = function(obj){
        return !obj.href.match(/^mailto\:/)
                && (obj.hostname != location.hostname);
    },
        // Add 'external' CSS class to all external links
        _extlinkclass.attr('rel', 'external'),


    // Open External Links In New Window
    _extlink.click(function(){
        $(this).attr('target','_blank');
    }),

    // Links that have class of noclick not direct to target href
    _noclick.click(function() {
        return false;
    });

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

}

function initLightbox(){
                //Examples of how to assign the ColorBox event to elements
                $("a.gallerybox").colorbox();
}

