$(document).ready(function(){
	// add mouseovers for tiles
	$('.tiles li')
		.hover(function() {
			$(this).find('img').stop().animate({ opacity: .2 }, 'medium');
		}, function() {
			$(this).find('img').stop().animate({ opacity: 1}, 'medium');
	});
	//
	function BeforeCycle(curr,next,opts) { 
		$('.content').hide();
	} 	
	function AfterCycle(curr,next,opts) { 
		$('.content')
		.hide()
		.animate({
			height: 'toggle'
		  }, {
			duration: 2500, 
			specialEasing: {
			  height: 'easeOutQuint'
			}//, 
			//complete: function() {
			 // $(this).after('<div>done!</div>');
			//}
		  });
	} 
	$('ul#feature')
			.cycle({ 
				before:  BeforeCycle, 
				after:  AfterCycle, 
				fx: 'fade', 
				easeIn: 'easeInQuint', 
				easeOut: 'easeOutQuint', 
				timeout:  10000,
				cleartype: true,
				cleartypeNoBg: true,
				speedIn:  1000, 
				speedOut:  500
			}			
		);
	//
	$('#socnetList a[href*="twitter"]').addClass('twitter_link');
	$('#socnetList a[href*="facebook"]').addClass('facebook_link');
	

   

	$("#socnetList a[href^='/girlup/posts']").attr('href', function() { return this.replace(/girlup/, 'upgirl'); });

	// in case feed wigs out and uses relative urls
	//$('.socnet_list a[href^="/posted.php"]').val('/facebook.com'+(this).attr('href')).addClass('facebook_link');
	//$('.socnet_list a[href^="/posted.php"]').attr('href','/facebook.com'+(this).attr('href')).addClass('facebook_link');

	
	$('#socnetList').after('<div id="socnetNav"></div>');
	// convio wraps feeds in a div, we need to remove 
	var husk = $("#socnetList div"); // wrapper element
	husk.children('li').insertBefore(husk);  // insert children before wrapper element
	husk.remove(); // remove wrapper element 
	//	connect widget
	$('#socnetList')
			.cycle({ 
				fx:      'fade', 
				pagerEvent:   'click',
				speed:    500, 
				timeout:  15000,
				pager:  '#socnetNav',
                pagerAnchorBuilder: function(idx, slide) {
					var lnk = $('.post_text a',slide).attr('class');
//					if($(lnk*="facebook")){
//                        var socNetClass = 'fb';
//					} else if($(lnk*="twitter")) {
//                        var socNetClass = 'tw';
//					}
					return '<a class="'+ lnk +'" href="#">'+idx+'</a>';
                }
        }); 

	//	hi 5 widget
	$('.front #hiFive').after('<div id="hiFiveNav"></div>');
	$('.front #hiFive')
			.cycle({ 
				fx:      'fade', 
				// pagerEvent:   'click',
				speed:    500, 
				timeout:  0,
				pager:  '#hiFiveNav'			
			}			
	);
	//

	//	teamraiser-demo
	$('#teamraiser-slides-wrapper')
			.cycle({ 
				fx:      'fade', 
				pagerEvent:   'click',
				speed:    500, 
				timeout:  0,
				pager:  '#teamraiser-nav2',
				pagerAnchorBuilder: function(idx, slide) {
					// return selector string for existing anchor
					return '#teamraiser-nav li:eq(' + idx + ') a';
				}    
			}
		);
		$('.direct-0').click(function() { 
			$('#teamraiser-slides-wrapper').cycle(0); 
			return false; 
		}); 
		$('.direct-1').click(function() { 
			$('#teamraiser-slides-wrapper').cycle(1); 
			return false; 
		}); 
		$('.direct-2').click(function() { 
			$('#teamraiser-slides-wrapper').cycle(2); 
			return false; 
		});
		$('.direct-3').click(function() { 
			$('#teamraiser-slides-wrapper').cycle(3); 
			return false; 
		}); 
		$('.direct-4').click(function() { 
			$('#teamraiser-slides-wrapper').cycle(4); 
			return false; 
		}); 
		$('.direct-5').click(function() { 
			$('#teamraiser-slides-wrapper').cycle(5); 
			return false; 
		}); 
		$('.direct-6').click(function() { 
			$('#teamraiser-slides-wrapper').cycle(6); 
			return false; 
		}); 
		$('.direct-7').click(function() { 
			$('#teamraiser-slides-wrapper').cycle(7); 
			return false; 
		}); 
		$('.direct-8').click(function() { 
			$('#teamraiser-slides-wrapper').cycle(8); 
			return false; 
		}); 
		$('.direct-0').click(function() { 
			$('#teamraiser-slides-wrapper').cycle(0); 
			return false; 
		});  	
	//

	//
	function temp(){

	}
	//
	
	$('#signUp #cons_email').focus(function () {
		$(this).addClass('uFocus');
		if( $(this).val()=='Email*' ) {
			$(this).val('');
		}
	});
	$('#signUp #cons_zip_code').focus(function () {
		$(this).addClass('uFocus');
		if( $(this).val()=='Zip/Postal code*' ) {
			$(this).val('');
		}
	});
	$('#signUp #cons_first_name').focus(function () {
		$(this).addClass('uFocus');
		if( $(this).val()=='First name' ) {
			$(this).val('');
		}
	});
	//restore login form text
	$('#signUp #cons_email').blur(function () {
		$(this).removeClass('uFocus');
		if( $(this).val()=='') {
			$(this).val('Email*');
		}
	});
	$('#signUp #cons_zip_code').blur(function () {
		$(this).removeClass('uFocus');
		if( $(this).val()=='') {
			$(this).val('Zip/Postal code*');
		}
	});
	// font replacement
	  Cufon.replace('h1 , h2 , h3', {
		  hover: true
	  });
	  Cufon.replace('ul#primary-links li a', {
		  hover: true
	  });
	  Cufon.replace('ul#feature li h3', {
		  hover: false
	  });
	  Cufon.replace('ul#feature li p.fact', {
		  hover: false
	  });
	//
	//var what = $('ul#primary-links a').text();
	//$('ul#primary-links a').text(what + 'test');
    // reload cufon on carousel wrap
    $('#caro_1').jcarousel({
    	wrap: 'circular',
		easing: 'easeOutQuint',
		animation: 'slow'//,
     // itemVisibleInCallback: {onBeforeAnimation: ItemVisibleInCallback}
    });
	// tweets
	//search form: focus elements
	$('#cons_searchterm').focus(function () {
		$(this).addClass('uFocus');
		if( $(this).val()=='Search' ) {
			$(this).val('');
		}
	});
	//restore login form text
	$('#cons_searchterm').blur(function () {
		$(this).removeClass('uFocus');
		if( $(this).val()=='') {
			$(this).val('Search');
		}
	});
	//
	//$('a.vid_link').wrap('<div class="thumb_frame_outer">');
	//$('img.vid_thumb').before('<div class="thumb_frame_inner"></div>');
});



