var agent = navigator.userAgent.toLowerCase(); 
var mac = agent.indexOf('mac') != -1;
var w3c = document.getElementById ? true : false;
var iex = document.all ? true : false;
var ns4 = document.layers ? true : false;
function fixNetscape(){
	if(origWidth != window.innerWidth || origHeight != window.innerHeight){
		window.location.reload();
	}	
}
if(ns4){
	origWidth = window.innerWidth;
	origHeight = window.innerHeight;
	window.onresize = fixNetscape;
}
function getStyle(name, nest){
	nest = nest ? 'document.'+nest+'.' : '';
	return w3c ? document.getElementById(name).style : iex ? document.all[name].style : ns4 ? eval(nest+'document.'+name) : false;
}
// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
// Menu Constructor
CenterMenu = function(name,left,top){
	this.name = name;
	this.left = left;
	this.top = top;
	this.timer = null;
	this.obj = name+'Object';
	eval(this.obj+'=this');
}
CenterMenu.prototype.show = function(){
	clearTimeout(this.timer);
	var windowWidth = iex ? document.body.clientWidth : window.innerWidth;
	var offset = Math.floor((windowWidth-pageWidth)/2);
	if(offset < 0){
		offset = 0;
	}
	if(ns4 && offset > 0){ // Ugly NS4 Bug Fix
		if(mac){
			if(document.height < window.innerHeight){
				offset -= 8;
			}
		}else{
			offset -= 8;
		}
	}
	getStyle(this.name).left = offset+this.left;
	getStyle(this.name).visibility = 'visible';
	curMenu = this.name;
}
CenterMenu.prototype.hide = function(){
	this.timer = setTimeout(this.obj+'.hideIt()',1);
}
CenterMenu.prototype.hideIt = function(){
	getStyle(this.name).visibility = 'hidden';
}
CenterMenu.prototype.startMenu = function(){
	var html;
	if(ns4){
		html = '<layer name="'+this.name+'" left="'+this.left+'" top="'+this.top+'" z-index="1000" visibility="hidden" ';
	}else{
		html = '<div id="'+this.name+'" style="position:absolute; left:'+this.left+'px; top:'+this.top+'px; z-index:1000; visibility:hidden" ';
	}
	html += 'onMouseOver="Menus.'+this.name+'.show()" onMouseOut="Menus.'+this.name+'.hide()">';
	return html;
}

// Global Menu Functions
hideCur = function(){
	if(curMenu != null){
		Menus[curMenu].hideIt();
		curMenu = null;
	}
}
endMenu = function(){
	 return ns4 ? '<\/layer>' : '<\/div>';
}
createCenterMenu = function(name,left,top){
	Menus[name] = new CenterMenu(name,left,top);
}
Menus = new Object();
var curMenu = null;
var pageWidth = 858;



// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
// Build Menu Structure


var detect = navigator.userAgent.toLowerCase();
var browser;

if(navigator.appName=="Netscape" ){
	 if (checkIt('safari')){
		 
	 // Safari ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~	

	createCenterMenu('submenu1',190,267);
	createCenterMenu('submenu2',240,151);
	createCenterMenu('submenu3',465,151);
	createCenterMenu('submenu4',554,151);
	createCenterMenu('submenu5',335,151);
	createCenterMenu('submenu6',725,132);
	// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~	
	
	 }
	else if (checkIt('firefox'))
	{
	//Firefox~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~	
	createCenterMenu('submenu1',274,230);
	createCenterMenu('submenu2',231,151);
	createCenterMenu('submenu3',496,230);
	createCenterMenu('submenu4',545,151);
	createCenterMenu('submenu5',326,151);	
	createCenterMenu('submenu6',717,132);
	// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~	
	}
}
else 
{	// EI~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
	createCenterMenu('submenu1',282,230);
	createCenterMenu('submenu2',240,151);
	createCenterMenu('submenu3',503,230);
	createCenterMenu('submenu4',554,151);
	createCenterMenu('submenu5',335,151);
	createCenterMenu('submenu6',725,132);

	

	// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
}
function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~

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_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_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];}
}

