
function setOpacity(styleEl, valueOpacity)
{	
  // IE/Win
  styleEl.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity = " + valueOpacity + ")";
  
  valueOpacity = (valueOpacity - 0.01)/100;
  
  // Safari<1.2, Konqueror
  styleEl.KHTMLOpacity = valueOpacity;  
  
  // Older Mozilla and Firefox
  styleEl.MozOpacity = valueOpacity;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  styleEl.opacity = valueOpacity;
  
 // opera ...
 // opera doesn't support css3...

}

function setScale(El, valuescale)
{	
  El.width = El.width * valuescale;
  El.height = El.height * valuescale;
}

// Add an eventListener to browsers that can do it somehow.
// Originally by the amazing Scott Andrew.
function addEvent(obj, evType, fn)
{
  if (obj.addEventListener)
  {
    obj.addEventListener(evType, fn, true);
    return true;
  } else if (obj.attachEvent)
  {
	var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else 
  {
	return false;
  }
}

function AttachOnLoadFunction(funcName)
{
	if (window.addEventListener)
		window.addEventListener("load", funcName, false);
	else if (window.attachEvent)
		window.attachEvent("onload", funcName);
	else
		window.onload=funcName;
}

function AttachOnResizeFunction(funcName)
{
	if (window.addEventListener)
		window.addEventListener("resize", funcName, false);
	else if (window.attachEvent)
		window.attachEvent("onresize", funcName);
	else
		window.onresize=funcName;
}

function refreshcall()
{
	window.location.href = unescape(window.location.pathname);
}

var g_receivedData;


function SendDataToParent()
{
	if (typeof(parent.ReceiveDataFromChild) != 'undefined') // Any scope)
	{
		var elToSend = document.getElementById('data');
		parent.ReceiveDataFromChild (elToSend );
	}
	
}

function loadData(datasource)
{
	if (window.frames['dataframe'])
		window.frames['dataframe'].window.location.replace(datasource);
}

function GetTime()
{
	 var d = new Date();
	   jour = d.getDate();
	   mois = d.getMonth();
	   annee = d.getFullYear();
	   heure = d.getHours();
	   minute = d.getMinutes();
	   sec = d.getSeconds();
	   sec0="" ; min0="" ;
	   heure0="" ; mois0="" ;
	   jour0="" ; annee0="";
	   if(sec<10)
			sec0="0";
	   if (minute<10)
			min0="0";
	   if (heure<10)
			heure0="0";
	   if (mois<10)
			mois0="0";
	   if (jour<10)
			jour0="0";
	   sec0+=sec;
	   min0+=minute;
	   heure0+=heure;
	   mois0+=mois;
	   jour0+=jour;
	   return jour0+'/'+mois0+'/'+annee+' ' + heure0+':'+min0+':'+sec0;
}


function getCookieVal (offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0)
			break;
	}
	return null;
}
function SetCookie (name, value)
{
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires, path, domain, secure;
	if (argc == 2)
	{
		var expDays = 1;
		var expDate = new Date();
		expDate.setTime(expDate.getTime() + (expDays*24*60*60*1000));
		//expDate.setTime(expDate.getTime() + 1000);
		//expires = expDate.toGMTString();
		expires = expDate.toUTCString();
	}
	else
	{
		expires = argv[2];
		path = (argc > 3) ? argv[3] : null;
		domain = (argc > 4) ? argv[4] : null;
		secure = (argc > 5) ? argv[5] : false;
	}

	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires)) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}
function DeleteCookie (name)
{
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function fadeIn(objId, opacity) 
{
  if (document.getElementById) 
  {
    var obj = document.getElementById(objId);
    if (opacity <= 100) 
	{
      setOpacity(obj.style, opacity);
      opacity += 5;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 50);
    }
  }
  return true;
}

function fadeOut(objId, opacity) 
{
  if (document.getElementById) 
  {
    var obj = document.getElementById(objId);
    if (opacity >= 0) {
      setOpacity(obj.style, opacity);
      opacity -= 5;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 50);
    }
	else{
		obj.style.visibility = "hidden";
	}
  }
  return true;
}

function zoomingIn(objId, w, h) 
{
	if (document.getElementById)
	{
		var obj = document.getElementById(objId);
		if (obj.alreadyzoomingOut != 1 && 
			obj.width < w && obj.height < h) 
		{
			obj.alreadyzoomingIn = 1;
			
			obj.width = obj.width + 4;
			obj.height = obj.height + 4;
			
			window.setTimeout("zoomingIn('"+objId+"',"+w+","+h+")", 40);
		}
		else
		{
			obj.alreadyzoomingIn = 0;
		}
	} 
}

function zoomIn(objId, w, h) 
{
	if (document.getElementById)
	{
		var obj = document.getElementById(objId);
		if (obj.alreadyzoomingIn != 1)
		{		
			obj.alreadyzoomingIn = 1;
			obj.alreadyzoomingOut = 0;
			window.setTimeout("zoomingIn('"+objId+"',"+w+","+h+")", 5);		
		}
	}
  return true;
}

function zoomingOut(objId, w, h) 
{
	if (document.getElementById)
	{
		var obj = document.getElementById(objId);
		if (obj.width > w && obj.height > h) 
		{
			obj.alreadyzoomingOut = 1;	
			
			obj.width = obj.width - 4;
			obj.height = obj.height - 4;
			
			window.setTimeout("zoomingOut('"+objId+"',"+w+","+h+")", 40);	  
		}
		else
		{
			obj.alreadyzoomingOut = 0;
		}
	}
}	


function zoomOut(objId, w, h) 
{	
	if (document.getElementById)
	{
		var obj = document.getElementById(objId);
		if (obj.alreadyzoomingOut != 1)
		{		
			obj.alreadyzoomingOut = 1;	
			obj.alreadyzoomingIn = 0;
			window.setTimeout("zoomingOut('"+objId+"',"+w+","+h+")", 5);		
		}
	}
	return true;
}	

function getMousePosition(event) 
{
  if (browser.isIE) 
  {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) 
  {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }
  return [x,y];
}

// Determine browser and version.

function Browser() 
{
// blah, browser detect, but mouse-position stuff doesn't work any other way
  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) 
  {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) 
  {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) 
  {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}
function make_hex(r,g,b) 
{
	r = r.toString(16); 
	if (r.length == 1) 
		r = '0' + r;
	g = g.toString(16); 
	if (g.length == 1) 
		g = '0' + g;
	b = b.toString(16); 
	if (b.length == 1) 
		b = '0' + b;
	return "#" + r + g + b;
}
function make_rgb(hex) 
{	
	this.hex = hex;
	if (hex.idexOf('#') != -1)
		this.hex = hex.substring(1);
	
	this.r = parseInt(to.substr(0,2), 16);
	this.g = parseInt(to.substr(2,2), 16);
	this.b = parseInt(to.substr(4,2), 16);
}
function Color(hex)
{
	this.rgb2hex =make_hex;
	this.hex2rgb = make_rgb;
	
	this.rgb2hex(hex);
}

function getParent(el, pTagName) 
{
	if (el == null) return null;
	else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())	// Gecko bug, supposed to be uppercase
		return el;
	else
		return getParent(el.parentNode, pTagName);
}

