//Created by garry, 06/26/2004.
var ie4=document.all;
var ns6=document.getElementById&&!document.all;
var ns4=document.layers;
var DHTML = (document.getElementById || document.all || document.layers);


function getObj(name) {
  if (document.getElementById)
  {
	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
	this.obj = document.layers[name];
	this.style = document.layers[name];
  }
}


//---------------------------------------------------------------------------------------
//position functions
function xDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

function xParent(e,bNode){
  var p=null;
  if (!bNode && xDef(e.offsetParent)) p=e.offsetParent;
  else if (xDef(e.parentNode)) p=e.parentNode;
  else if (xDef(e.parentElement)) p=e.parentElement;
  else if (xDef(e.parentLayer)){if (e.parentLayer!=window) p=e.parentLayer;}
  return p;
}

function xPageY(e) {
  if (xDef(e.pageY)) return e.pageY;
  var y = 0;
  while (e) {
    if (xDef(e.offsetTop)) y += e.offsetTop;
    e = xParent(e);
  }
  return y;
}

function xPageX(e) {
  if (xDef(e.pageX)) return e.pageX;
  var x = 0;
  while (e) {
    if (xDef(e.offsetLeft)) x += e.offsetLeft;
   // e = xDef(e.offsetParent) ? e.offsetParent : null;
   e=xParent(e);
  }
  return x;
}
//----------------------------------------------------------------------------------------


function getRounded(val, factor)
{
	var factor;
	var i;
  var places = 1;

	// round to a certain precision
	// factor = 1;
	for (i=0; i<places; i++)
	{	factor *= 10; }
	val *= factor;
	val = Math.round(val);
	val /= factor;

	return (val);
}

function formatPrice(amount)
{
  var num = amount;
  num = num.toString().replace(/\$|\,/g,'');
  CurrencySymbol = "$";

  if(isNaN(num))
  num = "0";
  sign = (num == (num = Math.abs(num)));
  num = Math.floor(num*100+0.50000000001);
  cents = num%100;
  num = Math.floor(num/100).toString();
  if(cents<10)
  cents = "0" + cents;
  for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
  num = num.substring(0,num.length-(4*i+3))+','+
  num.substring(num.length-(4*i+3));

  return (((sign)?'':'-') + CurrencySymbol + num + '.' + cents);
}

function formatDeltaPrice(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
  if(i >= 0) { minus = '+'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }

	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + "$" + s;

	return s;
}

function changeSpanText(spanID,text){
	text=text.replace(/\n/g,"<BR>");
	text=text.replace(/\'/g,"\\\'");

	//document.all[spanID ].innerHTML='a'+text;
	var s;
	if(document.all){
		s="document.all['" + spanID + "'].innerHTML='" +text + "';";
		//alert(s)
	}else if(document.getElementById){
		s="document.getElementById('" + spanID +"').innerHTML='" + text +"';";
	}

	try{
		eval(s);
	}catch(e){}
}

function showLayer(layerID,bVisible){
	var s;
	var visible=(bVisible)?"":"none";

	if(ie4){
		s=layerID+".style.display='" + visible +"';";
	}else{
		s="document.getElementById('"+layerID+"').style.display='" + visible +"';";
	}

	try{
		eval(s);
	}catch(e){}
}


//*******************************************************************
//open window functions
//*******************************************************************
function openWindow(url,width,height){
	var windowprops = "location=no,scrollbars=no,menubar=no,toolbar=no,resizable=no" +
		",left=100,top=50,width="+width+",height="+height;
	var popup = window.open(url,"MenuPopup",windowprops);
}
function openWindow2(url,width,height){
	var windowprops = "location=yes,scrollbars=yes,menubar=no,toolbar=no,resizable=no" +
		",left=100,top=50,width="+width+",height="+height;
	var popup = window.open(url,"MenuPopup",windowprops);
}
function openWindowR(url,width,height){
	var windowprops = "location=no,scrollbars=yes,menubar=no,toolbar=no,resizable=yes" +
		",left=100,top=50,width="+width+",height="+height;
	var popup = window.open(url,"MenuPopup",windowprops);
}

function openWindowS(url){
	var windowprops = "location=no,scrollbars=no,menubar=no,toolbar=no,resizable=no" +
		",left=100,top=50,width=400,height=350";
	var popup = window.open(url,"MenuPopup",windowprops);
}
function openWindowS2(url){
	var windowprops = "location=yes,scrollbars=yes,menubar=no,toolbar=no,resizable=yes" +
		",left=100,top=50,width=400,height=350";
	var popup = window.open(url,"MenuPopup",windowprops);
}

function openWindowM(url){
	var windowprops = "location=no,scrollbars=no,menubar=no,toolbar=no,resizable=no" +
		",left=100,top=50,width=600,height=500";
	var popup = window.open(url,"MenuPopup",windowprops);
}
function openWindowM2(url){
	var windowprops = "location=no,scrollbars=yes,menubar=no,toolbar=no,resizable=yes" +
		",left=100,top=50,width=620,height=500";
	var popup = window.open(url,"MenuPopup",windowprops);
}

function openWindowL(url){
	var windowprops = "location=no,scrollbars=yes,menubar=no,toolbar=no,resizable=yes" +
		",left=100,top=50,width=800,height=700";
	var popup = window.open(url,"MenuPopup",windowprops);
}
function openWindowL2(url){
	var windowprops = "location=no,scrollbars=yes,menubar=no,toolbar=no,resizable=yes" +
		",left=100,top=50,width=820,height=700";
	var popup = window.open(url,"MenuPopup",windowprops);
}
