/**
 * @author oldoffice
 */

//*-FOR DYNAMIC JS FILE IMPORT---------------------------------------------------*//

function require($importFiles)
{
	for(var i = 0; i < $importFiles.length; i++)
	{
		var scriptElem = document.createElement('script');
		scriptElem.src = $importFiles[i];
		scriptElem.type = 'text/javascript';
		var head = document.getElementsByTagName('head')[0];
		head.appendChild(scriptElem);
	}
}

//*-FOR GET VARIOUS VALUE --------------------------------------------------------*//

var ValueUtil = function()
{
	this.init.apply(this, arguments);
}

ValueUtil.prototype = 
{
	month : 0,
	trimKey : "http://example.com/",
	key : "aaa",
	masterKey : "bbb",
	
	init : function()
	{
		//FOR CATEGORY
		var current = location.href;
		this.key = current.replace(this.trimKey, "");
		this.generate();
		
		//FOR MONTH
		this.month = new Date().getMonth();
	},
	
	generate : function()
	{
		var pos = this.key.indexOf("/");
		
		if(pos != -1)
		{
			this.masterKey = this.key.substring(0, pos);
		}
		else
		{
			this.masterKey = "GLOBAL_INDEX";
		}
	},
	
	getCategoryName : function()
	{
		return this.masterKey;
	},
	
	getCurrentMonth : function()
	{
		return this.month;
	}
}

//*-FOR USE DELEGATE --------------------------------------------------------*//

function createDelegate(func, thisObj)
{
	var del = function()
	{
		return func.apply(thisObj, arguments);
	}
	
	del.func = func;
	del.thisObj = thisObj;
	return del;
}

//*-FOR RELATIVE PATH TO ABSOLUTE PATH ----------------------------------------*//

function absolutePath(path)
{
	var e = document.createElement('span');
	e.innerHTML = '<a href="' + path + '" />';
	return e.firstChild.href;
}