function appendHeader(path){	$('head').append('<link rel="stylesheet" href="'+path+'" type="text/css" />');	}

function trim(v){	return v.replace(/\s+$/,"");	}

function array_unique(ar){
  var sorter = {};
  for(var i=0,j=ar.length;i<j;i++){
    sorter[ar[i]] = ar[i];
  }
  ar = [];
  for(var i in sorter){
    ar.push(i);
  }
  return ar;
}

function implode (glue, pieces) {
    // Joins array elements placing glue string between items and return one string  
    // 
    // version: 1009.2513
    // discuss at: http://phpjs.org/functions/implode    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Waldo Malqui Silva
    // +   improved by: Itsacon (http://www.itsacon.net/)
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: implode(' ', ['Kevin', 'van', 'Zonneveld']);    // *     returns 1: 'Kevin van Zonneveld'
    // *     example 2: implode(' ', {first:'Kevin', last: 'van Zonneveld'});
    // *     returns 2: 'Kevin van Zonneveld'
    
    var i = '', retVal='', tGlue='';
    
    if (arguments.length === 1) {        pieces = glue;
        glue = '';
    }
    if (typeof(pieces) === 'object') {
        if (pieces instanceof Array) {            return pieces.join(glue);
        }
        else {
            for (i in pieces) {
                retVal += tGlue + pieces[i];                tGlue = glue;
            }
            return retVal;
        }
    }    else {
        return pieces;
    }
}

function highlightMenu(key){
	$('.menu-tree .menu-'+key).addClass('active');
}

function thumbtopreview(s1,s2){
	$('#node #thumbnails li').click(function(){
		
		var img = $(this).children('img').attr('src');
		var txt = $(this).children('.hidden').html();
		
		img = img.replace("/thumbnail-"+s1+"/","/thumbnail-"+s2+"/");
		
		var myImg = new Image();
		myImg.src = img;
		
		$('#node #preview img').attr('src',img);
		$('#node #preview .text').html(txt);
		$('#node #preview .text').css('width', (myImg.width-10)+'px' );
		
		var uid = $('.box1').attr('id').replace("box-","");
		window.setTimeout("refix( '"+uid+"' )",400);
	});
}

function refix(uid){
	var newH = $('#box-'+uid+' .box1_middle_content').innerHeight();
	$('#box-'+uid+' .box1_middle_left').css('height',newH+'px');
	$('#box-'+uid+' .box1_middle_right').css('height',newH+'px');
}

$(document).ready(function(){
	
	$('.view-shotguns .record').hover(function(){
		if(!$(this).hasClass('bounce') ){
			$(this).children('.fields').effect("bounce", {times:3}, 300);
			$(this).addClass('bounce');
		}
	},
	function(){
		$(this).removeClass('bounce');
	});
});
