function preloader() {

	MenuitemBlock1 = new Image(); 
	MenuitemBlock1.src = "http://www.chwaraeteg.com/tinyimages/chwaraeteg-home1_01.jpg";
	
	MenuitemBlock2 = new Image(); 
	MenuitemBlock2.src = "http://www.chwaraeteg.com/tinyimages/chwaraeteg-home2_01.jpg";
	
	MenuitemBlock3 = new Image(); 
	MenuitemBlock3.src = "http://www.chwaraeteg.com/tinyimages/chwaraeteg-home3_01.jpg";
	
	
	<!--Welsh set to preload-->
	
	MenuitemBlock4 = new Image(); 
	MenuitemBlock4.src = "http://www.chwaraeteg.com/tinyimages/chwaraeteg_1_01a.jpg";
	
	MenuitemBlock5 = new Image(); 
	MenuitemBlock5.src = "http://www.chwaraeteg.com/tinyimages/chwaraeteg_1_01b.jpg";
	
	MenuitemBlock6 = new Image(); 
	MenuitemBlock6.src = "http://www.chwaraeteg.com/tinyimages/chwaraeteg_1_01c.jpg";


}


function slideSwitch() {
    var $active = $('#slideshow DIV.active');

    if ( $active.length == 0 ) $active = $('#slideshow DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        //: $('#slideshow DIV:first');
		: jQuery('#slideshow DIV:first');

    // pull the divs randomly
    //var $sibs  = $active.siblings();
   // var rndNum = Math.floor(Math.random() * $sibs.length );
   // var $next  = $( $sibs[ rndNum ] );

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 3000, function() { //duration of fade + increases
            $active.removeClass('active last-active');
        });
}






jQuery(function() {
    setInterval( "slideSwitch()", 5000 ); //speed of fade + increases
});




jQuery(document).ready(function(){

	preloader();





		jQuery('.subject_block').hover(function(){

			jQuery(this).css('background-position','-220px 0px');

		}, function(){

			jQuery(this).css('background-position','0px 0px');

		});


		jQuery('.subject_block').click(function(){

			var id = jQuery(this).attr('id');
			
			//console.log(jQuery('#'+id+' a').attr('href'));

			link = jQuery('#'+id+' a').attr('href');
		
			window.location = link;
		
		
		});



		jQuery('.small_subject_block').hover(function(){

			jQuery(this).css('background-position','-220px 0px');

		}, function(){

			jQuery(this).css('background-position','0px 0px');

		});


		jQuery('.small_subject_block').click(function(){
		
			link = jQuery('.small_subject_block a').attr('href');
		
			window.location = link;
		
		
		});


		jQuery('#nav ul li ul').hover(function(){
	
			jQuery(this).parent().children().addClass('active');
	
		}, function(){
	
			jQuery(this).parent().children().removeClass('active');
	
		});


		//jQuery('#home_slideshow').innerfade({speed: 2000,timeout: 5000,type: 'sequence',containerheight: '250px'});



				jQuery("#twitter_feed").getTwitter({
					userName: "womenspire",
					numTweets: 10,
					loaderText: "Loading tweets...",
					slideIn: false,
					slideDuration: 50,
					showHeading: false,
					headingText: "Latest Tweets",
					showProfileLink: false,
					showTimestamp: true
				});



				setTimeout(function(){

					jQuery("#twitter_feed ul li:even").each(function(){

						jQuery(this).add( $(this).next() ).wrapAll('<div class="tweet_slide"></div>');

	
					});

				},1000);

		
				setTimeout(function(){
		
					jQuery('#twitter_feed ul').cycle({
						fx:			'fade',
						timeout: 	8000, 
						speed:	 	1000,
						pause:		1,
						slideExpr:	'div.tweet_slide'
					});
		
				},1000);


				jQuery('#home_news').cycle({
					fx:			'fade',
					timeout: 	8000, 
					speed:	 	1000,
					pause:		1,
					slideExpr:	'div.quick_news'
				});

				jQuery('#home_events').cycle({
					fx:			'fade',
					timeout: 	8000, 
					speed:	 	1000,
					pause:		1,
					slideExpr:	'div.quick_news'
				});


				jQuery('.members_slideshow').cycle({
					fx:			'fade',
					timeout: 	6000, 
					speed:	 	1000,
					pause:		1
				});




				jQuery('#comp_main_image').cycle({
					fx:			'fade',
					timeout: 	0, 
					speed:	 	1000,
					pause:		1,
					slideExpr:	'img',
					pager:  	'#slideshow_nav'
				});



	jQuery('#comp_main_image img').hide().delay(500).fadeIn(500);

	var comp_image_container_width = jQuery('#comp_main_image').width();
	var comp_image_width = jQuery('#comp_main_image img').width();
	var central_position_value = (comp_image_container_width/2)-(comp_image_width/2);
	
	jQuery('#comp_main_image img').css('left', central_position_value);


	function centerCompImages(){

		if(jQuery('#comp_main_image img:first-child').is(':visible')){

			jQuery('#comp_main_image img').hide().delay(100).fadeIn(500);

		}

		var comp_image_container_width = jQuery('#comp_main_image').width();
		var comp_image_width = jQuery('#comp_main_image img').width();
	
		var central_position_value = (comp_image_container_width/2)-(comp_image_width/2);
	
		jQuery('#comp_main_image img').css('left', central_position_value);
	
	}


	jQuery('#comp_main_image a').click(function(){

		centerCompImages();

	})


	jQuery('#comp_thumbs a').click(function(){

		centerCompImages();

	})



});
