function breadcrumbs() {
	var url = "www.angelo.edu";	// Enter your domain name here, 
	var home = "Home";			// Enter the word you want to use to describe the home page of your site
	var divide = "";			// Enter the character(s) you want to use to separate your breadcrumbs
	var pre = "";				// Enter text you'd like to see.  You can make this blank as well - "";
	var ext = ".php";			// Enter the extension you use for your pages
	var root = "index";			// Enter the default file name you use for the root file of your folders
	divide = " " + divide + " ";
	var a = "" + window.location;
	var b = "";
	var bar = divide + root;
	var crumbs = "";
	var foo = root + ext;
	var left = "";
	var counter = 0;
	a = a.replace(ext,"");
	left = a.lastIndexOf("/");
	if (a.substring(a.lastIndexOf("/")) == "/") {
		a = a + root;
	}
	b = a.substring(left+1);
	b = b.replace(/_/g," ");
	b = b.replace(/#/g,divide);
	b = "/" + b
	b = b.replace(divide,"#");
	b = b.replace(/ /g,"_");
	a = a.replace(b,"");
	if (a.substring(left-1) != "/") {
		do  {
			left = a.lastIndexOf("/");
			b = a.substring(left+1);
			b = b.replace(/_/g," ");
			if (a.substring(left-1,left) != '/') {
				crumbs = "<li><a href=\"" + foo + "\">" + b + "</a></li>" + crumbs;
			} else {
				crumbs = "<li class='first'><a href=\"" + foo + "\">" + b + "</a></li>" + crumbs;
			}
			foo = "../" + foo;
			b = "/" + b;
			b = b.replace(/ /g,"_");
			a = a.replace(b,"");
			counter ++;
		} while (a.substring(left-1) != "/");
	}
	crumbs = crumbs.replace(url,home);
	crumbs = crumbs.replace(bar,"");
	crumbs = (crumbs.substring(crumbs.indexOf("<")));
	crumbs = pre + crumbs;
	var bread_title = '<li class="last">'+document.title+'</li>';
	crumbs = '<ul>' + crumbs + divide + bread_title + '</ul>';   // add document title to breadcrumb
	jQuery('#breadcrumbs').html(crumbs);
}

function getTimeStamp() {
	var aDate = new Date();
	var stamp = aDate.getTime();
	return stamp;
}

function clearText(thefield){
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
}
function resetText(thefield) {
	if (thefield.value=="")
	thefield.value = thefield.defaultValue
}

function sizeFloats() {
	var lists = jQuery(".floatList");
	for (var i=0; i<lists.length; i++) {
		var firstItemInRow = 0;
		var items = jQuery(lists[i]).children();
		var height = jQuery(items[0]).height();
		for (var j=1; j<items.length; j++) {
			if (jQuery(items[j]).position().top == jQuery(items[j-1]).position().top) {
				if (jQuery(items[j]).height() > height) {
					height = jQuery(items[j]).height();
				}
			}
			else {
				height = jQuery(items[j]).height();
				firstItemInRow = j;
			}
			for (var k=firstItemInRow; k<=j; k++) {
				jQuery(items[k]).css('height', height+"px");
			}
		}
	}
}

function loadImages() {
	var loadimages = jQuery('.loadimage');
	for (i=0; i<loadimages.length; i++) {
		var src = jQuery(loadimages[i]).attr('href');
		var alt = jQuery(loadimages[i]).html();
		jQuery(loadimages[i]).replaceWith('<img src="'+ src +'" alt="'+ alt +'" />');
	}
}

function toggleBoxes() {
	var toggles = jQuery('.expandable');
	for(i=0;i<toggles.length;i++) {
		var toggle = jQuery(toggles[i]).children(":first-child");
		if (jQuery(toggles[i]).hasClass('open')) {
			jQuery(toggles[i]).addClass('expanded');
		} else {
			jQuery(toggles[i]).addClass('collapsed');
		};
		toggle.addClass('toggle').click(function(){
			jQuery(this).parent().toggleClass('collapsed').toggleClass('expanded');
		});
	}
}

function initNavs() {
	jQuery('#sideBar li').has('ul').addClass('more');
	jQuery('#sideBar li.lw_separator').not(':has(li)').addClass('separator');
	jQuery('#sideBar a[href="#"]').addClass('anchor');
	jQuery('#sideBar li a').filter(function() {
		return this.hostname && this.hostname !== location.hostname;
	}).addClass('external').attr('target', '_blank');
	jQuery('#pageContent .lw_widget a').filter(function() {
		return this.hostname && this.hostname !== location.hostname;
	}).addClass('external').attr('target', '_blank');
	jQuery('#sidebarRight .lw_widget a').filter(function() {
		return this.hostname && this.hostname !== location.hostname;
	}).addClass('external').attr('target', '_blank');
	jQuery('a[href$="/class_schedule/"]').addClass('external').attr('target', '_blank');
	jQuery('a[href$="/request_info/"]').addClass('external').attr('target', '_blank');
	jQuery('a[href$="/graduate_application/"]').addClass('external').attr('target', '_blank');
}

function hideRegistrants() {
	if (jQuery('.hideRegistrants').length) {
		jQuery("input[name='events_registrations_attending']").val('1').closest('tr').hide();
	}
}

function italicize() {
	if (jQuery("#template_group").length) jQuery("#template_group").html(jQuery("#template_group").html().replace(' of ', ' <i>of</i> '));
}

Shadowbox.init({continuous: "true",overlayColor: "#021827",overlayOpacity: .9});

jQuery(document).ready(function() {
	//make content narrower for pages still using the old "news and announcements" box
	if (jQuery('#audience').length || jQuery('#audienceCore').length) {
		jQuery('#content').addClass("narrowContent");
	}
	initNavs();
	//add class to any sidebar headers that contain an image
	//jQuery('#content .header').has('img').addClass('withImage');
	//replace links to images in slideshows with the actual image
	loadImages();
	//setup up cycle slideshow on anything with the crossfade class
	jQuery('.crossfade').cycle({ fx: 'fade', speed: 2000, timeout: 5000, random: 0, pause: 1 });
	//set up zebra-striping for tables with class of style1
	jQuery("table.style1 tbody tr:even").addClass("even");
	jQuery("table.style1 tbody tr:odd").addClass("odd");
	//set up toggle boxes
	toggleBoxes();
	//set up tabs
	jQuery('.tabs').tabs({ cookie: { expires: 1 } });
	breadcrumbs();
	hideRegistrants();
	italicize();
	jQuery("#footer .lw_subnav_toggle").removeClass("lw_subnav_toggle").click(function(event) { event.preventDefault(); });
	jQuery("#globalNav .lw_subnav_toggle").removeClass("lw_subnav_toggle").click(function(event) { event.preventDefault(); });
	jQuery("#sideBar .lw_subnav_toggle").removeClass("lw_subnav_toggle").click(function(event) { event.preventDefault(); });
});
jQuery(window).load(function() {
	//set up .floatList items to be equal height per row
	sizeFloats();
	Shadowbox.setup(".lw_gallery_shadowbox .thumbnails li a", {gallery: "group"});
});
