/*
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 MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function rollon(a) 
{
	a.style.backgroundColor='#F0F8FF';
}	
function rolloff(a)
{
	a.style.backgroundColor='';
}

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 = this.open(url,"_blank", "toolbar=no,menubar=no,location=no,scrollbars=no,status=no,resize=no,resizable=yes,width="+width+",height="+height+",top=100,left=100'");
}

function popup_status(url,width,height) 
{
	OpenWin = this.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 tab_chart(img_name)
{
		document['hastc'].src='images/tab/hastc_off.jpg';
		document['hostc'].src='images/tab/hostc_off.jpg';
		
		document[img_name].src='images/tab/' + img_name + '_on.jpg';
	
		
}



// ajax
var http = createRequestObject();	
function createRequestObject()
{
	var connect;
    var browser = navigator.appName;
    if(browser == 'Microsoft Internet Explorer') 
    {
    	try
    	{
    		connect = new ActiveXObject("Msxml2.XMLHTTP");
    	}
    	catch(e)
    	{
    		try
    		{
    			connect = new ActiveXObject("Microsoft.XMLHTTP");
    		}
    		catch(e){}
    	}    	
    }
    else
    {
        connect = new XMLHttpRequest();
    }
    return connect;
}

function display(url, id)
{
	document.getElementById(id).style.display = "block";
	preloader(id); // preloading image waiting
	http.open("GET", url, true);
	http.onreadystatechange = function(){handleResponse(id);}
	http.send(null);
}

function handleResponse(id)
{
	if(http.readyState == 4 && http.status == 200)
	{
    	document.getElementById(id).innerHTML = http.responseText;
    }
}


function isValidEmail(str)
{
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function switch_tab(tab_name,id,page,param,location,numtab)
{
	
	var i = 0;
	var tabid = "";	
	for (i = 0; i < numtab; i ++)
	{			
		if ((i + 1) == id)
		{			
			tabid = tab_name + id;	
			document.getElementById(tabid + "_off").style.display = "none";
			document.getElementById(tabid + "_on").style.display = "block";
		}
		else
		{
			tabid = i + 1;				
			tabid = tab_name + tabid;
			document.getElementById(tabid + "_off").style.display = "block";
			document.getElementById(tabid + "_on").style.display = "none";
		}
	}
	// get source
	url = "inc/" + page + ".php?" + param;
	// display on location
	display(url,location);
	
}

function menu_jump_ajax(page,param,location)
{
	// get source
	url = "inc/" + page + ".php?" + param;
	// display on location
	display(url,location);
}

function switch_page(page,param,location)
{
	// get source
	url = "inc/" + page + ".php?" + param;
	// display on location
	display(url,location);
}

function changeclass(id, newclass)
{
	document.getElementById(id).className = newclass;
}
function preloader(el)
{
	var preloader = document.getElementById(el);
	preloader.innerHTML = "<div align=center><div style='width:100; padding:5px; background-color:#FFFFFF'><img src='images/loading.gif'><br/><font style='color:#666666'>Please wait !</font></div></div>";
	
}

function submit_login()
{
	user = document.getElementById('username');
	if(user.value.length == ""){
		alert('Please Enter Username');
		user.focus();
	}
	pass = document.getElementById('password');
	if(pass.value.length == ""){
		alert('Please Enter Pasword');
		pass.focus();
	}
	else
	{
	  document.login.submit();
	}
}
////////////////////////////////////////////////////////////////
function db_display(x)       
   {
   ajaxLoad('include/menu_2.php?cat='+x,'showmenu_r');
   }
function db_display_en(x)       
   {
   ajaxLoad('include/menu_2_en.php?cat='+x,'showmenu_r');
   }

function db_display2(x)       
   {
   ajaxLoad('include/menu_3.php?cat_2='+x,'showmenu_r2');
   }
function db_display2_en(x)       
   {
   ajaxLoad('include/menu_3_en.php?cat_2='+x,'showmenu_r2');
   }

/************************************************************************************************************
Ajax chained select
************************************************************************************************************/	
var ajax = new Array();
function getMenu1(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('cat_1').options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'include/menu_2.php?cat='+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createMenu1(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}
function getMenu1_en(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('cat_2').options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'include/menu_2_en.php?cat='+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createMenu1(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createMenu1(index)
{
	var obj = document.getElementById('cat_2');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}



function getMenu2(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('cat_3').options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'include/menu_3.php?cat_2='+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createMenu2(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}
function getMenu2_en(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('cat_3').options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'include/menu_3_en.php?cat_2='+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createMenu2(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createMenu2(index)
{
	var obj = document.getElementById('cat_3');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}



/***********************************************************************************************************/

function ShowPopup(event)

{

   mnu = document.getElementById('JSPopup');

   mnu.style.left = event.clientX+document.body.scrollLeft+'px';

   mnu.style.top = event.clientY+document.body.scrollTop+'px';

   mnu.className = 'visiblePopup';

}

function ClosePopup()

{

    document.getElementById('JSPopup').className='hiddenState';

}

function getCityList_r(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('district_r').options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'include/inc_district.php?id='+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCities_r(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}
function getCityList_r_en(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('district_r').options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'include/inc_district_en.php?id='+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCities_r(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createCities_r(index)
{
	var obj = document.getElementById('district_r');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}


function getStreets_r(sel)
{
	var category = sel.options[sel.selectedIndex].value;
	document.getElementById('street_r').options.length = 0;	// Empty city select box
	if(category.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'include/inc_street.php?id='+category;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createStreets_r(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}
function getStreets_r_en(sel)
{
	var category = sel.options[sel.selectedIndex].value;
	document.getElementById('street_r').options.length = 0;	// Empty city select box
	if(category.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'include/inc_street_en.php?id='+category;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createStreets_r(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createStreets_r(index)
{
	var obj = document.getElementById('street_r');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}


////////////////////////////////////////////////////
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////

	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, October 2005
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/	
	// You can modify these three values
	var slideshow2_noFading = false;	// Just normal show/hide without fading ?
	var slideshow2_timeBetweenSlides = 1500;	// Amount of time between each image(1000 = 1 second)
	var slideshow2_fadingSpeed = 20;	// Speed of fading
	
	
	/* Don't change any of these values */
	var slideshow2_galleryHeigh;	// Height of galery	
	var slideshow2_galleryContainer;	// Reference to the gallery div
	var slideshow2_galleryWidth;	// Width of gallery	
	var slideshow2_slideIndex = -1;	// Index of current image shown
	var slideshow2_slideIndexNext = false;	// Index of next image shown
	var slideshow2_imageDivs = new Array();	// Array of image divs(Created dynamically)
	var slideshow2_currentOpacity = 100;	// Initial opacity
	var slideshow2_imagesInGallery = false;	// Number of images in gallery
	
	function getGalleryImageSize(imageIndex)
	{
		if(imageIndex==slideshow2_imagesInGallery){			
			showGallery();
		}else{
			var imgObj = document.getElementById('galleryImage' + imageIndex);
			var imgWidth = imgObj.width;
			var imgHeight = imgObj.height;
			if(imgWidth>50){						
				var tmpDiv = document.createElement('DIV');
				tmpDiv.id = 'galleryDiv' + imageIndex;
				tmpDiv.style.visibility = 'hidden';
				tmpDiv.className='imageInGallery';
				slideshow2_galleryContainer.appendChild(tmpDiv);
				tmpDiv.appendChild(imgObj);
				imgObj.style.left = Math.round((slideshow2_galleryWidth - imgWidth)/2)  + "px";
				imgObj.style.top = Math.round((slideshow2_galleryHeight - imgHeight)/2)  + "px";
				tmpDiv.style.visibility = 'hidden';
				slideshow2_imageDivs.push(tmpDiv);
				imageIndex++;
				getGalleryImageSize(imageIndex);
			}else{
				setTimeout('getGalleryImageSize(' + imageIndex + ')',10);
			}
		}		
	}
	
	function showGallery()
	{
		if(slideshow2_slideIndex==-1)slideshow2_slideIndex=0; else slideshow2_slideIndex++;	// Index of next image to show
		if(slideshow2_slideIndex==slideshow2_imageDivs.length)slideshow2_slideIndex=0;
		slideshow2_slideIndexNext = slideshow2_slideIndex+1;	// Index of the next next image
		if(slideshow2_slideIndexNext==slideshow2_imageDivs.length)slideshow2_slideIndexNext = 0;
		
		slideshow2_currentOpacity=100;	// Reset current opacity

		// Displaying image divs
		slideshow2_imageDivs[slideshow2_slideIndex].style.visibility = 'visible';
		if(navigator.userAgent.indexOf('Opera')<0){
			slideshow2_imageDivs[slideshow2_slideIndexNext].style.visibility = 'visible';
		}
		
		
		if(document.all){	// IE rules
			slideshow2_imageDivs[slideshow2_slideIndex].style.filter = 'alpha(opacity=100)';
			slideshow2_imageDivs[slideshow2_slideIndexNext].style.filter = 'alpha(opacity=1)';
		}else{
			slideshow2_imageDivs[slideshow2_slideIndex].style.opacity = 0.99;	// Can't use 1 and 0 because of screen flickering in FF
			slideshow2_imageDivs[slideshow2_slideIndexNext].style.opacity = 0.01;
		}		
		

		setTimeout('revealImage()',slideshow2_timeBetweenSlides);		
	}
	
	function revealImage()
	{
		if(slideshow2_noFading){
			slideshow2_imageDivs[slideshow2_slideIndex].style.visibility = 'hidden';
			showGallery();
			return;
		}
		slideshow2_currentOpacity--;
		if(document.all){
			slideshow2_imageDivs[slideshow2_slideIndex].style.filter = 'alpha(opacity='+slideshow2_currentOpacity+')';
			slideshow2_imageDivs[slideshow2_slideIndexNext].style.filter = 'alpha(opacity='+(100-slideshow2_currentOpacity)+')';

		}else{
			slideshow2_imageDivs[slideshow2_slideIndex].style.opacity = Math.max(0.01,slideshow2_currentOpacity/100);	// Can't use 1 and 0 because of screen flickering in FF
			slideshow2_imageDivs[slideshow2_slideIndexNext].style.opacity = Math.min(0.99,(1 - (slideshow2_currentOpacity/100)));
		}
		if(slideshow2_currentOpacity>0){
			setTimeout('revealImage()',slideshow2_fadingSpeed);
		}else{
			slideshow2_imageDivs[slideshow2_slideIndex].style.visibility = 'hidden';			
			showGallery();
		}
	}
	
	function initImageGallery()
	{
		slideshow2_galleryContainer = document.getElementById('imageSlideshowHolder');
		slideshow2_galleryWidth = slideshow2_galleryContainer.clientWidth;
		slideshow2_galleryHeight = slideshow2_galleryContainer.clientHeight;
		galleryImgArray = slideshow2_galleryContainer.getElementsByTagName('IMG');
		for(var no=0;no<galleryImgArray.length;no++){
			galleryImgArray[no].id = 'galleryImage' + no;
		}
		slideshow2_imagesInGallery = galleryImgArray.length;
		getGalleryImageSize(0);		
		
	}
		

