 var theoldcell = ""
function showhide(thecell)
{ 
if(theoldcell == thecell){
eval('document.all.'+thecell).style.display = 'none'
eval('document.all.'+theoldcell).style.display = 'none'
theoldcell = ""
}else{
if(theoldcell != thecell){
if(theoldcell != "")
eval('document.all.'+theoldcell).style.display = 'none'
eval('document.all.'+thecell).style.display = ''
theoldcell = thecell
}
}
}
function openReview(id) {
document.getElementById('rev' + id + '_overview').style.display = 'none';
document.getElementById('rev' + id).style.display = '';
}
function closeReview(id) {
document.getElementById('rev' + id + '_overview').style.display = '';
document.getElementById('rev' + id).style.display = 'none';
}

/*
function hidestatus(){
window.status='Welcome to Da Nang Securites Company [www.dnsc.com.vn]'
return true
}

if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)

document.onmouseover=hidestatus
document.onmouseout=hidestatus



document.oncontextmenu=function()
{
	return false
}

if(document.layers)
{
	window.captureEvents(Event.MOUSEDOWN);
	window.onmousedown=function(e)
	{
		if(e.target==document)return false;
	}
}
else
{
	document.onmousedown=function()
	{
		return false
	}
}
*/
function rollon(a) 
{
	a.style.backgroundColor='#F0F8FF';
}	
function rolloff(a)
{
	a.style.backgroundColor='';
}

function tab_2chart(div_open, div_close)
{
	/* button */
	document.getElementById('tab_off_' + div_open).style.display = "none";
	document.getElementById('tab_on_' + div_open).style.display = "inline";
	document.getElementById('tab_off_' + div_close).style.display = "inline";
	document.getElementById('tab_on_' + div_close).style.display = "none";
	
	/* chart */
	
	document.getElementById(div_open).style.display = "inline";
	document.getElementById(div_close).style.display = "none";
}

function tab_3chart(div_open, div_close1, div_close2)
{
	/* button */
	document.getElementById('tab_off_' + div_open).style.display = "none";
	document.getElementById('tab_on_' + div_open).style.display = "inline";
	document.getElementById('tab_off_' + div_close1).style.display = "inline";
	document.getElementById('tab_on_' + div_close1).style.display = "none";
	document.getElementById('tab_off_' + div_close2).style.display = "inline";
	document.getElementById('tab_on_' + div_close2).style.display = "none";
	
	/* chart */
	document.getElementById(div_open).style.display = "inline";
	document.getElementById(div_close1).style.display = "none";
	document.getElementById(div_close2).style.display = "none";
}

function exp_res(div_id)
{
	if(div_id.style.display == "inline")
	{ 	
		div_id.style.display = "none"; 
	}
	else
	{ 
		div_id.style.display = "inline";
	}
}

function exp_res_img(div_id,img_name)
{
	
	var btn_max = new Image();
	btn_max.src = "images/folder_off.jpg";
	var btn_min = new Image();
	btn_min.src = "images/folder_on.jpg";
	
	if(div_id.style.display == "inline")
	{ 	
		div_id.style.display = "none"; 
		if(img_name.src == btn_min.src) img_name.src = btn_max.src;
		else img_name.src = btn_min.src;
	}
	else
	{ 
		div_id.style.display = "inline";
		if(img_name.src== btn_min.src) img_name.src = btn_max.src;
		else img_name.src = btn_min.src;
	};
}

function menu_jump(url)
{
	if (url != "")
	{
		window.location=url;
	}
	else return false;
}
function menu_gourl(url)
{
	if (url != "")
	{
		window.location=url;
	}
	else return false;
}
function menu_submit(data,form)
{
	if (data != "")
	{ 
		form.action=document.URL;
		form.submit();
	}
	else return false;
}
function ask(url,msg)
{
	if (!confirm(msg))
	{ //do nothing
		return false;
	}
	else 
	{window.location = url}
}

