/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);


/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

/* SALOGIC CODE BEGIN */

    var SALOGIC = {};

    /* Begin IE6 warning code */
    SALOGIC.display_ie6alert = function() {
        var ie6msg = "<div class='ie6msg'><div class='closebutton'><a href='###'>close</a></div>" +
        "Hey there.<br />I couldn't help but notice you are using Internet Explorer 6.<br /><br />" +
        "Seriously?  IE6?<br />  Time to upgrade.<br /><br />"+
        "You see IE6 is outdated so I can't promise you'll get the best experience using it (here on my site or on the rest of the Internet) "+
        "and while developers can add extra little hacks to make it work, to me it just isn't worth the effort for my site.<br /><br />"+
        "Of course, you are welcome to use " +
        "whatever web browser you would like (even <a href='http://en.wikipedia.org/wiki/Lynx_(web_browser)'>lynx</a>) but " +
        "don't say I didn't warn you and please don't email me about how my website looks busted in Internet Explorer 6.<br /><br />" +
        "Hopefully, at this point you are saying,<br />\"OK, let's do it.  Let's upgrade my web browser.\"<br /><br />" +
        "I recommend the free open source browser " +
        "<a href='http://www.mozilla.com/firefox/'>Firefox</a>" +
        " but for those of you who love your Microsoft, you can get the latest version of Internet Explorer from<br />" +
        "<a href='http://www.microsoft.com/windows/internet-explorer/worldwide-sites.aspx'>Microsoft's Internet Explorer 8 download page</a>.<br /><br />" +
        "Thanks for visiting.<br /><br />- Sal" +
        "</div>";

        SALOGIC.ie6alert(ie6msg);
    
    }; // SALOGIC.display_ie6alert = function() {
    
    SALOGIC.ie6alert = function(ie6msg) {

        jQuery('body').prepend(ie6msg);
        
        // center div horizontally
        //var marg-left = jQuery(window).width());
        var marg_left = (jQuery(window).width()-600)/2;
        jQuery('.ie6msg').css('margin-left', marg_left);
    
        // assign event to closebutton
        jQuery('.ie6msg .closebutton').click(function(e) {
           // prevent following the link when clicked
    	   e.preventDefault();
    	   
        // set cookie ie6warning
        // this is so the user will only see the ie6warning once (as long as the cookie continues to exist)
        jQuery.cookie('ie6warning', 'true', { path: '/', expires: 10 });        


           jQuery('.ie6msg').slideUp();        
        }); //  jQuery('.ie6msg .closebutton').click(function(e) {        
    }; //  SALOGIC.ie6alert = function(ie6msg) {
   /* End IE6 warning code */

   /* Begin menu minimize/restore code */      
   SALOGIC.minmenu = function() {
        jQuery('.navmenu').slideUp('normal', function() {
        jQuery('.restoremenu').show();
            jQuery('.minmenu').hide();
        });        
        jQuery('.nav_container').animate({width: '5em'});
   }; // SALOGIC.minmenu
   
   SALOGIC.restoremenu = function() {
        jQuery('.nav_container').animate({width: '11em'});
        jQuery('.navmenu').slideDown();
        jQuery('.minmenu').show();
        jQuery('.restoremenu').hide();
   }; // SALOGIC.restoremenu  

   /* End menu minimize/restore code */
   
   
   
   

// code to execute when document loads (note: css may not be oaded yet)
jQuery(document).ready(function(){

    // if the browser is ie and ver 6 and cookie has NOT been set
    // cookie is checked so the user will only see the ie6warning once (as long as the cookie continues to exist)
    // cookie is assigned when user clicks "close" button on message
    if(jQuery.browser.msie && jQuery.browser.version.substr(0,2)=="6." && !$.cookie('ie6warning')) {
        
        SALOGIC.display_ie6alert();           
    }  // if(jQuery.browser.msie && jQuery.browser.version.substr(0,2)=="6.") {

    /* Contact Form Validation */
    $('.contact_form input.submit').click(function(e) {
      if ($('input[name=email]').val().search(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/) == -1) {
        // email address does NOT validate
        $('.emailerror').fadeIn();
        $('form.contact_form div.emailfieldname').css('backgroundColor', '#FF9C03');
        e.preventDefault();  // prevent following link
      }
    });

}); //jQuery(document).ready(function(){

// code to execute after everything (including css and images has loaded)
window.onload = function() {
    // code to reveal min button in menu and bind function to minimize
    // placed here b/c show in doc ready gets overwritten when css loads
    /*jQuery('.minmenu').show().find('a').click(function (e) { 
      e.preventDefault();  // prevent following link
      SALOGIC.minmenu(); 
    });
    jQuery('.restoremenu a').click(function(e) {
      e.preventDefault();  // prevent following link
      SALOGIC.restoremenu();
    })*/
    SALOGIC.minmenu();
    jQuery('.nav_container').hoverIntent(
        function() {
            SALOGIC.restoremenu();
        },
        function() {
            SALOGIC.minmenu();
        }
    );
    
}
/* SALOGIC CODE END */
