/***************
 *  JQUERY
 ***************/

var browser = navigator.userAgent.toLowerCase();
var isIE = ( (browser.indexOf("msie") != -1) && (browser.indexOf("opera") == -1) && (browser.indexOf("webtv") == -1));
var processedCaptions = new Array();


appendCaption = function () {
	var imageToProcess =  $(this).parent().attr('href');
	var captionExists = (processedCaptions[imageToProcess] == undefined) ? false : true;
	
	if (captionExists) {
		return;
	} else {
		processedCaptions[imageToProcess] = true;
	}
	
	var caption = '<span class="caption">' + $(this).parent().attr('title') + '</span>';
	var imageWidth = isIE ? $(this).width() + 4 : $(this).width();

	var leftBorder = '<img class="caption_left" src="/fileadmin/templates/bartenbach_de/images/caption_left.gif" alt="" title="" />';
	var rightBorder = '<img class="caption_right" src="/fileadmin/templates/bartenbach_de/images/caption_right.gif" alt="" title="" />';

	$(this).parent().attr('rel', 'shadowbox');
	$(this).parent().addClass('image_container');

	$(this).after('<span class="caption_container" style="width:' + imageWidth + 'px">' + leftBorder + caption + rightBorder + '</span>');
}

processCustomerImages = function () {
	$('.reference-imagelist a > img').each(appendCaption);
}

$(document).ready(function() {
	/***************
	 *  CUSTOMER
	 ***************/
/*
	// CUSTOMER DROPDOWNS
	$("select.jdrop").jdrop();

	// CUSTOMER SELECT FADING
	customerShowSelection = function(type,fadeClass) {
		var signFadeSpeed = 500;
		var signFadeTo = 0.3;

		$("form#customer-select div.active").removeClass("active");
		$("form#customer-select div.box div[title!=" + type + "] div.jSel span.jSelOp").text("");

		$("ul#customer-sign-list li").fadeTo(signFadeSpeed,1);
		$("ul#customer-sign-list li").not("." + fadeClass).fadeTo(signFadeSpeed,signFadeTo);
	}

	$("form#customer-select div.box").hover(function(){
		$(this).addClass("hover");
		$("form#customer-select div.box").not(".hover").fadeTo(1,0.4);
	},function() {
		$(this).removeClass("hover");
		$("form#customer-select div.box").not(".hover").fadeTo(1,1);
	});
*/

	// APPEND CAPTION BOXES TO REFERENCE IMAGE THUMBNAILS
	setTimeout("processCustomerImages()", 5000);
});
