/*-------------------------------------------------------------------- 
 * JQuery Plugin: "EqualHeights"
 * by:	Scott Jehl, Todd Parker, Maggie Costello Wachs (http://www.filamentgroup.com)
 *
 * Copyright (c) 2008 Filament Group
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Description: Compares the heights or widths of the top-level children of a provided element 
 		and sets their min-height to the tallest height (or width to widest width). Sets in em units 
 		by default if pxToEm() method is available.
 * Dependencies: jQuery library, pxToEm method	(article: 
		http://www.filamentgroup.com/lab/retaining_scalable_interfaces_with_pixel_to_em_conversion/)							  
 * Usage Example: $(element).equalHeights();
  		Optional: to set min-height in px, pass a true argument: $(element).equalHeights(true);
 * Version: 2.0, 08.01.2008
--------------------------------------------------------------------*/

$.fn.equalHeights = function(px) {
	$(this).each(function(){
		var currentTallest = 0;
		$(this).children().each(function(i){
			if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
		});
		if (!px || !Number.prototype.pxToEm) currentTallest = currentTallest.pxToEm(); //use ems unless px is specified
		// for ie6, set height since min-height isn't supported
		if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({'height': currentTallest}); }
		$(this).children().css({'min-height': currentTallest}); 
	});
	return this;
};

$(document).ready(function() {
var sPath = window.location.href;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
var giftoffer = 0;

        if( giftoffer && sPage.indexOf('one-page-checkout.asp')  != -1 ) {
            $('input[name^="Orders.Custom_Field_FreeCami"]').closest('tr').hide();
            var currency = $('font.colors_productprice').text();
            var amount = currency.replace(/[^0-9\.]+/g,"");
            if( amount >= 200.00 ) {
             $('input[name="Orders.Custom_Field_FreeCamiName"]').closest('tr').append('<td rowspan="3"></td><td rowspan="3" valign="top" width="225px"><i><b>Free Camisole!</b><br>All orders over $200 are eligible for a free Camisole as a gift for a friend.  Please provide a friend&apos;s name, shipping address and preferred size and we will handle the rest.</i></td>');
             $('input[name="Orders.Custom_Field_FreeCamiAddress"]').replaceWith('<textarea rows="3" columns="30" name="Orders.Custom_Field_FreeCamiAddress"></textarea>');
             var tmpTD = $('input[name="Customers.Custom_Field_Birthday"]').parent();

var tmpTR = tmpTD.closest('tr');
tmpTR.append("<td></td><td><i>"+tmpTD.text()+"</i></td>");
tmpTD.empty().html('<input type="text" maxlength="50" name="Customers.Custom_Field_Birthday" value />');

$('[name="Customers.Custom_Field_Foundushow"]').closest('td').attr('colspan',3);
$('[name="Orders.Custom_Field_GiftWrap"]').closest('td').attr('colspan',3);
             $('[name^="Orders.Custom_Field_FreeCami"]').closest('tr').show();
          } else {
            $('input[name^="Orders.Custom_Field_FreeCami"]').closest('tr').hide();
          }
       }

	$("div.swatch").hover( function() {
		var swatchimgsrc = $(this).find("img").attr("src");
		var showsamplesrc = swatchimgsrc.replace(/colorpage/, "colorpage/samples");
		var showsampleimg = $("div#show-sample").find("img");
		showsampleimg.attr("src", showsamplesrc).stop().show();
	});

	$("ul#slides").hover( function() {
		$("div.bw").stop().fadeTo('normal', 0, function() {
			$("div.bw").hide() //Hide the bw div after fade in of color div
		});
	} , function() { //on hover out...
		//Fade the image to 1 
		$("div.bw").stop().fadeTo('normal', 1).show();
	});

	$("#slideshow").css("overflow", "hidden");
	
	$("ul#slides").cycle({
		fx: 'fade',
		pause: 1,
                timeout: 60000,
		startingSlide: Math.floor( Math.random() * 3 )
	});
	
	$("#slideshow").hover(function() {
    	$("ul#nav").fadeIn();
  	},
  		function() {
    	$("ul#nav").fadeOut();
  	});
   $("#adea-career").hover( function() {
        $("ul#slides").cycle(0);
        return false;
    });
    $("#adea-travel").hover( function() {
        $("ul#slides").cycle(1);
        return false;
    });
    $("#adea-play").hover( function() {
        $("ul#slides").cycle(2);
        return false;
    })	
        
   	$("ul.rollover li").hover(function() { //On hover...
		var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
var label = $(this).find("div.thumb-label");

		
      	//Set a background image(thumbOver) on the &lt;a&gt; tag 
		$(this).find("a.button").css({'background' : '#000000 url(' + thumbOver + ') no-repeat center bottom'});
		//Fade the image to 0 
		$(this).find("span").stop().fadeTo('normal', 0 , function() {
			$(this).hide() //Hide the image after fade
		}); 
if( label ) {
label.stop().fadeTo('normal', 1).show();
}
	} , function() { //on hover out...
var label = $(this).find("div.thumb-label");
		//Fade the image to 1 
		$(this).find("span").stop().fadeTo('normal', 1).show();
if( label ) {
label.stop().fadeTo('normal', 0, function() {
label.hide();
});
}
	});

var url = window.location.href;


//if( url.search (/\/s-/) > -1 ) {
//$("#page-body").addClass("black-background");
//} else {
//$("#page-body").addClass("white-background"); 
//}

$("#MainForm table:first").hide();

});
