// libのロード
if (!window['jQuery']) {
	document.write('<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>');
}
if (!window['jQuery'] || !$.ui) {
	document.write('<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>');
}

// dialog格納要素の挿入
var gaRegisterPopupuID = 'register_' + (new Date()).getTime();
//document.write('<div id="' + gaRegisterPopupuID + '" class="ga_register_popup"></div>');

$(document).ready(function() {
	var e = document.createElement('div');
	e.id = gaRegisterPopupuID;
	e.setAttribute("class","ga_register_popup");
	document.getElementById('ga_register_root').appendChild(e);
});


/**
 * ダイアログ初期化
 */
$(function() {
	$('#' + gaRegisterPopupuID).dialog({
		title: 'CosmicBreak',
		bgiframe: true,
		autoOpen: false,
		width: 760,
		height: 570,
		position: ['center', 'center'],
		modal: true,
		resizable: false,
		show: 'blind'
	});

	$('#' + gaRegisterPopupuID).bind(
		"dialogclose",
		function (event) {
			if (!$('#landing_body').length) {
				window.location.reload();
			}
		}
	);
});

/**
 * GA.com登録ダイアログを表示します。
 */
function showGARegisterPopup() {
	var d_height = 570;
	var f_height = 525;

	if ($(window).height() && $(window).height() - 85 > 0) {
		d_height = $(window).height() - 50;
		f_height = d_height - 35;
	}
	$('#' + gaRegisterPopupuID).dialog('option', 'height', d_height);

	// 空ダイアログのオープン
	$('#' + gaRegisterPopupuID).empty().dialog('open');

	// ダイアログオープンを少し待ってからiframe展開
	setTimeout(function() {
		var iframe = document.createElement('iframe');
		iframe.frameBorder = 0;
		iframe.width = 750;
		iframe.height = f_height;
		iframe.src = base_url('ssl') + 'register/n_form';
		$('#' + gaRegisterPopupuID).empty().append(iframe);
	}, 700);

	return;
}


/**
 * GA.com登録ダイアログを閉じます。
 */

function closeGARegisterPopup() {
	$('#' + gaRegisterPopupuID).dialog('close');
}


