
var _debug=0;
var _console=null;

function myDebug(msg) {
	if (!_debug)
		return ;
  if ((_console==null) || (_console.closed)) {
    _console=window.open("","console","width=300,height=600,resizable,left=0,top=0")
	_console.document.open("text/plain")
  }
  _console.document.writeln(msg)
}

function cp(cImg,pic)
{
	myDebug("cp:"+cImg+" <- "+pic);
	document.images[cImg].src = pic;
}

function gp(cImg)
{
	return document.images[cImg].src;
}



function cburl(tag,pic)
{
	myDebug("cburl:"+tag+" <- "+pic);
	o = document.getElementById(tag);
	if (o)
		o.style.background = 'url('+pic+')';
}

function moveTo(link)
{
	window.location=link;
}

function moveToNewWindow(link)
{
	window.open(link);
}
function cb(name,color)
{
	
	theRow = document.getElementById(name);
	if (theRow)
	{
	myDebug("cb:"+name+" <- "+color);
		theRow.style.backgroundColor=color;
		}
}

function switchFrame(_style,_id)
{

	cp("ul"+_id,_style+"_ul.png");
	cp("ur"+_id,_style+"_ur.png");
	cp("ll"+_id,_style+"_ll.png");
	cp("lr"+_id,_style+"_lr.png");
	cburl("top"+_id,_style+"_top.png");
	cburl("left"+_id,_style+"_left.png");
	cburl("right"+_id,_style+"_right.png");
	cburl("bottom"+_id,_style+"_bottom.png");
}


function getPicState(_id)
{
	pic = gp(_id);
	i = pic.lastIndexOf("_")+1;
	j = pic.lastIndexOf(".");
	state = pic.substring(i,j); 
	return state;
}

function switchPic(_type,_id)
{
	pic = gp(_id);
	i = pic.lastIndexOf("_")+1;
	path = pic.substring(0,i);
	path += _type;
	path +=".png";
	cp(_id,path);
}


function  mouseEvent(_type,_group,_id,_link,_target)
{
	myDebug("mouseEvent:"+_type+"|"+_group+"|"+_id);
	if (_type=="down")
	{
		if (getPicState(_group+_id)!="active")
		{
			eval("t=typeof(g_"+_group+");");
			if (t!="undefined")
			{
				switchPic("active",_group+_id);
				eval("cur=g_"+_group);
				switchPic("out",cur);	
				eval("g_"+_group+"='"+_group+_id+"';");
			}
			else
			{
//				t="toto";
			}
		}
		
		if (_link)
		{
			if (_link.substr(0,11)=="javascript:")
			{
				cmd = _link.substring(11,_link.length);
			}
			else
			{
				if (_target)
					cmd = "window."+_target+".location='"+_link+"';";
				else
					cmd = "window.location='"+_link+"';";
			}
			eval (cmd);
			return 0;
		}	
		
	}
	else
	{
		if (getPicState(_group+_id)!="active")
		{
			switchPic(_type,_group+_id);
		}
	}		
	
	
}

function mailto(user,domain)
{
 email=user+"@"+domain;
 window.location="mailto:"+email;
 }
 
 function cmd(_id,_cmd)
 {
 	obj = document.getElementById(_id);
 	if (obj)
 		eval ("obj."+_cmd+";");
 }
 
function myOpen(url,name,height,width) 
{
	attributes="width="+width+",height="+height;
    windowHandle = window.open(url,name,attributes);
}


function SetCookie ( name, value, expires, path, domain, secure) {
	 domain="www.freetoolsassociation.com";
         szCookie = name + "=" + escape (value) +
                  ((expires) ? "; expires=" + expires.toGMTString() :                   "") +
                  ((path) ? "; path=" + path : "") +
                  ((domain) ? "; domain=" + domain : "") +
                  ((secure) ? "; secure" : "");
                  document.cookie = szCookie;
}

function GetCookie (name) {
         if ( document.cookie) { // Le cookie est-il valide ?
                  index = document.cookie.indexOf( name);
                  if ( index != -1) {
                           nDeb = (document.cookie.indexOf( "=", index) + 1);
                           nFin = document.cookie.indexOf( ";", index);
                           if (nFin == -1) {nFin = document.cookie.length;}
                           return unescape(document.cookie.substring(nDeb, nFin));
                  } 
         }
         return null;
}

