$(window).load(function() {
	
	var photobox =$('div#main_photo');
    photobox.cycle({
        fx:     'fade',
        speed:  'slow',
        timeout: 0,
		next:   'div#main_photo', 
        pager:  '#thumbnail_photo',
       	pagerAnchorBuilder: function(idx, slide) { 
        	return '#thumbnail_photo ul li:eq(' + idx + ') a';
    	}
    });
	
	  
	 //fade in
	 var mainPhoto = $("div#main_photo");
	mainPhoto.fadeIn(800)
	  
	  
	//mouse over text button
	$('p#show_text a').toggle(function() {
		$('div#thumbnail_photo').fadeOut(200, function(){
														$('div#detail_texts').fadeIn(200);
														$('div#thumbnail_photo').hide(0);
														})
	
	}, function() {
   	
		$('div#detail_texts').fadeOut(200, function(){
													$('div#thumbnail_photo').fadeIn(200);
													$('div#detail_texts').hide(0);
													});
	
	});

	
	  
	//swap img
	var conf = {className : 'btn',postfix : '2'};
	var image_cache = new Object();
	$('img.'+conf.className).each(function(i) {
	  var imgsrc = this.src;
	  var dot = this.src.lastIndexOf('.');
	  var imgsrc_on = this.src.substr(0, dot) +  conf.postfix + this.src.substr(dot, 4);
	  image_cache[this.src] = new Image();
	  image_cache[this.src].src = imgsrc_on;
	  $(this).hover(function() { this.src = imgsrc_on;},function() { this.src = imgsrc; });
	});
	
});



//scroll up
jQuery.easing.easeOutQuart = function (x, t, b, c, d) {return -c * ((t=t/d-1)*t*t*t - 1) + b;}

$(function () {
    $('#gotop').click(function () {
		$(this).blur();
        $('html,body').animate({ scrollTop: 0 }, 850, 'easeOutQuart');
		return false;
    });
});