// Cufon.now();
// 
// Cufon.replace('.site_menu .current_page_item', {  color: '#fff', hover: { color: '#fff'}});
// Cufon.replace('.menu_container li a', {  hover: { color: '#fff'}});
// Cufon.replace('.site_menu .current_page_item', {  color: '#fff'});
// Cufon.replace('.site_menu ul .current_page_item', {  color: '#555', hover: { color: '#fff'}});
// Cufon.replace('.headlines_menu li a', {  color: '#fff', hover: { color: '#555'}});
// Cufon.replace('.ah, .some_title, h1, h2, h3, h4, h5, .title, .widgets_title, .recent_inside_title, .simple_page_title, .custom_title');
// 
// Cufon.replace('.page_categories ul li.current_page_item', {  color: '#32719E', hover: { color: '#32719E'}});
// Cufon.replace('.page_categories ul li', {  color: '#555', hover: { color: '#32719E'}});
// Cufon.replace('.page_categories ul li.current_page_item', {  color: '#32719E'});
// 
// 
// Cufon.replace('.page_navigation_container ul li.current_page_item', {  color: '#32719E', hover: { color: '#32719E'}});
// Cufon.replace('.page_navigation_container ul li', {  color: '#555', hover: { color: '#32719E'}});
// Cufon.replace('.page_navigation_container ul li.current_page_item', {  color: '#32719E'});
// 	
$(document).ready(function(){
// 
// 	// We only want these styles applied when javascript is enabled
// 	$('div.gf_navigation').css({'width' : '850px'});//, 'float' : 'left'});
// 	$('div.gf_content').css('display', 'block');
// 
// 	// Initially set opacity on thumbs and add
// 	// additional styling for hover effect on thumbs
// 	var onMouseOutOpacity = 0.67;
// 	$('#gf_thumbs ul.gf_thumbs li').opacityrollover({
// 		mouseOutOpacity:   onMouseOutOpacity,
// 		mouseOverOpacity:  1.0,
// 		fadeSpeed:         'fast',
// 		exemptionSelector: '.selected'
// 	});
// 
// 	// Enable toggling of the caption
// 	var captionOpacity = 0.0;
// 	$('#gf_captionToggle a').click(function(e) {
// 		var link = $(this);
// 		
// 		var isOff = link.hasClass('off');
// 		var removeClass = isOff ? 'off' : 'on';
// 		var addClass = isOff ? 'on' : 'off';
// 		var linkText = isOff ? 'Hide Caption' : 'Show Caption';
// 		captionOpacity = isOff ? 0.7 : 0.0;
// 
// 		link.removeClass(removeClass).addClass(addClass).text(linkText).attr('title', linkText);
// 		$('#gf_caption span.gf_image-caption').fadeTo(1000, captionOpacity);
// 		
// 		e.preventDefault();
// 	});
// 	
// 	// Initialize Advanced Galleriffic Gallery
// 	var gallery = $('#gf_thumbs').galleriffic({
// 		delay:                     2500,
// 		numThumbs:                 9,
// 		preloadAhead:              10,
// 		enableTopPager:            true,
// 		enableBottomPager:         false,
// 		maxPagesToShow:            7,
// 		imageContainerSel:         '#gf_slideshow',
// 		controlsContainerSel:      '#gf_controls',
// 		captionContainerSel:       '#gf_caption',
// 		loadingContainerSel:       '#gf_loading',
// 		renderSSControls:          true,
// 		renderNavControls:         true,
// 		playLinkText:              'Play Slideshow',
// 		pauseLinkText:             'Pause Slideshow',
// 		prevLinkText:              '&lsaquo; Previous Photo',
// 		nextLinkText:              'Next Photo &rsaquo;',
// 		nextPageLinkText:          'Next &rsaquo;',
// 		prevPageLinkText:          '&lsaquo; Prev',
// 		enableHistory:             true,
// 		autoStart:                 false,
// 		syncTransitions:           true,
// 		defaultTransitionDuration: 900,
// 		onSlideChange:             function(prevIndex, nextIndex) {
// 			// 'this' refers to the gallery, which is an extension of $('#thumbs')
// 			this.find('ul.gf_thumbs').children()
// 				.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
// 				.eq(nextIndex).fadeTo('fast', 1.0);
// 		},
// 		onTransitionOut:           function(slide, caption, isSync, callback) {
// 			slide.fadeTo(this.getDefaultTransitionDuration(isSync), 0.0, callback);
// 			caption.fadeTo(this.getDefaultTransitionDuration(isSync), 0.0);
// 		},
// 		onTransitionIn:            function(slide, caption, isSync) {
// 			var duration = this.getDefaultTransitionDuration(isSync);
// 			slide.fadeTo(duration, 1.0);
// 			
// 			// Position the caption at the bottom of the image and set its opacity
// 			var slideImage = slide.find('img');
// 			caption.width(slideImage.width())
// 				.css({
// 					'bottom' : Math.floor((slide.height() - slideImage.outerHeight()) / 2),
// 					'left' : Math.floor((slide.width() - slideImage.width()) / 2) + slideImage.outerWidth() - slideImage.width()
// 				})
// 				.fadeTo(duration, captionOpacity);
// 		},
// 		onPageTransitionOut:       function(callback) {
// 			this.fadeTo('fast', 0.0, callback);
// 		},
// 		onPageTransitionIn:        function() {
// 			this.fadeTo('fast', 1.0);
// 		},
// 		onImageAdded:              function(imageData, $li) {
// 			$li.opacityrollover({
// 				mouseOutOpacity:   onMouseOutOpacity,
// 				mouseOverOpacity:  1.0,
// 				fadeSpeed:         'fast',
// 				exemptionSelector: '.gf_selected'
// 			});
// 		}
// 	});
// 	
	// pretty photo
	$("a[rel^='prettyPhoto']").prettyPhoto({
		theme:'dark_square',
		social_tools: '<div class="pp_social"><div class="twitter"><a href="http://twitter.com/share" class="twitter-share-button" data-count="none" data-via="AngelofWaterCM1">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="facebook"><iframe src="http://www.facebook.com/plugins/like.php?locale=en_US&href='+location.href+'&amp;layout=button_count&amp;show_faces=true&amp;width=500&amp;action=like&amp;font&amp;colorscheme=light&amp;height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:23px;" allowTransparency="true"></iframe></div></div>'
		});
	
	// notifications
	$('#success').hide();
	$('#error').hide();
	
	$('#myform').FormValidate({
		phpFile:"mail.php",
		ajax:true
	});
	
	
		$('.portfolio_box_anime').hover(function(){
		$(".portfolio_zoom", this).fadeIn('500');
	
	}, function() {
		$(".portfolio_zoom", this).fadeOut('500');
	});
	
	
		$(".activefocus").focus(function () {
			if ($(this).attr("value") == $(this).attr("defaultValue")) {
					$(this).attr("value", '');
			}

	});

	$(".activefocus").blur(function () {
			if ($(this).attr("value") == '') {
					$(this).attr("value", $(this).attr("defaultValue"));
			}

	});
	
});


