// クエリ取得
var query = location.search.substring(1);
var params = query.split('&');
var query_parameter = new Array();

for(var i=0;i<params.length;i++){
	var entry = params[i].split("=", 2);
	var key = entry[0];
	var val = entry[1];
	query_parameter[key] = val;
}

function init(){
	var src = "POPUP/detail_" + getParamater("id") + ".html";
	document.getElementById("popup_iframe").src = src;

	// ムービーサイズ
	if(getParamater("size") == "MEGA"){
		document.getElementById("popup_detail").style.display = "none";
		document.getElementById("popup_movie").style.paddingLeft = 138 + "px";
		document.getElementById("popup_movie").style.width = 524 + "px";
		document.getElementById("popup_external").style.width = 524 + "px";
	}else{
		document.getElementById("popup_external").style.width = 320 + "px";
		document.getElementById("popup_movie").style.width = 320 + "px";
		document.getElementById("popup_movie").style.paddingLeft = 40 + "px";
		document.getElementById("popup_detail").style.display = "block";
	}
}

// パラメータ取得
function getParamater(key){
	return query_parameter[key];
}

function swapimage(nm,img) {
	document.images[nm].src = img;
}

function closeWindow() {
	if(window.opener){
		if(window.opener.name == "NISSAN_CM_GALLERY_TOP"){
			window.opener.location.href = "close.html";
		}else{
			window.opener.top.location.href = "close.html";
		}
		window.self.close();
	}else{
		window.self.location.href = "close.html";
	}
}

if (window.addEventListener) {
	window.addEventListener("load",init,false);
}
else if (window.attachEvent && document.getElementById) {
	window.attachEvent("onload",init);
}
