/** 
 * Version: $Id: gui.js 9 2009-06-02 14:15:03Z Slawek $
 */
$( document ).ready( function(){

/**
 * style for forms
 */
	initGUI();

	
	$('#slider > ul > li').each(function(){
		//alert( $(this).width() );
		//alert( $(this).html() );
	});
	
	

});

function initGUI(){
	$( 'input[type=submit]' ).addClass( 'btnSubmit' );
	$( 'p:has( input[type=submit] )' ).addClass( 'submit' );
	
	/**
	 * focus field style
	 */
	$( 'input[type=text]' ).bind( 'focus', function(){
		$( this ).addClass( 'focus' );  
	});
	$( 'input[type=text]' ).bind( 'blur', function(){
		$( this ).removeClass( 'focus' );
	});
	$( 'input[type=password]' ).bind( 'focus', function(){
		$( this ).addClass( 'focus' );
	});
	$( 'input[type=password]' ).bind( 'blur', function(){
		$( this ).removeClass( 'focus' );
	});
	$( 'textarea' ).bind( 'focus', function(){
		$( this ).addClass( 'focus' );
	});
	$( 'textarea' ).bind( 'blur', function(){
		$( this ).removeClass( 'focus' );
	});
	
	/**
	 * Required form field utility
	 */
	$('form .req' ).bind( 'focus', function(){
		$( this ).parent().not(':has("span")').append( '<span class="required">To pole jest wymagane.</span>' );
	});
	
	$('form .req').bind( 'blur', function(){
		$( this ).next( '.required' ).remove();
	});
	
    
    $(function (){
		//facebook widget
		$(".widget_social").hover(function(){
				$(".widget_social").stop(true, false).animate({right:"0"},"medium");
			},function(){
				$(".widget_social").stop(true, false).animate({right:"-205"},"medium");
			},500);
		
		$(".widget_konkurs").hover(function(){
			$(".widget_konkurs").stop(true, false).animate({left:"0"},"medium");
		},function(){
			$(".widget_konkurs").stop(true, false).animate({left:"-205"},"medium");
		},500).click(function(){location.href="/konkurs_na_kubek";});
		
		return false;
	});

    
	
	/**
	 * Mask for input
	 * a - Represents an alpha character (A-Z,a-z)
	 * 9 - Represents a numeric character (0-9)
	 * * - Represents an alphanumeric character (A-Z,a-z,0-9) 
	 */
	if( $.mask ){
		$(function($){
			$(".maskedDate").mask("99/99/9999");
		});
		
		$(function($){
			$(".maskedPhone").mask("(99) 999 99 99");
		});
		
		$(function($){
			$(".maskedMobile").mask("+99 999 999 999");
		});
		
		$(function($){
			$(".maskedNIP").mask("999-99-99-999");
		});
		
		$(function($){
			$(".maskedPESEL").mask("99-99-99-99999");
		});
		$(function($){
			$(".maskedPostCode").mask("99-999");
		});
	}
}