// Include the appropriate style sheet for browser/OS
var agt=navigator.userAgent.toLowerCase();
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_gecko = (agt.indexOf('gecko') != -1);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_aol   = (agt.indexOf("aol") != -1);
var is_opera = (agt.indexOf("opera") != -1);
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_mac    = (agt.indexOf("mac")!=-1);
var agent = navigator.userAgent.toLowerCase(); 
var mac = agent.indexOf('mac') != -1;
var w3c = document.getElementById ? true : false;
var iex = document.all ? true : false;
var ns4 = document.layers ? true : false;
function fixNetscape(){
	if(origWidth != window.innerWidth || origHeight != window.innerHeight){
		window.location.reload();
	}	
}
if(ns4){
	origWidth = window.innerWidth;
	origHeight = window.innerHeight;
	window.onresize = fixNetscape;
}
function getStyle(name, nest){
	nest = nest ? 'document.'+nest+'.' : '';
	return w3c ? document.getElementById(name).style : iex ? document.all[name].style : ns4 ? eval(nest+'document.'+name) : false;
}
// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
// Menu Constructor
CenterMenu = function(name,left,top){
	this.name = name;
	this.left = left;
	this.top = top;
	this.timer = null;
	this.obj = name+'Object';
	eval(this.obj+'=this');
}
CenterMenu.prototype.show = function(){
	clearTimeout(this.timer);
	var windowWidth = iex ? document.body.clientWidth : window.innerWidth;
	var offset = Math.floor((windowWidth-pageWidth)/2);
	if(offset < 0){
		offset = 0;
	}
	if(ns4 && offset > 0){ // Ugly NS4 Bug Fix
		if(mac){
			if(document.height < window.innerHeight){
				offset -= 8;
			}
		}else{
			offset -= 8;
		}
	}
	getStyle(this.name).left = offset+this.left;
	getStyle(this.name).visibility = 'visible';
	curMenu = this.name;
}
CenterMenu.prototype.hide = function(){
	this.timer = setTimeout(this.obj+'.hideIt()',1);
}
CenterMenu.prototype.hideIt = function(){
	getStyle(this.name).visibility = 'hidden';
}
CenterMenu.prototype.startMenu = function(){
	var html;
	if(ns4){
		html = '<layer name="'+this.name+'" left="'+this.left+'" top="'+this.top+'" z-index="1000" visibility="hidden" ';
	}else{
		html = '<div id="'+this.name+'" style="position:absolute; left:'+this.left+'px; top:'+this.top+'px; z-index:1000; visibility:hidden" ';
	}
	html += 'onMouseOver="Menus.'+this.name+'.show()">';
	return html;
}

// Global Menu Functions
hideCur = function(){
	if(curMenu != null){
		Menus[curMenu].hideIt();
		curMenu = null;
	}
}
endMenu = function(){
	 return ns4 ? '<\/layer>' : '<\/div>';
}
createCenterMenu = function(name,left,top){
	Menus[name] = new CenterMenu(name,left,top);
}
Menus = new Object();
var curMenu = null;
var pageWidth = 858;



// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
// Build Menu Structure


var detect = navigator.userAgent.toLowerCase();
var browser;

if(navigator.appName=="Netscape" ){
	 if (checkIt('safari')){
		 
	 // Safari ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~	

	createCenterMenu('submenu1',546,264);
	createCenterMenu('submenu2',526,107);
	createCenterMenu('submenu3',320,132);
	createCenterMenu('submenu4',441,132);
	createCenterMenu('submenu5',584,132);
	createCenterMenu('submenu6',725,132);
	// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~	
	
	 }
	else if (checkIt('firefox'))
	{
	//Firefox~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~	
	createCenterMenu('submenu1',546,264);
	createCenterMenu('submenu2',606,107);
	createCenterMenu('submenu3',312,132);
	createCenterMenu('submenu4',433,132);
	createCenterMenu('submenu5',576,132);	
	createCenterMenu('submenu6',717,132);
	// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~	
	}
}
else 
{	// EI~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
	createCenterMenu('submenu1',554,264);
	createCenterMenu('submenu2',614,107);
	createCenterMenu('submenu3',320,132);
	createCenterMenu('submenu4',441,132);
	createCenterMenu('submenu5',584,132);
	createCenterMenu('submenu6',725,132);

	

	// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
}
function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~

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_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_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];}
}
// JavaScript Document 

