/*
	Mailstreet scripts (utilizing jQuery 1.3.2)
	Developed by Foamcube | TAW(theassociatedweb.com) tdblanchard
*/

/* --- Initialize page --- */
$(document).ready(function(){

//   Browser sniffers
//~~~~~~IE7

if ($.browser.msie) {
	$("html").addClass("browser-ie7")
	.addClass("browser-ie");
	}
//~~~~~~IE6
if ($.browser.msie && $.browser.version < 7) {
	$("html")
	.removeClass("browser-ie7")
	.addClass("browser-ie6");
	}
//~~~~~~Firefox
if ($.browser.mozilla) {
	$("html").addClass("browser-firefox");
	}
//~~~~~~Safari
if ($.browser.safari) {
	$("html").addClass("browser-safari");
	}



	// Stripe row colors
	$("table.data tr:nth-child(even)").not(".even").not(".odd").addClass("even");
	
	// Column childs CSS3 fix
	$(".columns .col:last-child").addClass("last-child");
	$(".columns .col:first-child").addClass("first-child");
	$(".columns.three .col:eq(1)").addClass("middle-child");
	
	$("#second-notch td:first-child").addClass("first");

	// IE6 helper functions
	if ($.browser.msie && $.browser.version < 7) {

	}


//inject title attribute with text of link
$("a.title-injector, #home-wrap-nav li a, #footer a, #cycle-belt a").each(function(){
   $(this).attr("title", $(this).text());
});

// add hover class
$("#sidenav ul li ul li, #primary-nav ul li, #utility-nav ul>li").hover(function(){
		$(this).addClass("hover");
	}, function(){
		$(this).removeClass("hover");
	});

$("#utility-nav ul>li").each(function(i){
	$(this).addClass("item-" + i);
});

$("#sidenav>ul>li.with-third>a").click(function() {
		$(this).parents("li")
		.toggleClass("on")
		.find("ul").stop()
		.animate({"opacity": "toggle"
		}, "fast");
		return false;

	});


//education bucket bubble flyout

$("#education-bucket div.bubble").each(function(){
   $(this)
   .wrapInner("<div class='bubble-wrap'></div>")
   .parent().addClass("bubbled");
});

if ($.browser.msie) {
$("#education-bucket ul li").hover(function() {
		$(this).find("div.bubble").stop()
		.css("display","block")

	}, function() {
		$(this).find("div.bubble").stop()
		.css("display","none")
	});


	}
	else{

// everyone except IE gets the fade...sorry IE :(
$("#education-bucket ul li").hover(function() {
		$(this).find("div.bubble").stop()
		.animate({opacity:1}, "fast")
		.css("display","block")

	}, function() {
		$(this).find("div.bubble").stop()
		.animate({opacity: 0
		}, "fast")
		.css("display","none")
	});
	
	}


// tabbed belt area

if (document.getElementById("sub-belt-buckle")) {
$('#cycle-belt')	.cycle({ 
    fx:     'scrollHorz',
    speed:  '1200', 
    timeout: 12000, 
    pause: true,
    pager:  '#cycle-belt-ctrl', 
    pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
        return '#cycle-belt-ctrl li:eq(' + idx + ')'; 
    } 
});
};

if (document.getElementById("home-top-photo-area")) {
$('#top-photo-cycle').cycle({ 
    fx:     'scrollHorz', 
    speed:  '1200',
    timeout: 12000,
    pause: true,
    cleartype: true,
    cleartypeNoBg: true,
    pager:  '#home-wrap-nav',
    pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
        return '#home-wrap-nav li:eq(' + idx + ')'; 
    }
});
};




		$("#layout-switch a").click(function () {			
			$("#content")
			.toggleClass("with-sidebar")
			.toggleClass("no-sidebar")
			$("#sidebar").toggle();
			
		  return false;
		});
//



	/*
show/hide more-text
*/

$("a.show-toggle").click(function () {
		$(this).parents().next(".more-text").toggle();
		return false;
});


$("a.show-more").click(function () {
		$(this).parents().next(".more-text").show();
		return false;
});

$("a.hide-more").click(function () {
		$(this).parents(".more-text").hide();
		return false;
		
		
});


//tabbed phone box
// When a link is clicked
		$("ul.tabs>li>a").click(function () {
			
			// switch all tabs off
			$("ul.tabs>li .active").removeClass("active");
			
			// switch this tab on
			$(this).addClass("active");
			
			// slide all elements with the class 'tabbed-content' up. if you have more than one instance of this function on a page, you need to specify by traversing...tdb
			$(".tabbed-content").hide();
			
			// Now figure out what the 'rel' attribute value is and find the element with that id.  Then slide that down.
			var content_show = $(this).attr("rel");
			$("#"+content_show).show();
		  return false;
		});


//

		$("#layout-switch a").click(function () {			
			$("#content")
			.toggleClass("with-sidebar")
			.toggleClass("no-sidebar")
			$("#sidebar").toggle();
			
		  return false;
		});
//


});//end docready







/* IE PNG fix multiple filters */
(function ($) {
    if (!$) return;
    $.fn.extend({
        fixPNG: function(sizingMethod, forceBG) {
                if (!($.browser.msie)) return this;
                var emptyimg = "/_images/empty.gif"; //Path to empty 1x1px GIF goes here
                sizingMethod = sizingMethod || "scale"; //sizingMethod, defaults to scale (matches image dimensions)
                this.each(function() {
                        var isImg = (forceBG) ? false : jQuery.nodeName(this, "img"),
                                imgname = (isImg) ? this.src : this.currentStyle.backgroundImage,
                                src = (isImg) ? imgname : imgname.substring(5,imgname.length-2);
                        this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + sizingMethod + "')";
                        if (isImg) this.src = emptyimg;
                        else this.style.backgroundImage = "url(" + emptyimg + ")";
                });
                return this;
        }
    });
})(jQuery);




/* Webparts Tabbed Box */

/*
--tabbed table box--
*/
$(".tabbed-table-wrap>div:first-child, .tabbed-table-wrap ul.table-tabs>li:first-child").addClass("first");
$(".tabbed-table-wrap>div:last-child, .tabbed-table-wrap ul.table-tabs>li:last-child").addClass("last");

$("ul.table-tabs>li>a").click(function () {
	var content_show = $(this).attr("rel");
			// switch this tab on
			$("ul.table-tabs>li>a.active").removeClass("active");
			$(this).parent().parent().siblings(".tabbed-table-content").hide();
			// switch this tab on
			$(this).addClass("active");
			$("#"+content_show).fadeIn();
			
		  return false;
		});


//$("table.package-data tr.details").after("<tr><td></td></tr>");
//stripe the rows
$("table.package-data tr:nth-child(even)").not(".even").not(".odd").addClass("even");

$("table.package-data tr td:first-child").addClass("first");

$("tr.with-details>td").hover(function(){
				$(this).addClass("hover");
			}, function(){
				$(this).removeClass("hover");
			});
$("tr.with-details>td").click(function () {
var theDetails = $(this).parents().children().children(".details")
if (theDetails.is(":hidden")){
		$(theDetails).show();
		$(this).parents("tr").addClass('showing');
}
else {
		$(theDetails).hide();
		$(this).parents("tr").removeClass('showing');
}
		  return false;
});




