jQuery.noConflict();
jQuery(document).ready(function() {
	jQuery("ul.headline_content_tabs").tabs("div.panes > div",{effect: 'ajax', 
		onBeforeClick: function(event, i) { 
		   var pane = this.getPanes("div.panes > div"); 
			pane.html('<div class="spinner"><object width="12" height="12" data="flash/loader.swf" type="application/x-shockwave-flash"><param value="swf/loaders/throbber.swf" name="movie"><param value="transparent" name="wmode"><param value="false" name="menu"></object></div>');
		    
		} 
		
	});
});

jQuery(document).ready(function() {
	jQuery("ul.updates_content_tabs").tabs("div.panes > div",{effect: 'ajax', 
		onBeforeClick: function(event, i) { 
		   var pane = this.getPanes("div.panes > div"); 
			pane.html('<div class="spinner"><object width="12" height="12" data="flash/loader.swf" type="application/x-shockwave-flash"><param value="swf/loaders/throbber.swf" name="movie"><param value="transparent" name="wmode"><param value="false" name="menu"></object></div>');
		    
		} 
		
	});
});


jQuery(document).ready(function() {
	jQuery("ul.video_tabs").tabs("div.panes > div",{effect: 'ajax', 
		onBeforeClick: function(event, i) { 
		   var pane = this.getPanes("div.panes > div"); 
			pane.html('<div class="loader_anim2"><object width="12" height="12" data="flash/loader.swf" type="application/x-shockwave-flash"><param value="swf/loaders/throbber.swf" name="movie"><param value="transparent" name="wmode"><param value="false" name="menu"></object></div>');
		    
		} 
		
	});
});

jQuery(function() {
	jQuery("ul.sajat_tabs").tabs("div.panes > div",{effect:'fade', history: true});
});

jQuery(function() {
	jQuery("ul.sajat_tabs_alt").tabs("div.panes > div",{effect:'ajax'});
});

jQuery(function() {
 jQuery("ul.edit_tabs").tabs("div.panes > div",{effect:'ajax'});
});

jQuery(function() {
	jQuery('#webshop_nav')
	   .find('.nav_dropdown').hide().end()
	   .find('.nav_dropup').click(function() {
	      jQuery(this).toggleClass('open').siblings().removeClass('open').end()
			.next('.nav_dropdown').slideToggle().siblings('.nav_dropdown:visible').slideUp();
	   	return false;
	   });
});

jQuery(function() {
	jQuery('#school_search_holder')
	   .find('.school_searchform').hide().end()
	   .find('.school_s_toggle').click(function() {
	      jQuery(this).toggleClass('open').siblings().removeClass('open').end()
			.next('.school_searchform').slideToggle().siblings('.school_searchform:visible').slideUp();
	   	return false;
	   });
});


jQuery(document).ready(function() {
	jQuery("ul#category_box_tabs").tabs("ul#category_panes > li");
});

jQuery(function() {		
	
	// email and embed tab actions
	jQuery("#panes + #shareTabs a").click(function(e)  { 
		flowplayer().hide(true);  
		
		// toggle tab class
		var tab = jQuery(this); 
		jQuery("#shareTabs a").removeClass("current");
		tab.addClass("current");
		
		// show / hide panes
		jQuery(tab.attr("href")).show();
		var other = (tab.attr("href") == "#emailPane") ? jQuery("#embedPane") : jQuery("#emailPane");
		other.hide();		
		
		// prevent link's default behaviour
		return e.preventDefault();
	});
	
	// close buttons
	jQuery("#panes div.close").click(function() {
		jQuery("#shareTabs a").removeClass("current");
		jQuery("#emailPane, #embedPane").hide();
		flowplayer().show();
	});
	
	/*
		email form setup. depends on simple JSON responses of the form
			- on error: {message: 'error message'}
			- otherwise it's successs
	*/
	jQuery("#shareForm").submit(function(e) {
			
		var form = jQuery(this);
		form.fadeTo(500, 0.1);
		
		jQuery.getJSON(form.attr("action") + "?" + form.serialize() + "&format=json&jsoncallback=?", function(json) {
			form.fadeTo(500, 1);
			var info = jQuery("#info").show();
			
			if (json.message) {
				info.html(json.message);			
			} else {
				info.html("Email was successfully sent");
			} 
		});	
		
		e.preventDefault();
		return false;		
	});
	
});

