$(document).ready(function() {
	// Cufon settings
    Cufon.replace('h1, h2, h3, h4, #gNav li, #howItWorksList p, #requestedWrapText, #requestedWrapText2, .cufonReg', { fontFamily: 'DIN', hover: true });
    Cufon.replace('form#sendInvitationForm label, #secNav .header p, #storeFilter h3',         { fontFamily: 'DIN' });
    Cufon.replace('#myMintboxInvitationHdr h2, #pageLinks li a, #pageLinks li span, #orderDetailItemDesc h3',    { fontFamily: 'DINBold', hover: true });
    Cufon.replace('#orderDetailShippingDesc div h3, .overlayInnerModuleContent h3, #confirmationDetails h3, .redemptionOptsModule h4', { fontFamily: 'DINBold', hover: true });
    Cufon.replace('.sideNav li, .cufonBld, .cufonBld h4, .viewall, #howItWorksWrap h3, a.arrowRightOnDark, .overlayContent h3.onlineSaleInfo a',  { fontFamily: 'DINBold', hover: true });
    Cufon.replace('.editorsPicksItem.style_3 .editorsPicksTitle h3, #sendInvitation h3, #sendPersonalLink h3',    { fontFamily: 'DINBold', hover: true });
    Cufon.replace('a.changeBtn, #whyMintBoxLeft h4, button.btnRender, a.btnStandard, a#howItWorksBtn, #landingPartners h4, #privateSaleClone h4', { fontFamily: 'DINBold', hover: true });
    Cufon.replace('#scNav li, .butbuynow h4, .scci_total_checkout h4, .osbw_item_vccgroup_checkout h4, .buynow_addtocart h4, .greenbutton h4',    { fontFamily: 'DINBold', hover: true });
    Cufon.replace('.editorsPicksItem .editorsPicksTitle p, .cufonBodo, .osbw_item_title h3, .description_group_title h2, #requestedWrapTitle', { fontFamily: 'Bodoni' });
	
	// Sortable list drop-down menu
	$("#btn_sortByWrap").hover(function(){
		$('a.btn_sortBy').addClass('active');
        $('ul#sortByMenu').css('display', 'block');
    }, function(){
		$('a.btn_sortBy').removeClass('active');
        $('ul#sortByMenu').css('display', 'none');
    });
    $('a.btn_sortBy').click(function(e){
		e.preventDefault();
	});
	
    $('#float_login_box').overlay({
        top:160, fixed: false, closeOnClick: false, load: false,
        mask: {color:'#fff', loadSpeed: 200, opacity: 0.1}
    });
    
	$('#signin_link, #signin_link2').click(function() {
        //$.cookie('WebSite','show_signin', {path:'/'});
        //$('#float_login_box').show();
        $("#float_login_box").appendTo('body');
        $('#float_login_box').overlay().load();
        $('#registerWrap2').fadeOut(250);
        $('#signInWrap2').fadeIn(250);
        $('#signInEmail2').focus();
        $.post('/WebSite/LogPageView', {pageId: 101}, function(){}, 'json' );
        return false;
    });
	$('#signup_link, #signup_link2').click(function() {
        //$.cookie('WebSite','show_signup', {path:'/'});
        $("#float_login_box").appendTo('body');
        $('#float_login_box').overlay().load();
        $('#signInWrap2').fadeOut(250);
        $('#registerWrap2').fadeIn(250);
        $.post('/WebSite/LogPageView', {pageId: 103}, function(){}, 'json' );
        return false;
    });
    
    //change location 
    $('#showChangeLocation>a').click(function () {
        $(this).addClass('active');
        $('#changeLocation').show();
        $('#alertsDetail').hide();
        $('#showAlerts > a').removeClass('active');
        return false;
    });

    $('#changeLocation #location-close').click(function () {
        $('#changeLocation').hide();
        $('#showChangeLocation a').removeClass('active');
        return false;
    });

	//Email Preferences Toggle
	/*
	$('#emailPrefsSettingsForm li, #emailPrefsSettingsForm li').click(function(e){
		e.preventDefault();
		$(this).find('span').toggleClass('on');
	});
	//Email Preferences Confirmation Overlays
	$(".emailPrefOverlay[rel]").overlay({
		closeOnClick: true,
		fixed: false
	});
	// Brand Feature Overlays
	$("a.rsvpOverlay[rel]").overlay({
		closeOnClick: true,
		fixed: false
	});
	*/
    
    /*************** FOR OLD FEATURE PAGE  *****************
	// Give every 1st of 3 the class of "first"
	$('.redemptionOptsModule:nth-child(3n+1)').addClass('first');
	// Apply Equal Heights plugin
	$('.redemptionOptsModule').equalHeights();
	*******************************************************/
	
	// Form placeholder text
	$('.default-value').each(function() {
	    var default_value = this.value;
	    $(this).focus(function() {
	        if(this.value == default_value) {
	            this.value = '';
	            $(this).css('color', '#333');
	        }
	    });
	    $(this).blur(function() {
	        if(this.value == '') {
	            $(this).css('color', '#333');
	            this.value = default_value;
	        }
	    });
	});
	
	// to prevent to overflow the text from the box (ending soon offers)
    $('.clientNameInBox').each(function() {
        var overflow = $(this).textWidth() - 78;
        if (overflow > 0) {
            overflow = 94 + overflow;
            $(this).parent().parent().css('width', overflow + 'px' );
        }
    });
});


/**
 * Equal Heights Plugin
 * Equalize the heights of elements. Great for columns or any elements
 * that need to be the same size (floats, etc).
 * 
 * Version 1.0
 * Updated 12/10/2008
 *
 * Copyright (c) 2008 Rob Glazebrook (cssnewbie.com) 
 *
 * Usage: $(object).equalHeights([minHeight], [maxHeight]);
 * 
 * Example 1: $(".cols").equalHeights(); Sets all columns to the same height.
 * Example 2: $(".cols").equalHeights(400); Sets all cols to at least 400px tall.
 * Example 3: $(".cols").equalHeights(100,300); Cols are at least 100 but no more
 * than 300 pixels tall. Elements with too much content will gain a scrollbar.
 * 
 */
(function($) {
	$.fn.equalHeights = function(minHeight, maxHeight) {
		tallest = (minHeight) ? minHeight : 0;
		this.each(function() {
			if($(this).height() > tallest) {
				tallest = $(this).height();
			}
		});
		if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
		return this.each(function() {
			$(this).height(tallest).css("overflow","auto");
		});
	}
	/* Jun added to measure the length of text - ex) client name for ending soon offer*/
    $.fn.textWidth = function(){
      var sensor = $('<div />').css({margin: 0, padding: 0});
      $(this).append(sensor);
      var width = sensor.width();
      sensor.remove();
      return width;
    }
})(jQuery);









