$.include('/ext/jquery/plugin-livequery-1.0.3/jquery.livequery.js');
$.include('/ext/jquery/plugin-tooltip-1.3/jquery.tooltip.min.js');

$.include('/ext/jquery/plugin-markitup-1.1.12/markitup/jquery.markitup.js');
$.include('/ext/jquery/plugin-markitup-1.1.12/markitup/sets/bbcode/set.js');


/* SLIDESHOW */
$.include('/ext/jquery/plugin-crossslide-0.6.2/crossslide.min.js');
//$.include('/ext/jquery/plugin-crossslide-0.6.2/pause.min.js');
//$.include('/ext/jquery/plugin-easing-1.3/easing.js');


/* Messagebox Confirm */
(function($) {
	$.fn.confirmBox = function (msg, action){
		if(action.substr(0,1)=='/' || action.substr(0,7)=='http://' || action.substr(0,1)=='?'){
			var confButton = '<input type="button" onclick="location.href=\''+action+'\'" value="Bestätigen" />';
		}else{
			var confButton = '<input type="button" onclick="'+ action +'" value="Bestätigen" />';
		}
		$('#loader').fadeIn().children().hide();
		$('#msgBox_Type').addClass('ask');
		$('#msgBox_Content').html(msg);
		$('#msgBox_Buttons').html('<input type="button" onclick="$(\'#loader\').fadeOut(400, function(){$(this).children().show()}); $(\'#msgBox\').fadeOut()" value="Abbrechen" /> '+confButton);
		$('#msgBox').fadeIn();
	}
})(jQuery);


/* Upload by changing file-field
	//normal
(function($) {
	$.fn.uploadByFilechoose = function(){
		$('#uploadform input[type="submit"]').live('click', function(){
			$('#uploadform').removeAttr('action').submit();
		});
			//upload
		$('input[type="file"]').live('change', function(){
			$('input[type="file"]').hide();
			$('#fileupload').show();
			$('#uploadform').submit();
		});
	}
})(jQuery); */


	/* Scroll to anchor, storaged in Session 
	function doScroll(){
		$.get(document.URL, 'ajax=getSession&name=scrollTo', function(resp){
			
			if(resp!=''){
				//scroll what?
				if($.browser.opera){
					var target = 'html';
				}else{
					var target = 'html,body';
				}
				//calculate height (position of element - height of msgline - height of adminline)
				var h = $(resp).offset().top - $('#jMsg').height() - $('#adminline').height() -10;
				//do scroll
				$(target).animate({ scrollTop: h }, 600);
				//remove session
				$.get(document.URL, 'ajax=setSession&name=scrollTo&value=');
			}
	
		});
	}

	/* Highlight an Element, storaged in Session 
	function doHighlight(){
		$.get(document.URL, 'ajax=getSession&name=Highlight', function(resp){
			
			//get current css
			var css = $(resp).css('background-color');
			//highlighting element
			$(resp).css('background-color', '#ffcccc').change(function(){ $(this).css('background-color', css) });
			//remove session
			$.get(document.URL, 'ajax=setSession&name=Highlight&value=');
	
		});
	}*/



$(document).ready(function() {
	
	//$('input[type="file"].upload').uploadByFilechoose();												//Upload File on changing the file-input field
	$('*[title]').tooltip({ track:true, showURL:false, extraClass:"micro" });
	
	
	/* Fieldset Slide-Effect */
	$('fieldset[name="'+ document.URL.split("#")[1] +'"]').removeClass('slide-off').addClass('slide-on').find('div[name="expand"]').hide().next('div[name="collapse"]').show(); // open fieldset by anchor
	//close
	$('fieldset.slide-on').find('legend, div[name="collapse"]').css('cursor', 'pointer').live('click', function(){
		$(this).parent().removeClass('slide-on').addClass('slide-off');
		$( '#slide-'+$(this).parent().attr('name') ).slideUp();
		$(this).parent().find('div[name="expand"]').slideDown();
		$(this).parent().find('div[name="collapse"]').hide();
		$.get(document.URL, 'ajax=setSession&name=Slide_'+ document.URL.split("?")[0] + '_' + $(this).parent().attr('name') +'&value=false');
	});
	//open
	$('fieldset.slide-off').find('legend, div[name="expand"]').css('cursor', 'pointer').live('click', function(){
		$(this).parent().removeClass('slide-off').addClass('slide-on');
		$( '#slide-'+$(this).parent().attr('name') ).slideDown();
		$(this).parent().find('div[name="expand"]').slideUp();
		$(this).parent().find('div[name="collapse"]').show();
		$.get(document.URL, 'ajax=setSession&name=Slide_'+ document.URL.split("?")[0] + '_' + $(this).parent().attr('name') +'&value=true');
	});
	$('fieldset.slide-off *[id|="slide"]').hide();
	

	/* Messagebox Closer */
	$('.msgline').livequery(function(){
		$(this).next().css('height', $(this).height());
		$('#jMsg').children().hide().slideDown();
		$('a.closer', this).click(function(){ $(this).parentsUntil('#jMsg').slideUp().next('.msgline-spacer').slideUp() });
	});
	

	/* Slideshow */
	if( $('#slidepic').length ){
		$('#slidepic').crossSlide({
			fade: 1,
		}, [{ src: $('#slidepic').attr('address'), from: "top center", to: "bottom center", time: 16 }, 
				{ src: $('#slidepic').attr('address'), from: "bottom center", to: "top center", time: 16 }] );
	}
	/* Pause & Resume Slideshow 
	$('#teaserpause').live('click', function(){
		$(this).hide();
		$('#teaserpic').crossSlidePause();
		$('#teaserresume').show();
	});
	$('#teaserresume').live('click', function(){
		$(this).hide();
		$('#teaserpic').crossSlideResume();
		$('#teaserpause').show();
	});*/
	/*************************************************/
	

});
