var $objects = new Object();

	if (!("console" in window)) {
		window.console = {};
		window.console.log = function(str){
			return str;
		};
	}

//--------------------------------------------
// ready 
//--------------------------------------------
$(document).ready(function(){

	//--------------------------------------------
	// common 
	//--------------------------------------------
	//browser check -------------------------------------------- */
	if (navigator.platform.indexOf("Win") != -1) {
		$objects.os = "win";
		$('body').addClass("win");
		if ( !jQuery.support.leadingWhitespace ) { $('body').addClass("win-ie"); }
	}

	//scroll - anchor  -------------------------------------------- */
	$('a.a-anchor').click( function() { 
		var target = $(this).attr('href');
		var scroll = $(target).offset();
		$('html,body').animate({ scrollTop: scroll.top }, 800, 'quart');
		$(this).blur();
		return false;
	});

	//rollovar - alpha --------------------------------------------
	$('.alpha').hover(function() {
		$(this).stop(true, false).animate({ opacity: .5 }, { duration: 100});
		if ( !jQuery.support.leadingWhitespace ) { this.style.removeAttribute('filter'); }
	}, function () {
		$(this).stop(true, false).animate({ opacity: 1 }, { duration: 100});
		if ( !jQuery.support.leadingWhitespace ) { this.style.removeAttribute('filter'); }
	});

	//--------------------------------------------
	// objects 
	//--------------------------------------------
	//objects -------------------------------------------- */
	$objects = {
		html : $('html'),
		body : $('body')
	};


	vg = $('#grids').hide();
	
	//--------------------------------------------
	// ui-toggle 
	//--------------------------------------------
	$('.ui-toggle').click(function() {
		var target = '#' + $(this).attr('rel');
		if ($(target).is(':hidden')) {
			$(target).slideDown();
			$(this).addClass('current');
		} else {
			$(target).slideUp();
			$(this).removeClass('current');
		}
		return false;
	});

	//--------------------------------------------
	//#nav 
	//--------------------------------------------
	$('#nav-line').hover(function() {
		$(this).siblings('.show').slideDown();
		}, function() {
		//$(this).children('.active').slideDown();
	});

	$('#nav dl').hover(function() {
	}, function() {
		$(this).slideUp();
	}).find('dt .current').parent().parent().parent().parent().slideDown().addClass('show');

	$('.ui-nav').click(function() {
		var target = '#' + $(this).attr('rel');
		$('#nav').children('dl').hide();
		$(target).slideToggle(function() {
			if ($(this).is(':hidden')) {
			} else {
			}
		}).addClass('active');
		return false;
	});

	//--------------------------------------------
	// #home 
	//--------------------------------------------
	$('#home div').hide();

});

//--------------------------------------------------------------------------
// load 
//--------------------------------------------------------------------------
$(window).load(function() {
	
	if ( !jQuery.support.leadingWhitespace ) { 
		$('#home div').show();
	 } else {
		$('#home div').fadeIn(1200);
	}
	
	vg.find('img').css('visibility','visible');
	
	//--------------------------------------------
	// grids 
	//--------------------------------------------
	vg.show().vgrid({
		easeing: "easeOutQuint",
		useLoadImageEvent: true,
		time: 400,
		delay: 20,
		fadeIn: {
			time: 500,
			delay: 50
		}
	});
	
	
	$('strong.ui-count').each(function() {
		var num = 1;
		var count= vg.children().length;
		var timer = setInterval(function(){
			if (num < count ) {
				num = num + 1;
				$('strong.ui-count').text(num);
				console.log(num);
			} else {
				clearInterval(timer);
				$('#nav dl dt .current').parent().parent().parent().parent().delay(1000).slideUp();
			}
		},40); 
	});
	
	vg.dt = vg.find('dt');
	vg.dd = vg.find('dd');

	//open------------------------------
	vg.dt.click(function() {
		var target = $(this).next();
		//open : other hide------------------------------
		vg.dd.each(function(e) {
			$(this).hide(function() {
				if ($(this).hasClass('image')) {
					var _w = 140; var _h = 225;
				} else {
					var _w = 430; var _h = 225;
				}
				$(this).parent().animate({
					width : _w,
					height : _h
				},0, function() {
					vg.vgrefresh();
					$(this).find('dt').show();
				});
			});
		});
		
		//open : this hide & show ------------------------------
		$(this).fadeOut('fast', function() {
			if ($(this).hasClass('image')) {
				var _w = 430; var _h = 685;
			} else {
				var _w = 720; var _h = 455;
			}
			$(this).parent().animate({
				width : _w,
				height : _h
			},0, function() {
				//vg.vgrid({ easeing: "easeOutQuint", time: 800,delay: 100, fadeIn: { time: 100, delay: 0 }});
				vg.vgrefresh(null, null, null, function(){
					target.fadeIn('slow',function() {
						var offset = $(this).parent().offset();
						$('html,body').animate({scrollTop: offset.top - 5}, 400, 'easeOutQuint');
					});
				});
			});
		}).addClass('visited');
		return false;
	}).hover(function() {
		if (!$(this).hasClass('visited')) {
			$(this).stop(true, false).animate({ opacity: .3 }, { duration: 500});
		}
	}, function() {
		if (!$(this).hasClass('visited')) {
			$(this).stop(true, false).animate({ opacity: 1 }, { duration: 500});
		}
	});

	//hide ------------------------------
	vg.dd.click(function() {
		var target = $(this).prev();
		
		//hide : this ------------------------------
		$(this).fadeOut('fast', function() {
			if ($(this).hasClass('image')) {
				var _w = 140;
				var _h = 225;
			} else {
				var _w = 430;
				var _h = 225;
			}
			$(this).parent().animate({
				width : _w,
				height : _h
			},0, function() {
				//vg.vgrid({ easeing: "easeOutQuint", time: 800,delay: 100, fadeIn: { time: 100, delay: 0 }});
				vg.vgrefresh(null, null, null, function(){
					target.fadeIn('slow',function() {
						var offset = $(this).parent().offset();
						$('html,body').animate({scrollTop: offset.top - 5}, 400, 'easeOutQuint');
					});
				});
			});
		});
		return false;
	});


	$(window).resize(function(){
	});
});

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

//--------------------------------------------------------------------------
//functions 
//--------------------------------------------------------------------------
//window size -------------------------------------------- */
function window_size () {
	$objects.w = window.innerWidth || document.body.clientWidth || document.documentElement.clientWidth || document.body.clientWidth || $(window).width();
	$objects.h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || $(window).height();
	console.log('window size:' + $objects.w + "/" + $objects.h );
}

//window size -------------------------------------------- */
function countup (tg) {
	var num = tg.text();
	$(this)

}



