var blurb_texts = {
    // "id" : "text for blurb"
    "nav-home" : "The main blog with posts by The Wedding Chicks.",
    "nav-RW" : "Real weddings posted daily by real vendors.",
    "nav-RB" : "A place for brides to blog, share, and be inspired.",
    "nav-plan" : "Find the perfect vendors for your Big Day.",
    "nav-diy" : "Browse our unique DIY projects and exclusive free downloads.",
    "nav-sweet" : "Amazing offers posted by The Wedding Chicks vendors.",
    "nav-hp" : "View outstanding vendors hand picked by The Wedding Chicks.",
    "nav-shop" : "Find adorable custom tees, tanks, and more in our shop."
};

var _whatever = new Array();
var _t = 0;
var _max = 0;
function fff() {
    if (_whatever.length == 0) {
	jQuery('#myGallery > .imageElement').each(function () {
	    _whatever.push(this);
	});
	_max = _whatever.length - 1;
    }
    if (_t > _whatever.length) _t = 0;
    if (_t == _max) next = 0;
    else next = _t + 1;

    jQuery(_whatever[_t]).fadeOut('slow', function () {
	jQuery(_whatever[next]).fadeIn('slow');
    });

    if (_t == _max) _t = 0;
    else _t += 1;
    setTimeout('fff()', 5000);
}

function SlideShow(selector) {
    this.delay = 5000;
    this.selector = selector;

    this.next = function() {
	console.log(this);
	if (this.q == undefined) {
	    jQuery(this.selector + " > .imageElement").each(function() {
		_whatever.push(this)
	    });
	}
	console.log('hi there = ' + _whatever);
	this.timer = setTimeout(this.next, this.delay);
    };

    this.timer = setTimeout(this.next, this.delay);
}

function monogram_submit(target) {
    if (target == undefined) {
	target = '.monogram-form';
    }
    // TODO: validation
    jQuery.post(
	'/draw/monogram.php', 
	jQuery(target).serialize(), 
	function(data) {
		jQuery('#success-div').fadeIn();	
	    // todo: add success stuff
	}
    );
}

jQuery(document).ready(function(){
       jQuery.fn.fadeToggle = function(speed, easing, callback) {
          return this.animate({opacity: 'toggle'}, speed, easing, callback);
       };

       // Add a timestamp to the Dessy Group 1 ad.
       var tstamp = new Date().getTime();

       var link_href = jQuery(".dessy_ad_link").attr('href');
       var img_src = jQuery(".dessy_ad_link > img").attr('src');
       if (link_href && img_src) {
	   jQuery(".dessy_ad_link > img").attr('src', img_src.replace('DESSY_TSTAMP', tstamp));
	   jQuery(".dessy_ad_link").attr('href', link_href.replace('DESSY_TSTAMP', tstamp));
       }

       var small_href = jQuery(".dessy_ad_link_small").attr('href');
       var small_src = jQuery(".dessy_ad_link_small > img").attr('src');
       if (small_href && small_src) {
	   jQuery(".dessy_ad_link_small").attr('href', small_href.replace('DESSY_TSTAMP', tstamp));
	   jQuery(".dessy_ad_link_small > img").attr('src', small_src.replace('DESSY_TSTAMP', tstamp));
       }
       // jQuery(".dessy_ad_link").attr('href', "http://ad.doubleclick.net/jump/N6103.286691.WEDDINGCHICKS.COM/B4907666;sz=300x250;ord=DESSY_TSTAMP?".replace('DESSY_TSTAMP', tstamp)).html('<img src="http://ad.doubleclick.net/ad/N6103.286691.WEDDINGCHICKS.COM/B4907666;sz=300x250;ord=DESSY_TSTAMP?" border=0 width=300 height=250 alt="Click Here">'.replace('DESSY_TSTAMP', tstamp));

       // jQuery(".dessy_ad_link_small").attr('href', "http://ad.doubleclick.net/jump/N6103.286691.WEDDINGCHICKS.COM/B4907666.2;sz=300x120;ord=DESSY_TSTAMP?".replace('DESSY_TSTAMP', tstamp)).html('<img src="http://ad.doubleclick.net/ad/N6103.286691.WEDDINGCHICKS.COM/B4907666.2;sz=300x120;ord=DESSY_TSTAMP?" border=0 width=300 height=120 alt="Click Here">'.replace('DESSY_TSTAMP', tstamp));

       jQuery(".comment_button").click(function (){
         var p = jQuery(this).parents('.share_comment_1')[0];
         jQuery(p).children('.seecomments').fadeToggle();
       });
       jQuery(".monogram-form").show();
       jQuery(".monogram-facade").hide();

       jQuery(".leave_button").click(function (){
         jQuery('.seecomments').hide()
         var p = jQuery(this).parents('.share_comment_1')[0];
         var c = jQuery(p).children('.respond');
         jQuery(c).fadeToggle();
       });
       
	jQuery(".mylink img").hover(function(evt) {
	    this.src = this.src.replace("1","2");
	    jQuery('#' + this.className).text(blurb_texts[this.id]);
	    jQuery('#' + this.className).fadeIn();
	},
	function(evt) {
	    this.src = this.src.replace("2","1");
	    jQuery('#' + this.className).hide();
	});

	// if there are forms that should email out monograms, modify them to do so.
	// We are now showing these in the browser, not emailing them
	// jQuery('.monogram-form').submit(function (evt) {
	 //    monogram_submit(evt.target);
	   //  return false;
	// });
	
		jQuery("#vendor_login_link").click(function() {
		 jQuery("#LoginWithAjax_Form").fadeToggle();
		});
		
		jQuery("#LoginWithAjax_Links_Remember").click(function(){
		 jQuery("#LoginWithAjax_Form").hide();
		});
       
       jQuery(".dest_wed_sub a").click(function () {
         jQuery(this).parent('li').children('ul:first').fadeToggle("normal")
   		 });   
		
		jQuery(".side_cat_title").click(function() {
    	  jQuery("#side_cat_list").fadeToggle("normal");
    	});
    	
    	jQuery(".side_archives_title").click(function() {
    	  jQuery("#side_archives_list").fadeToggle("normal");
    	});
    	
    	jQuery("#USgraphic").click(function() {
    	  jQuery("#USlist").toggle("normal");
    	});
    	
    	jQuery("#worldgraphic").click(function() {
    	  jQuery("#worldlist").toggle("normal");
    	});
    	
    	jQuery(".bio_pinkbutton").click(function() {
         jQuery(this).children('.review').fadeToggle("normal");
    	});         
        
        jQuery("a[href*='http://']:not([href*='weddingchicks.com'])").attr("target","_blank");
 });

