/* child
--------------------------------------------------------- */
$ (function () {

	if ($.browser.msie) {
		if ($.browser.version < 7) {
			$ (":first-child").addClass ("first-child");
			$ ("input").each (function () {
				$ (this).addClass ($ (this).attr ("type"));
			});
		}
		if ($.browser.version < 8) {
			$ (":last-child").addClass ("last-child");
		}
	}
});


/* lightbox
--------------------------------------------------------- */
$ (function() {
	$ ("div.grid-image a.gallery").lightBox();
});

/* rollover
--------------------------------------------------------- */
$ (function () {
	$ ("img.rollover").each (function () {
		$ ("<img />").attr ("src", this.src.replace (/\.([^.]+)$/, "_hover." + "$1"));
	});
	$ ("a:has(img.rollover)").hover (function () {
		$ ("img.rollover", this).each (function () {
			this.src = this.src.replace (/\.([^.]+)$/, "_hover." + "$1");
		});
	}, function () {
		$ ("img.rollover", this).each (function () {
			this.src = this.src.replace (/_hover\.([^.]+)$/, "." + "$1");
		});
	});
	$ ("input.rollover").each (function () {
		$ ("<img />").attr ("src", this.src.replace (/\.([^.]+)$/, "_hover." + "$1"));
		$ (this).hover (function () {
			this.src = this.src.replace (/\.([^.]+)$/, "_hover." + "$1");
		}, function () {
			this.src = this.src.replace (/_hover\.([^.]+)$/, "." + "$1");
		});
	});
});

/* scroll
--------------------------------------------------------- */
$ (function () {
	$ ('div.pagetop a').click (function (){
		$.scrollTo( 0, 400 );
		return false;
	});
});

/* snap
--------------------------------------------------------- */
$ (function () {
	var setSnapWidth = function () {
		$ ("div.container").css ("width", "auto");
		var width = $ ("div.container").width ();
		$ ("div.container").width (parseInt (width / 193) * 193);
	};
	$ (window).load (function () {
		setSnapWidth ();
	});
	$ (window).resize (function () {
		setSnapWidth ();
	});
});

/* vgrid
--------------------------------------------------------- */
$ (function () {
	$ ("div.grid-content").vgrid ({
		easeing: "easeOutQuint",
		time: 250,
		delay: 0
	});
});

/* window
--------------------------------------------------------- */
$ (function () {
	$ (".external").attr ("target", "_blank");
});