window.yourrss = {

	BASEDIR: "http://yourrss.jp/blogparts/siteinfo/",
	SWFFILE: "main.swf",
	BOXNAME: "yourrss",
	SWFNAME: "yourrssswf",
	RSSPATH: "http://quality.ekndesign.com/index.rdf",
	basedoc: document,
	basewin: window,
	mybody : document.body,
	basebody : null,
	obox:null,
	Utils:null,
	trace:null,
	Events:null,
	bilded:false,
	initStatus:false,
	showStatus:false,
	
	build: function() {
		//if(!this.bilded){
			this.bilded = true;
			this.insertSrc(this.getEmbedSrc());
		//}
	},

	getEmbedSrc: function() {
		var flashvars = "u=" + this.RSSPATH;
		var mySrc = '';
		//mySrc += '<div style="position:absolute; top:0px; left:0px; z-index:1">';
		//mySrc += 'aaaaa';
		mySrc += '<object style="z-index:99;" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"100%\" height=\"100%\" id="' + this.SWFNAME + '">';
		mySrc += '<param name=\"movie\" value=\"' + this.SWFFILE + '\">';
		mySrc += '<param name=\"quality\" value=\"high\">';
		mySrc += '<param name=\"wmode\" value=\"transparent\">';
		mySrc += '<param name=\"allowScriptAccess\" value=\"always\">';
		mySrc += '<param name=\"FlashVars\" value=\"' + flashvars + '\">';
		mySrc += '<embed src="' + this.SWFFILE + '" name="' + this.SWFNAME + '" FlashVars="' + flashvars + '" allowScriptAccess="always" FlashVars="" quality="high" scale="noscale" wmode="transparent" width="100%" height="100%" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		mySrc += '</object>';
		//mySrc += '</div>';
		return mySrc;
	},

	insertSrc: function(str){
		var o = this.getBox();
		o.innerHTML = str;
	},

	getBox: function(){
	  if(!this.obox){
		this.obox = this.basedoc.createElement('div');
		this.obox.setAttribute('id',this.BOXNAME);
		this.obox.style.position = 'absolute';
		this.obox.style.top = '0';
		this.obox.style.left = '0';
		this.obox.style.visibility = 'visible';
		this.mybody.appendChild(this.obox);
	  }
	  return this.obox;
	},

	/*
	* Visible
	*/

	show: function(rsspath){
		if(!this.initStatus) return;
		this.RSSPATH = rsspath;
		if(this.Utils.isSupportedBrowser() && this.Utils.getFlashPlayerVersion()[0] >= 8){
			this.Utils.hideScrollbar();
			this.Utils.hideAllItemByTag("embed");
			this.Utils.hideAllItemByTag("object");
			this.setEventHandler();
			this.build();
			//if(this.Utils.isNotIE()) this.getBox().style.visibility = 'visible';
			if(this.Utils.getDOM(this.SWFNAME).onEventShow)this.Utils.getDOM(this.SWFNAME).onEventShow();
		}else{
			//alert("is not supported browser.");
			location.href = rsspath;
		}
	},

	hide: function(){
		this.Utils.showScrollbar();
		var s = this;
		var siid = setInterval(function(){
			clearInterval(siid);
			s.Utils.showAllItemByTag("embed");
			s.Utils.showAllItemByTag("object");
			s.removeEventHandler();
			s.sizeReset();
			//if(this.Utils.isNotIE()) this.getBox().style.visibility = 'hidden';
			if(s.Utils.getDOM(s.SWFNAME).onEventHide) s.Utils.getDOM(s.SWFNAME).onEventHide();
			var bnm = s.Utils.getBrowserName();
			if(bnm == "MSIE"){ s.insertSrc(" "); };
		},100);
	},
	
	hideAndMove: function(trgUrl){
		this.removeEventHandler();
		this.sizeReset();
		//if(this.Utils.isNotIE()) this.getBox().style.visibility = 'hidden';
		if(this.Utils.getDOM(this.SWFNAME).onEventHide) this.Utils.getDOM(this.SWFNAME).onEventHide();
		var bnm = this.Utils.getBrowserName();
		if(bnm == "MSIE"){ this.insertSrc(" "); };
		location.href = trgUrl;
	},

	/*
	* Position size
	*/
	
		setEventHandler: function(){
			this.setOnResizeEventHandler();
			this.setOnScrollEventHandler();
		},
		
		removeEventHandler: function(){
			this.Events.windowResizeRemoveListener(this.onResizeEventHandler);
			this.Events.windowScrollRemoveListener(this.onScrollEventHandler);
		},
		

		setOnResizeEventHandler: function(){
			this.Events.windowResizeAddListener(this,this.onResizeEventHandler,true);
		},
		
		setOnScrollEventHandler: function(){
			this.Events.windowScrollAddListener(this,this.onScrollEventHandler,true);
		},

		onResizeEventHandler: function(){
			var bnm = this.Utils.getBrowserName();
			if(bnm == "MSIE"){
				var h = this.basebody.clientHeight;
				var w = this.basebody.clientWidth;
			}else if(bnm == "SAFARI"){
				var h = this.basewin.innerHeight;
				var w = this.basewin.innerWidth;
			}else{
				var h = this.basewin.innerHeight;
				var w = this.basewin.innerWidth - 17;
			}
			this.getBox().style.height = h + 'px';
			this.getBox().style.width = w + 'px';
		},
		
		onScrollEventHandler: function(){
			var bnm = this.Utils.getBrowserName();
			if(bnm == "MSIE"){
				var yps = this.basebody.scrollTop;
			}else{
				var yps = this.basewin.pageYOffset;
			}
			this.getBox().style.top = yps + 'px';
		},
		
		sizeReset: function(){
			this.getBox().style.height = '0px';
			this.getBox().style.width = '0px';
		},
		
	

	// ------------------------------

	initialize: function(){
		this.initStatus = true;
		this.Utils = this.basewin.ekndesignUtils;
		this.Events = this.basewin.ekndesignEvents;
		this.trace = this.Utils.trace;
		
		if(this.Utils.isSupportedBrowser()){

			if(!this.Utils.isLoacal())
			this.SWFFILE = this.BASEDIR + this.SWFFILE;
			
			var bnm = this.Utils.getBrowserName();
			this.basebody = document['CSS1Compat' == document.compatMode ? 'documentElement' : 'body']

			if(bnm == "MSIE"){
				window.attachEvent("onunload",this.hide);
			};

		}
	}
	
}

