function testalert() {var value_temp=document.getElementById('clickback').value;if(value_temp) {clicktab(6);document.getElementById('clickback').value="";}}

function display(sID) {

	oObj = document.getElementById(sID);
	if (oObj) {
		oObj.style.display='inline';
	}
}

function hide(sID) {
	oObj = document.getElementById(sID);
	if (oObj) {
		oObj.style.display='none';
	}
}

function gettab(id){
	for (i=1;i<=10;i++)
	{
		if (id == i)
		{
			display("box_content"+i);
      		document.getElementById("li"+i).className ='font18';
		}else{
			hide("box_content"+i);
      		document.getElementById("li"+i).className ='font12';
		}
	}

}

function clicktab(id){
	if(id==7)
		document.getElementById("sponsor").style.display="none";
	else
		document.getElementById("sponsor").style.display="";

	for (i=1;i<=10;i++)
	{
		if (id == i)
		{
			display("box_content"+i);
      		document.getElementById("li"+i).className ='font18';
		}else{
			hide("box_content"+i);
      		document.getElementById("li"+i).className ='font12';
		}
	}
}

function stoper() {
	clearTimeout(timer);
}

function rotate(id,settime){
	if (id >10){id=1;}
		gettab(id);
		id++;
		timer = setTimeout("rotate("+id+","+settime+")", settime);
}

function listshow(eleID,courseID) {
	elemID=eleID.style.display;
	if(elemID) {
		workC=document.getElementById('work'+courseID);
		if(workC.innerHTML=="")
		{
			var url="listshowdate.php";
			url=url+"?courseID="+courseID;
			url=url+"&sid="+Math.random();
			xmlhttp=GetXmlHttpObject()
			xmlhttp.open("GET", url, false);
			xmlhttp.send(null);
			document.getElementById('work'+courseID).innerHTML=xmlhttp.responseText;
		}
		eleID.style.display='';
	}
	else
	{
		eleID.style.display='none';
	}
}

function send_temp(va1,va2,va3)
{
	if(va3=="room")
	{
		//document.getElementById('unchecked').style.display='';
		checkroom1=document.getElementById('cdicradio1').checked;
		checkroom2=document.getElementById('cdicradio2').checked;
		if(checkroom1)
		{
			var url="send_temp_room.php";
			url=url+"?courseID="+va2;
			url=url+"&session="+va1;
			url=url+"&sid="+Math.random();
		}
		else if(checkroom2)
		{
			var url="send_temp_room.php";
			url=url+"?courseID="+va2;
			url=url+"&session="+va1;
			url=url+"&sid="+Math.random();
		}
	}
	else
	{
		elid=document.getElementById(va2).checked;
		var url="send_temp.php";
		url=url+"?courseID="+va2;
		url=url+"&session="+va1;
		if(elid==true)
		{
			url=url+"&sta=Insert";
			url=url+"&sid="+Math.random();
		}
		else
		{
			url=url+"&sta=Del";
			url=url+"&sid="+Math.random();
		}
	}

	xmlhttp=GetXmlHttpObject()
	xmlhttp.open("GET", url, false);
	xmlhttp.send(null);
}

function GetXmlHttpObject() {
	var objXMLHttp=null;
	if (window.XMLHttpRequest) {
		objXMLHttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}

function ClickNext(va)
{
	if(va==1)
	{
		var xmlhttpResponse;
		var url="send_view.php";
		url=url+"?sid="+Math.random();
		xmlhttp=GetXmlHttpObject()
		xmlhttp.open("GET", url, false);
		xmlhttp.send(null);
		xmlhttpResponse=xmlhttp.responseText;
		if(xmlhttpResponse==1)
		{
			window.location.replace('./company_f.php');
			//window.location.replace('./view_course.php');
		}
		else if(xmlhttpResponse==2)
		{
			window.location.replace('http://localhost/www.acisonline.net/regis');
		}
		else
		{
			alert('You must checked to the date before continuing.');
		}
	}
	else if(va==2)
	{
		var com_field=document.getElementById('company_field').value;
		var bill_name=document.getElementById('bill_name').value;
		var bill_add=document.getElementById('bill_add').value;
		if(com_field==0)
		{
			alert("ลักษณะหน่วยงาน /ประเภทของหน่วยงาน");
			document.getElementById('company_field').focus();
		}
		else if(com_field>0)
		{
			var url="session_regis.php";
			url=url+"?sid="+Math.random();
			url=url+"&com_field="+com_field;
			url=url+"&bill_name="+bill_name;
			url=url+"&bill_add="+bill_add;
			xmlhttp=GetXmlHttpObject()
			xmlhttp.open("GET", url, false);
			xmlhttp.send(null);
			window.location.replace('./view_course.php');
		}
	}
	else if(va==3)
	{
		window.location.replace('http://www.acisonline.net/regis');
	}
	else if(va=='night')
	{
		var hackatnight=document.getElementById('hackatnight').checked;
		var url="session_regis.php";
		url=url+"?sid="+Math.random();
		if(hackatnight==true){va='night';}else{va='';}
		url=url+"&night="+va;
		xmlhttp=GetXmlHttpObject()
		xmlhttp.open("GET", url, false);
		xmlhttp.send(null);
	}
}

function ClickBack(va)
{
	if(va==1)
	{
		window.location.replace('.././cdic2008?clickback=true');
	}
	else if(va==2)
	{
		window.location.replace('./company_f.php');
	}
}

function setCookiename(val){
	var cookies;
    var c = document.cookie + ";";
    var re = /\s?(.*?)=(.*?);/g;
    var matches;
    while((matches = re.exec(c)) != null){
		var name = matches[1];
        var value = matches[2];
        if(name== val){
			cookies=value;
        }
	}
    return cookies;
}

function unchecked(va1)
{
	document.getElementById('cdicradio1').checked=false;
	document.getElementById('cdicradio2').checked=false;
	document.getElementById('cdicradio3').checked=true;
	document.getElementById('unchecked').style.display="none";
	var url="send_temp_room.php";
	url=url+"?&del3=Del";
	url=url+"&sid="+Math.random();
	xmlhttp=GetXmlHttpObject()
	xmlhttp.open("GET", url, false);
	xmlhttp.send(null);
}

function onchange_company(com_field)
{
	var url="session_regis.php";
	url=url+"?sid="+Math.random();
	url=url+"&com_field="+com_field;
	url=url+"&get_com_field="+1;
	xmlhttp=GetXmlHttpObject()
	xmlhttp.open("GET", url, false);
	xmlhttp.send(null);
}