$(document).ready(function() {



  $('html').addClass('jsOn');

	

	$('div.accordion>.toggle a').click(function() {

	  if($(this).parent().next().is(':hidden')) {

		  $('div.accordion>div.section').slideUp('normal');	

		  $(this).parent().next().slideDown('normal');

  		if(this.rel && /^[\.#]/.test(this.rel)) {

  		  $('#content>.col2>*').slideUp('normal');

  		  $(this.rel).slideDown('normal');

  		}

		} else {

		  $(this).parent().next().slideUp('normal');

		  if($('#defaultImage').length) {

		    $('#content>.col2>*').slideUp('normal');

		    $('#defaultImage').slideDown('normal');

		  }

		}

		location.hash='#'+this.href.split('#')[1];

		return false;

	});



	$('div.accordion>div.section').hide();

	$('#insideViewDetails').css({height:'auto'});

	if(location.hash.length>1) {

    var rel=$('div.accordion>.toggle a[href$="'+location.hash+'"]')

      .parent().next().show().end().end().attr('rel');



		if(rel && /^[\.#]/.test(rel)) {

		  $('#content>.col2>*').slideUp('normal',function(){

        $('#insideViewDetails').css({visibility:'visible'}).hide();

      });

		  $(rel).slideDown('normal');

		}

  } else {

    setTimeout("$('#insideViewDetails').hide().css({visibility:'visible'})",500);

  }



var isMSIE=/*@cc_on!@*/false; // http://dean.edwards.name/weblog/2007/03/sniff/

var IEpre7=(isMSIE&&(typeof document.body.style.maxHeight=='undefined'));



  if(!IEpre7) {

    var insideViewEvents=function(e) {

      e=e||window.event;

      var s=$('#'+this.href.split('#')[1]);

      if(s.is(':hidden')) {

        $('#insideViewDetails ol.details li').slideUp('normal');

        s.slideDown('normal');

      }

    }

    $('#insideViewDetails .imagemap a').mouseover(insideViewEvents).

    focus(insideViewEvents).click(function() {

      return false;

    });

  }



  if(!IEpre7) { // disable colorbox in IE6

    var colorBoxOpt = {

      transition:'none',width:'900px',height:'620px',current:'',

      onLoad:function(){

        this.href+=(this.href.indexOf('?')==-1?'?':'&')+'ajax=yes';},

      onComplete:function(){

        this.href=this.href.replace(/[\?&]ajax=yes$/,'');

      }

    };

    $('#vineyardMap a').each(function(){

      if(this.href.indexOf('avellana')!=-1) colorBoxOpt.height='600px';

      else if(this.href.indexOf('estate')!=-1) colorBoxOpt.height='630px';

      else if(this.href.indexOf('la-luce')!=-1) colorBoxOpt.height='610px';

      else if(this.href.indexOf('aurora')!=-1) colorBoxOpt.height='720px';

      else if(this.href.indexOf('abetina-and-madrona')!=-1) colorBoxOpt.height='710px';
	  
      $(this).colorbox(colorBoxOpt);

    });

  }

});

