//doc ready
$(document).ready(function() {
	//homepage slideshow
	$('#slideshowTop').cycle({
		fx:    'fade',
		speed:  1000,
		timeout:  6000
 	});

	// navigation menu minimize/maximize
	$('.nav-minimizer').click(function() {
		var targetID = $(this).parent('h2').next('.submenu');
		if ( $(targetID).is(":hidden") ) {
			$(targetID).slideDown();
			$(this).removeClass('icon-plus').addClass('icon-minus').attr('title','Minimize');		
		} else {
			$(targetID).slideUp();	
			$(this).removeClass('icon-minus').addClass('icon-plus').attr('title','Maximize');
		}
	});
	// if navigation menu is opened by css, change icon to minus
	$('.nav-minimizer').each(function() {
		var targetID = $(this).parent('h2').next('.submenu');
		if ( $(targetID).is(":visible") ) {
			$(this).removeClass('icon-plus').addClass('icon-minus').attr('title','Minimize');		
		}
	});
	
	// print page function
	$('#toolbar_print').click(function(){
		window.print();
		return false;
	});
	// FONT SIZER
	$('#toolbarIcons').find('li.hover').removeClass('hover');
	$('#toolbarIcons > li').hoverIntent(function(){
		$(this).find('ul').slideDown();									 
	}, function(){
		$(this).find('ul').slideUp();					
	});
	// Reset Font Size
	var originalFontSize = $('.font').css('font-size');
	$(".resetFont").click(function(){
	$('.font').css('font-size', originalFontSize);
	});
	// Increase Font Size
	$(".increaseFont").click(function(){
	var currentFontSize = $('.font').css('font-size');
	var currentFontSizeNum = parseFloat(currentFontSize, 10);
	var newFontSize = currentFontSizeNum*1.2;
	$('.font').css('font-size', newFontSize);
	return false;
	});
	// Decrease Font Size
	$(".decreaseFont").click(function(){
	var currentFontSize = $('.font').css('font-size');
	var currentFontSizeNum = parseFloat(currentFontSize, 10);
	var newFontSize = currentFontSizeNum*0.8;
	$('.font').css('font-size', newFontSize);
	return false;
	});
	
	//form validation
	$("#contactForm").validate({
		rules: {
		name: "required",
		email: {
					required: true,
					email: true
				},
		phone: "required",
		project_details: "required"
		
		},
		messages: {
		name: "Please enter your name.",
		phone: "Please enter your phone number.",
		email: "Please enter your email address.",
		project_details: "Please enter your project details."
		}
	});
	
	// blog section rss feeds
	$('#rss-events').rssfeed('http://www.comtrst.com/trust-our-word/category/events/feed', {
		limit : 1,
		header : false,
		titletag : 'p',
		snippet : false
	});
	$('#rss-news').rssfeed('http://www.comtrst.com/trust-our-word/category/news/feed', {
		limit : 1,
		header : false,
		titletag : 'p',
		snippet : false
	});
	$('#rss-publications').rssfeed('http://www.comtrst.com/trust-our-word/category/legislation/feed', {
		limit : 1,
		header : false,
		titletag : 'p',
		snippet : false
	});
	
	// fancybox lightbox
	$("a#timebox").fancybox({
		'titleShow'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	}); // close fancybox function

	
	
});//doc ready	
