$(function () {
	
	// this is used in conjunction with the CSS, eg. changing the cursor to a pointer on clickable divs
	$("html").addClass("js-enabled");
	
	// makes the pull-in boxes (quotes) clickable
	$("div.snippet, blockquote.pull-in").click(function () {
		window.location = $(this).find("a:last").attr("href");
		return false;
	});
	
	// makes sure the search instruction stays in the box if nothing has been entered
	search_instruction = "Enter search term";
	$("#footer input").attr("value", search_instruction);
	$("#footer input").focus(function() {
		
		if ($(this).attr("value") == search_instruction) {
			$(this).attr("value","");
		}
	});
	$("#footer input").blur(function() {
		
		if ($(this).attr("value") == "") {
			$(this).attr("value", search_instruction);
		}
	});
	
	$("#print-this").click(function () {
		window.print();
		return false;
	});
	
	// Flash video for advert page
	var params = {
		menu: "false",
		wmode: "transparent"
	};
	swfobject.embedSWF("/flash/nytol-tv-advert.swf", "advert-1", "250", "188", "7", null, null, params);
	swfobject.embedSWF("/flash/nytol-making-of-tv-advert.swf", "advert-2", "250", "188", "7", null, null, params);

	//salutation on homepage
	//(Good morning (4.00-12.00) / Good afternoon (12.00-18.00) / Good evening (18.00-24.00) / Hello (0.00-4.00))
	var currentTime = new Date();
	var hour = currentTime.getHours();
	
	$('#salutation').each(function(){							
		if (hour < 4){
			//default greeting 'hello';
		}
		else if((hour >= 4) && (hour < 12)){
			$(this).html('Good morning');
			$(this).addClass('good-morning');
		}
		else if((hour >= 12) && (hour < 18)){
			$(this).html('Good afternoon');
			$(this).addClass('good-afternoon');
		}
		else if(hour >= 18){
			$(this).html('Good evening');
			$(this).addClass('good-evening');
		}								
	})

});