/*-------------------------------------------------------------------- 
 * jQuery plugin: customInput()
 * by Maggie Wachs and Scott Jehl, http://www.filamentgroup.com
 * Copyright (c) 2009 Filament Group
 * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
 * Article: http://www.filamentgroup.com/lab/accessible_custom_designed_checkbox_radio_button_inputs_styled_css_jquery/  
 * Usage example below (see comment "Run the script...").
--------------------------------------------------------------------*/


jQuery.fn.customInput = function(){
	jQuery(this).each(function(i){	
		if(jQuery(this).is('[type=checkbox],[type=radio]')){
			var input = jQuery(this);
			
			// get the associated label using the input's id
			var label = jQuery('label[for='+input.attr('id')+']');
			
			//get type, for classname suffix 
			var inputType = (input.is('[type=checkbox]')) ? 'checkbox' : 'radio';
			
			// wrap the input + label in a div 
			jQuery('<div class="custom-'+ inputType +'"></div>').insertBefore(input).append(input, label);
			
			// find all inputs in this set using the shared name attribute
			var allInputs = jQuery('input[name='+input.attr('name')+']');
			
			// necessary for browsers that don't support the :hover pseudo class on labels
			label.hover(
				function(){ 
					jQuery(this).addClass('hover'); 
					if(inputType == 'checkbox' && input.is(':checked')){ 
						jQuery(this).addClass('checkedHover'); 
					} 
				},
				function(){ jQuery(this).removeClass('hover checkedHover'); }
			);
			
			//bind custom event, trigger it, bind click,focus,blur events					
			input.bind('updateState', function(){	
				if (input.is(':checked')) {
					if (input.is(':radio')) {				
						allInputs.each(function(){
							jQuery('label[for='+jQuery(this).attr('id')+']').removeClass('checked');
						});		
					};
					label.addClass('checked');
				}
				else { label.removeClass('checked checkedHover checkedFocus'); }
										
			})
			.trigger('updateState')
			.click(function(){ 
				jQuery(this).trigger('updateState'); 
			})
			.focus(function(){ 
				label.addClass('focus'); 
				if(inputType == 'checkbox' && input.is(':checked')){ 
					jQuery(this).addClass('checkedFocus'); 
				} 
			})
			.blur(function(){ label.removeClass('focus checkedFocus'); });
		}
	});
};

	
	

