//java enabled
var is_je = false;
//cookie enabled
var is_ce = false;
//on line
var is_ol = false;
//opera
var is_opera = false;
//safary
var is_saf = false;
//webtv
var is_webtv = false;
//ie
var is_ie = false;
var is_ie4 = false;
var is_ie6 = false;
var is_ie7 = false;
//.net
var is_ie_NET_1_1 = false;
var is_ie_NET_2_0 = false;
//mozilla/Gecko
var is_moz = false;
//konqueror
var is_kon = false;
//netscape
var is_ns = false;
var is_nsff = false;
var is_nsie = false;
//firefox
var is_ff = false;
//mac
var is_mac = false;
setNavInfo();

function showServices()
{
  var url = 'docs/services.htm';
  var name = 'services';
  var sWidth = 800;
  var sLeft = ((screen.width - sWidth) / 2);
  var sHeight = 650; 
  var sTop = ((screen.height - sHeight) / 3);
  var sFeatures = 
  "channelmode=no," + 
  "directories=no," + 
  "height=" + sHeight + "," + 
  "left=" + sLeft + "," + 
  "location=no," + 
  "menubar=no," + 
  "resizable=yes," + 
  "scrollbars=yes," + 
  "status=no," + 
  "titlebar=no," + 
  "toolbar=no," + 
  "top=" + sTop + "," + 
  "width=" + sWidth;
  win = window.open(url, name, sFeatures);
  try {win.focus();} catch (e) {}
}

function showServices1(url)
{
  var name = 'services';
  var sWidth = 800;
  var sLeft = ((screen.width - sWidth) / 2);
  var sHeight = screen.height * 0.8;
  var sTop = screen.height * 0.05;
  var sFeatures = 
  "channelmode=no," + 
  "directories=no," + 
  "height=" + sHeight + "," + 
  "left=" + sLeft + "," + 
  "location=yes," + 
  "menubar=yes," + 
  "resizable=yes," + 
  "scrollbars=yes," + 
  "status=no," + 
  "titlebar=no," + 
  "toolbar=yes," + 
  "top=" + sTop + "," + 
  "width=" + sWidth;
  win = window.open(url, name, sFeatures);
  try {win.focus();} catch (e) {}
}

function showServices2(url)
{
  var name = 'services';
  var sWidth = 800;
  var sLeft = ((screen.width - sWidth) / 2);
  var sHeight = screen.height * 0.8;
  var sTop = screen.height * 0.05;
  var sFeatures = 
  "channelmode=no," + 
  "directories=no," + 
  "height=" + sHeight + "," + 
  "left=" + sLeft + "," + 
  "location=no," + 
  "menubar=no," + 
  "resizable=yes," + 
  "scrollbars=yes," + 
  "status=no," + 
  "titlebar=no," + 
  "toolbar=no," + 
  "top=" + sTop + "," + 
  "width=" + sWidth;
  win = window.open(url, name, sFeatures);
  try {win.focus();} catch (e) {}
}

function showServices3(url, sWidth, sHeight)
{
  var name = 'services';
  //var sWidth = 800;
  var sLeft = ((screen.width - sWidth) / 2);
  //var sHeight = screen.height * 0.8;
  //var sTop = screen.height * 0.05;
  var sTop = ((screen.height - sHeight) / 3);
  var sFeatures = 
  "channelmode=no," + 
  "directories=no," + 
  "height=" + sHeight + "," + 
  "left=" + sLeft + "," + 
  "location=no," + 
  "menubar=no," + 
  "resizable=yes," + 
  "scrollbars=yes," + 
  "status=no," + 
  "titlebar=no," + 
  "toolbar=no," + 
  "top=" + sTop + "," + 
  "width=" + sWidth;
  win = window.open(url, name, sFeatures);
  try {win.focus();} catch (e) {}
}

