// Vantage Scripts

$.noConflict();

jQuery(document).ready(function($) {

	// Typekit loader
	try{Typekit.load();}catch(e){}

	// Navigation
	$("ul.AspNet-Menu li").hover(function(event){
      $(this).addClass("over");
	}, function(){
      $(this).removeClass("over");
	});
	
	// Navigation icons
    var ext = jQuery('ul.AspNet-Menu a').filter(function() { return this.hostname && this.hostname !== location.hostname; });
    var links = jQuery("ul.AspNet-Menu li a");

    ext.after('<span class="external"></span>');

    jQuery("ul.AspNet-Menu > li:has('ul')").each(function(){
		jQuery(this).find("a:first").after('<span class="down-arrow"></span>');
    });

    jQuery("ul.AspNet-Menu ul.AspNet-Menu > li:has('ul')").each(function(){
		jQuery(this).find("span.down-arrow").remove();
		jQuery(this).find("a:first").after('<span class="side-arrow"></span>');
    });

    links.hover(function(){
		jQuery(this).next('span').addClass('hover')
    }, function(){
		jQuery(this).next('span').removeClass('hover')
    });
	
	// Print stylesheet switcher
	$('#printable-button').show().toggle(function() {
		$("link[media=screen]").attr({href : "assets/css/vantageprint.css"});
		$(this).removeClass('viewprint').addClass('viewnonprint').text('View normal version');
		$('#content').removeClass().addClass('clear span-24 last');
		$('#actionbar').removeClass().addClass('clear span-24 last');
		return false;
	}, function() {
		$("link[media=screen]").attr({href : "assets/css/vantage.css"});
		$(this).removeClass('viewnonprint').addClass('viewprint').text('View printable version');
		$('#content').removeClass().addClass('prepend-1 span-11 append-1');
		$('#actionbar').removeClass().addClass('clear span-17');
		return false;
	});

	$('#print-button').click(function() {
		window.print();
		return false;
	});
	
	$('#loading').show();
	
	$("#iframeForm").load(function (){
		$('#loading').fadeOut('fast');
	});


});