window.ekndesignUtils = new Object();
window.ekndesignUtils = {

	getBody :function(){
		return document['CSS1Compat' == document.compatMode ? 'documentElement' : 'body'];
	},

	getBrowserName: function(){
		var ua = navigator.userAgent;
		var str = navigator.userAgent.split(")");
		if (String(str[0]).indexOf("MSIE") > -1){
			if(str[1] == "") return "MSIE";
			else return "OPERA"
		}
		if (ua.indexOf("Safari") > -1) return "SAFARI";
		return "Mozilla";
		
	},
	
	isSupportedBrowser: function(){
		var bws = this.getBrowserName()
		//if(bws == "OPERA" || bws == "SAFARI"){
		if(bws == "OPERA"){
			return false;
		}
			return true;
	},
	
	isNotIE: function(){
		if(this.getBrowserName() == "MSIE"){
			return false;
		}else{
			return true;
		}
	},
	
	getOS: function(){
		var uAgent  = navigator.userAgent.toUpperCase();
		if (uAgent.indexOf("MAC") >= 0) return "MAC";
		if (uAgent.indexOf("WIN") >= 0) return "WIN";
		if (uAgent.indexOf("X11") >= 0) return "UNIX";
		return "";
	},
	
	trace: function(o){
		this.alert(o);
	},
		
	getDOM: function(str){
		if(this.getBrowserName() == "MSIE"){
			return window[str];
		}else{
			return document[str];
		}
	},
	
	isLoacal: function(){
		if(location.href.split("/")[0] == "file:"){
			return true;
		}else{
			return false;
		}
	},
	
	showAllItemByTag: function(tagname){
		var aitem = document.all;
		if (!aitem) aitem  = document.getElementsByTagName("*");
		for (i = 0; i < aitem.length; i++){
			if(aitem[i].tagName.toLowerCase() == tagname.toLowerCase()){
				aitem[i].style.visibility = 'visible';
			}
		}
	},
	
	hideAllItemByTag: function(tagname){
		var aitem = document.all;
		if (!aitem) aitem  = document.getElementsByTagName("*");
		for (i = 0; i < aitem.length; i++){
			if(aitem[i].tagName.toLowerCase() == tagname.toLowerCase()){
				aitem[i].style.visibility = 'hidden';
			}
		}
	},
	
	hideScrollbar: function(){
		//if(this.getOS() != "MAC") this.getBody().style.overflow = 'hidden';
		//alert(this.getBody().style.overflow);
		//this.getBody().style.overflow = 'hidden';
		//document.body.style.overflow  = 'hidden';
	},
	
	showScrollbar: function(){
		//if(this.getOS() != "MAC") this.getBody().style.overflow = 'auto';
		//document.body.style.overflow  = '';
		//this.getBody().style.overflow = 'scroll';
	},
	
//Flash player

	getFlashPlayerVersion:function (){
		var PlayerVersion = [0,0,0];
		if(navigator.plugins && navigator.mimeTypes.length){
			var x = navigator.plugins["Shockwave Flash"];
			if(x && x.description) {
				PlayerVersion = x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".");
			}
		}else{
			try{
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
			}catch(e){
				try {
					var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
					PlayerVersion = [6,0,21];
					axo.AllowScriptAccess = "always"; // throws if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
				} catch(e) {
					if (PlayerVersion[0] == 6) {
						return PlayerVersion;
					}
				}
				try {
					axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
				} catch(e) {}
			}
			if (axo != null) {
				PlayerVersion = axo.GetVariable("$version").split(" ")[1].split(",");
			}
		}
		return PlayerVersion;
	},

	hasFlashPlayer: function(){
		if(getFlashPlayerVersion()[0] != 0) return true;
		else  return false;
	}
};

