/********************************/
/* Author: Tomasz Bińkowski     */
/* Email:  tomasz.binkowski@yahoo.pl */
/********************************/
var BRASIL = function(){

	return {
		 vote: function(objectId, objectType, vote, voteStars) {
			 $.ajax({
			   type: "POST",
			   url: '/main/components/vote/' ,
			   data: 'object_id=' + objectId + '&object_type=' + objectType + '&vote=' + vote + '&voteStars=' + voteStars,
			   success: function(textResponse){
				   $('#rating-container').html(textResponse);
			   }
			 });
		 },

		 addComment: function(objectId, objectType, content, creatorName) {
			 $.ajax({
			   type: "POST",
			   url: '/main/components/addComment/' ,
			   data: 'object_id=' + objectId + '&object_type=' + objectType + '&content=' + content + '&creator_name=' + creatorName,
			   success: function(textResponse){
				    $('#comments-container-list').prepend(textResponse);
			   }
			 });
		 },

		 showArticle: function(objectType) {
			$('.' + objectType + '_item_head').bind('click', function(){
				var obj = $(this).next('.' + objectType + '_item_content');
				if(obj.css('display') == 'none') {
					obj.slideDown("slow");
					var obj1 = $(this).find('.left_item_plus');
					obj1.removeClass('left_item_plus');
					obj1.addClass('left_item_minus');
				} else {
					obj.slideUp();
					var obj1 = $(this).find('.left_item_minus');
					obj1.removeClass('left_item_minus');
					obj1.addClass('left_item_plus');
				}
			});
		 },

		 leftMenu: function() {
			$('.left_item_head').each(function(){
				var obj = $(this).next('.left_item_content');

				if(obj.css('display') != 'none') {
					var obj1 = $(this).find('.left_item_plus');
					obj1.removeClass('left_item_plus');
					obj1.addClass('left_item_minus');
				}
			});

			$('.left_item_head').bind('click', function(){
				var obj = $(this).next('.left_item_content');
				if(obj.css('display') == 'none') {
					obj.slideDown("slow");
					var obj1 = $(this).find('.left_item_plus');
					obj1.removeClass('left_item_plus');
					obj1.addClass('left_item_minus');
				} else {
					obj.slideUp();
					var obj1 = $(this).find('.left_item_minus');
					obj1.removeClass('left_item_minus');
					obj1.addClass('left_item_plus');
				}
			});


			 $('.left_item_click').bind('click', function(){
					var obj1 = $(this).find('a');
					window.location.href = obj1.attr('href');
			 });
		 },

		 topHeader: function(){
			 $('.long_input_size').bind('focus', function(){
				 if ($(this).val() == 'wpisz swój login') {
					 $(this).val('')
				 }
			 })

			 $('#newsletter_email').bind('focus', function(){
				 if ($(this).val() == 'wpisz adres') {
					 $(this).val('')
				 }
			 })

			 $('#search_txt').bind('focus', function(){
				 if ($(this).val() == 'wpisz słowo kluczowe') {
					 $(this).val('')
				 }
			 })


			 $('.short_input_size').bind('focus', function(){
				 if ($(this).val() == 'wpisz swoje haslo') {
					 $(this).val('')
					 $(this).prev('input').show();
					 $(this).prev('input').focus();
					 $(this).hide();
				 }
			 })
		 },

		 homeMenu: function(){

			 $('.home_sub_item').bind('click',function(){
				var obj1 = $(this).find('a');
				window.location.href = obj1.attr('href');
			 })

			 $('.search_item_click').bind('click',function(){
				var obj1 = $(this).find('a');
				window.location.href = obj1.attr('href');
			 })

			 $('.pagination_item').bind('click',function(){
				var obj1 = $(this).find('a');
				window.location.href = obj1.attr('href');
			 })



			 $('.home_sub_item').mouseover(function(){
				$(this).find('.home_sub_head').css('visibility', 'visible');
				$(this).find('.home_sub_foot').css('visibility', 'visible');
				$(this).find('.home_sub_content').addClass('home_sub_content_bg');
				$(this).find('.home_sub_arrow').attr('class', 'home_sub_arrow_active');
			 });

			 $('.home_sub_item').mouseout(function(){
				$(this).find('.home_sub_head').css('visibility', 'hidden');
				$(this).find('.home_sub_foot').css('visibility', 'hidden');
				$(this).find('.home_sub_content').removeClass('home_sub_content_bg');
				$(this).find('.home_sub_arrow_active').attr('class', 'home_sub_arrow');
			 });
			 
			 $('.left_menu_sub1').mouseover(function(){
				 var item = $(this).find('.left_item_sub1_children');
				 if (item.css('display') == 'none')
					$(this).addClass('active1');
			 });

			 $('.left_menu_sub1').mouseout(function(){
				 var item = $(this).find('.left_item_sub1_children');
				 if (item.css('display') == 'none')
					$(this).removeClass('active1');
			 });
		 }
	};
}();

$(document).ready(function(){
	BRASIL.leftMenu();
	BRASIL.topHeader();
	BRASIL.homeMenu();
	$('#logo').bind('click', function(){
		window.location.href = '/';
	});

	$('#partners').cycle({
		fx: 'fade'
	});
})


