jQuery.noConflict();

jQuery(function($){
  $(".aside dt").add("#extrabox a").css("cursor","pointer");
  $(".aside dt.hide").next().hide();
  $("#extrabox.hide div").hide();
  $(".aside dt").click(function(){
    $(this).next().slideToggle("fast");
    $(this).toggleClass("hide");
  });
  $("#extrabox a").click(function(){
    var color = $("#extrabox div:first").is(":hidden") ? "#DDFFBB" : "#CCFF99";
    $("#extrabox div").slideToggle("fast");
    $("#extrabox").animate({
      backgroundColor: color
    }, "normal");
  });
  var tallest = 0;
  $(".news").each(function(){
    if ($(this).outerHeight(true) > tallest)
      tallest = $(this).outerHeight(true);
  });
  $(".news").height(tallest);
  var labels = new Object();
  $(".aside input:text").add(".aside input:password").not('.notEmpty').addClass('empty');
  $(".aside input:text").add(".aside input:password").focus(function(){
    if ($(this).hasClass('empty')) {
      labels[$(this).attr('id')] = $(this).val();
      $(this).val('').removeClass('empty');
    }
  });
  $(".aside input:text").add(".aside input:password").blur(function(){
    if (!$(this).val()) {
      $(this).addClass('empty');
      $(this).val(labels[$(this).attr('id')]);
    }
  });
  $(".products a").not('.pagination a').add(".seminars .leaders a").click(function(){ return false; });
  var isIE = navigator.userAgent.toLowerCase().indexOf('msie')>-1;
  $(".products a").not('.pagination a').add(".seminars .leaders a").mouseover(function(){
    if (isIE) {
      var image = new Image();
      image.src = $(this).attr('href');
      $(".qtip, .qtip *, .qtip img").css('width',image.width);
      $(".qtip, .qtip *, .qtip img").each(function() {
        this.style.width = image.width;
      });
      $(".qtip img").attr('height',image.height);
    }
    /*return hs.expand(this, { 
      src: this.getAttribute('href'),
      anchor: 'bottom left'
    });*/
  });
  $(".products a").not('.pagination a').add(".seminars .leaders a").each(function(i){
    $(this).qtip({
      content: '<img src="'+$(this).attr("href")+'" />',
      position: { target: 'mouse', corner: { target: 'rightMiddle', tooltip: 'leftMiddle' }, adjust: { screen: true } },
      show: { effect: { length: 300 } },
      hide: { effect: { length: 300 } },
      style: { border: { width: 0 }, margin: 0, padding: 0, width: 'auto', background: '#fff' }
    });
  });
  $(".news img").css('cursor','pointer');
  $(".news").each(function(i){
    var img = $(this).children('img');
    var target = i%2==0 ? 'rightMiddle' : 'leftMiddle';
    var tooltip = i%2!=0 ? 'rightMiddle' : 'leftMiddle';
    $(img).qtip({
      content: '<img src="'+$(img).attr("src")+'" />',
      position: { target: 'mouse', corner: { target: target, tooltip: tooltip }, adjust: { screen: true } },
      show: { effect: { length: 300 } },
      hide: { effect: { length: 300 } },
      style: { border: { width: 0 }, margin: 0, padding: 0, width: 'auto', background: '#fff' }
    });
  });
  $("a.preview").click(function(){
    return hs.expand(this, { 
      src: this.getAttribute('href'),
    	outlineType: 'rounded-white'
    }); 
  });
  $('a.mp3').click(function(){
    return hs.htmlExpand(this, { 
      objectType: 'swf',
      src: this.getAttribute('href'),
      allowSizeReduction: false, 
      wrapperClassName: 'draggable-header no-footer',
		  outlineType: 'rounded-white',
			preserveContent: false, 
			width: 300, 
			objectWidth: 300, 
			objectHeight: 20,
			maincontentText: 'You need to upgrade your flash player', 
			headingText: this.getAttribute('title')
    }); 
  });
  $('a.flv').click(function(){
    return hs.htmlExpand(this, { 
      objectType: 'swf',
      src: this.getAttribute('href'),
      allowSizeReduction: false, 
      wrapperClassName: 'draggable-header no-footer',
		  outlineType: 'rounded-white',
			preserveContent: false, 
			width: 500, 
			objectWidth: 500, 
			objectHeight: 300,
			maincontentText: 'You need to upgrade your flash player', 
			headingText: this.getAttribute('title')
    }); 
  });
  $("#galleryNav").show();
  var instance = new Object();
  $("#galleryNav li").click(function(){
    $('.articleimage').add('.imageflow').hide()
    $("#galleryNav li").removeClass('active');
    var classN = $(this).attr('class');
    $(this).addClass('active');
    if (classN == 'show_articleimage') {
      $('.articleimage').css('display','block');
    } else {
      $('#'+classN).css('display','block');
      if (instance[classN] == undefined) {
        instance[classN] = new ImageFlow();
    	  instance[classN].init({ 
    	    ImageFlowID: classN, 
    	    reflectionGET: '&bgc=ffffff&fade_start=20%', 
    	    aspectRatio: 3.263,
    	    imageCursor: 'pointer',
    	    sliderCursor: 'pointer',
    	    imagesHeight: 0.75,
    	    reflectionP: 0.45,
    	    buttons: true,
    	    onClick: function() {
    	      var src = this.getAttribute('src');
    	      return hs.expand(this, { 
    	        src: 'files/' + src.substr(81,(src.length-107)),
    	        outlineType: 'rounded-white'
    	      }); 
          }
    	  });
  	  }
	  }
    return false;
  });
  $(".imageflow.active").each(function(){
    $('.'+$(this).attr('id')).click();
  });
});