// JavaScript Document

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

	// rollover.
	jQuery("img[@class=rollover]").hover(
		function(){
			this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1on$2");
		},
		function(){
			this.src = this.src.replace(/^(.+)on(\.[a-z]+)$/, "$1$2");
		})
		.each(function(){
			this.preloaded = new Image;
			this.preloaded.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1on$2");
		}
	);

	// rolloveron
	jQuery("img[@class=rolloveron]").each(function(i){
		this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1on$2");
	});

// ----------------------------------------------------------------
});

// util: cookie
function getCookie(name) {
	var value = null;
	if (document.cookie && document.cookie != '') {
		var cookies = document.cookie.split(';');
		var cookie = null;
		for (var i = 0; i < cookies.length; i++) {
			cookie = cookies[i].replace(/^\s+|\s+$/g, '');
			if (cookie.substring(0, name.length + 1) == (name +'=')) {
				value = decodeURIComponent(cookie.substring(name.length + 1));
				break;
			}
		}
	}
	return value;
}
function setCookie(name, value, options) {
	options = options || {};
	if (value == null) {
		value = '';
		options.expires = -1;
	}
	var expires = '';
	if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
		var date;
		if (typeof options.expires == 'number') {
			date = new Date();
			date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
		} else {
			date = options.expires;
		}
		expires = '; expires='+ date.toUTCString();
	}
	var path = options.path ? '; path='+ (options.path) : '';
	var domain = options.domain ? '; domain='+ (options.domain) : '';
	var secure = options.secure ? '; secure' : '';
	document.cookie = [ name, '=', encodeURIComponent(value), path, domain, secure].join('');
}
