// JavaScript Document
$(document).ready(function(){
    $(".rounded").each(function(){
		eval(
			$(this).corner()
		);
	});
    $(".rounded_top").each(function(){
		eval(
			$(this).corner("top")
		);
	});
    $(".rounded_bottom").each(function(){
		eval(
			$(this).corner("bottom")
		);
	});


	$(function(){
		
		// Accordion
			$("#accordion").accordion({ header: "h3",collapsible: true,autoHeight: false,active:false });

			// Tabs
			$('#tabs').tabs();


			// Dialog			
			$('#dialog').dialog({
				autoOpen: false,
				width: 600,
				buttons: {
					"Ok": function() { 
						$(this).dialog("close"); 
					}, 
					"Cancel": function() { 
						$(this).dialog("close"); 
					} 
				}
			});
			
			// Dialog Link
			$('#dialog_link').click(function(){
				$('#dialog').dialog('open');
				return false;
			});

			// Datepicker
			$('#datepicker').datepicker({
				dateFormat: 'yy-mm-dd',
				showAnim: 'slideDown',
				showOn: 'button',
				buttonImage: 'graphics/calendar.gif',
				inline: true,
				changeYear: true,
				changeMonth: true,
				defaultDate: '-22y'
			});
			// Slider
			$('#slider').slider({
				range: true,
				values: [17, 67]
			});
			
			// Progressbar
			$("#progressbar").progressbar({
				value: 20 
			});
			
			//hover states on the static widgets
			$('#dialog_link, ul#icons li').hover(
				function() { $(this).addClass('ui-state-hover'); }, 
				function() { $(this).removeClass('ui-state-hover'); }
			);
			
	  });
		});	
$(document).ready(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		allowresize: true, /* true/false */
		theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
		modal: false /* If set to true, only the close button will close the window */
	});
	$('#side .fieldDescription').hide();
	$('.input-extra1').show();
	$('.input-extra2').show();
	$('#password').hide();
	$('#passwordCheck').hide();
	$('.input-side').each(function() {
	    var default_value = this.value;
	    $(this).focus(function() {
	        if(this.value == default_value) {
	            this.value = '';
	        }
	    });
	    $(this).blur(function() {
	        if(this.value == '') {
	            this.value = default_value;
	        }
	    });
	});
	$('.input-extra1').focus(function() {
	    $('.input-extra1').hide();
	    $('#password').show();
	    $('#password').focus();
	});
	$('#password').blur(function() {
	    if($('#password').val() == '') {
	        $('.input-extra1').show();
	        $('#password').hide();
	    }
	});
	$('.input-extra2').focus(function() {
	    $('.input-extra2').hide();
	    $('#passwordCheck').show();
	    $('#passwordCheck').focus();
	});
	$('#passwordCheck').blur(function() {
	    if($('#passwordCheck').val() == '') {
	        $('.input-extra2').show();
	        $('#passwordCheck').hide();
	    }
	});
	var unreadMessagesAmount = $('.unreadMessagesAmount').text();
	if($('.unreadMessagesAmount').length){
	$('.menu-item-more:contains(Poczta) a').append(' ('+unreadMessagesAmount+')');/*FIXME*/
	$('.menu-item-active-more:contains(Poczta) a').append(' ('+unreadMessagesAmount+')');/*FIXME*/
	}

});

/*
function addMenuEffects()
{
  var menu= document.getElementById('menu');
  var options= menu.getElementsByTagName('div');

  for(var i= 0; i<options.length; i++)
  {
 var a= options[i].getElementsByTagName('a');
 options[i].removeChild(a[0]);
  
 options[i].onmouseover= function()
 {
  this.id= this.id + '_over';
 }
 
 options[i].onmouseout= function()
 {
  var first= this.id.split('_');
  this.id= first[0];
 }
 
 options[i].onclick= function()
 {
	 var first= this.id.split('_');
	 this.id= first[0];
	 location.href= 'index.php?pod=' + this.id;
 }
  }
}

/*
function $(aElement)
{
  return document.getElementById(aElement);	
}

function addImage() {
    var d = document.getElementById('35');
    d.innerHTML = d.innerHTML + '<img src="graphics/yourClubs.png">';
}

function DPSubmit()
{
  
}

$(document).ready(function() {
	    $('#extlinks a').filter(function() {
	      return this.hostname && this.hostname !== location.hostname;
	    }).after(' <img src="/images/external.png" alt="external link"/>');
	  });
function addImage() {
    var d = document.getElementById('myDiv');
    d.innerHTML = d.innerHTML + '<span><img src="graphics/yourClubs.png"></span>';
}

*/

/*
function init()
{

 //addMenuEffects();
}
*/