jQuery.iFormValidate = {
	build : function(options)
	{
		var defaults = {
			phpFile:"mail.php",
			ajax: true
		};
		var options = $.extend(defaults, options); 
		return $(this).each(
			function() {
			$inputs = $(this).find(":input").filter(":not(:submit)");
			$(this).submit(function(){
				var isValid = jQuery.iFormValidate.validateForm($inputs);
				if(!isValid){
					$('#error').fadeIn("slow");
					$('#success').fadeOut("slow");
					return false;
				};
				if(options.ajax){
					var data = {};
					$inputs.each(function(){
						data[this.name] = this.value
					});
					$inputs.each(function(){
						data[this.name] = this.value
						
					});
					
						$('#error').fadeOut("slow");
						$('#success').load(options.phpFile, data, function(){
						$('#success').fadeIn("slow");
						
						
						$(':input','#myform')
						 .not(':button, :submit, :reset, :hidden')
						 .val('')
						 .removeAttr('checked')
						 .removeAttr('selected');

					});
					return false;
				}else{
					return true;
				}
			});
			
			$inputs.bind("keyup", jQuery.iFormValidate.validate);
			$inputs.filter("select").bind("change", jQuery.iFormValidate.validate);
		});
	},
	validateForm : function($inputs)
	{
		var isValid = true; //benifit of the doubt?
		$inputs.filter(".is_required").each(jQuery.iFormValidate.validate);
		if($inputs.filter(".is_required").hasClass("invalid")){isValid=false;}
		return isValid;
	},
		
	validate : function(){
		var $val = $(this).val();
		var isValid = true;
		

		
		if($(this).hasClass('vdate')){
			var Regex = /^([\d]|1[0,1,2]|0[1-9])(\-|\/|\.)([0-9]|[0,1,2][0-9]|3[0,1])(\-|\/|\.)\d{4}$/;
			isValid = Regex.test($val);
		}else if($(this).hasClass('vemail')){
			var Regex =/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if(!Regex.test($val)){isValid = false;};
		}else if($(this).hasClass('vname')){
			if($val == "name" || $val == ""){
				isValid = false;
				$('.vname').val('name');
				$('.vsemail').val('email address');
				$('.vsubject').val('subject');
				$('.vmessage').val('message');
			};
		}else if($(this).hasClass('vsemail')){
			if($val == "email address" || $val == ""){
				isValid = false;
			};
		}else if($(this).hasClass('vsubject')){
			if($val == "subject" || $val == ""){
				isValid = false;
			};
		}else if($(this).hasClass('vmessage')){
			if($val == "message" || $val == ""){
				isValid = false;
			};
		}else if($(this).hasClass('vphone')){
			var Regex =/^([0-9a-zA-Z]+([_+.-]?[0-9a-zA-Z]+)*@[0-9a-zA-Z]+[0-9,a-z,A-Z,.,-]*(.){1}[a-zA-Z]{2,4})+$/;
			if(!Regex.test($val)){isValid = false;}
		}else if($val.length == 0){
			isValid = false;
		}
		
		if(isValid){
			$(this).removeClass("invalid");
			$(this).addClass("valid");
		}else{
			$(this).removeClass("valid");
			$(this).addClass("invalid");
		}
		return isValid;
	}	
}
jQuery.fn.FormValidate = jQuery.iFormValidate.build;









         $(function() {
                $('.headlines_content').tabs({ fxFade: true, fxSpeed: 'fast' });
            });

   
    function formatText(index, panel) {
	  return index + "";
    }
    
    $(function () {
        
		$('.anythingSlider').anythingSlider({
            easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
            autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
            delay: 3000,                    // How long between slide transitions in AutoPlay mode
            startStopped: false,            // If autoPlay is on, this can force it to start stopped
            animationTime: 600,             // How long the slide transition takes
            hashTags: true,                 // Should links change the hashtag in the URL?
            buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
        	pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
			startText: null,             // Start text
			stopText: null,               // Stop text
			navigationFormatter: function(){}   
		});
            
        $("#slide-jump").click(function(){
            $('.anythingSlider').anythingSlider(1);
        });
    
    });
