/*================================================
-Main.js Document;
================================================*/
Cufon.replace('.network-head h5, .post-head-inn h2', {hover: true, fontFamily: 'NeoSans' });

$(window).load(function(){
	$('#pane2').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 28});
})

//----------------------------------------------- $(document).ready start
$(document).ready(function(){
//$('#nav li:first-child').addClass('nav-first');
$('#nav li').not('#nav li:last, #nav li:first').addClass('cuf');
$('.footer-nav li:first-child').addClass('footer-nav-first');
$('.footer-nav li:last-child').addClass('footer-nav-last');
//$('.game-box:last-child').addClass('game-box-last');
//$('.network:last').addClass('network-last');
$('.grid:last').addClass('grid-last');
$('.slider-row li:last-child').addClass('slider-list-last');
$('.numbering li:last-child').addClass('numbering-last');
$('.grid-category li:first-child').addClass('grid-categ-first');
$('.content-head-img img').attr('title', '');
$('.content-head-img img').attr('alt', '');
$('img.attachment-post-thumbnail').attr('title', '');
$('img.attachment-post-thumbnail').attr('alt', '');
//inputReseter($('.search-input'), 'Search');
//$('.content-menu li a span').hAlign();
//$('.content-menu li:nth-child(1) span').addClass('console');
//$('.content-menu li:nth-child(2) span').addClass('mobile');
//$('.content-menu li:nth-child(3) span').addClass('pc');
//$('.content-menu li:nth-child(4) span').addClass('arcade');
//$('.content-menu li:nth-child(5) span').addClass('buy');
//$('#nav li a').append("<span class='nav-arrow'></span>");
$('#nav li:first-child a em').wrapInner('<span></span>');
$('ul.archive li a').wrapInner('<span></span>');
$('#related-posts-MRP_all ul').addClass('grid-list');
$('#related-posts-MRP_all ul.grid-list li a').wrapInner('<span></span>');
$('ul.socialwrap').addClass('head-icons');
$('#thumbnails li.thumbs:nth-child(5n)').addClass('thumbnails-last');
$('.block:nth-child(3n)').addClass('block-last');
$('table.job_table tr td:nth-child(2)').addClass('right_border');
//$('.pagenavigation').hAlign2();
$('#pane3').jScrollPane();
tabs();



			$('#office-gallery').anythingSlider({
				width : 586,// Override the default CSS width
				easing: 'easeInOutExpo',
				autoPlay: false
			});



		 
		 $('.game-box h5 a, .game-box-img a').hover(
		  function(){
		   $(this).parent().parent().attr('id' , 'game-box-ie');
		  },
		  function(){
		   if($('#game-box-ie').parent().hasClass('active')){
			
		   }else {
		   }
		  $(this).parent().parent().removeAttr('id');
		  }
		 );



        
        //view image
        $('.thumbs').children('a').click(function (e) {
        e.preventDefault();
        $(".selectedThumb").removeClass("selectedThumb");
        $(this).addClass("selectedThumb");
        var thumbnailLink = $(this).attr("href");
        if ($('#screenshot').hasClass("flash-cont")){
        $('#screenshot').removeClass("flash-cont");
        $('#screenshot').empty();
        $('#screenshot').append("\<img src='"+thumbnailLink+"' style='width:526px;height:246px;'\/>");
        $('#screenshot img').css({opacity: 0}).stop().animate({opacity: 0},1000).animate({opacity: 1},300, "easeInOutQuad");
        } else {
        $('#screenshot img').fadeOut('fast', function() {
        $('#screenshot').empty();
        $('#screenshot').append("\<img src='"+thumbnailLink+"' style='width:526px;height:246px;'\/>");
        $('#screenshot img').css({opacity: 0}).stop().animate({opacity: 0},500).animate({opacity: 1},500, "easeInOutQuad");
        });
        }
        }); 
		
		$('.paging-container').pajinate({
					num_page_links_to_display : 10,
					items_per_page : 1	
				});
                
        $('.paging-container-blog').pajinate({
					num_page_links_to_display : 10,
					items_per_page : 1	
				});

		$('.fan-art-container:odd, .tabs-container > *:odd').css('');

		$(function()
			{
				// this initialises the demo scollpanes on the page.
				
			});

		
		//$(function() {
		//	$('.fan-art-container li a').lightBox();
		//});

		
		
		$(function(){
			$('#slider-grid').anythingSlider({
				startStopped    : false, // If autoPlay is on, this can force it to start stopped
				width           : 284,   // Override the default CSS width
				theme           : 'metallic',
//				autoPlayLocked  : true,  // If true, user changing slides will not stop the slideshow
				resumeDelay     : 10000, // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
				autoPlay        : false,  // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
				onSlideComplete : function(slider){
					// alert('Welcome to Slide #' + slider.currentPage);
				}
			});

		});

/*twitterの読み込みを止めるからコメントにしておこう 20111031
		$(".tweet").tweet({
            username: "cavegames",
            join_text: "auto",
            avatar_size: 32,
            count: 1,
            auto_join_text_default: "",
            auto_join_text_ed: "",
            auto_join_text_ing: "",
            auto_join_text_reply: "",
            auto_join_text_url: "",
            loading_text: "loading tweets..."
        });
*/

//----------------------------------------------- Strict new page
	$(function() {
		 $('a[rel*=external]').click( function() {
			 window.open(this.href);
			 return false;
		 });
	 });


});


