var isIE = (document.documentElement.getAttribute("style") == document.documentElement.style);

function setEvent(obj,eventType,func){
	if(isIE) {
		obj.setAttribute(eventType,new Function(func));
	} else {
		obj.setAttribute(eventType,func);
	}
}

var util = {
     getParam: function (name) {
         if (location.href) {
            var urlStrNum = location.href.indexOf('?');
            var querySet = location.href.substring(urlStrNum + 1).split('&');
            var keyValue; var key; var value;
            for (var i = 0, num = querySet.length; i < num; i++) {
                keyValue = querySet[i].split('=');
                key = keyValue[0];
                value = keyValue[1];
                if (0 < value.indexOf('#')) {
                    value = value.substring(0, value.indexOf('#'));
                }
                if (name == key) {
                    return value;
                }
            }
        }
    },
    createCookie: function (name,value,days) {
        if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            var expires = "; expires=" + date.toGMTString();
        }
        else expires = "";
        document.cookie = name + "=" + value + expires + "; path=/";
    },
    readCookie: function (name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0)==' ') c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
        }
        return null;
    }
}

		defcss = 'no_moji_style.css';
        css1 = 'bg_moji_style.css';
        css2 = 'no_moji_style.css';
        css3 = 'sm_moji_style.css';
var setStyle = {
    getActiveCSS: function () {
        var head = document.getElementsByTagName('head')[0];
        var linkTags = head.getElementsByTagName('link');
        for(var i = 0,num = linkTags.length; i < num; i++){
	        if(linkTags[i].getAttribute('href')){
	            var activeCSS = linkTags[i].getAttribute('href');
	        }
	    }
	    return activeCSS;
	},
	getActiveCSSName: function() {
	    var activeCSSUrl = setStyle.getActiveCSS();
        var strNum = activeCSSUrl.lastIndexOf('/');
        var activeCSSName = activeCSSUrl.substring(strNum + 1);
        return activeCSSName;
	},
	setCSS: function(cssName) {

 	    if (cssName) {
            util.createCookie('css', cssName);
            location.reload();
 	    } else if (util.readCookie('css')) {
             cssName = util.readCookie('css');
         } else {
             cssName = defcss;
             util.createCookie('css', cssName);
 	    }
 	    return cssName;
	},
	setCSSTag: function() {
		document.write('<link href="/css/' + setStyle.setCSS() + '" rel="stylesheet" type="text/css" />');
	}
}