window.ekndesignEvents = new Object();
window.ekndesignEvents = {

	//Window
		Events:null,
		window_lisners_onResize: [],
		window_lisners_onScroll: [],

		initWindow: function(){
			var s = this;
			window.onresize = function(){
				for(var i in s.window_lisners_onResize){
					var t = s.window_lisners_onResize[i];
					t.func.apply(t.scope);
				}
			}
			
			window.onscroll = function(){
				for(var i in s.window_lisners_onScroll){
					var t = s.window_lisners_onScroll[i];
					t.func.apply(t.scope);
				}
			}
		},

		//onResize
		
			windowResizeAddListener: function(s,f,b){
			
				//var bnm = this.Utils.getBrowserName();
				//if(bnm == "MSIE"){
				//	window.attachEvent('onresize',f);
				//}else{
				//	window.addEventListener('resize',f,false);
				//}
				//window.onresize();
				
				this.window_lisners_onResize.push({scope:s,func:f});
				if(b){
					window.onresize();
				}
			},

			windowResizeRemoveListener: function(func){
				//var bnm = this.Utils.getBrowserName();
				//if(bnm == "MSIE"){
				//	window.detachEvent('onResize',f);
				//}else{
				//	window.removeEventListener('resize',f,false);
				//}
				for(var i in this.window_lisners_onResize){
					if(this.window_lisners_onResize[i].func == func) this.window_lisners_onResize.splice(i,1);
				}
			},
		
		//onScroll
		
			windowScrollAddListener: function(s,f,b){
				//var bnm = this.Utils.getBrowserName();
				//if(bnm == "MSIE"){
				//	window.attachEvent('onScroll',f);
				//}else{
				//	window.addEventListener('scroll',f,false);
				//}
				window.onscroll();
				this.window_lisners_onScroll.push({scope:s,func:f});
				if(b){
					window.onscroll();
				}
			},

			windowScrollRemoveListener: function(func){
				//var bnm = this.Utils.getBrowserName();
				//if(bnm == "MSIE"){
				//	window.detachEvent('onScroll',f);
				//}else{
				//	window.removeEventListener('scroll',f,false);
				//}
				for(var i in this.window_lisners_onScroll){
					if(this.window_lisners_onScroll[i].func == func) this.window_lisners_onScroll.splice(i,1);
				}
			},
	
	initialize: function(){
		this.Utils = window.ekndesignUtils;
		this.initWindow();
	}
}

window.old_onload = window.onload;
window.onload = function(){
	if(window.old_onload) window.old_onload();
	window.ekndesignEvents.initialize();
	window.yourrss.initialize();
}
