// disable the default behaviour of enter on ASPX forms
function disableEnterKey(e) {
    var key;
    if (window.event)
        key = window.event.keyCode; //IE
    else
        key = e.which; //firefox    

    return (key != 13);
}

//init page
jQuery.noConflict();  
jQuery(document).ready(function () {
	initOpenClose();
	//initAccordion();
});
//init open-close
function initOpenClose($){
    var holders = jQuery('.slide-block');
	var activeClass = 'active';
	holders.each(function(){
	    var holder = jQuery(this);
		var btnOpen = holder.find('.opener');
		var slide = holder.find('.block');
		
		if(!holder.hasClass(activeClass)){
			slide.slideUp();
} (jQuery);
		
		btnOpen.click(function(){
			if(!holder.hasClass(activeClass)){
				if (!slide.is(':animated')) {
					holder.addClass(activeClass);
					slide.slideDown();
				}
			}
			else{
				if (!slide.is(':animated')) {
					holder.removeClass(activeClass);
					slide.slideUp();
				}
			}
			return false;
		});
	});
}
// accordion function
function initAccordion($) {
    jQuery('ul.accordion').multiAccordion({
        activeClass: 'active',
        opener: '>span',
        slider: '>div.block',
        collapsible: false,
        slideSpeed: 500 
	});
} (jQuery);

// multilevel accordion plugin
jQuery.fn.multiAccordion = function(_options){
	// default options
	var _options = jQuery.extend({
		activeClass:'active',
		opener:'.opener',
		slider:'.slide',
		slideSpeed: 400,
		collapsible:true,
		event:'click'
	},_options);

	return this.each(function(){
		// options
		var _event = _options.event;
		var _accordion = jQuery(this);
		var _items = _accordion.find(':has('+_options.slider+')');

		_items.each(function(){
		    var _holder = jQuery(this);
			var _opener = _holder.find(_options.opener);
			var _slider = _holder.find(_options.slider);
			_opener.bind(_event, function(){
				if(!_slider.is(':animated')) {
					if(_holder.hasClass(_options.activeClass)) {
						if(_options.collapsible) {
							_slider.slideUp(_options.slideSpeed, function(){
								_holder.removeClass(_options.activeClass);
							});
						}
					} else {
						var _levelItems = _holder.siblings('.'+_options.activeClass);
						_holder.addClass(_options.activeClass);
						_slider.slideDown(_options.slideSpeed);

						// collapse others
						_levelItems.find(_options.slider).slideUp(_options.slideSpeed, function(){
							_levelItems.removeClass(_options.activeClass);
						})
					}
				}
				return false;
			});
			if(_holder.hasClass(_options.activeClass)) _slider.show(); else _slider.hide();
		});
	});
}
/* anythingslider.js */
jQuery(document).ready(function () {

    jQuery(".anythingSlider").anythingSlider({
        easing: "swing",                // Anything other than "linear" or "swing" requires the easing plugin
        autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not
        startStopped: false,            // If autoPlay is on, this can force it to start stopped
        delay: 10000,                    // How long between slide transitions in AutoPlay mode
        animationTime: 2000,             // How long the slide transition takes
        hashTags: false,                 // Should links change the hashtag in the URL?
        buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
        pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
        startText: "Start",             // Start text
        stopText: "Stop",               // Stop text
        navigationFormatter: null       // Details at the top of the file on this use (advanced use)
    });
});

