//パラメータ操作用

//NVRequest.getParameter("パラメータ名")でパラメータが取れる
function _NVRequest(){
	this.parameterMap = this.init();
}

_NVRequest.prototype = {
	queryString : function(){
		return window.location.search.substr(1);
	},
	init : function(){
	    var params = this.queryString().split("&");
		var paramMap = new Object();
	    for(var i = 0; i < params.length; i++) {
	        var keyVal = params[i].split("=");
			paramMap[keyVal[0]] = keyVal[1];
	    }
		return paramMap;
	},
	getParameter : function(nm){
		return this.parameterMap[nm];
	}
}

var NVRequest = new _NVRequest();


var CoBrand = null;
var paramCp = NVRequest.getParameter("CP");

var NullBrand = {
	head : function(){},
	foot : function(){}
}

//以下、CPパラメータの形式が妥当であれば、オブジェクトを生成
if(paramCp && paramCp.match(/^\d{3}$/)){

	function _CoBrand(cp){
		var self = this;
		this.error = null;

		//他の必要なJSと同期をとるためヘッダー部で読み込む
		document.write([

		'<script src="' + this.root + 'nv/js/' + cp + '-header.js"></script>', // get_co_header
		'<script src="' + this.root + 'nv/js/' + cp + '-footer.js"></script>', // get_co_footer
		'<script src="' + this.root + 'common/js/site_header.js"></script>', // get_site_header
		'<script src="' + this.root + 'common/js/site_footer.js"></script>', // get_site_footer

		''].join(" \n"));
	}

	_CoBrand.prototype = {
		head : function(){
			if (!this.error && "function" == typeof(get_co_header)){
				document.write(get_co_header() + get_site_header());
				return true;
			}
			return false;
		},
		foot : function(){
			if (!this.error && "function" == typeof(get_co_header)){
				document.write(get_site_footer() + get_co_footer());
				return true;
			}
			return false;
		}
	}

	_CoBrand.prototype.root = "/";
	CoBrand = new _CoBrand(paramCp);

}
