
$(document).ready(function() { q.Init(); });

var q = {
	
	Init : function() {
		q.Flash();
		q.Forms.Init();
		
		// Init datepicker
		$('#date_picker').datepicker({ dateFormat: 'yy-mm-dd' });
		
	},
	
	Forms : {
		
		Init : function() {
			$('#dd_week select').fancySelect();
			
			// Remove inputs initial values
			$('input').bind('focus', function() {
				if( $(this).val() == 'Namn' || $(this).val() == 'E-post'  ) {
					$(this).attr('rel', $(this).val() );				
					$(this).val('');
				}
			});
			
			$('input').bind('blur', function() {
				if( $(this).val() == '' ) {
					$(this).val( $(this).attr('rel') );
				}
			});			

			
			// Share links
			$('#content div.actions:first a.btn:not(.submit)').bind('click', function() {
				var a = q.GetDomID( $(this).attr('href') );
				var b = false;
				$('#content .collapsable').each(function(i){
					if( $(this).css('display') == 'block' && $(this).attr('id') != a ) {
						$(this).slideUp(300, function() {
							$('#' + a ).slideDown(300);						
						});
						b = true;
					}
				});

				if( !b ) { $('#' + a ).slideToggle(300); }
				return false;
			});
		}
	},
	
	Flash : function() {
		if( $.flash.hasVersion(9) ) {
			$('.no_flash').remove();
			$('#flash_slideshow').flash(
				{
					swf: 'swf/slideshow.swf',
					width: 610,
					height: 250,
					flashvars: { xmlPath: 'swf/ImageXml.ashx' } 
				}
			);
		}
	},
	
	GetDomID : function( a ) {
		a = a.split('#');
		return a[1];
	}
}