function setudt() {
  var dtm = window.document.getElementById('ctl00_mcph_id_dtm');
  if (dtm!=null){
    dtm.value = tzdtos(new Date());
    //dtm.value = DateTimeToString(new Date());
  }
  else {
    dtm = window.document.getElementById('id_dtm');
    if (dtm!=null) {
      dtm.value = tzdtos(new Date());
      //dtm.value = DateTimeToString(new Date());
    }
    else {
      alert('Object is not set. Plese report the error to the web master');
      return false;
    }
  }
  return true;
}
function tzdtos(dtm) {
  var s;
  s = dtm.getTimezoneOffset().toString();
  s += " ";
  s += dtm.getFullYear().toString();
  s += "/";
  s += formatNumeric((dtm.getMonth() + 1), 1, 2, "0");
  s += "/";
  s += formatNumeric(dtm.getDate(), 1, 2, "0");
  s += " ";
  s += formatNumeric(dtm.getHours(), 1, 2, "0");
  s += ":";
  s += formatNumeric(dtm.getMinutes(), 1, 2, "0");
  s += ":";
  s += formatNumeric(dtm.getSeconds(), 1, 2, "0");
  s += ".";
  s += formatNumeric(dtm.getMilliseconds(), 1, 3, "0");
  return(s);
}

function test_tzdtos() {
  var s, dtm;
  dtm = new Date();
  s = dtm.getTimezoneOffset().toString();
  s += " ";
  s += dtm.getFullYear().toString();
  s += "/";
  s += (dtm.getMonth() + 1).toString();
  s += "/";
  s += dtm.getDate().toString();
  s += " ";
  s += dtm.getHours().toString();
  s += ":";
  s += dtm.getMinutes().toString();
  s += ":";
  s += dtm.getSeconds().toString();
  s += ".";
  s += dtm.getMilliseconds().toString();
  return(s);
}

function focusFirst() {
  var form = document.forms[0];
  var i, e;
  
  for (var i = 0; i < form.elements.length; i++) {
    var element = form.elements[i];
    
    if (element != null) {
      try {
        form.elements[i].focus();
        break;
      } catch (e) {
        continue;
      }
    }
  }
}

function DateTimeToString(dtm){
	var s = formatNumeric((dtm.getMonth()+1), 1, 2, "0");
	s += "/";
	s += formatNumeric(dtm.getDate(), 1, 2, "0");
	s += "/";
	s += dtm.getFullYear().toString();
	s += " ";
	s += formatNumeric(dtm.getHours(), 1, 2, "0");
	s += ":";
	s += formatNumeric(dtm.getMinutes(), 1, 2, "0");
	s += ":";
	s += formatNumeric(dtm.getSeconds(), 1, 2, "0");
	//s += ".";
	//s += formatNumeric(dtm.getMilliseconds(), 1, 3, "0");
	return(s);
}

function ReplaceFirstText(strSource, textFind, textReplace) {
	var srcLen = strSource.length;
	var fndLen = textFind.length;
	if (srcLen>fndLen) {
		var pos = strSource.toLowerCase().indexOf(textFind.toLowerCase());
		if (pos>-1) {
			if (pos==0) 
				return textReplace+strSource.substr(pos+fndLen);
			else if ((pos+fndLen)==srcLen) 
				return strSource.substr(0, pos)+textReplace;
			else
				return strSource.substr(0, pos)+textReplace+strSource.substr(pos+fndLen);
		}
	}
	else if (srcLen==fndLen && strSource.toLowerCase()==textFind.toLowerCase())
		return textFind;
	return strSource;
}

//round with decimal precision
//d - value to be rounded
//p - precision
function roundDP(d, p) {
  if (d && p && !isNaN(parseFloat(d)) && !isNaN(parseInt(p))) {
    var m = Math.pow(10, p);
    return (Math.round(d * m) / m).toFixed(p);
  }
  else {
    return d;
  }
}

