      var preview_window = 0;
      function SaveQ()
      {
        document.iForm.target="_top"
        document.iForm.action="./act/postQ.php"
        document.iForm.submit()
      }

      function SaveA()
      {
        document.iForm.target="_top"
        document.iForm.action="../act/postA.php"
        document.iForm.submit()
      }

function Save() 

	{

	if (document.Form1.idgroup.value == ""){
		alert("โปรดเลือกกลุ่ม");
		return false;
	}else{

  	Form1.ishtml.value = idContent.document.body.innerHTML;
  	/*Form1.action="./act/postQ.php";*/
  	Form1.submit();
	}

	}

var displayMode = "RICH"
function setDisplayMode() 
	{
	if(displayMode=='RICH')
		{
		idContent.document.body.clearAttributes;
		idContent.document.body.style.fontFamily = 'Tahoma, Ms Sans Serif, sans-serif, Thonburi, Helvetica';
		idContent.document.body.style.fontSize = '11px';
		idContent.document.body.innerText = idContent.document.body.innerHTML;
		idContent.document.body.innerHTML = "" + idContent.document.body.innerHTML + ""
		displayMode = 'HTML';
		idToolbar.style.display = "none"
		} 
	else 
		{
		idContent.document.body.clearAttributes;
		idContent.document.body.style.fontFamily = '';
		idContent.document.body.style.fontSize = '';
		idContent.document.body.innerHTML = idContent.document.body.innerText;
		displayMode = 'RICH';
		idToolbar.style.display = "block"
		}
	}
function GetElement(oElement,sMatchTag) 
	{
	while (oElement!=null && oElement.tagName!=sMatchTag) 
		{
		if(oElement.id=="idContent") return null;
		oElement = oElement.parentElement
		}
	return oElement
	}


function FormatText(command, option){
	
  	frames.idContent.document.execCommand(command, true, option);
  	frames.idContent.focus();
}

function AddImage(){	
	imagePath = prompt('Enter the web address of the image', 'http://');				
	
	if ((imagePath != null) && (imagePath != "")){					
		frames.idContent.document.execCommand('InsertImage', false, imagePath);
  		frames.idContent.focus();
	}
	frames.idContent.focus();			
}

function AddSmileyIcon(imagePath){	
									
	frames.idContent.document.execCommand('InsertImage', false, imagePath);
  	frames.idContent.focus();			
}


function mygrade() {
	if (document.cgrade.login.value == ""){
		alert("โปรดกรอก รหัสนักศึกษา");
		document.cgrade.login.focus();
		return false;
	}
	
	if (document.cgrade.password1.value == ""){
		alert("โปรดกรอก ปีเดือนวัน");
		document.cgrade.password.focus();
		return false;
	}	
	
	
	return true
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function checkSearch()
{
      var v1 = document.SearchForm.q.value;
        if ( v1.length==0)
           {
           alert("กรุณาป้อนคำที่ต้องการค้นหา");
           document.SearchForm.q.focus();
           return false;
           }
		 else
           return true;
}