function popup(url,width,height) 
{
	OpenWin = window.open(url,"_blank", "toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=no,width="+width+",height="+height+",top=240,left=115");
} 
function win_alert(string)
{
	window.alert(string);
}
function popup_status(url,width,height) 
{
	OpenWin = window.open(url,"_blank", "toolbar=no,menubar=no,location=no,scrollbars=no,status=yes,resize=no,resizable=yes,width="+width+",height="+height+",top=100,left=100");
}

function changeclass(id, newclass)
{
	document.getElementById(id).className = newclass;
}

function PrintSubject()
{	
	w=open(location.href.concat('?q=1'), '_blank', '');
	return false;	
}

function makePopup(url, width, height, overflow)
{
if (width > 640) { width = 640; }
if (height > 480) { height = 480; }
if (overflow == '' || !/^(scroll|resize|both)$/.test(overflow))
{
overflow = 'both';
}
var win = window.open(url, '',
'width=' + width + ',height=' + height
+ ',scrollbars=' + (/^(scroll|both)$/.test(overflow) ?
'yes' : 'no')
+ ',resizable=' + (/^(resize|both)$/.test(overflow) ?
'yes' : 'no')
+ ',status=yes,toolbar=no,menubar=no,location=no'
);
return win;
}
///////////////////////////////////////
/////////////////////Load ajax///////////////////////
function sack(file) {
	this.xmlhttp = null;

	this.resetData = function() {
		this.method = "POST";
  		this.queryStringSeparator = "?";
		this.argumentSeparator = "&";
		this.URLString = "";
		this.encodeURIString = true;
  		this.execute = false;
  		this.element = null;
		this.elementObj = null;
		this.requestFile = file;
		this.vars = new Object();
		this.responseStatus = new Array(2);
  	};

	this.resetFunctions = function() {
  		this.onLoading = function() { };
  		this.onLoaded = function() { };
  		this.onInteractive = function() { };
  		this.onCompletion = function() { };
  		this.onError = function() { };
		this.onFail = function() { };
	};

	this.reset = function() {
		this.resetFunctions();
		this.resetData();
	};

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				this.xmlhttp = null;
			}
		}

		if (! this.xmlhttp) {
			if (typeof XMLHttpRequest != "undefined") {
				this.xmlhttp = new XMLHttpRequest();
			} else {
				this.failed = true;
			}
		}
	};

	this.setVar = function(name, value){
		this.vars[name] = Array(value, false);
	};

	this.encVar = function(name, value, returnvars) {
		if (true == returnvars) {
			return Array(encodeURIComponent(name), encodeURIComponent(value));
		} else {
			this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
		}
	}

	this.processURLString = function(string, encode) {
		encoded = encodeURIComponent(this.argumentSeparator);
		regexp = new RegExp(this.argumentSeparator + "|" + encoded);
		varArray = string.split(regexp);
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split("=");
			if (true == encode){
				this.encVar(urlVars[0], urlVars[1]);
			} else {
				this.setVar(urlVars[0], urlVars[1]);
			}
		}
	}

	this.createURLString = function(urlstring) {
		if (this.encodeURIString && this.URLString.length) {
			this.processURLString(this.URLString, true);
		}

		if (urlstring) {
			if (this.URLString.length) {
				this.URLString += this.argumentSeparator + urlstring;
			} else {
				this.URLString = urlstring;
			}
		}

		// prevents caching of URLString
		this.setVar("rndval", new Date().getTime());

		urlstringtemp = new Array();
		for (key in this.vars) {
			if (false == this.vars[key][1] && true == this.encodeURIString) {
				encoded = this.encVar(key, this.vars[key][0], true);
				delete this.vars[key];
				this.vars[encoded[0]] = Array(encoded[1], true);
				key = encoded[0];
			}

			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
		}
		if (urlstring){
			this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
		} else {
			this.URLString += urlstringtemp.join(this.argumentSeparator);
		}
	}

	this.runResponse = function() {
		eval(this.response);
	}

	this.runAJAX = function(urlstring) {
		if (this.failed) {
			this.onFail();
		} else {
			this.createURLString(urlstring);
			if (this.element) {
				this.elementObj = document.getElementById(this.element);
			}
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
					try {
						this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
					} catch (e) { }
				}

				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState) {
						case 1:
							self.onLoading();
							break;
						case 2:
							self.onLoaded();
							break;

						case 3:
							self.onInteractive();
							break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;

							if (self.execute) {
								self.runResponse();
							}

							if (self.elementObj) {
								elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input"
								|| elemNodeName == "select"
								|| elemNodeName == "option"
								|| elemNodeName == "textarea") {
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							if (self.responseStatus[0] == "200") {
								self.onCompletion();
							} else {
								self.onError();
							}

							self.URLString = "";
							break;
					}
				};

				this.xmlhttp.send(this.URLString);
			}
		}
	};

	this.reset();
	this.createAJAX();
}
/////////////////////////////////////////////////////////
var ajax = new Array();

