
  var isIE, isNS, isNS6, isDOM, lR, sR, 
      vis, invis, myTimeOut, goName, layerTimer;
  var middle_obj_width  = 777;
  var middle_obj_height = 0;
  var beforelast   = 1; 
  // chanage layers number
  var total_layers = 1; 
  var startleft    = 0;
  var starttop     = 0;

   // Internet Explorer  
  if (document.all) {
    isIE  = true;
    lR    = "document.all.";
    sR    = ".style"; 
    vis   = "visible";
    invis = "hidden";
    pixelsleft = ".pixelLeft";
    addmoretop  = 220;
    addmoreleft = 0;
  }

  // Netscape 4
  if (document.layers) {
    isNS       = true;
    lR         = "document.layers.";
    sR         = ""; 
    vis        = "show"; 
    invis      = "hide";
    pixelsleft = ".left";
    addmoretop  = 220;
    addmoreleft = 150;
  }
   
  // DOM browser
  if (document.getElementById && !isIE) {
    isDOM = true;
    lR    = "document.getElementById('";
    sR    = "').style";
    vis   = "visible";
    invis = "hidden";
    pixelsleft = ".left";
    addmoretop  = 220;
    addmoreleft = 170;
  }
 
  // Netscape 6/7
  if (isDOM == true && navigator.appName =="Netscape") {
    isNS6 = true;
    addmoretop  = 220;
    addmoreleft = 170;
  }

   // Hide menu
  function hidemenu() {
    for (i = 1; i <= total_layers; i++) {
      hidelayer = eval(lR + "l" + i + sR);
      hidelayer.visibility = invis;
    }

    //Always adjust layers
    moveLayers();
  }

  function layOver(str1, str2, str3) {
    //Always adjust layers
    moveLayers();

    // Stop all shown layers
    stopAll(beforelast);
    showlayer = eval(lR + "l" + str1 + sR);
    addmove (str1, str2, str3);
    showlayer.visibility = vis;
    beforelast  = str1;
  }

  function stopOver() {
    layerTimer = setTimeout("stopAll(" + beforelast + ")", 100)
  }

  function stopAll(str) {
    stoplayer = eval(lR + "l" + str + sR);
    stoplayer.visibility = invis;
    clearTimeout(layerTimer);
  }

  function startOver() {
    clearTimeout(layerTimer);
  }

  function moveLayers() {

   // Internet Explorer
    if (isIE) { 
      height = document.body.clientHeight;
      width  = document.body.clientWidth;
    }

    // Netscape
    if (isNS || isNS6) {
      height = window.innerHeight;
      width  = window.innerWidth;
    }

    // Find Left pixel start border 
    if (width > middle_obj_width) {
	   startleft = parseInt((width - middle_obj_width) / 2) + 1;
    } else {
	   startleft = 1;
    }

    starttop  = 0;

    for (num = 1; num <= total_layers; num++) {
	   newlpos  = eval(lR + "l" + num + sR);
      if (isIE) {
        newlpos.pixelLeft = startleft;
        newlpos.pixelTop  = starttop;
      }
      else {
        newlpos.left = startleft;
        newlpos.top  = starttop;
      }
    }
  }

  // Pass: layer number, 
  //       pixels left from current position
  //       pixels top from current position
  function addmove (str1, str2, str3) {
    newlpos  = eval(lR + "l" + str1 + sR);

    if (isIE) {
      newlpos.pixelLeft = startleft + str2 + addmoreleft;
      newlpos.pixelTop  = starttop + str3 + addmoretop;
    }
    else {
      newlpos.left = startleft + str2 + addmoreleft;
      newlpos.top  = starttop + str3 + addmoretop;
    }
    return;
  }
function atOnMouseOverLight(o) {
	o.style.backgroundColor = '';
	o.style.cursor = 'hand';
}

function atOnMouseOutLight(o) {
	o.style.backgroundColor = '';
}

function Mover(o) {
	o.style.backgroundColor='';
	o.style.cursor='hand';
}

function Mout(o) {
	o.style.backgroundColor='';
}

//-------------------------------------------

function GoUrl(s)
{
	if (s == "no")
	{
		return 0 ;
	}


	var d = s.options[s.selectedIndex].value
	window.top.location.href = d
	s.selectedIndex=0
}

function goto_web(sel, targetstr)
{
  var index = sel.selectedIndex;
  if (sel.options[index].value != '') {
     if (targetstr == 'blank') {
       window.open(sel.options[index].value, 'win1');
     } else {
       var frameobj;
       if (targetstr == '') targetstr = 'self';
       if ((frameobj = eval(targetstr)) != null)
         frameobj.location = sel.options[index].value;
     }
  }
}

function CheckForm(){
if(document.chkform.pTopic.value.length==0){
		alert('กรุณาใส่หัวข้อเรื่องที่ต้องการร้องเรียน ...')
	   	document.chkform.pTopic.focus();
	   	return false;	}
else if (document.chkform.pNote.value.length < 120){
	alert('ข้อความร้องเรียนอย่างน้อย 120 ตัวอักษรขึ้นไป')
	document.chkform.pNote.focus();
	return false;	}
	}
	
function DescriptionCharCount() {
	document.chkform.countcharacters.value = document.chkform.pNote.value.length;	}
