jQuery.noConflict();
/**
 * After document loaded
 */
jQuery(document).ready(function() {
   
   function separateTooltipClassName(object)
   {
   	var class_name = '';
  		var class_array = object.className.split(' ');
  		for (var i in class_array)
  			if (
  				class_array[i] == 'dfp' ||
  				class_array[i] == 'str' ||
  				class_array[i] == 'tuv' ||
  				class_array[i] == 'bor'
  			)
  				class_name = class_array[i];
  				
  		return class_name;
   }
   
   jQuery("a#roll")
        .click(function() {
        		var state = jQuery.data(this,"state");
        		if (state == 1)
        		{
        			jQuery("div#gallery-list").slideUp();
        			jQuery.data(this,"state",0);
        		}
        		else
        		{
        			var ctrlPos = jQuery("a#roll").position();
        			var ctrlHeight = jQuery("a#roll").height();
        			
        			jQuery("div#gallery-list")
        				.css("top",ctrlPos.top + 22)
        				.css("left",ctrlPos.left)
        				.slideDown();
        				
        			jQuery.data(this,"state",1);
        		}
        });
    
   jQuery("div#gallery-list a").click(function () {
   	return hs.expand(this);
   });
   
   jQuery("a#coffee-link").each(function(index) {
   	
   	var full = jQuery(this).text();
   	var short = full.trunc(400,true) + "";
   	  	
   	// shorten text
   	jQuery(this).text(short);
   });
   
   jQuery("img.sgn")
   	.mouseenter(function() {
   	
   		var class_name = separateTooltipClassName(this);		
   		jQuery("div." + class_name)
   			.css("left",jQuery("div#icon-list img:first").position().left)
   			.fadeIn('slow');
   	})
   	.mouseleave(function() {
   	
   		var class_name = separateTooltipClassName(this);
   		jQuery("div." + class_name).fadeOut('fast');
   	});
   
   // default values for tooltip
   jQuery("div.ttp")
   	.hide()
   	.css("position","absolute")
   	.css("background-color","#f7f0c4")
   	.css("padding","10px 20px 20px")
   	.css("color","#666666")
   	.css("width",jQuery("div#icon-list").outerWidth() + 25)
   	.css("left",jQuery("div#icon-list img:first").position().left)
   	.each(function(index) {
   		jQuery(this)
   			.css("top",jQuery("div#icon-list img:first").position().top - jQuery(this).outerHeight() - 20);
   	});
   	
});
