/**
 * SAKURA Creative Inc. Utility Functions.
 *
 * http://www.sakura-creative.com/
 *
 * Copyright (c) 2009 SAKURA Creative Inc.
 *
 * $Id: sc_utils.js 9:51 2009/10/12 Kaoru Ishikura $
 */

(function(){
	var d=this,f;
	var b=(function(){
		if(d.addEventListener){
			return function(i,g,h){
				i.addEventListener(g,h,false)
			}
		}else{
			if(d.attachEvent){
				return function(j,h,i){
					var g=function(){
						i.call(j,d.event)
					}
					;j.attachEvent("on"+h,g)
				}
			}else{
				return false
			}
		}
	})();
	
	function c(h,j,n,o,l,g){
		if(!navigator.cookieEnabled||!h){
			return f
		}
		var k=new Date();
		k.setTime(k.getTime()+((n||-1)*24*60*60*1000));
		var i=";expires="+k.toGMTString();var m=h+"="+escape(j)+i+";path="+(o||"/")+";domain="+(l||"")+";"+(g||"");
		document.cookie=m
	}
	function a(j){
		if(!navigator.cookieEnabled||!j){
			return f
		}
		var i=document.cookie;
		if(!i){
			return f
		}
		j+="=";
		var h=i.indexOf(j);
		if(h!=-1){
			h+=j.length;
			var g=i.indexOf(";",h);
			if(g==-1){
				g=i.length
			}
			return unescape(i.substring(h,g))
		}else{
			return undefined}
		}
		function e(l){
			var k=document.getElementById(l);
			var h=/*@cc_on!@*/false;
			if(h){
				k.style.fontSize="1em"
			}
			var j=k.currentStyle||document.defaultView.getComputedStyle(k,"");
			var i=j.fontSize;
			b(document.getElementById("resetFont"),"click",function(m){
				k.style.fontSize=i;
				c("fontSize",i,0,"/","support.sakura.ad.jp");
				if(m&&m.preventDefault&&m.stopPropagation){
					m.preventDefault();
					m.stopPropagation()
				}else{
					if(d.event){
						d.event.cancelBubble=true;
						d.event.returnValue=false
					}
				}
				return false;
			});
			var g=a("fontSize");
			if(g!==f){
				if(h){
				k.style.fontSize=g+"em"
				}else{
					k.style.fontSize=g+"px"
				}
			}
			b(document.getElementById("increaseFont"),"click",function(p){
				var n=k.currentStyle||document.defaultView.getComputedStyle(k,"");
				var o=parseFloat(n.fontSize,10);
				var m=o*1.2;
				if(h){
					k.style.fontSize=m+"em"
				}else{
					k.style.fontSize=m+"px"}
					c("fontSize",m,30,"/","support.sakura.ad.jp");
					if(p&&p.preventDefault&&p.stopPropagation){
						p.preventDefault();
						p.stopPropagation()
					}else{
						if(d.event){
						d.event.cancelBubble=true;
						d.event.returnValue=false
					}
				}
				return false;
			});
			
//			b(document.getElementById("decreaseFont"),"click",function(p){
//				var n=k.currentStyle||document.defaultView.getComputedStyle(k,"");
//				var o=parseFloat(n.fontSize,10);
//				var m=o*0.8;
//				if(h){
//					k.style.fontSize=m+"em"
//				}else{
//					k.style.fontSize=m+"px"
//				}
//				c("fontSize",m,30,"/","support.sakura.ad.jp");
//				if(p&&p.preventDefault&&p.stopPropagation){
//					p.preventDefault();
//					p.stopPropagation()
//				}else{
//					if(d.event){
//						d.event.cancelBubble=true;
//						d.event.returnValue=false}
//					}
//					return false
//				}
//			)}
		}
		b(d,"load",function(){
			//e("main_div")
			e("main-area");
		}
	)}
)();


