/**
 * @author Dani Vainstein
 */

var isDOM=document.getElementById?1:0,
isIE=document.all?1:0,
isNS4=navigator.appName=='Netscape'&&!isDOM?1:0,
isIE4=isIE&&!isDOM?1:0,
isOp=self.opera?1:0,
isDyn=isDOM||isIE||isNS4;


function openComment( url ) {
	
	window.open( url, '', 'height=600, width=700, left=50, top=50, resizable=yes, scrollbars=yes, status=yes');
}

function openCenteredWindow(url) {
    var width = 750;
    var height = 420;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,scrollbars,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    myWindow = window.open(url, "", windowFeatures);
}

//Get Position
function findPosY(obj) {
	var posTop = 0;
	do {posTop += obj.offsetTop;} while (obj = obj.offsetParent);
	return posTop;
}
function findPosX(obj) {
	var posLeft = 0;
	do {posLeft += obj.offsetLeft;} while (obj = obj.offsetParent);
	return posLeft;
}
function inputSubmit(el, imagesPath) { //extend Buttons
	if( imagesPath == "" ) { imagesPath = "../img/"; }
	el.oldClassName = el.className;
	el.left = document.createElement('img');
	el.left.className = "NFButtonLeft";
	el.left.src = imagesPath + "0.png";
	el.right = document.createElement('img');
	el.right.src = imagesPath + "0.png";
	el.right.className = "NFButtonRight";
	el.onmouseover = function() {
		this.className = "NFButton NFh";
		this.left.className = "NFButtonLeft NFh";
		this.right.className = "NFButtonRight NFh";
	}
	el.onmouseout = function() {
		this.className = "NFButton";
		this.left.className = "NFButtonLeft";
		this.right.className = "NFButtonRight";
	}
	el.init = function() {
		this.parentNode.insertBefore(this.left, this);
		this.parentNode.insertBefore(this.right, this.nextSibling);
		this.className = "NFButton";
	}
	el.unload = function() {
		this.parentNode.removeChild(this.left);
		this.parentNode.removeChild(this.right);
		this.className = this.oldClassName;
	}
	el.init();
	el.unload = function() { el.unload }
} 


function getRef(i, p) {
 	p=!p?document:p.navigator?p.document:p;
 	return isIE ? p.all[i] :
  	isDOM ? (p.getElementById?p:p.ownerDocument).getElementById(i) :
  	isNS4 ? p.layers[i] : null;
}

function getSty(i, p) {
 	var r=getRef(i, p);
 	return r?isNS4?r:r.style:null;
};

function collapseall( times )
{
	for( var i = 0; i <= times; i ++ )
	{
	 	var sObj = document.getElementById('section' + i + '_id');
	  	var img  = document.getElementById('section' + i + '_id_img');	
	  	if (! sObj.style.display) {
	  		sObj.style.display = 'none';
      		img.src = '../img/plus.gif';
	  	}
	}
}

function expandall( times )
{
	for( var i = 0; i <= times; i ++ )
	{
	 	var sObj = document.getElementById('section' + i + '_id');
	  	var img  = document.getElementById('section' + i + '_id_img');	
		  if (sObj.style.display)
		  {
		      img.src = '../img/minus.gif';
		
		      if (b_IEPC)
		      {
		          sObj.filters[0].apply();
		          sObj.style.display = '';
		          sObj.filters[0].play();
		      }
		      else
		          sObj.style.display = '';
		  }
	}
}

function dm_expandSection(sid)
// Expands section and changes image for expand-button
{
  var sObj = document.getElementById(sid);
  var img  = document.getElementById(sid+'_img');
  if (sObj.style.display)
  {
      img.src = '../img/minus.gif';

      if (b_IEPC)
      {
          sObj.filters[0].apply();
          sObj.style.display = '';
          sObj.filters[0].play();
      }
      else
          sObj.style.display = '';
  }
  else
  {
      sObj.style.display = 'none';
      img.src = '../img/plus.gif';
  }
}


//############################################################################//
//  Detect browser
//############################################################################//
var b_IE=0, b_MAC=0, b_IEMAC=0, b_IEPC=0, b_OP=0, b_NS=0, b_SAF=0;

function dm_getBrowser()
// Detects client's browser
{
  var nv = navigator;
  var a  = nv.userAgent;
  var n  = nv.appName;
  var v  = nv.appVersion;
  b_MAC  = v.indexOf("Mac") >= 0;

  if (parseInt(nv.productSub)>=20020000 && nv.vendor.indexOf('Apple Computer') != -1 && nv.product=='Gecko')
  {
      b_NS  = 1;
      b_SAF = 1;
      return;
  }

  if (a.indexOf('Opera')>=0)
  {
      b_OP = 1;
		  return;
  }
  
  if (n.toLowerCase()=='netscape')
  {
      b_NS = 1;
      return;
  }


  if (document.all?1:0)
  {
      b_IE     = 1;
      b_VER    = parseFloat(a.substring(a.indexOf('MSIE ')+5, a.length));
      b_IEMAC  = b_MAC;
      b_IEPC   = !b_MAC;
  }
}

var months = new Array ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
var days = new Array( "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" );

dm_getBrowser();