function getcar1(sel)
{
	var cid = sel.options[sel.selectedIndex].value;
	document.getElementById('district').options.length = 0;	// Empty city select box
	if(cid.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'include/city.inc.php?cid='+cid;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createcar1(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createcar1(index)
{
	var obj = document.getElementById('district');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}
/////////////////////////////////
function getCityList(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('district').options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'include/city.inc.php?cid='+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCities(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}
function createCities(index)
{
	var obj = document.getElementById('district');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

// Copyright (C) 2005-2008 Ilya S. Lyubinskiy. All rights reserved.
// Technical support: http://www.php-development.ru/
//
// YOU MAY NOT
// (1) Remove or modify this copyright notice.
// (2) Re-distribute this code or any part of it.
//     Instead, you may link to the homepage of this code:
//     http://www.php-development.ru/javascripts/dropdown.php
//
// YOU MAY
// (1) Use this code on your website.
// (2) Use this code as part of another product.
//
// NO WARRANTY
// This code is provided "as is" without warranty of any kind.
// You expressly acknowledge and agree that use of this code is at your own risk.


// ***** Popup Control *********************************************************

// ***** at_show_aux *****

function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ***** at_show *****

function at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

// ***** at_hide *****

function at_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 0);
}

// ***** at_click *****

function at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

// ***** at_attach *****

// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name

function at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  c.style.position   = "absolute";
  c.style.visibility = "hidden";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
  }
}

/***********************************************
* Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var delayb4scroll=5000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=0 //Pause marquee onMousever (0=no. 1=yes)?

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=marqueespeed
var pausespeed=0
var actualheight=''

function scrollmarquee(){
if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8)){
cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
}
else{
cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
}
}
function scrollmarquee2(){
if (parseInt(cross_marquee2.style.top)>(actualheight*(-1)+8)){
cross_marquee2.style.top=parseInt(cross_marquee2.style.top)-copyspeed+"px"
}
else{
cross_marquee2.style.top=parseInt(marqueeheight2)+138+"px"
}
}


function initializemarquee(){
cross_marquee=document.getElementById("vmarquee")
cross_marquee.style.top=0

cross_marquee2=document.getElementById("vmarquee2")
cross_marquee2.style.top=0

marqueeheight=document.getElementById("marqueecontainer").offsetHeight
actualheight=cross_marquee.offsetHeight

marqueeheight2=document.getElementById("marqueecontainer2").offsetHeight
actualheight2=cross_marquee2.offsetHeight

if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
cross_marquee.style.height=marqueeheight+"px"
cross_marquee.style.overflow="scroll"

cross_marquee2.style.height=marqueeheight2+"px"
cross_marquee2.style.overflow="scroll"
return
}
setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll)
setTimeout('lefttime=setInterval("scrollmarquee2()",30)', delayb4scroll)
}

if (window.addEventListener)
window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarquee)
else if (document.getElementById)
window.onload=initializemarquee
///////////////// FORM CHECK ////////////////////
<!--

/***********************************************
* Required field(s) validation v1.10- By NavSurf
* Visit Nav Surf at http://navsurf.com
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function formCheck(formobj){
	// Enter name of mandatory fields
	var fieldRequired = Array("name", "email", "subject", "message", "contact_code");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Họ & tên", "email", "Tiêu đề", "Nội dung", "Mã an toàn");
	// dialog message
	var alertMsg = "Vui lòng hoàn thành các ô bắt buộc:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}
// -->