//alert("cucucucucuc");
var brower=getbrowser();
function getObj(name) 
{   if (document.getElementById) { return document.getElementById(name); }
			else if (document.all)       { return document.all[name]; }
			else if (document.layers)    { return document.layers[name]; }
}


function offsetLeft(el)
  {
    x = el.offsetLeft
    for (e = el.offsetParent; e; e = e.offsetParent)
      x += e.offsetLeft;
    return x
  } 

 function offsetTop(el)
  {
    y = el.offsetTop
    for (e = el.offsetParent; e; e = e.offsetParent)
      y += e.offsetTop;
    return y
 } 
  
  

function getbrowser(){
	detect = navigator.userAgent.toLowerCase();
	if (checkIt('konqueror'))
	{
		browser = "Konqueror";
		OS = "Linux";
	}
	else if (checkIt('safari')) browser = "Safari"
	else if (checkIt('omniweb')) browser = "OmniWeb"
	else if (checkIt('opera')) browser = "Opera"
	else if (checkIt('webtv')) browser = "WebTV";
	else if (checkIt('icab')) browser = "iCab"
	else if (checkIt('msie')) browser = "Internet Explorer"
	else if (!checkIt('compatible'))
	{
		browser = "Netscape Navigator"
		version = detect.charAt(8);
	}
	else{
	 browser = "An unknown browser";  
	}
	return browser;
} 
	
function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


function getcombox(obj,idarray){
		removecombox(obj);
		
		switch(brower){
			case "Netscape Navigator":
				addtocombox1(obj,idarray);
				break;
			case "Internet Explorer":
				addtocombox2(obj,idarray);
				break;

		}
		
		

}

function removecombox(obj){
		n=obj.options.length
		for( i=0;i<n;i++){
//			alert(obj.options[1].text);
			obj.remove(0);

		}

}

function addtocombox1(obj,idarray){
		combox=null;
		str= 'if(typeof(combo_' + idarray +')!="undefined"){ combox=combo_' + idarray +';}';
		eval(str);
		e=document.createElement("OPTION");
		e.value="";
		e.text="-- ch?n qu?n/huy?n --";
		obj.appendChild(e);		
		if(combox!=null){
			 for ( i = 0; i < combox.length; i++ ) {
				e=document.createElement("OPTION");
				parts = combox[i].split( '|' )
				e.value=parts[0];
				e.text=parts[1];
				obj.appendChild(e);		
			 }
		 }
		 
		combox1=null;
		str1= 'if(typeof(combo1_' + idarray +')!="undefined"){ combox1=combo1_' + idarray +';}';
		eval(str1);
		e1=document.createElement("OPTION");
		e1.value="";
		e1.text="-- ch?n qu?n/huy?n --";
		obj.appendChild(e1);		
		if(combox!=null){
			 for ( i = 0; i < combox1.length; i++ ) {
				e1=document.createElement("OPTION");
				parts = combox1[i].split( '|' )
				e1.value=parts[0];
				e1.text=parts[1];
				obj.appendChild(e1);		
			 }
		 }		 
	}

function addtocombox2(obj,idarray){
		combox=null;
		str= 'if(typeof(combo_' + idarray +')!="undefined"){ combox=combo_' + idarray +';}';
		eval(str);
		e=document.createElement("OPTION");
		e.value="";
		e.text="------------------";
		obj.add(e);		
		if(combox!=null){
			 for ( i = 0; i < combox.length; i++ ) {
				e=document.createElement("OPTION");
				parts = combox[i].split( '|' )
				e.value=parts[0];
				e.text=parts[1];
				obj.add(e);		
			 }
		 }
		combox1=null;
		str1= 'if(typeof(combo1_' + idarray +')!="undefined"){ combox1=combo1_' + idarray +';}';
		eval(str1);
		e1=document.createElement("OPTION");
		e1.value="";
		e1.text="------------------";
		obj.add(e1);		
		if(combox1!=null){
			 for ( i = 0; i < combox1.length; i++ ) {
				e1=document.createElement("OPTION");
				parts = combox1[i].split( '|' )
				e1.value=parts[0];
				e1.text=parts[1];
				obj.add(e1);		
			 }
		 }		 
	}
	
