	var themeSettings = {
		'logoAnimated' 	: false,
		'logoHover'		: false,
		'twitter'		: {
			'active'		: true,
			'username'		: 'ermarkstudio'
			}
	};
	
	//if (themeSettings.logoAnimated){
		//** load the animation javscript 
		//$.getScript('js/jquery.frame.animation.js', function() {
		
				//$(window).load(function() { 
					//** create a hidden element and load animation frames
					//$('body').append('<img id="preload-logo" style="display:none;" src="images/light/logo-anim.png"> ');
					
					//** on image load
					//$('#preload-logo').load(function(){
						
						//** replace the current static logo with an animated one
						//$('#header').css("background","url('images/light/logo-anim.png') no-repeat center 0px")
									//.frameAnimation({ 
										//imageHeight:1640, 
										//delay:50,
										//horizontalOffset:397,
										//hoverMode:false,
										//repeat:-1
									//});
					
					//}); // image load
					
				//}); // on document load
		
		
		//}); // load remote script for logo animation
	//}


	
	//** on DOM loaded
	$(function() {
	
		//** Replace text with cufon using the right color theme
		cufonReplace('light');
		
		//** check if the slider exist on the current page
		if ( $("#slider").size() ) { loadSlider(); } 			
			
		//** load the latest update on twitter account
		if (themeSettings.twitter.active){ loadTwitter(); }
		
		//** check if inGallery is needed and load the script
		loadInGallery()
		
		//** load the newsletter validation and behavior
		loadNewsletterValidation();
		
		//** check if logo hover is active
		if (themeSettings.logoHover){
			$('.logo').hover(function(){
				$('#header .logo').stop(true, false).animate({'opacity':0.7}, 500);
			},function(){
				$('#header .logo').stop(true, false).animate({'opacity':1}, 500);
			});
		}
	  

		// The "Get in touch" button behavior
		$('#notice .touch').click(function(){
			if ($('#notice').css('top')=='-230px') {
				$('#notice').animate({top:'-30px'}, 250,'easeInOutCirc');
				$(this).removeClass('down').addClass('up');						// add the arrow pointing up
			}else{
				$('#notice').animate({top:'-230px'}, 650,'easeInOutCirc');
				$(this).removeClass('up').addClass('down');						// add the arrow pointing down
			}
			
			return false;
		});
	});
	
	function loadInGallery(){
		var setDefault = false;
		
		// Check if there are articles with more than one image
		$('.section.articles div.imgLarge').each( function(){
			if ( $('img',this).size()>1 ){ setDefault=true; }
		});
		
		if (setDefault){
			$.getScript('js/jquery.inGallery.js', function() {
			
				$('.section.articles div.imgLarge').each( function(){
					if ($('img',this).size()>1){
						var newGal = new inGallery(this, {'slideInArticle':true });
					}
				});
				
			});
		}
	}
	
	function loadTwitter(){
		//** load tweetable javscript 
		$.getScript('js/jquery.tweetable.js', function() {
			$('.tweets span').tweetable({'username':themeSettings.twitter.username, 'callback':function(){
				$('.tweets').fadeIn('slow');
			}});
		});
	}
	
	function loadSlider(){
		//** load coin slider javscript 
		$.getScript('js/jquery.coin-slider.js', function() {
			var slideDelay = 2500;
			
			// attach the slider to #slider
			$("#slides").coinslider({
				width			: 850, 						// width of slider panel
				height			: 250, 						// height of slider panel
				spw				: 12,						// squares per width
				sph				: 1, 						// squares per height
				delay			: slideDelay,				// delay between images in ms
				sDelay			: 70, 						// delay beetwen squares in ms
				opacity			: 0.7, 						// opacity of title and navigation
				titleSpeed		: 500, 						// speed of title appereance in ms
				effect			: 'straight', 				// random, swirl, rain, straight
				navigation		: true, 					// prev next and buttonsu 
				links 			: false, 					// show images as links 
				navLetters		: false,					// show letters on nav buttons
				navHolder		: '#slider div.pager',		// pager navigation
				hoverPause		: true 						// pause on hover
			});
			
		});
	}
	
	
	function loadNewsletterValidation(){
		$('.newsletter input').click(function(){
			var mail = $(this).attr('value');
			
			if (mail=='Please enter a valid email...' || mail=='Enter your e-mail address') { 
				$(this).css('color', '#3d393a').attr('value','');
			}
		});
		
		$('.newsletter a').click(function(){
			var mail = $('.newsletter input').attr('value');
			
			if (mail=='Enter your e-mail address') { 
				$('.newsletter input').fadeOut(350, function(){
					$(this).css('color','#cd2707')
						   .attr('value', 'Please enter a valid email...')
						   .fadeIn(350);
				});
				
				return false;
			}
			
			if (mail=='Please enter a valid email...') { 
				$('.newsletter input').fadeOut(350, function(){
					$(this).fadeIn(350);
				});
				
				return false;
			}
			
			if (isValidEmailAddress(mail)){
				$('.newsletter div>*').fadeOut('fast', function(){
					$('.newsletter a').css('display','none');
					
					$('.newsletter input').css('width', '380px')
										  .css('color','#3d393a')
										  .css('text-align','center')
										  .attr('value','Thank you for your intrest!')
										  .fadeIn();
				});
			}else{
				$('.newsletter input').fadeOut(350, function(){
					$(this).css('color','#cd2707')
						   .attr('value', 'Please enter a valid email...')
						   .fadeIn(350);
				});
			}
		});
	}
	
	// Replace text style  for the correct color theme 
	function cufonReplace(){
		Cufon.replace('h1, h2, h3, h4, h5, a.info, .form-button', { fontFamily:'BonvenoCF',fontWeight:'normal'});
		Cufon.replace('a.more', { fontFamily:'Rockwell',fontWeight:'normal', fontSize:'11px', hover:'true', textShadow:'0px 1px #938e78'});
		Cufon.replace('.menu a', { fontFamily:'BonvenoCF',fontWeight:'normal', fontSize:'13px', hover:'true' });
		Cufon.replace('a.collection, a.pricelist', { fontFamily:'Rockwell',fontWeight:'normal', fontSize:'14px', hover:'true', textShadow:'0px 1px #938e78' });
	}
	
	// debuging purpose when new functionality is added
	function log(msg){
		if(window.console&&window.console.log){
			window.console.log("** "+msg);
		}
	}
	
	//Function for e-mail validation on newsletter field
	function isValidEmailAddress(emailAddress) {
		var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
		return pattern.test(emailAddress);
	}
	
	/* Start FAQ Accordion */
jQuery(document).ready(function() {
    $('.accordion .accContent').hide().end()
		   .find('.accToggler').click(function() {
	         this.className = this.className == 'accToggler' ? 'accTogglerOpen' : 'accToggler';
	         $(this).next().slideToggle();
	       });

			$('.accordion').find('.accToggler:first').removeClass("accTogglerOpen").addClass("accToggler");

	       $('.accordion p.close').click(function() {
	         $(this).parent().slideUp()
	         .prev().removeClass('accTogglerOpen').addClass('accToggler');
	  });
});
