/**
 * This file contains the functionality for initializing all the scripts in the
 * site and also there are some main initial settings included here, such as
 * setting rounded corners automatically, setting the Twitter functionality,
 * etc.
 * 
 * @author Pexeto
 */

var tonicSite = {
	initSite : function() {
		// load the slider
		tonicSite.loadSlider();

		// load the scrolling functionality
		$('.jLink').click(function(event) {
			event.preventDefault();
			var rel = $(this).attr('rel');
			if (rel && $('#' + rel)[0]) {
				$.scrollTo($('#' + rel), 700);
			}
		});

		// fix the IE6 position fixed issue
		if ($.browser.msie && $.browser.version.substr(0, 1) < 7) {
			$("#menu_container").css("position", "absolute");
			$(window).scroll(function() {
				$("#menu_container").css("top", $(window).scrollTop() + "px");
			});
		}

		// set rounded corners
		window.onload = this.setDefaultRoundedCorners;

	},

	/**
	 * Loads the Nivo image slider.
	 */
	loadSlider : function() {
		// load the Nivo slider
		$(window)
				.load(function() {
					$('#slider').nivoSlider( {
						effect : 'random', // Specify sets like:
						// 'fold,fade,sliceDown'
						slices : 15,
						animSpeed : 800,
						pauseTime : 7000,
						startSlide : 0, // Set starting Slide (0 index)
						directionNav : false, // Next & Prev
						directionNavHide : true, // Only show on hover
						controlNav : true, // 1,2,3...
						controlNavThumbs : false, // Use thumbnails for
						// Control
						// Nav
						controlNavThumbsFromRel : false, // Use image rel for
						// thumbs
						keyboardNav : true, // Use left & right arrows
						pauseOnHover : true, // Stop animation while hovering
						manualAdvance : false, // Force manual transitions
						captionOpacity : 0, // Universal caption opacity
						beforeChange : function() {
						},
						afterChange : function() {
						},
						slideshowEnd : function() {
						} // Triggers after all slides have been shown
					});

					// remove numbers from navigation
						$('.nivo-controlNav a').html('');

						// center the slider navigation
						var slideNumber = $('.nivo-controlNav a').length;
						var slideLeft = 960 / 2 - slideNumber * 21 / 2;
						$('.nivo-controlNav:first').css( {
							left : slideLeft
						});

						// set corners to the slider
						$('#slider_container')
								.append(
										'<div id="corner_left_top"></div><div id="corner_right_top"></div><div id="corner_left_bottom"></div><div id="corner_right_bottom"></div>');
					});
	}
};
