var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up  = (is_ie && (is_major >= 4));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);




function windowOpen(surl,width,height) {
 //alert(surl);
 if (is_ie4up) {
  var ret = window.showModalDialog(surl,'','center:yes;help:no;resizeable:no;scroll:no;status:no;dialogHeight:'+height+'px;dialogWidth:'+width+'px;');
  if (!ret) {
   ret = false;
  }
  return ret;
 }
 else {
  var tmp = window.open(surl,null,'height='+height+'px,width='+width+'px,innerwidth='+width+'px,innerheight='+height+'px,status=no,scrollbars=yes,toolbar=no,menubar=no,location=no,resizable=yes')
 }
}

function windowOpen2(surl,width,height,scroll) {
 if (!scroll) { var scroll = 'no' }
 if (is_ie4up) {
  var ret = window.showModelessDialog(surl,'','center:yes;help:no;resizeable:no;scroll:no;status:no;dialogHeight:'+height+'px;dialogWidth:'+width+'px;');
  if (ret == 1) {
   window.location.href= window.location.href;
  }
 }
 else {
  var tmp = window.open(surl,null,'height='+height+'px,width='+width+'px,innerwidth='+width+'px,innerheight='+height+'px,status=no,scrollbars='+scroll+',toolbar=no,menubar=no,location=no,resizable=yes')
 }
}

function popup(w,h,url) {
 ret = windowOpen(url,w,h);
 if (is_ie4up) {
   if (ret != false) {
     document.location.reload();
   }
 }
}

function dataBackgroundChange(cl,el) {
 el.className = cl;
}

function unix_timestamp() {
 var d = new Date();
 //    d = d.;
 return Math.round(d.getTime()/1000);
}

function httpRequest(url) {
 styleElement(document.body).cursor = 'progress';
 if (url.indexOf("?") == -1) url += '?ts=' + unix_timestamp();
 else url += '&ts=' + unix_timestamp();
 if (document.all) {
  // IE version
  var xml = new ActiveXObject("Microsoft.XMLHTTP");
  // older versions (IE4 and some IE5.0) might be using MSXML2.XMLHTTP.4.0
  xml.Open( "GET", url, false );
  xml.Send()
 } else {
  // Mozilla/Netscrap 6+ version
  var xml=new XMLHttpRequest();
  xml.open("GET",url,false);
  xml.send(null);
 }
 styleElement(document.body).cursor = 'auto';
 return xml.responseText;
}

function styleElement(el) {
 if (el.style) return el.style;
 else return el;
}