//numeric - value to be formatted
//alignment - numeric : 0(left - default), 1(right), [2(middle) - not implemented yet]; 
//length - numeric : length of result
//filler - string : default - space
function formatNumeric(numeric, alignment, length, filler){
	var _n;	//string representation of parameter 'numeric'
	var _ln = 0; //length of 'numeric'
	var _a;
	var _l;
	var _lf = 0; //length of a space to be filled
	var _f;
	//numeric
	if (typeof(numeric)=="undefined")
		return "[parameter 'numeric' is undefined]";
	else if (isNaN(numeric)) 
		return "[parameter 'numeric' is not a number]";
	else {
		_n = numeric.toString();
		_ln = _n.length;
		if (_ln==0)
			return "[string representation of parameter 'numeric' has zero length]";
	}
	//alignment
	if (typeof(alignment)=="undefined")
		_a = 0;
	else if (isNaN(alignment)) 
		_a = 0;
	else if (!(alignment==0 || alignment==1)) //left or right
		_a = 0;
	else
		_a = alignment;
	//length
	if (typeof(length)=="undefined")
		return "[expected numeric parameter 'length' is undefined]";
	else if (isNaN(length)) 
		return "[expected numeric parameter 'length' is not a number]";
	else if (length<=0)
		return "[parameter 'length' should be positive number]";
	else
		_l = length;
	_lf = _l - _ln;
	//filler
	if (typeof(filler)=="undefined")
		_f = " ";
	else if (filler==null) 
		_f = " ";
	else {
		f1 = Trim(filler);
		if (f1.length==0)
			_f = " ";
		else if (f1.length>1)
			_f = f1.substr(0, 1);
		else
			_f = f1;
	}

	if (_lf<0) {
		if (_a==0) { //left alignment==cut left _l chars of _n
			return _n.substr(0, _l);
		}
		else if (_a==1) { //right alignment==cut right _l chars of _n
			return _n.substr(_ln - _l);
		}
	}
	else if (_lf==0) {
		return _n
	}
	else {
		if (_a==0) { //left alignment==add _lf chars to the right of _n
			return _n+getFiller(_f, _lf);
		}
		else if (_a==1) { //right alignment==add _lf chars to the left of _n
			return getFiller(_f, _lf)+_n;
		}
	}
}

function getFiller(fc, fl){
	var _fc;
	var _fl;
	var _f = "";
	//filler
	if (typeof(fc)=="undefined")
		_fc = " ";
	else if (fc==null) 
		_fc = " ";
	else {
		fc1 = Trim(fc);
		if (fc1.length==0)
			_fc = " ";
		else if (fc1.length>1)
			_fc = fc1.substr(0, 1);
		else
			_fc = fc1;
	}
	//length
	if (typeof(fl)=="undefined")
		return _fc;
	else if (isNaN(fl)) 
		return _fc;
	else if (fl<=1)
		return _fc;
	else
		_fl = fl;
	for (var i = 0; i<fl; i++)
		_f = _f+_fc;
	return _f;
}

function LTrim(s){
	if (typeof(s)=="undefined")
		return "";
	else if (s==null) 
		return "";
	else if (s.length==0)
		return "";
	while (s.length>0 && s.substr(0, 1)==' ')
		s = s.substr(1);
	return(s);
}

function RTrim(s){
	if (typeof(s)=="undefined")
		return "";
	else if (s==null) 
		return "";
	else if (s.length==0)
		return "";
	while (s.length>0 && s.substr(s.length-1, 1)==' ')
		s = s.substr(0, s.length-1);
	return(s);
}

function Trim(s){
	if (typeof(s)=="undefined")
		return "";
	else if (s==null) 
		return "";
	else if (s.length==0)
		return "";
	return(RTrim(LTrim(s)));
}

function newstring(n, c){
	var s = "";
	for (var i=0; i<n; i++)
		s = s+c;
	return(s);
}

function empty(o){
  //six possible values that typeof returns: 
  //"number," "string," "boolean," 
  //"object," "function," and "undefined."
	if (typeof(o) == "undefined")
		return true;
	else if (typeof(o) == "function")
		return true;
	else if (typeof(o) == "object")
	  return o == null;
	else if (typeof(o) == "number")
	{
		return o == 0;
	}
	else if (typeof(o) == "string")
	{
		return Trim(o).length == 0;
	}
	else if (typeof(o) == "boolean")
	{
		return !o;
	}
	return true;
}

function textIsEmpty(txt)
{
  if (typeof txt!='string' || txt.length==0) return true;
  for (var i=0;i<txt.length;i++)
  {
    if (txt.charCodeAt(i)>32 && txt.charCodeAt(i)<127) return false;
  }
  return true;
}

