jQuery.noConflict();

(function ($){

	var Weplay = {

		Init: function(){

			$('#MainMenu a.over').show();

			$('img[src$=.png], #mainWrap ').ifixpng(); 

			$('#MainMenu a.over').hide();

			Weplay.Mainmenu.Init();
			Weplay.Forum.init();		

			/* banneri osa uus */

			$('#myBanner').banner({
				width: 603, 
				height: 243, 
				interval: 5,
				zindex: 100
			});
		
			$('.auto-submit-star').rating({
		       callback: function(value, link){
		          
		           $.post($('#image-url').val(), {rating: value }, 	
					function(data) {
						if(parseInt(data) >= 1) {
							 alert('Hinne edukalt edastatud!');
						}		
		             	$('#rating-value').html(data);
		           });
		        },
				required: true,
				starWidth: 20
		     });
		},

		Mainmenu:{
			Init: function() {
				$('#MainMenu a.out').mouseover(
					function (){
						$(this).hide().parent().find('a.over').show();
					}
				);

				$('#MainMenu a.over').mouseout(
					function (){
						$(this).hide().parent().find('a.out').show();
					}
				);
			}
		},

		ToggleNews: function(el,imgOpen,imgClose){

			var e = $(el);
			if(e.parent().parent().find('.newsContent').css('display')=='none'){
				/* show */
				e.parent().parent().find('.newsContent').css('display','');
				e.parent().find('.openCloseArr').attr('src',imgOpen);

			} else {

				e.parent().parent().find('.newsContent').css('display','none');
				e.parent().find('.openCloseArr').attr('src',imgClose);
				/* hide */

			}

		},

		

		Forum: {

			init: function(){

				$('.forumTbl .cell span').each(function(){
					$(this).height($(this).parent().parent().height()-4);
				});

				$('.forumTbl .cell').each(function(){

					$(this).height($(this).parent().height()-4);

				});

			}

		},
		ChangeCategory: function(url) {
			window.location = url;
		},
		LoadPage: function(pageId,categoryId) {
			$('#art-thumbnails').html('<p style="text-align:center;margin-top:50px;"><img src="/skin/frontend/weplay/default/images/ajax-loader.gif" width="220" height="19" /></p>');
		    $.ajax({
			  url: '/weplay/galerii',
			  data: 'page_id='+pageId+'&category='+categoryId,
			  success: function(data) {
			    $('#art-thumbnails').html(data);
			  }
			});
		}	
	}

	$(document).ready(function(){

		Weplay.Init();

	});

	window.Weplay = Weplay;

})(jQuery);