var req=null;
var which=null;
function retrieveURL(url) {
	req=null;
	which=null;
	if (window.XMLHttpRequest) { // Non-IE browsers
		req = new XMLHttpRequest();
		req.onreadystatechange = processStateChange;
		try {
			req.open("GET", url, true);
		} catch (e) {
			alert(e);
		}
		req.send(null);
	} 
	else if (window.ActiveXObject) { // IE
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processStateChange;
			req.open("GET", url, true);
			req.send();
		}
	}

}

function processStateChange() {
	if (req.readyState == 4) { // Complete
		if (req.status == 200) { // OK response
			//document.getElementById("fileuploaded").innerHTML = req.responseText;
			alert(req.responseText);
		}
	 	else {
			alert("Problem: " + req.statusText);
		}
	}
}

function openMedia(url, vHeight, vWidth)
{	
	winDef = 'status=no,resizable=no,scrollbars=yes,toolbar=no,location=no,fullscreen=no,titlebar=no,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	var winmedia ;
	winmedia= window.open(url,'_blank', winDef);
	winmedia.focus();

}
function openPage(url, vHeight, vWidth)
{	
	winDef = 'status=yes,resizable=yes,scrollbars=yes,fullscreen=no,titlebar=no,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	var winmedia ;
	winmedia= window.open(url,'_blank', winDef);
	winmedia.focus();
	

}

function select_all_checkbox(tableid,checkname,checked){
		//this.checked=false; 
		//this.checked=!this.checked;
		table=getObj(tableid);
		input=table.getElementsByTagName("input");
		for(var no=0;no<input.length;no++){
			if((input[no].type=="checkbox")&&(input[no].name==checkname)){
				input[no].checked=checked;
			}
		}
}
	
function get_checked(tableid,checkname){
	//alert("vo get ne");
	array_id="";
	table=getObj(tableid);
	if(!table) return ;
	input=table.getElementsByTagName("input");
	for(var no=0;no<input.length;no++){
		if((input[no].type=="checkbox")&&(input[no].name==checkname)&&(input[no].checked==true)){
			array_id =array_id + input[no].value +"|";
		}
	}		
	n=array_id.length;
	if(n>0)	array_id=	array_id.substring(0,n-1);
	//alert(array_id);
	return array_id;
}


//Dung cho truong hop 2 ngon ngu


function getcombox2(obj,idarray,mess){
		removecombox(obj);
		
		switch(brower){
			case "Netscape Navigator":
				addtocombox1_FF(obj,idarray,mess);
				break;
			case "Internet Explorer":
				addtocombox2_IE(obj,idarray,mess);
				break;

		}
}


function addtocombox1_FF(obj,idarray,mess){
		combox=null;
		str= 'if(typeof(combo_' + idarray +')!="undefined"){ combox=combo_' + idarray +';}';
		eval(str);
		e=document.createElement("OPTION");
		e.value="";
		//alert(mess);
		e.text= mess ;
		obj.appendChild(e);		
		if(combox!=null){
			 for ( i = 0; i < combox.length; i++ ) {
				e=document.createElement("OPTION");
				parts = combox[i].split( '|' )
				e.value=parts[0];
				e.text=parts[1];
				obj.appendChild(e);		
			 }
		 }
	}
	

function addtocombox2_IE(obj,idarray,mess){
		combox=null;
		str= 'if(typeof(combo_' + idarray +')!="undefined"){ combox=combo_' + idarray +';}';
		eval(str);
		e=document.createElement("OPTION");
		e.value="";
		e.text="-- " + mess + " --";
		obj.add(e);		
		if(combox!=null){
			 for ( i = 0; i < combox.length; i++ ) {
				e=document.createElement("OPTION");
				parts = combox[i].split( '|' )
				e.value=parts[0];
				e.text=parts[1];
				obj.add(e);		
			 }
		 }
	}
		// Include the appropriate style sheet for browser/OS
var agt=navigator.userAgent.toLowerCase();
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_gecko = (agt.indexOf('gecko') != -1);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_aol   = (agt.indexOf("aol") != -1);
var is_opera = (agt.indexOf("opera") != -1);
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_mac    = (agt.indexOf("mac")!=-1);

