﻿
function SetAm(id)
{
	var selHour = document.getElementById(id);
	ClearOptions(selHour);
	AppendOptionLast(selHour, '', '시간 선택');
	AppendOptionLast(selHour, 'AM5', '5~6시');
	AppendOptionLast(selHour, 'AM6', '6~7시');
	AppendOptionLast(selHour, 'AM7', '7~8시');
	AppendOptionLast(selHour, 'AM8', '8~9시');
	AppendOptionLast(selHour, 'AM9', '9~10시');
	AppendOptionLast(selHour, 'AM10', '10~11시');
	AppendOptionLast(selHour, 'AM11', '11~12시');
}
function SetPm(id)
{
	var selHour = document.getElementById(id);
	ClearOptions(selHour);
	AppendOptionLast(selHour, '', '시간 선택');
	AppendOptionLast(selHour, 'PM12', '12~1시');
	AppendOptionLast(selHour, 'PM1', '1~2시');
	AppendOptionLast(selHour, 'PM2', '2~3시');
	AppendOptionLast(selHour, 'PM3', '3~4시');
	AppendOptionLast(selHour, 'PM4', '4~5시');
	AppendOptionLast(selHour, 'PM5', '5~6시');
	AppendOptionLast(selHour, 'PM6', '6~7시');
	AppendOptionLast(selHour, 'PM7', '7~8시');
	AppendOptionLast(selHour, 'PM8', '8~9시');
	AppendOptionLast(selHour, 'PM9', '9~10시');
}
function AppendOptionLast(sel, value, text)
{
  var opt = document.createElement('option');
  opt.text = text;
  opt.value = value;

  try {
    sel.add(opt, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    sel.add(opt); // IE only
  }
}
function ClearOptions(sel)
{
	while(sel.length > 0)
  {
    sel.remove(sel.length - 1);
  }
}

function WriteBuyForm()
{
	document.write('<form id="frmToBuy" name="frmToBuy" method="post">');
	document.write('<input id="ext_sel2" name="ext_sel2" type="hidden" />');
	document.write('<input id="ordernum" name="ordernum" type="hidden" />');
	document.write('<input id="saleinfo_id" name="saleinfo_id" type="hidden" />');
	document.write('<input id="cat_id" name="cat_id" type="hidden" />');
	document.write('</form>');
}
function FillBuyForm(id, cat, ext)
{
	var _id  = window.document.getElementById('saleinfo_id');
	var _num = window.document.getElementById('ordernum');
	var _ext = window.document.getElementById('ext_sel2');
	var _cat = window.document.getElementById('cat_id');
	_num.name = 'ordernum_'+id;
	_ext.name = 'ext_sel2_'+id;
	
	_id.value = id;
	_num.value = 1;
	_ext.value = ext;
	_cat.value = cat;
}
function SubmitToBuyProduct(id, cat, ext)
{
	FillBuyForm(id, cat, ext);
	window.document.frmToBuy.action = '/Tss/Pay/buyproduct.aspx';
	window.document.frmToBuy.submit();
}
var param = '';
function getParam()
{
	return param;
}
function setParam(id, cat, ext)
{
	param =	'&saleinfo_id='+id+'&ordernum_'+id+'=1&ext_sel2_'+id+'='+ext+'&cat_id='+cat;
}
function chkSelect()
{ }
function OnSmsBuySuccess(msg)
{
	alert(msg);
	window.opener.document.location.href = 'http://ts.studymania.com/Tss/Mymania/English/SmsMain.aspx?tab=1';
	self.close();
}