$(document).ready(function() {

    $("#nav li a.main-link").hover(
        function(){
            $("#nav li a.main-link").removeClass("active");
            $("#sub-nav-bar").hide();
            $(".sub-nav").hide();
            if($(this).next().hasClass("sub-nav")){
                $(this).addClass("active");
                $("#sub-nav-bar").css({
                        "display" : "block",
                        "height" : "40px"
                });
                $(".sub-nav").hide();
                $(this).siblings(".sub-nav").show();
            }
        },
        function(){
            if(!$(this).hasClass("active")){
                $("#sub-nav-bar").hide();
                $(".sub-nav").hide();
            }
        }
    );

    $('#slideshow')
        .cycle({
            fx:     'fade',
            speed:  700,
            timeout: 5000
    });
    $('.content-slideshow')
        .cycle({
            fx:     'fade',
            speed:  700,
            timeout: 5000
    });
		
    $('a[rel*=facebox]').facebox();

    

    /*_fontConfig = {
            outline :true, // Apply the outline effect
            outlineColor1 :"#FFF", // [find contrasting] The upper left outline color
            outlineColor2 :"#FFF", // [outlineColor1] the lower right outline color
            outlineWeight :1, // 1=light,2=normal,3=bold
            mirror :false, // Apply the mirror effect
            mirrorColor :"", // [object color] The color of the reflex
            mirrorOffset :-10, // The distance from text
            mirrorHeight :50, // The height of the reflex (perc.)*
            mirrorDetail :1, // The reflex detail 1=high,2=medium,3=low
            mirrorTLength :50, // The length of the sfumature (perc.)*
            mirrorTStart :0.2, // The starting opacity of the reflex (0-1)
            shadow :true, // Apply the shadow effect
            shadowColor :"#000",// The color of the shadow
            shadowOffsetTop :2, // The top offset position (px)
            shadowOffsetLeft:1, // The left offset position (px)
            shadowBlur :1, // The shadow blur 1=none,2=low,3=high
            shadowOpacity :0.1, // The opacity of the shadow (0=none,1=all)
            gradient :false, // Apply the gradient effect
            gradientColor :"", // The color of the gradient
            gradientPosition:20, // The start position of the gradient (perc.)*
            gradientLength :50, // The length of the gradient (perc.)*
            gradientSteps :20, // the steps of the gradient
            hideText :false // Hide the source text
    };
    $('.dropshadow').FontEffect(_fontConfig);*/

    $('.text').each(function() {
        var default_value = this.value;
        $(this).attr("title",default_value);
        $(this).focus(function(){
            if(this.value == default_value) {
                this.value = '';
            }
        });
        $(this).blur(function(){
            if(this.value == '') {
                this.value = default_value;
            }
        });
    });
        var fbConfig = {
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
                'padding' : 5
	}
	$("a[rel=fancybox]").fancybox(fbConfig);
	$("a[rel=fbox]").fancybox(fbConfig);

        $('.news-controls a.gallery-prev').addClass('disabled');
        if($("#headlines_holder li").length < 3) $('.news-controls a.gallery-next').addClass('disabled');
    $("#headlines_holder").jCarouselLite({
        btnNext: ".gallery-next",
        btnPrev: ".gallery-prev",
        visible: 3,
        vertical:true,
        circular:false
    });
    
});


var directionDisplay;
var directionsService = new google.maps.DirectionsService();
var map;

function initialize() {
    directionsDisplay = new google.maps.DirectionsRenderer();
    var chicago = new google.maps.LatLng(-25.9047456, 27.9129982);
    var myOptions = {
      zoom:13,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      center: chicago
    }
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    directionsDisplay.setMap(map);
}

function calcRoute() {
    var start = document.getElementById("start").value;
    var end = document.getElementById("end").value;
    var request = {
        origin:start,
        destination:end,
        travelMode: google.maps.DirectionsTravelMode.DRIVING
    };
    directionsService.route(request, function(response, status) {
      if (status == google.maps.DirectionsStatus.OK) {
        directionsDisplay.setDirections(response);
      }
    });
}

Cufon.replace('h2', { fontFamily: 'popp', hover: true });
Cufon.replace('h3', { fontFamily: 'popp', hover: true });
Cufon.replace('h6', { fontFamily: 'popp', hover: true });





