/*
//    UMeedia Javascript framework
//	  Copyright by soimon.com,
//	  Simon Boer - soimon@soimon.com
//	  
///////////////////////////////////////////////////////////////////*/

var Umeedia = {
	
	// Start
	Start: function( ) {
	
		Umeedia.Listen.call( Umeedia );
	
	},
	
	// Listen
	Listen: function( ) {
	
		this.Style( );
		this.Menu( );
		this.Navigation( );
		this.Slideshow( );
		
	},
	
	// Slideshow
	Slideshow: function( ) {
		
		var Slideshow = new SWFObject( "Web/Images/Root/Slideshow.swf", "Slideshow", 844, 203, 8, "#FFFFFF" );
			Slideshow.addParam( "wmode", "transparent" );
			Slideshow.addParam( "scale", "default" );
			Slideshow.addParam( "salign", "tl" );
		
		//Slideshow.write( "slideshow" );
		var SlideHTML = $(Slideshow.getSWFHTML( ));
		$('#slideshow').append($(SlideHTML)).show(3000);
		
	},
	
	// Navigation
	Navigation: function( ) {
		
		$( "a.navigation" ).click( function( e ) {
			
			e.preventDefault( );
			
			var NewUrl = window.location.search.replace( /p\=[0-9]+/, 'p=' + $( this ).attr( "href" ) );
			
			if( NewUrl == window.location.search )
				if( NewUrl == "" )
					NewUrl = "?p=" + $( this ).attr( "href" );
				else
					NewUrl += "&p=" + $( this ).attr( "href" );
					
			window.location.search = NewUrl;
			
		} );
		
	},
	
	// Menu
	Menu: function( ) {
	
		$( "#menu a" ).each( function( ) {
		
			if( window.location.search.indexOf( $( this ).attr( "href" ) ) > -1 )
				$( this ).addClass( "selected" );
		
		} );
		
		if( !$( "#menu a.selected" ).get( 0 ) )
			$( "#menu a:first" ).addClass( "selected" );
	
	},
	
	// Style
	Style: function( ) {
		
		$( "input" ).livequery( function( ) {
			$( this ).addClass( "input-" + $( this ).attr( "type" ) );
		} );
		$( "input[type=button], input[type=submit]" ).livequery( function( ) {
			$( this ).hover( function( ) {
				$( this ).addClass( "hover" );
			}, function( ) {
				$( this ).removeClass( "hover" );
			} )
	   } );
		
	},
	
	////////////// AJAX
	
	AJAX: {
	
		Send: function( module, header, data, callback ) {
		
			var R = { 'H': header, 'C': data };
			var J = encodeURIComponent( JSON.stringify( R ) );
		
			$.ajax( {
				   
				type: "POST",
				url: "AJAX.php?a=" + module,
				data: "c=" + J,
				success: callback
				
		   } );
			
		},
		
		GetData: function( d ) {
			
			return JSON.parse( d );
			
		}
	
	}
	
}

// Start

$( Umeedia.Start );
