Cufon.replace('#cycleContent h1', { fontFamily: 'Futura' , hover: false });
Cufon.replace('#footer h3', { fontFamily: 'Futura' , hover: false });

$(document).ready(function() {
	
	function pauseCycle() {
		$('#cycleContent').cycle('pause');
	}
	function resumeCycle() {
		$('#cycleContent').cycle('resume'); 
	}
	function onAfter(curr, next, opts) {
		var index = opts.currSlide;
        $('#cyclePrev')[index == 0 ? 'hide' : 'show']();
        $('#cycleNext')[index == opts.slideCount - 1 ? 'hide' : 'show']();
    }
	function onBefore() {
		$('#menu li').removeClass("active");
		var bnbefore = '#' + this.className;
		$(bnbefore).addClass("active");
	}
	function myOnComplete() {
		return true;
	}
	
	if (jQuery('#cycleContent').length>0) {
	
		//Process Photo Fancybox
		$(".cyclePhoto a").fancybox({
			'overlayColor': '#2e333a',
			'overlayOpacity': '0.7',
			'transitionIn': 'elastic',
			'transitionOut': 'elactic',
			'onStart': pauseCycle,
			'onClosed': resumeCycle,
			'titlePosition': 'over'
		});
		
		//Process Cycle
		$('#cycleContent').cycle({
	    	fx: 'scrollHorz',
	    	prev: '#cyclePrev', 
		    next: '#cycleNext',
	    	timeout: 0,    
		    nowrap: 1,
		    speed: 500,
	    	startingSlide: 0,
			before: onBefore,
			after: onAfter
		});
		
		//Process Buttons
		$('#logo').click(function() { 
    		$('#cycleContent').cycle(0); 
	    	return false; 
		});		
		$('#process-01 a').click(function() { 
    		$('#cycleContent').cycle(0); 
	    	return false; 
		});
		$('#process-02 a').click(function() { 
	    	$('#cycleContent').cycle(1); 
		    return false; 
		});
		$('#process-03 a').click(function() { 
	    	$('#cycleContent').cycle(2); 
		    return false; 
		});
		$('#process-04 a').click(function() { 
	    	$('#cycleContent').cycle(3); 
		    return false; 
		});
		$('#process-05 a').click(function() { 
	    	$('#cycleContent').cycle(4); 
		    return false; 
		});
		$('#process-06 a').click(function() { 
	    	$('#cycleContent').cycle(5); 
		    return false; 
		});
		$('#btnProcess-02').click(function() { 
	    	$('#cycleContent').cycle(1); 
		    return false; 
		});
		$('#btnProcess-03').click(function() { 
	    	$('#cycleContent').cycle(2); 
		    return false; 
		});
		$('#btnProcess-04').click(function() { 
	    	$('#cycleContent').cycle(3); 
		    return false; 
		});
		$('#btnProcess-05').click(function() { 
	    	$('#cycleContent').cycle(4); 
		    return false; 
		});
		$('#btnProcess-06').click(function() { 
	    	$('#cycleContent').cycle(5); 
		    return false; 
		});
	}
	
	if (jQuery('.videoClip').length>0) {
	
		//Process Photo Fancybox
		$("a.videoClip").fancybox({
			'overlayColor': '#2e333a',
			'overlayOpacity': '0.7',
			'transitionIn': 'elastic',
			'transitionOut': 'elactic',
			'titlePosition': 'over'
		});
	}
	
	if (jQuery('#galleryContent').length>0) {
	
		//Process Photo Fancybox
		$("#galleryContent a").fancybox({
			'overlayColor': '#2e333a',
			'overlayOpacity': '0.7',
			'transitionIn': 'elastic',
			'transitionOut': 'elactic',
			'titlePosition': 'over'
		});
	}		
	
	if (jQuery('#emailForm').length>0) {
	
		//Email form validate
		$("#emailForm").RSV({
			onCompleteHandler: myOnComplete,
			errorFieldClass: "errorField",
			rules: [
				"required,name,Please enter your name.",
				"required,phone,Please enter your phone number.",
				"required,email,Please enter your email address.",
				"valid_email,email,Please enter a valid email address."
			]
		});	
	}
});
