

$(document).ready(function(){
	
	if($.browser.msie && $.browser.version=="6.0"){
	
	}else{
		
		FLIR.init({ path: '/assets/facelift/' });
		
		$("#home2collay .content h3").each( function() { FLIR.replace(this, new FLIRStyle({output:'gif',cBackground:'white'}) ); } );
		
		$(".homeRightCol h1").each( function() { FLIR.replace(this, new FLIRStyle({output:'gif',cBackground:'white', mode:'wrap'}) ); } );
		$(".homeRightCol h2").each( function() { FLIR.replace(this, new FLIRStyle({output:'gif',cBackground:'white',  mode:'wrap', cFont:'itcfdc'}) ); } );
		$(".homeRightCol h2 a").each( function() { FLIR.replace(this, new FLIRStyle({output:'gif',mode:'wrap',cBackground:'white', cFont:'itcfdc'}) ); } );
		$(".homeRightCol h3").each( function() { FLIR.replace(this, new FLIRStyle({output:'gif',cBackground:'white', mode:'wrap'}) ); } );
		$(".homeRightCol h3 a").each( function() { FLIR.replace(this, new FLIRStyle({output:'gif',cBackground:'white', mode:'wrap'}) ); } );
		
		$("#ningbo2collay .content h3").each( function() { FLIR.replace(this, new FLIRStyle({output:'gif',cBackground:'white'}) ); } );
		$("div.menuv3header h3").each( function() { FLIR.replace(this, new FLIRStyle({mode:'wrap',cSize:'16',cBackground:'white'}) ); } );
		$("div.menuv3headerCal h3").each( function() { FLIR.replace(this, new FLIRStyle({mode:'wrap',cSize:'16',cBackground:'white'}) ); } );
		$("#pageTitle h1").each( function() { FLIR.replace(this, new FLIRStyle() ); } );
		$("#pageTitle h2").each( function() { FLIR.replace(this, new FLIRStyle() ); } );
		$("#content .header h1").each( function() { FLIR.replace(this, new FLIRStyle() ); } );
		$("#content .header h2").each( function() { FLIR.replace(this, new FLIRStyle() ); } );
		$("h2.drawer-handle").each( function() { FLIR.replace(this, new FLIRStyle({cSize:'18',cBackground:'white',output:'gif'}) ); } );
		
		$(".content h1").each( function() { FLIR.replace(this, new FLIRStyle({mode:'wrap',cSize:'24',cBackground:'white'}) ); } );
	
	}
	
	
	// starting the script on page load
	tooltip();
	
	//detect fashion management degree and change the right side bg image
	var pathname = window.location.pathname;
	if(pathname.search("degree/fashion-management") > 1){
		
		$('#secondaryHeader .degree').css("background-image", "url(assets/comp/fashiondegreesidebar.jpg)");
		
	}else{
		
	}
	
	

	$("a.rollover-ad-h85").each(function (i) {
		var img = $(this).children("img").attr("src");
		$(this).empty();
		$(this).css({'background-image' : 'url('+img+')'});
	});
	$("a.rollover-ad-h59").each(function (i) {
		var img = $(this).children("img").attr("src");
		$(this).empty();
		$(this).css({'background-image' : 'url('+img+')'});
	});
	$("a.rollover-ad-h60").each(function (i) {
		var img = $(this).children("img").attr("src");
		$(this).empty();
		$(this).css({'background-image' : 'url('+img+')'});
	});
	$("a.rollover-ad-h298").each(function (i) {
		var img = $(this).children("img").attr("src");
		$(this).empty();
		$(this).css({'background-image' : 'url('+img+')'});
	});
	
	
	//generic open close func
	if($('div.openClose').length != 0){
				
		//detect FAQS
		if($('.openClose div.question').length != 0){
			$('.openClose h3').wrap("<div class='question'></div>");
			$('div.question').addClass('closeHeader');
		
			$('.openClose div.question').click(function() {
				var thisEl = $(this);
				
				$(this).toggleClass('openHeader');
				
				
				$(this).next('div').slideToggle("medium",function(){
					
					var contentHeight = $("div#content").height();
					//secondaryContentHeight = $("div#secondaryContent").height();
					var secondaryContentHeight = $("div.topRightBoxTestimonials").height() + $("div#infoGoBottom").height();
					//alert(secondaryContentHeight);
					if(contentHeight > secondaryContentHeight){
						var margintop = contentHeight - secondaryContentHeight + 10;
					}else{
						var margintop = 0;
					}
					$('div#infoGoBottom').css('margin-top',margintop + 'px');
														  
				});
				
				return false;
			}).next('div').hide();	
		}
		
		
		//detect Programs By field
		if($('.programsByField').length != 0){
			
			$('div.openClose').addClass('closeHeader');
			
			$('div.openClose').click(function() {
				var thisEl = $(this);
				
				$(this).toggleClass('openHeader');
				
				
				$(this).next('table').slideToggle("medium");
				
				return false;
			}).next('table').hide();	
		}
		
		//detect Programs By field
		if($('.typeOfWorkTerms').length != 0){
			
			$('div.openClose').addClass('closeHeader');
			
			$('div.openClose').click(function() {
				var thisEl = $(this);
				
				$(this).toggleClass('openHeader');
				
				
				$(this).next('table').slideToggle("medium");
				
				return false;
			}).next('table').hide();	
		}
		
		
	}
	
	//video switcher for law firm profile
	if($('div.lawFirmVideoPlayerContainer').length != 0){
		
		/* removed - no need to play when banner is clicked
		$("div.lawFirmVideoPlayerContainer").click(function(){
			$("div.lawFirmVideoPlayerContainer").load("movie530x298.php",{movie : $("a.lawFirmProfileVideoLink:first").attr("href")});
		});
		*/
		
		$("a.lawFirmProfileVideoLink").click(function() {
			$("#mainHeader").removeAttr("style");
			$("div.lawFirmVideoPlayerContainer").load("movie530x298.php",{movie : $(this).attr("href")});
			return false;
		})
	}
	
	if($('#awardsScholarshipsFT').length != 0){
		
		//add dotted line
		$('.awardContent').after('<tr class="rowHeaderSpacer"><td colspan="3"></td></tr>');
		
		//on select show values
		$("select#awardSelect").change(function () {
			
			var sVal = $("select option:selected").val();
			
			$('#awardsScholarshipsPT').hide();
			
			if(sVal){
				//reset open style
				$("td.awardTitle").removeClass('awardTitleOpen');
				
				$('#awardsScholarshipsFT').show();
				$('#awardsScholarshipsFT tbody tr').hide();
				$('.award-' + sVal).show();
				$('.award-' + sVal).next().next().show();
				
			}else{
				$('#awardsScholarshipsFT').hide();
			}
			
		}).change();
		
		//opn close
		$("td.awardTitle").click(function () {
	      $(this).parent().nextAll('.awardContent:first').toggle();
	      $(this).toggleClass('awardTitleOpen');
	      
	    }, function () {
	      $(this).parent().nextAll('.awardContent').toggle();
	      $(this).toggleClass('awardTitleOpen');
	    });
	}
	
	$('#showPartTimeAwards').click(function(){
		$('#awardSelect').find('option:first').attr('selected', 'selected').parent('select');
		$('#awardsScholarshipsFT').hide();
		$('#awardsScholarshipsPT').show();
	});
	
	
	//insert new link in the Student resources section when  	Scholarships & Awards is selected
	if($('#ScholarshipsAwards-2249').length != 0){
		if( $('#ScholarshipsAwards-2249').attr('class') == 'selected' ){
			$('#ScholarshipsAwards-2249').after('<a href="http://business.humber.ca/resources/scholarships-and-awards-search" class="specialScholarshipsAwards">&raquo; Search</a>');
		}
	}
	//continued - as above insert new menu item and highlight
	if($('.searchScholarshipsAwards').length != 0){
		$('#ScholarshipsAwards-2249').after('<a href="http://business.humber.ca/resources/scholarships-and-awards-search" class="specialScholarshipsAwards">&raquo; Search</a>');
		$('#ScholarshipsAwards-2249').addClass('selected');
		$('a.specialScholarshipsAwards').css("color","#CC9900");
		
	}    
});


