var scrollHeight = 0;

$(document).ready(function(){
	var startPos = $('.sel').position().left;
	$('.mover').css({'left': startPos});
	$('.navigation a').hover(function(){$('.mover').animate({left: $(this).position().left,width: $(this).width()}, { queue: false, duration: 500 });});
	$('.touchMore a').mouseenter(function(){$(this).animate({bottom: 5, opacity: .8 }, { queue: false, duration: 200 });});
	$('.touchMore a').mouseleave(function(){$(this).animate({bottom: 0, opacity: 1 }, { queue: false, duration: 200 });});
	$('.previousThree img').mouseenter(function(){$(this).animate({bottom: 15}, { queue: false, duration: 600 });});
	$('.previousThree img').mouseleave(function(){$(this).animate({bottom: 0}, { queue: false, duration: 600 });});
	$('.servicesInfo li').mouseenter(function(){$(this).animate({left: 25, opacity: .6 }, { queue: false, duration: 200 });});
	$('.servicesInfo li').mouseleave(function(){$(this).animate({left: 0, opacity: 1 }, { queue: false, duration: 200 });});
	
	$().UItoTop({ easingType: 'easeOutQuart' });
	
	WebFontConfig = {google: { families: [ 'Droid+Sans::latin' ] }};
  	(function() {
		var wf = document.createElement('script');
		wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
		  '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
		wf.type = 'text/javascript';
		wf.async = 'true';
		var s = document.getElementsByTagName('script')[0];
		s.parentNode.insertBefore(wf, s);
	})(); 
		
	$(window).scroll(function() {
		scrollHeight = $(window).scrollTop();
		if (scrollHeight > 50) {
			$('.nav').animate({top : -3}, { queue: false, duration: 200 })
		} else {
			$('.nav').animate({top: 25}, { queue: false, duration: 200 })
		}
	});
	
	$('.holder').mouseenter(function(){	
		$('.overlay', this).animate({bottom:150},{ queue: false, duration: 300 });
		$('img', this).animate({opacity:0.5},{ queue: false, duration: 300 });
	});
	
	$('.holder').mouseleave(function(){	
		$('.overlay', this).animate({bottom:55},{ queue: false, duration: 300 });
		$('img', this).animate({opacity:1 },{ queue: false, duration: 300 });
	});
	
	
	$('.imageSlide').cycle({ 
		fx:     'fade', 
		speed:  'slow', 
		timeout: 5000, 
		next:   '#next2', 
		prev:   '#prev2' 
	});
	
	$('.servicesInfo li').click(function(){
		$('.servicesInfo2').html('<b><u>'+$(this).html() +'</u></b><br /><br />' + $('div', this).html());
		$('.selectedLi').animate({left:0});
		$('.selectedLi').removeClass('selectedLi')
		$(this).attr('class','selectedLi');
	});
	
	$('#home, #folio, #contact, #about, #services, #logo').click(function() {
       		
		if ($(this).attr('href') == '#top') {
			var target_top = $($(this).attr('href')).position().top;
		} else {
			var target_top = $($(this).attr('href')).position().top + 560;
		}
				
        $('html, body').animate({scrollTop:target_top},{queue:false, duration:1500, easing:"swing"});
    });
	
	function start(){
		$('.nav').hide();
	}
	function stops(){
		$('.nav').show();
	}
	
	$(".contacts").fancybox({
		'width'				: 400,
		'height'			: 680,
		'autoScale'			: false,
		'centerOnScroll'	: true,
		'overlayOpacity'	: 0.90,
		'overlayColor'		: '#000',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'onStart'			:  start,
		'onCleanup'			:  stops,
		'type'				: 'iframe'
	});
	
	
});


function checkfrm() {

		var message = "";
		var inputs = document.getElementsByTagName('input');
		for (var i in inputs) {
			if (inputs[i].className == "check" || inputs[i].className == "win" || inputs[i].className == "lose") {
				if (inputs[i].value.indexOf("*") == 0 || inputs[i].value == "")
					{
						inputs[i].className  = "lose";
						message = message + "** " + inputs[i].id + "\n";
					} else {
						inputs[i].className  = "win";
					}
			}
		}

		if (message == ""){
			return true;	
		} else {
			message = "Please enter a correct value for the items in red. ";
			alert(message.replace(/_/g," "));
			return false;
		}	

	}
	
function moveScroll(page){
		
	var target = $(this.hash);
	target = target.size() && target || $("[name=" + this.hash.slice(1) +']');
	if (target.size()) {
	   target.ScrollTo(400);
	   return false;
	}
	
}

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-8368334-5']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

