/**
 * %Root%/root.js
 * Copyright (c) 2000-2008 Ayumin. All rights reserved.
 * 
 * $Revision: 0.0.0 $
 * 
 */


if (typeof Ayumin == 'undefined' || !Ayumin) {
	var Ayumin = {
		emptyFunc: function() {}
	};
}

/* Location
___________________________ */

Ayumin.Loc = function() {};
Ayumin.Loc.prototype = {
	init: function(uri) {
		this.uri = uri;
	},

	getRedirected: function() {
		try {
			window.location.href = this.uri;
		} catch (e) {
			try {
				window.location.href = this.uri;
			} catch (e) {}
		}
	}
};

/* Enter Site
___________________________ */

Ayumin.Gateway = new Ayumin.Loc();

// Ayumin.Gateway.enterSite = function() {/*...*/};
var enterSite = function() { // 'enterSite': used in SWF
	var hn = window.location.hostname.toLowerCase();
	var portfolioURI = 'about:blank';

	if (hn.indexOf('tripod') != -1) {
		portfolioURI = 'http:\/\/beads.sytes.net/~beads/beads/';
	} else if (
		(hn.indexOf('geocities') != -1) || 
		(hn.indexOf('iipark')    != -1) ||
		(hn.indexOf('sytes.net') != -1) ||
		(hn.indexOf('hopto.org') != -1)

	) {
		portfolioURI = './beads/';
	} else {
		portfolioURI = 'http:\/\/beads.sytes.net/~beads/beads/';
	}
	Ayumin.Gateway.init(portfolioURI);
	Ayumin.Gateway.getRedirected();

	hn = portfolioURI = null;
};

/* Movie
___________________________ */

Ayumin.Movie = {
	hasLoaded: false,

	load: function(swfContainerId, swfURL, swfId, swfWidth, swfHeight, swfVer, swfBgColor) {
		if (!this.hasLoaded) {
			// see /scripts/swfobject.js
			if (typeof SWFObject != 'undefined') {
				Ayumin.Swf = new SWFObject(
					swfURL, swfId,
					swfWidth, swfHeight, swfVer, swfBgColor
				);
				Ayumin.Swf.addParam('allowScriptAccess', 'always');
				Ayumin.Swf.write(swfContainerId);
				this.hasLoaded = true;
			}
		}
	}
};

Ayumin.setMovie = function() {
	Ayumin.Movie.load(
		'movieBox', './ayumins.swf', 'sitetopMovie',
		'600', '330', '6', '#ffffff'
	);
};


/* Init
___________________________ */

if (typeof(Ayumin.addWinOnLoadEvent) == 'undefined') {
	Ayumin.addWinOnLoadEvent = function(func) {
		var lambda = func;
		if (window.addEventListener) { // W3C DOM
			window.addEventListener('load', lambda, false);
		} else if (window.attachEvent) { // IE
			window.attachEvent('onload', lambda);
		} else {
			var loadEvent = window.onload;
			if (typeof window.onload != 'function') {
				window.onload = lambda;
			} else {
				window.onload = function() {
					if (loadEvent) {
						loadEvent();
					}
					lambda();
				};
			}
		}
	};
}
Ayumin.addWinOnLoadEvent(Ayumin.setMovie);
