
/* Fix MSIE6 Image flicker */var m = document.uniqueID /*IE*/ && document.compatMode /*>=IE6*/ && !window.XMLHttpRequest /*<=IE6*/ && document.execCommand ; try{ if(!!m){ m("BackgroundImageCache", false, true) /* = IE6 only */ } }catch(oh){};

// Site credits
$('a#sitecredits').hover(
	function(){$(this).text('CreateThe Group');},
	function(){$(this).text('Site Credits');}
);

// Global promo
var globalPromo = function() {
    var $this = $("#globalpromo");

    $this.find("dt a").click(function() {
        $this.find("dd").fadeIn();
        return false;
    });

    $this.find(".btn-close").click(function() {
        $this.find("dd").fadeOut();
    });
};
globalPromo();

// Help Popup
$('a.help-open').click(function(e){
    e.preventDefault();
    $(this).next().addClass('show');
});
$('a.help-close').click(function(e){
    e.preventDefault();
    $(this).parent().removeClass('show');
});

// print page
$('a.print').click(function(e){
    e.preventDefault();
    window.print();
});

// open popup
$("a.popup").popupwindow({
    popupBasic:{
	    width: 820,
        height: 500,
        status: 1,
        resizable: 0,
        scrollbars: 1
	},
	popupSendToFriend:{
	    width: 620,
        height: 500,
        status: 1,
        resizable: 0,
        scrollbars: 1,
        createnew:0
	},
	popupChat:{
	    width: 470,
        height: 320,
        status: 1,
        resizable: 0,
        scrollbars: 0
	}
});

// close browser window
$('.closewindow').click(function(){
    self.close();
});

// show nav on landing pages
//var isNavVisible = false;

function showNav()
{
//    showNavEffect();
//    isNavVisible = true;
}

if($('.couturecouture').length < 1 )
{
//    setTimeout("showNavEffect()", 5000);
}

function showNavEffect()
{
//    (!isNavVisible)
//        $('ul#subnav').fadeIn(500);
//    isNavVisible = true;
}


// Window Resize
$(window).resize(function(){
	
	// Center content vertically
	//centerContent($('body:not(.landing, .couturecouture) div#content-container'));
	//$('body.landing div#footer-container').css('bottom', '-' + $(this).height() + 'px');
	
	// set min height to flash container
	setMinHeight($('div#background'), 768);
	
	// position the footer
	//positionFooter();
	
	// center the subnav
	//centerSubNav(607);
});

// terms and conditions modal
$('a.terms-open').click(function(e) {
    e.preventDefault();
    $.get((("https:" == document.location.protocol) ? '/images/filedownloadproxy.ashx?thumbnailUrl=http://www.juicycouture.com/html/terms.html' : '/html/terms.html'), function(data) {
        $(data).modal({
            close: true,
            overlay: 75,
            onOpen: modalFunctions.openTerms,
            onClose: modalFunctions.close
        });
    });
});

// size guide modal
$('a.sizeguide-open').click(function(e) {
    e.preventDefault();
    $.get('/html/sizeguide.html', function(data) {
        $(data).modal({
	        close: true,
            overlay: 75,
            onOpen: modalFunctions.openSizeGuide,
            onClose: modalFunctions.close
        });
    });
});

// email to friend modal
$('a.emailtofriend-open').click(function(e){
    e.preventDefault();
    $('<iframe frameborder="0" scrolling="no" src="/images/filedownloadproxy.ashx?thumbnailUrl=' + $(this).attr('rel') + '"></iframe>').modal({
        close: true,
        overlay: 75,
        onOpen: modalFunctions.open,
        onClose: modalFunctions.close,
        containerId: 'emailtofriend'
    });
});

// help modal
//$('a.help-open').click(function(e){
//    e.preventDefault();
//    $('div#help-content').modal({
//        close: true,
//        overlay: 75,
//        onOpen: modalFunctions.openSizeGuide,
//        onClose: modalFunctions.close
//    });
//});

var modalFunctions = {
    open: function(dialog){
	    dialog.overlay.fadeIn(200, function(){
		    dialog.container.show(200, function(){
		        dialog.data.fadeIn(200);
		    });
	    });
    },
    close: function(dialog){
	    dialog.container.fadeOut(200, function(){
		    dialog.overlay.fadeOut(200, function(){
		        $.modal.close();
	        });
		});
    },
    openSizeGuide: function(dialog){
	    dialog.overlay.fadeIn(200, function(){
		    dialog.container.show(200, function(){
		        dialog.data.fadeIn(200);
		        $expandable = dialog.data.children('ul.expandable');
		        $expandable.children('div.expandable-section-content').addClass('expandable-section-content-show');
		        $('.expandable-section-toggle').click(function(){
		        });
		    });
	    });
    },
    openTerms: function(dialog){
        dialog.overlay.fadeIn(200, function(){
	        dialog.container.show(200, function(){
	            dialog.data.fadeIn(200);
	        });
        });
    }
}