jQuery(function() {		
	jQuery(".scrollable").scrollable({ vertical: true, mousewheel: true });	
	
});


/*jQuery(document).ready(function(){
	 jQuery(".tweet").tweet({
			username: "szalainori",
			join_text: "auto",
			avatar_size: 40,
			count: 5,
			auto_join_text_default: "NÃ³ri said,",
			auto_join_text_ed: "we",
			auto_join_text_ing: "we were",
			auto_join_text_reply: "we replied to",
			auto_join_text_url: "we were checking out",
			loading_text: "loading tweets..."
	  });
 });*/
 
function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
	cntfield.value = maxlimit - field.value.length;
}

jQuery(document).ready(function() {
	  
	jQuery(".login_lightbox").fancybox({
	'padding'			: 0,
	//'showCloseButton'	: false,
	'transitionIn'		: 'fade',
	'transitionOut'	: 'fade',
	'autoDimensions'	: false,
	'width'         	: 215,
	'height'        	: 'auto',
	'overlayColor'		: '#000',
	'overlayOpacity'	:  0.7
	});
});

jQuery(document).ready(function() {
	  
	jQuery(".inquiry_lightbox").fancybox({
	'padding'			: 0,
	//'showCloseButton'	: false,
	'transitionIn'		: 'fade',
	'transitionOut'	: 'fade',
	'autoDimensions'	: false,
	'width'         	: 350,
	'height'        	: 'auto',
	'overlayColor'		: '#000',
	'overlayOpacity'	:  0.7
	});
});

jQuery(document).ready(function() {
	  
	jQuery("#subscr_lightbox").fancybox({
	'padding'		: 0,
	//'showCloseButton'	: false,
	'transitionIn'		: 'fade',
	'transitionOut'	: 'fade',
	'autoDimensions'	: false,
	'width'         	: 400,
	'height'        	: 550,
	'overlayColor'		: '#000',
	'overlayOpacity'	:  0.7,
	'type'				: 'iframe'
	});
});

var addthis_config = {
    ui_click: true /* normally would disable mouseover behavior */
}


jQuery(function(){
    // Find all the "reply to" links and bind to the click event
    jQuery('a[href^=/5pa/comment_form/]').click(function() {

      var url_array = jQuery(this)    // The anchor object
        .attr('href')    // Fetch the value of the href attribute
        .split("/");    // Divide into chunks, using / as the divider

      var id = url_array[4];    // We want the fourth chunk

      // Change the value of weever-parent-id
      jQuery('#weever-parent-id').val(id);
      
      // Now we'll move the form
      jQuery('form#comment_form')
        .insertAfter(    // Insert the comment form after div.entry
          jQuery(this)
          .parent()    // The containing p tag
          .parent()    // div.entry
          );

      return false;
    });
  });


jQuery().ready(function() {
jQuery("#comment_form").validate({
		rules: {
			name: {
				required: true,
				maxlength: 20
			},
			email: {
				required: true,
				email: true
			},
			captcha: "required"
			
		},
		messages: {
			name: {
				required: "Kérjük adj meg egy valós nevet",
				maxlength: "Maximum 20 karaktert használj!"
			},
			
			email: "Kérjük adj meg valós emailcímet",
			captcha: "Kérjük írd be az ellenőrző kódot",
		}
	});


});

jQuery(function() {
	jQuery('#webshop_menu')
   .find('.collapser').hide().end()
   .find('.expander').click(function() {
      jQuery(this).toggleClass('open').siblings().removeClass('open').end()
		.next('.collapser').slideToggle().siblings('.collapser:visible').slideUp();
   	return false;
   });
});
