/*
jQuery code used by Sofa Disordery theme. Feel free to modify in order to fit your needs!
*/

jQuery( document ).ready( function() {
	
	// main navig : find out whether main navig items have title attribute. if true, extract and append
	/*
	jQuery( '#globalnavi li' ).each( function( i ) {
		var titl = jQuery( 'a', this ).attr( 'title' );
		if( titl != '' ) jQuery( 'a:first', this ).append( '<span>' + titl + '</span>' );
	} );
	*/
	// scroll to top
	jQuery( '#totop' ).click( function() {
		var bodyelem = '';
		if( jQuery.browser.safari ) bodyelem = jQuery( 'body' ); // only Opera specific
		else bodyelem = jQuery( 'html' );
		jQuery( bodyelem ).animate( { scrollTop: jQuery( '#gettotop' ).offset().top }, 'slow' );
		return false;
	} );	

} );

jQuery( function() {
	// early document ready bugfix for webkit & opera
	if( document.readyState != 'complete' ) {
		setTimeout( arguments.callee, 100 );
		return;
	} else {
		// wp-captions
		jQuery( 'div.wp-caption' ).each( function( xyz ) {
			var real_width = jQuery( 'img', this ).outerWidth( true );
			jQuery( this ).css( 'width', real_width );
		} );
	}
} );

// uniforms (do not require document ready)
jQuery( function() {
	jQuery( "input, checkbox, textarea, button, select" ).uniform();
} );
