﻿String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

  var neu = null;
  function myNewWindow(urltosite,fieldname,width,height,autoclose) {
      if (width==null) width=550;
      if (height==null) height=500;
      neu = window.open('', fieldname, 'width='+width+',height='+height+',resizable=0,scrollbars=1');
      if (neu != null) {
      if (neu.opener == null) {
          neu.opener = self;
          }
      neu.location.href = urltosite;
      if (autoclose!=null) neu.close();
      }
  }


function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}

function softpackvnexec(url,xmlHttp,placeID)
{
	if (url.length==0)
	  { 
		//
	  return;
	  }

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	  {
	  alert ("Trinh duyet cua quy vi khong duoc ho tro AJAX!\nVui long su dung Internet Explorer, Opera, Firefox, Safari...");
	  return;
	  } 
	document.getElementById(placeID).innerHTML = "<br><br><b><font class=pleasewait><img src=\'/images/wait_cam.gif\' border=0 hspace=5 align=absmiddle>Vui l&#242;ng ch&#7901; trong gi&#226;y l&#225;t...</font></b>";
	xmlHttp.onreadystatechange= function () 
	{ 
		if (xmlHttp.readyState==4)
		{ 
		document.getElementById(placeID).innerHTML=xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 


function autoresize(objname,myobject,maxwidth) {
	var obj =myobject;
	if (obj==null) document.getElementById(objname);
	if (obj!=null) {
		var currentwidth = obj.width;
		var currentheight = obj.height;
		if (currentwidth>maxwidth) {
			obj.width=maxwidth;
			obj.height=maxwidth / currentwidth * currentheight;
		}
	}
}

function chooseimage (objname) {
    var txt = document.getElementById(objname);
    myNewWindow ('filemanager.aspx',objname,600,400);
    
}