function showextwin(link)
{
  var win;
  var sw = (screen.width * 0.70);
  var sl = (screen.width * 0.15);
  var sh = (screen.height * 0.5); 
  var st = (screen.height * 0.25);
  var sf = 
	  "channelmode=no," + 
	  "directories=no," + 
	  "height="+sh+"," + 
	  "left="+sl+"," + 
	  "location=no," + 
	  "menubar=no," + 
	  "resizable=yes," + 
	  "scrollbars=yes," + 
	  "status=no," + 
	  "titlebar=no," + 
	  "toolbar=no," + 
	  "top="+st+"," + 
	  "width="+sw;
	//if (is_ff || is_nsff)
    win = window.open(link, "ext_win", sf);
  //else { //if (is_ie || is_nsie)
  //  win = window.open("", "ext_win", sf);
  //  win.navigate(link);
  //}
  try {win.focus();} catch (e) {}
  return false;
}

function showextwinbars(link)
{
  var win;
  var sw = (screen.width * 0.80);
  var sl = (screen.width * 0.10);
  var sh = (screen.height * 0.7); 
  var st = (screen.height * 0.05);
  var sf = 
	  "channelmode=no," + 
	  "directories=no," + 
	  "height="+sh+"," + 
	  "left="+sl+"," + 
	  "location=no," + 
	  "menubar=no," + 
	  "resizable=yes," + 
	  "scrollbars=yes," + 
	  "status=yes," + 
	  "titlebar=no," + 
	  "toolbar=yes," + 
	  "top="+st+"," + 
	  "width="+sw;
  win = window.open(link, "ext_win", sf);
  try {win.focus();} catch (e) {}
  return false;
}

function showextwintd(tdtext, wtitle, wname)
{
  if (textIsEmpty(tdtext)) return false;
  if (textIsEmpty(wtitle)) wtitle = 'Contour Logistics Inc';
  if (textIsEmpty(wname)) wname = 'ContourLogisticsInc';
  var sw = (screen.width * 0.70);
  var sl = (screen.width * 0.15);
  var sh = (screen.height * 0.5); 
  var st = (screen.height * 0.25);
  var sf = 
	  "channelmode=no," + 
	  "directories=no," + 
	  "height="+sh+"," + 
	  "left="+sl+"," + 
	  "location=no," + 
	  "menubar=no," + 
	  "resizable=yes," + 
	  "scrollbars=yes," + 
	  "status=no," + 
	  "titlebar=no," + 
	  "toolbar=no," + 
	  "top="+st+"," + 
	  "width="+sw;
  var win = window.open("", wname, sf);
  win.document.writeln('<html>');
  win.document.writeln('<head>');
  win.document.writeln('<title>' + wtitle + '</title>');
  win.document.writeln('<link href=styles/main.css rel=stylesheet type=text/css />');
  win.document.writeln('</head>');
  win.document.writeln('<body>');
  win.document.writeln('<form>');
  win.document.writeln('<table style="font-family:Tahoma,Arial,Verdana;font-size:10pt;">');
  win.document.writeln('<tr>');
  win.document.writeln('<td>');
  win.document.writeln(new Date());
  win.document.writeln('<br />');
  win.document.writeln('The content of this window does not reflect data changes made in application!');
  win.document.writeln('<br /><br />');
  win.document.writeln('</td>');
  win.document.writeln('</tr>');
  win.document.writeln('<tr>');
  win.document.writeln('<td>');
  win.document.writeln(tdtext);
  win.document.writeln('</td>');
  win.document.writeln('</tr>');
  win.document.writeln('</table>');
  win.document.writeln('</form>');
  win.document.writeln('</body>');
  win.document.writeln('</html>');
  win.document.close();
  try {win.focus();} catch (e) {}
  return false;
}

