/*
Live-Search Plugin
http://andreaslagerkvist.com/
*/
jQuery.fn.liveSearch=function(conf){var config=jQuery.extend({url:'/search-results.php?q=',additionalParam:'&tx_ttnews[swords]=',id:'jquery-live-search',duration:400,typeDelay:200,loadingClass:'loading',onSlideUp:function(){},uptadePosition:false},conf);var liveSearch=jQuery('#'+config.id);if(!liveSearch.length){liveSearch=jQuery('<div id="'+config.id+'"></div>').appendTo(document.body).hide().slideUp(0);jQuery(document.body).click(function(event){var clicked=jQuery(event.target);if(!(clicked.is('#'+config.id)||clicked.parents('#'+config.id).length||clicked.is('input'))){liveSearch.slideUp(config.duration,function(){config.onSlideUp()})}})}return this.each(function(){var input=jQuery(this).attr('autocomplete','off');var liveSearchPaddingBorderHoriz=parseInt(liveSearch.css('paddingLeft'),10)+parseInt(liveSearch.css('paddingRight'),10)+parseInt(liveSearch.css('borderLeftWidth'),10)+parseInt(liveSearch.css('borderRightWidth'),10);var repositionLiveSearch=function(){var tmpOffset=input.offset();var inputDim={left:tmpOffset.left,top:tmpOffset.top,width:250,height:input.outerHeight()};inputDim.topPos=inputDim.top+inputDim.height;inputDim.totalWidth=inputDim.width-liveSearchPaddingBorderHoriz;liveSearch.css({position:'absolute',left:inputDim.left+'px',top:inputDim.topPos+'px',width:inputDim.totalWidth+'px'})};var showLiveSearch=function(){repositionLiveSearch();$(window).unbind('resize',repositionLiveSearch);$(window).bind('resize',repositionLiveSearch);liveSearch.slideDown(config.duration)};var hideLiveSearch=function(){liveSearch.slideUp(config.duration,function(){config.onSlideUp()})};input.focus(function(){if(this.value.length > 2){if(liveSearch.html()==''){this.lastValue='';input.keyup()}else{setTimeout(showLiveSearch,1)}}}).keyup(function(){if(this.value.length > 2){if(this.value!=this.lastValue){input.addClass(config.loadingClass);var q=this.value;if(this.timer){clearTimeout(this.timer)}this.timer=setTimeout(function(){jQuery.get(config.url+q+config.additionalParam+q,function(data){input.removeClass(config.loadingClass);if(data.length&&q.length){liveSearch.html(data);showLiveSearch()}else{hideLiveSearch()}})},config.typeDelay);this.lastValue=this.value}}})})};

jQuery(document).ready(function(){
	if(navigator.platform.indexOf("Mac") > -1) {
		jQuery('*').css({'letter-spacing':'0em'});
	}
	var lang = jQuery('#currentLanguage').text();

	jQuery('#sword').liveSearch({
		url: '/index.php?type=9421&L='+lang+'&tx_kmproducts_pi1[sword]='
	});
	if(!(jQuery.browser.msie && parseInt(jQuery.browser.version) < 8)){
		jQuery('.suche a').click(function(){return false;}).css({'cursor':'default'});
	}
	/*
	* Form-Value ersetzen
	*/
	swapValue = [];
	jQuery("#sword").each(function(i){
		swapValue[i] = jQuery(this).val();
		jQuery(this).focus(function(){
			if (jQuery(this).val() == swapValue[i]) {
			jQuery(this).val("");
		}
	}).blur(function(){
			if (jQuery.trim(jQuery(this).val()) == "") {
				jQuery(this).val(swapValue[i]);
			}
		});
	}); 
	
	jQuery('body').append('<div class="simple_overlay" id="overlay"><div class="contentWrap"><a class="prev">prev</a><a class="next">next</a></div></div>');
	jQuery('.csc-frame-frame1').append('<div class="navi"></div>');
	jQuery('.csc-frame-frame2').append('<div class="navi"></div>');

/*	jQuery(".lightboxLink:not(.trailer)").overlay({ 
		mask: '#333',
		onBeforeLoad: function() {
			// grab wrapper element inside content
			var wrap = this.getOverlay().find(".contentWrap");
			// load the page specified in the trigger
			wrap.html('<img src="'+this.getTrigger().attr("href")+'" alt="" />');
		}
	});
	jQuery(".lightboxLink.trailer").overlay({ 
		mask: '#333',
		onBeforeLoad: function() {
			// grab wrapper element inside content
			var wrap = this.getOverlay().find(".contentWrap");
			// load the page specified in the trigger
			wrap.flashembed(this.getTrigger().attr("href"));
		}
	});
*/
	jQuery("a[rel*=overlay]").colorbox({maxWidth:'75%',current:"{current} / {total}"});
	jQuery("a[rel*=overlay1]").colorbox({maxWidth:'75%',current:"{current} / {total}"});
	jQuery("a[rel*=trailer]").colorbox({iframe:true, innerWidth:850, innerHeight:480});

	jQuery(".csc-frame-frame1 .csc-textpic-imagecolumn").scrollable({circular: true, mousewheel: true}).autoscroll({ autoplay: true, interval: '10000' }).navigator(".csc-frame-frame1 .navi");
	jQuery(".csc-frame-frame2 .csc-textpic-imagecolumn").scrollable({circular: true, mousewheel: true}).autoscroll({ autoplay: true, interval: '10000' }).navigator(".csc-frame-frame2 .navi");
	jQuery(".csc-frame-indent").scrollable({vertical: true,circular:true}).autoscroll({ autoplay: true, interval: '10000' });
	
});	

