// Start XmlHttp Object ทดสอบ

function uzXmlHttp()
{
			var xmlhttp = false;
			try
			{
						xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e)
			{
						try
						{
								xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
						}
						catch(e)
						{
								xmlhttp = false;
						}
			}
		 
			if(!xmlhttp && document.createElement)
			{
					xmlhttp = new XMLHttpRequest();
			}
		
			return xmlhttp;
}
// End XmlHttp Object

function form_session_clear()
{
	var url = 'clear_session.php';
	
	xmlhttp = uzXmlHttp();
	xmlhttp.open("POST", url, false);
	xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
	xmlhttp.send();
}

function calendar_next(factor)
{
	var url = 'block-ThaiCal.php';
	
	xmlhttp = uzXmlHttp();
	xmlhttp.open("POST", url, false);
	xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
	xmlhttp.send("factor=" + factor + "&action=next");

	//alert(xmlhttp.responseText);
	document.getElementById('calendar_pwn').innerHTML = xmlhttp.responseText;
}

function calendar_prev(factor)
{
	var url = 'block-ThaiCal.php';
	
	xmlhttp = uzXmlHttp();
	xmlhttp.open("POST", url, false);
	xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
	xmlhttp.send("factor=" + factor + "&action=prev");

	//alert(xmlhttp.responseText);
	document.getElementById('calendar_pwn').innerHTML = xmlhttp.responseText;
}

function dousoukai_form()
{ // custname_fm custname_l title custname_n email_pre email_sub tel ooo gradof_rad gradof_rad1 gradof_rad2 ooo ungrad_sch gradyear_b grad_sch gradyear_mp ooo attp_rad attp_rad1 attp_rad2 ooo noap
//alert('in'); // gradof_rad1 gradof_rad2 nondegree_program gradyear_ndp
	var custname_fm = document.getElementById('custname_fm').value;
	var custname_l 	= document.getElementById('custname_l').value;
	var title 		= document.getElementById('title').value;
	var custname_n 	= document.getElementById('custname_n').value;
	var email_pre	= document.getElementById('email_pre').value;
	var email_sub	= document.getElementById('email_sub').value;
	
	var email		= email_pre + '@' + email_sub;
	
	var tel 		= document.getElementById('tel').value;
	var ungrad_sch 	= document.getElementById('ungrad_sch').value;
	var gradyear_b 	= document.getElementById('gradyear_b').value;
	var grad_sch 	= document.getElementById('grad_sch').value;
	var gradyear_mp = document.getElementById('gradyear_mp').value;
	var nondegree_program 	= document.getElementById('nondegree_program').value;
	var gradyear_ndp 		= document.getElementById('gradyear_ndp').value;
	var noap		= document.getElementById('noap').value;

// ########### ccc ########### //
	var sec_1_array_var	  = new Array('gradof_rad1','gradof_rad2');
	var sec_1_array_value = new Array('','');
	var sec_1_parm		  = "";
	var sec_1_check		  = 0;
	
	for (var i=0;i<=1;i++)
	{
		if (document.getElementById(sec_1_array_var[i]))
		{
			var choiceCheck		= document.getElementById(sec_1_array_var[i]).checked;
			if (choiceCheck)
			{
				sec_1_array_value[i]	= document.getElementById(sec_1_array_var[i]).value;
				sec_1_check			= 1;
			}
			else
			{
				sec_1_array_value[i]	= "";
			}
		}
		else
		{
			sec_1_array_value[i]		= "";
		}

		sec_1_parm += '&' + sec_1_array_var[i] + '=' + sec_1_array_value[i];
	}
// ########### ccc ########### //

	//var gradof_rad 		= document.app_form.gradof_rad;
	var attp_rad 		= document.app_form.attp_rad;

	/*
	var gradof_radBuffer	= "";
	for(var i=0;gradof_radCounter=gradof_rad[i];i++) 
	{
		gradof_radBuffer = (gradof_radCounter.checked) ? (gradof_radCounter.value) : (gradof_radBuffer);
	}
	gradof_rad = gradof_radBuffer;
	*/
	
	var attp_radBuffer	= "";
	for(var i=0;attp_radCounter=attp_rad[i];i++) 
	{
		attp_radBuffer = (attp_radCounter.checked) ? (attp_radCounter.value) : (attp_radBuffer);
	}
	attp_rad = attp_radBuffer;

	var url = 'dousoukai_form_submit.php';
	
	// custname_fm custname_l title custname_n email_pre email_sub tel ooo gradof_rad gradof_rad1 gradof_rad2 ooo ungrad_sch gradyear_b grad_sch gradyear_mp ooo attp_rad attp_rad1 attp_rad2 ooo noap
	
	xmlhttp = uzXmlHttp();
	xmlhttp.open("POST", url, false);
	xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
	xmlhttp.send("custname_fm=" + custname_fm + "&custname_l=" + custname_l + "&title=" + title + "&custname_n=" + custname_n + "&email_pre=" + email_pre + "&email_sub=" + email_sub + "&email=" + email + "&tel=" + tel + "&ungrad_sch=" + ungrad_sch + "&gradyear_b=" + gradyear_b + "&grad_sch=" + grad_sch + "&gradyear_mp=" + gradyear_mp + "&attp_rad=" + attp_rad + "&noap=" + noap + "&nondegree_program=" + nondegree_program + "&gradyear_ndp=" + gradyear_ndp + sec_1_parm);

	//alert(xmlhttp.responseText);
	eval(xmlhttp.responseText);
}