function setNavInfo(){
  try {
    is_je = navigator.javaEnabled();
    is_ce = navigator.cookieEnabled;
    is_ol = navigator.onLine;
    var userAgent = navigator.userAgent.toLowerCase();
    //opera
    is_opera = (userAgent.indexOf('opera') != -1);
    //safary
    is_saf = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == 'Apple Computer, Inc.'));
    //webtv
    is_webtv = (userAgent.indexOf('webtv') != -1);
    //ie
    is_ie = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
    is_ie4 = ((is_ie) && (userAgent.indexOf('msie 4.') != -1));
    is_ie6 = ((is_ie) && (userAgent.indexOf('msie 6.') != -1));
    is_ie7 = ((is_ie) && (userAgent.indexOf('msie 7.') != -1));
    //.net
    is_ie_NET_1_1 = ((is_ie) && (userAgent.indexOf('.net clr 1.1.') != -1));
    is_ie_NET_2_0 = ((is_ie) && (userAgent.indexOf('.net clr 2.0.') != -1));
    //mozilla/Gecko
    is_moz = ((navigator.product == 'Gecko') && (!is_saf));
    //konqueror
    is_kon = (userAgent.indexOf('konqueror') != -1);
    //netscape
    is_ns = (userAgent.indexOf('netscape') != -1);
    is_nsff = ((is_ns) && (userAgent.indexOf('gecko') != -1));
    is_nsie = is_ns && is_ie;
    //firefox
    is_ff = (userAgent.indexOf('firefox') != -1);
    //mac
    is_mac = (userAgent.indexOf('mac') != -1);
  }
  catch(exc) {
    if ((exc.number & 0xFFFF)>0)
      alert('Navigator Info Error: ' + (exc.number & 0xFFFF).toString() + ". " + exc.description);
    else
      alert('Navigator Info Error: ' + exc);
  }
}

function viewportWidth() {
  var width = 0;
  if (document.documentElement && document.documentElement.clientWidth)
    width = document.documentElement.clientWidth;
  else if (document.body && document.body.clientWidth)
    width = document.body.clientWidth;
  else if (window.innerWidth)
    width = window.innerWidth - 18;
  return width;
};

function viewportHeight() {
  var height = 0;
  if (document.documentElement && document.documentElement.clientHeight)
    height = document.documentElement.clientHeight;
  else if (document.body && document.body.clientHeight)
    height = document.body.clientHeight;
  else if (window.innerHeight)
    height = window.innerHeight - 18;
  return height;
};

function viewportScrollX() {
  var scrollX = 0;
  if (document.documentElement && document.documentElement.scrollLeft)
    scrollX = document.documentElement.scrollLeft;
  else if (document.body && document.body.scrollLeft)
    scrollX = document.body.scrollLeft;
  else if (window.pageXOffset)
    scrollX = window.pageXOffset;
  else if (window.scrollX)
    scrollX = window.scrollX;
  return scrollX;
};

function viewportScrollY() {
  var scrollY = 0;
  if (document.documentElement && document.documentElement.scrollTop)
    scrollY = document.documentElement.scrollTop;
  else if (document.body && document.body.scrollTop)
    scrollY = document.body.scrollTop;
  else if (window.pageYOffset)
    scrollY = window.pageYOffset;
  else if (window.scrollY)
    scrollY = window.scrollY;
  return scrollY;
};

function disableId(disableList) {
  if (disableList && !textIsEmpty(disableList)){
    var disableArray = disableList.split(",");
    for (var di in disableArray){
      var dc = disableArray[di];
      if (dc){
        var de = document.getElementById(dc);
        if (de)
          de.disabled = true;
      }
    }
  }
}

function hideId(hideList) {
  if (hideList && !textIsEmpty(hideList)){
    var hideArray = hideList.split(",");
    for (var hi in hideArray){
      var hc = hideArray[hi];
      if (hc){
        var he = document.getElementById(hc);
        if (he)
          he.style.display = "none";
      }
    }
  }
}

var wait_width = 200;
var wait_height = 70;
var sh_right = 16;
var sh_down = 32;

function showWaitingMessage(disableList, hideList) {
  disableId(disableList);
  hideId(hideList);
  centerWaitingMessage();
  if (is_ie || is_nsie) {
    var waiting_Frm = document.getElementById("waitingframe");
    if (waiting_Frm)
      waiting_Frm.src = "docs/waiting.htm";
  }
  if (window.addEventListener)
    window.addEventListener("resize", centerWaitingMessage, false);
  else if (window.attachEvent)
    window.attachEvent("onresize", centerWaitingMessage);
  return true;
}