//----------------------------------------------- Reset input
	function inputReseter(jqObj, iniVal){
		$(jqObj).focus(function(){
		value = $(this).val();
		if( value == iniVal ){
		$(this).val('');
		}else{
		// user has ented input, do nothing
		}
		});
		$(jqObj).blur(function(){
		if($(this).val() === ''){
		$(this).val(iniVal);
		}else{
		// user has ented input, do nothing
		}
		});
		}

	function tabs() {
	   $('.menu-panel').hide();
	   $('.sidebar-open').click(
	   function() {
		  if($(this).hasClass('current')){
		  $(this).removeClass('current');
		   $(this).next().slideUp();
		   
		  }
		  else {
					$(this).addClass('current');
		  $(this).next().slideDown('normal');
			 };
	
	 })
	}



		$.fn.hAlign = function() {
			return this.each(function(i){
			var ah = $(this).width();
			var ph = $(this).parent().width();
			var mh = ((ph - ah) / 2 - 20);
			$(this).css('margin-left', mh);
			});
		};
        
        $.fn.hAlign2 = function() {
			return this.each(function(i){
			var ah = $(this).width();
			var ph = $(this).parent().width();
			var mh = ((ph - ah) / 2 - 5);
			$(this).css('margin-left', mh);
			});
		};
        

		$(function(){

			// External Link
			$("a.muppet").click(function(){
				$('#slider1').anythingSlider(5);
				$(document).scrollTop(0);
				return false;
			});

			// Report Events to console & features list
			$('#slider1').bind('before_initialize initialized swf_completed slideshow_start slideshow_stop slideshow_paused slideshow_unpaused slide_init slide_begin slide_complete', function(e, slider){
				// show object ID + event (e.g. "slider1: slide_begin")
				var txt = slider.$el[0].id + ': ' + e.type + ', now on panel #' + slider.currentPage;
				$('#status').text(txt);
				if (window.console && window.console.firebug){ console.debug(txt); } // added window.console.firebug to make this work in Opera
			});

			// Theme Selector (This is really for demo purposes only)
			var themes = ['minimalist-round','minimalist-square','metallic','construction','cs-portfolio'];
			$('#currentTheme').change(function(){
				var theme = $(this).val();
				if (!$('link[href*=' + theme + ']').length) {
					$('body').append('<link rel="stylesheet" href="css/theme-' + theme + '.css" type="text/css" media="screen" />');
				}
				$('#slider1').closest('div.anythingSlider')
					.removeClass( $.map(themes, function(t){ return 'anythingSlider-' + t; }).join(' ') )
					.addClass('anythingSlider-' + theme);
			});

			// Add a slide
			var imageNumber = 1;
			$('button.add').click(function(){
				$('#slider1')
					.append('<li><img src="images/slide-tele-' + (++imageNumber%2 + 1)  + '.jpg" alt="" /></li>')
					.anythingSlider(); // update the slider
			});
			$('button.remove').click(function(){
				if ($('#slider1').data('AnythingSlider').pages > 1) {
					$('#slider1 > li:not(.cloned):last').remove();
					$('#slider1').anythingSlider(); // update the slider
				}
			});

		});