$(window).load(function(){ 
	
	//go bottom for hire a student page
	if($('div#rightColAdviserWrapper').length != 0){
		var h1 = $("td.rightCol").height();
		var h2 = $("div#rightColAdviserWrapper").height();
		var h=h1-h2;
		//alert(h);
		if(h>20){$("div#infoGoBottomAdviser").css("margin-top",h);}
	}
	
	
	
	//add rolover states to side generated images H2
	$(".homeRightCol h2 a").each(function (i) {
		var ifH = $(this).children('img').height();
		var ifW = $(this).children('img').width();
		var img = $(this).children("img").attr("src");
		$(this).empty();
		$(this).css({'background-image' : 'url('+img+')','width':ifW+'px','height':ifH+'px'});
	});
	
	$(".homeRightCol h2 a").hover(
			function () {
				var oldStyle = $(this).attr('style');
				var newStyle = oldStyle.replace('0%2C45%2C98', '75%2C163%2C213');
				$(this).attr('style', newStyle);
			}, 
			function () {
				var oldStyle = $(this).attr('style');
				var newStyle = oldStyle.replace('75%2C163%2C213', '0%2C45%2C98');
				$(this).attr('style', newStyle);
			}
	);

	//add rolover states to side generated images H3
	$(".homeRightCol h3 a").each(function (i) {
		var ifH = $(this).children('img').height();
		var ifW = $(this).children('img').width();
		var img = $(this).children("img").attr("src");
		$(this).empty();
		$(this).css({'background-image' : 'url('+img+')','width':ifW+'px','height':ifH+'px'});
	});
	
	$(".homeRightCol h3 a.flir-replaced").hover(
			function () {
				var oldStyle = $(this).attr('style');
				var newStyle = oldStyle.replace('0%2C45%2C98', '75%2C163%2C213');
				$(this).attr('style', newStyle);
			}, 
			function () {
				var oldStyle = $(this).attr('style');
				var newStyle = oldStyle.replace('75%2C163%2C213', '0%2C45%2C98');
				$(this).attr('style', newStyle);
			}
	);
}); 