function centerWaitingMessage() {
  var waiting_Id = document.getElementById("waiting_Id");
  if (waiting_Id) {
    var waiting_left = (viewportWidth() - (wait_width + sh_right)) / 2 + viewportScrollX();
    if (waiting_left < 0)
      waiting_left = 0;

    var waiting_top = (viewportHeight() - (wait_height + sh_down)) / 3 + viewportScrollY();
    if (waiting_top < 0)
      waiting_top = 0;

    if (waiting_left >= 0 && waiting_top >= 0) {
      waiting_Id.style.left = waiting_left + "px";
      waiting_Id.style.top = waiting_top + "px";
    }
  }
  return true;
}
function shpLstCollExp()
{
  if (document.getElementById) // && document.getElementById("generaldata_row").style.display == ""
  {
    if (document.getElementById("shpLstStateID").value=="show")
    {
      document.getElementById("shpLstRowID").style.display = "";
      document.getElementById("shpLstImgID").src = "images/collapse_16x16.png";
      document.getElementById("shpLstImgID").alt = "Collapse Shipping list";
      document.getElementById("shpLstStateID").value = "hide";
      document.getElementById("shpLstImgTextID").innerHTML="Collapse Shipping list"
    }
    else
    {
      document.getElementById("shpLstRowID").style.display = "none";
      document.getElementById("shpLstImgID").src = "images/expand_16x16.png";
      document.getElementById("shpLstImgID").alt = "Expand Shipping list";
      document.getElementById("shpLstStateID").value = "show";
      document.getElementById("shpLstImgTextID").innerHTML="Expand Shipping list"
    }
  }
}
function shpLstCollExp2()
{
  if (document.getElementById)
  {
    if (document.getElementById("shpLstStateID2").value=="show")
    {
      document.getElementById("shpLstRowID2").style.display = "";
      document.getElementById("shpLstImgID2").src = "images/collapse_16x16.png";
      document.getElementById("shpLstImgID2").alt = "Collapse Shipping list";
      document.getElementById("shpLstStateID2").value = "hide";
      document.getElementById("shpLstImgTextID2").innerHTML="Collapse Shipping list"
    }
    else
    {
      document.getElementById("shpLstRowID2").style.display = "none";
      document.getElementById("shpLstImgID2").src = "images/expand_16x16.png";
      document.getElementById("shpLstImgID2").alt = "Expand Shipping list";
      document.getElementById("shpLstStateID2").value = "show";
      document.getElementById("shpLstImgTextID2").innerHTML="Expand Shipping list"
    }
  }
}
function isZip(zip) 
{
  if(zip && zip.length > 0)
  {
    var reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
    if (reZip.test(zip)) 
    {
      return true;
    }
  }
  return false;
}
function isEmail(email)
{
  //const string emailPattern = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
  if(email && email.length > 0)
  {
    var reEmail = new RegExp(/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/);
    if (reEmail.test(email)) 
    {
      return true;
    }
  }
  return false;
}
function maxWinHeight() {
  var client_height = 0;
  var scroll_height = 0;
  if (window.innerHeight || window.scrollMaxY) {
    if (window.innerHeight) {
      client_height = window.innerHeight;
    }
    if (window.scrollMaxY) {
      scroll_height = window.innerHeight + window.scrollMaxY;
    }
  }
  else if (document.documentElement) {
    if (document.documentElement.clientHeight) {
      client_height = document.documentElement.clientHeight;
    }
    if (document.documentElement.scrollHeight) {
      scroll_height = document.documentElement.scrollHeight;
    }
  }
  else if (document.body) {
    if (document.body.clientHeight) {
      client_height = document.body.clientHeight;
    }
    if (document.body.scrollHeight) {
      scroll_height = document.body.scrollHeight;
    }
  }
  if(client_height >= scroll_height)
    return client_height;
  return scroll_height;
};
function maxWinWidth() {
  var client_width = 0;
  var scroll_width = 0;
  if (window.innerWidth || window.scrollMaxX) {
    if (window.innerWidth) {
      client_width = window.innerWidth;
    }
    if (window.scrollMaxX) {
      scroll_width = window.innerWidth + window.scrollMaxX;
    }
  }
  else if (document.documentElement) {
    if (document.documentElement.clientWidth) {
      client_width = document.documentElement.clientWidth;
    }
    if (document.documentElement.scrollWidth) {
      scroll_width = document.documentElement.scrollWidth;
    }
  }
  else if (document.body) {
    if (document.body.clientWidth) {
      client_width = document.body.clientWidth;
    }
    if (document.body.scrollWidth) {
      scroll_width = document.body.scrollWidth;
    }
  }
  if(client_width >= scroll_width)
    return client_width;
  return scroll_width;
};

