
	$(document).ready( function(){
		
		// work out what page we're on
		var url = location.href;
		//url = url.replace( 'http://', '' );
		//url = url.split( '/' );
		//url = url[ url.length - 1 ];
		
		// remove any hash reference
		url = url.split( '#' );
		url = url[0];
		
		// mark the current page in the main menu
		$('.mainmenu li').each( function(){
		
			var $link = $( 'a', $(this) ).eq(0);
			if( $link.attr('href') == url )
			{
				$(this).addClass( 'current' );
			}
		
		});
		
		// mark the current page in the footer menu
		$( '.footer_inner a' ).each( function(){
		
			if(  $(this).attr('href') == url ) $(this).addClass( 'current' );
		
		});
	
		// sexy lava lamp menu
		$(".mainmenu").lavaLamp({
			fx: 'backout',
			speed: 400
		});
		
		function tour_onbefore( curr, next, opts )
		{
			var $button = $('.features-list li').eq( opts.nextSlide );
			tab_select( $button, '.features-list li' );
		}
		
		function tour_onafter( curr, next, opts )
		{
			var $button = $('.features-list li').eq( opts.currSlide );
			tab_select( $button, '.features-list li' );
		}
		
		// function to select tabs
		function tabs_onbefore( curr, next, opts )
		{
			var $button = $('.tabmenu li').eq( opts.nextSlide );
			tab_select( $button, '.tabmenu li' );
		}
		
		// function to select tabs
		function tabs_onafter( curr, next, opts )
		{
			var $button = $('.tabmenu li').eq( opts.currSlide );
			tab_select( $button, '.tabmenu li' );
			
			var $tab = $('.tabs .tab .tabwrapper').eq( opts.currSlide );
			
			$('.tabs').animate({
				height: $tab.attr('scrollHeight')
			});
		}
		
		// function to deselect all tabs
		function tabs_deselect( selector )
		{
			$( selector ).each( function(){
			
				$(this).removeClass( 'selected' );
				$(this).removeClass( $(this).attr('id')+'-selected' );
			
			});
		}
		
		// tab mouseover
		function tab_over( $el, selector )
		{
			$($el).addClass('over');
			$($el).addClass( $($el).attr('id')+'-over' );
			$( selector ).cycle('pause');
		}
		
		// tab mouseout
		function tab_out( $el, selector )
		{
			$($el).removeClass('over');
			$($el).removeClass( $($el).attr('id')+'-over' );
			$( selector ).cycle('resume');
		}
		
		// tab click
		function tab_select( $el, selector )
		{
			tabs_deselect( selector );
			$($el).addClass( 'selected' );
			$($el).addClass( $($el).attr('id')+'-selected' );
		}
		
		// cycle tabs
		$('.tabs').cycle({
			fx 		: 'scrollHorz', 	// transition to use
			speed	: 500,				// speed of the transition
			timeout	: 0,				// time between slides, in milliseconds
			pause	: true,				// stop the animation when your mouse is over the tab
			before	: tabs_onbefore,	// function called when the tab is about to start changing
			after	: tabs_onafter		// function called when the tab is finished changing
		});
		
		// set up the tab menu to interact with the tabs
		$('.tabmenu li').each( function(i){
		
			$(this).addClass( $(this).attr('id') );
			
			$(this).click( function(){
			
				tab_select( $(this), '.tabmenu li' );
				
				$('.tabs').cycle( i );
				
				return false;
			
			}).hover( function(){
			
				tab_over( $(this), '.tabs' );
			
			}, function(){
			
				tab_out( $(this), '.tabs' );
			
			});
		
		});
		
		// set up the tab menu to interact with the tabs
		$('.features-list li').each( function(i){
		
			$(this).addClass( $(this).attr('id') );
			
			$(this).click( function(){
			
				tab_select( $(this), '.features-list li' );
				
				$('.features-frames').cycle( i );
				
				return false;
			
			});
		
		});
		
		
		// set up the testimonial cycle
		$('.testimonialCycle').cycle({
			pause	: true,
			//pager	: '.testimonialNav',
			next	: '.testimonialNext',
			prev	: '.testimonialPrev'
		});
		
		
		// set up software features cycle
		$('.features-frames').cycle({
			fx 		: 'scrollHorz', 	// transition to use
			speed	: 500,				// speed of the transition
			timeout	: 0,				// time between slides, in milliseconds
			pause	: true,				// stop the animation when your mouse is over the tab
			before	: tour_onbefore,
			after	: tour_onafter,
			cleartypeNoBg: false
		});
		
		// set up software features inner screenshots slideshow
		$('#screen-shots').cycle({
			fx 		: 'fade', 	// transition to use
			speed	: 1000,				// speed of the transition
			timeout	: 4000,				// time between slides, in milliseconds
			pause	: true,				// stop the animation when your mouse is over the tab
			pager	: '#screen-shots-links',
			pagerEvent: 'click.cycle',
			fastOnEvent: true
		});
		
		// set up software features inner screenshots slideshow
		$('#screen-shots1').cycle({
			fx 		: 'fade', 	// transition to use
			speed	: 1000,				// speed of the transition
			timeout	: 4000,				// time between slides, in milliseconds
			pause	: true,				// stop the animation when your mouse is over the tab
			pager	: '#screen-shots-links1',
			pagerEvent: 'click.cycle',
			fastOnEvent: true
		});
		
		// set up software features inner screenshots slideshow
		$('#screen-shots2').cycle({
			fx 		: 'fade', 	// transition to use
			speed	: 1000,				// speed of the transition
			timeout	: 4000,				// time between slides, in milliseconds
			pause	: true,				// stop the animation when your mouse is over the tab
			pager	: '#screen-shots-links2',
			pagerEvent: 'click.cycle',
			fastOnEvent: true
		});
		
		// set up software features cycle
		$('.premium-designs').cycle({
			fx 		: 'scrollHorz', 	// transition to use
			speed	: 500,				// speed of the transition
			timeout	: 0,				// time between slides, in milliseconds
			pause	: true				// stop the animation when your mouse is over the tab
		});
		
		// set up the tab menu to interact with the tabs
		$('.premium-design-thumbs li').each( function(i){
		
			$(this).addClass( $(this).attr('id') );
			
			$(this).click( function(){
			
				$('.premium-designs').cycle( i );
				
				return false;
			
			});
		
		});
		
		// Jquery scroll effect
		$(document).ready(function(){
			$(".scroll").click(function(event){
			//prevent the default action for the click event
			event.preventDefault();

			//get the full url - like mysitecom/index.htm#home
			var full_url = this.href;

			//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
			var parts = full_url.split("#");
			var trgt = parts[1];

			//get the top offset of the target anchor
			var target_offset = $("#"+trgt).offset();
			var target_top = target_offset.top;

			//goto that anchor by setting the body scroll top to anchor top
			$('html, body').animate({scrollTop:target_top}, 500);
				});
			});

		
		// set up software features cycle
		$('.premium-plus-designs').cycle({
			fx 		: 'scrollHorz', 	// transition to use
			speed	: 500,				// speed of the transition
			timeout	: 0,				// time between slides, in milliseconds
			pause	: true				// stop the animation when your mouse is over the tab
		});
		
		// set up the tab menu to interact with the tabs
		$('.premium-plus-design-thumbs li').each( function(i){
		
			$(this).addClass( $(this).attr('id') );
			
			$(this).click( function(){
			
				$('.premium-plus-designs').cycle( i );
				
				return false;
			
			});
		
		});
		
		// sexy form styles
		$(".infieldLabels label").inFieldLabels({
			fadeOpacity: 0.4
		});
		$(".simpleform label").inFieldLabels({
			fadeOpacity: 0.2
		});
		
		$('.textfield, .textarea', $('.infieldLabels')).bind( 'focus', function(){
			$(this).addClass('focus');
		}).bind( 'blur', function(){
			$(this).removeClass('focus');
		});
		
		// Website Premium Designs Sexyness
		$('.premium-design-thumbs li, .premium-plus-design-thumbs li, .home-buttons li').hover( function(){
		
			$(this).siblings().animate({ opacity: 0.2 }, { queue: false });
		
		}, function(){
		
			$(this).siblings().animate({ opacity: 1 }, { queue: false });
		
		});
		
		$('.menupages .radiowrapper').each( function(){
		
			var wrapper = $(this);
			$('input[type=checkbox]', $(this)).click( function(){
				if( $(this).attr('checked') )
				{
					$('p', wrapper).fadeIn();
				}
				else
				{
					$('p', wrapper).fadeOut();
				}
			});
		
		});
		
		if( !$.browser.msie || parseInt( $.browser.version ) >= 8 )
		{
			Cufon.replace('h1');
			Cufon.replace('h2');
			Cufon.replace('h3');
		}
		
		// Show/Hide Login div
		$('.login_wrap').hide();
		
		// hides the login box 
		$('#login-close').click(function() {
			$('.login_wrap').hide('fast');
			return false;
		});
		 
		// toggles the login box 
		 $('#login-toggle').click(function() {
			$('.login_wrap').toggle(500);
			return false;
		});
		
		$(function() {
			$('.compare tr:nth-child(2n+1)').addClass('even');
		});
		
	});
