var caseHovering=0;
var _isset=0;

$(function() {
    $('.printBar').click(function(){        
        $(this).next().slideToggle().toggleClass('dontPrint');
        if ($(this).children('p').children('a').text() == "Dont Print" ){
            $(this).children('p').children('a').text('Do Print'); 
        }  else {
            $(this).children('p').children('a').text('Dont Print'); 
        }     
    })
    
    $(".action.print").click( function() {
         window.print();                                                                                                                                                  
    });             

    $(".action.review").click(function(){
        $('a.userreview').parent().next().next().hide();
        $('#product-info-tabs > ul').tabs('select', 3);
        setTimeout("$('a.myreview').parent().next().next().slideDown();", 1200);                                                                                                                                                                               
    });   
    
    $(".video a").click(function(){
        $('#product-info-tabs > ul').tabs('select', 4);
        var com = "$('iframe#video').attr('src','video.html');";        
        setTimeout(com, 1500);
    });              
        					
    // NORMAL PRINT VIEW //
    $('div#container > div.leftcol > div.calls-to-action > a.styleswitch').click(function(){ window.print(); return false; });
    
    // TASTING NOTE VIEW //
    $('a.printtasting').click(function(){
            //window.onbeforeunload = function () {
            //  window.location.reload();
              //$('link[@rel*=stylesheet][@media*=screen]').attr("disabled", "false");
            //  return "Click OK to return to the product list or CANCEL to stay with this item.";
            //};
            //$('link[@rel*=stylesheet][@media*=screen]').attr("disabled", "true");
            //$('link[@rel*=PrintTasting]').attr("rel", "stylesheet");
            //$('link[@rel*=PrintTasting]').attr("disabled", "false");

            //$('#contentframe').prepend()
            window.print();

             //window.location.reload();
            return false;

    });
    
    
		// IE OR NOT - SHOW/HIDE DIFFERENCES
    if ($.browser.msie ) {  						
        $('#product-info-tabs > ul').tabs({ fx: { opacity: 'toggle' } });
        $('.review .title a').click( function(){   $(this).parent().next().next().animate({opacity: 'toggle'},300).parent().toggleClass('dontPrint'); return false; })
        $('.delivery span a, .delivery span a ').click( function(){  $(this).parent().next().animate({opacity: 'toggle'},300); return false;  } );
    } else {
        $('#product-info-tabs > ul').tabs({ fx: { opacity: 'toggle', height:'toggle' } });
        $('.review .title a').click( function(){   $(this).parent().next().next().slideToggle(300).parent().toggleClass('dontPrint'); return false; });
        $('.delivery span a, .delivery span a ').click( function(){  $(this).parent().next().slideToggle(); return false;  } );
    }
    
    $('#product-info-tabs > ul > li > a ').click(function(){        
        $('iframe#video').attr('src', '');
    });
        
    $('.review blockquote:gt(0)').css({display:'none'})        
    $('.my.review form').css({display:'none'})
    
    $('#product-info-tabs > ul > li > a > span:contains("Video")').click(function(){                        
        var com = "$('iframe#video').attr('src','video.html');";        
        setTimeout(com, 1500);
                        
    });
	
	/// DROPSHADOW FOR CASES ///////////////////////////////////////////////////
    $('.enlarge').click(
        function enlarge(){
            caseHovering=1;
            $(this).parent().parent().find('.case .bottle-image').prepend('<div class="caseshadow"></div>');
            $(this).parent().parent().find('.case .bottle-image').prepend('<div class="caseshadow-ie"></div>');
            $(this).parent().parent().find('.case .bottle-image').animate({width:'280px'}, function(){
                if ($.browser.msie && $.browser.version < 7) {        // IE6 //
                    $(this).children('.caseshadow').css({height: $(this).height()+5, width: $(this).width()+51, display:'block'});
                    $(this).children('.caseshadow-ie').css({ marginTop: $('.case .bottle-image').height()+2, display:'block'});
                } else if ($.browser.msie && $.browser.version > 6) { // IE7 //
                    $(this).parent().parent().find('.caseshadow').css({height: $(this).height()+48, width: $(this).width()+12, display:'block'});
                } else {                                              // FFX ETC. //
                    $(this).children('.caseshadow').css({height: $(this).outerHeight()+46, width: $(this).outerWidth()+51, display:'block', opacity:'0'}).animate({opacity:'1'});
                }
            });
            $(this).parent().parent().find('.case .bottle-image').children('img').animate({width: '260px'});
            return false;
        },
        function shrink(){
        }
    );

    $('.case .bottle-image').hover(
      function(){},
      function(){
          if (caseHovering==1){
            $(this).children('.caseshadow').remove();
            $(this).children('.caseshadow-ie').remove();
            $(this).animate({width:'140px'})
            $(this).children('img').animate({width: '140px'});
            caseHovering=0;
          }
      }
    );



	// REMOVE XML APPLIED HEIGHT ATTRIBUTE OF CASE IMGAES TO STOP STRETCHING //
    $('.case .bottle-image img').removeAttr("height");

          
})
