///===================================================================================
///                                                             Fichier : cc.js
///===================================================================================
///
///  Variables et procÚdures JavaScript de l'application
///
///===================================================================================

var windowParams='width=500,height=500,'+
                 'location=no,status=no,menubar=yes,toolbar=no,scrollbars=yes,resizable';

var smallWindowParams='width=350,height=300,'+
                 'location=no,status=no,menubar=no,toolbar=no,scrollbars=no,resizable';

var formWindowParams='width=500,height=600,'+
                 'location=no,status=no,menubar=no,toolbar=no,scrollbars=yes,resizable';
//
//--------------------------------------------------------------------------------------------
//
function debugA(u,u_name) { var i; for (i in u) document.write("<br>"+u_name+"["+i+"]="+u[i]); document.writeln("<br>&nbsp;");}
function debugO(u,u_name) { var i; for (i in u) document.write("<br>"+u_name+"."+i+"="+u.i);   document.writeln("<br>&nbsp;");}
//
//--------------------------------------------------------------------------------------------

var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;


if (document.getElementById) {isID = 1; isDHTML = 1;}
else {
  if (document.all) {isAll = 1; isDHTML = 1;}
  else {
    browserVersion = parseInt(navigator.appVersion);
    if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {isLayers = 1; isDHTML = 1;}
  }
}

//--------------------------------------------------------------------------------------------
function MM_findObj(n, d) { //v4.01
//--------------------------------------------------------------------------------------------
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&& d.all) x=d.all[n]; for (i=0;!x && i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x && d.layers && i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

//--------------------------------------------------------------------------------------------
function MM_showHideLayers() { //v3.0
//--------------------------------------------------------------------------------------------
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

//--------------------------------------------------------------------------------------------
function noAccents(str) {
//--------------------------------------------------------------------------------------------
  q='';
  if (str.length!=0)
    for(i=0; i<str.length; i++) {
      switch(str[i]) {
        case 'à':
        case 'â':
          q+='a';
          break;
        case 'ç':
          q+='c';
          break;
        case 'é':
        case 'è':
        case 'ê':
          q+='e';
          break;
        case 'î':
          q+='i';
          break;
        case 'ô':
          q+='o';
          break;
        case 'ù':
        case 'û':
          q+='u';
          break;
        default:
          q+=str[i];
      }
  }
  return q;
}

//--------------------------------------------------------------------------------------------
function toUnicode(str) {
//--------------------------------------------------------------------------------------------
  q='';
  for(i=0; i<str.length; i++) {
    j=str.charCodeAt(i);
    q+=(j==38)?'&amp;':(j<128)?str.charAt(i):'&#'+j+';';
  }
  return q;
}

//--------------------------------------------------------------------------------------------
// functions utf8Encode(str) et utf8Decode(str)
//--------------------------------------------------------------------------------------------
/* UTF8 encoding/decoding functions
 * Copyright (c) 2006 by Ali Farhadi.
 * released under the terms of the Gnu Public License.
 * see the GPL for details.
 *
 * Email: ali[at]farhadi[dot]ir
 * Website: http://farhadi.ir/
 */

//an alias of String.fromCharCode
function chr(code)
{
	return String.fromCharCode(code);
}

//returns utf8 encoded charachter of a unicode value.
//code must be a number indicating the Unicode value.
//returned value is a string between 1 and 4 charachters.
function code2utf(code)
{
	if (code < 128) return chr(code);
	if (code < 2048) return chr(192+(code>>6)) + chr(128+(code&63));
	if (code < 65536) return chr(224+(code>>12)) + chr(128+((code>>6)&63)) + chr(128+(code&63));
	if (code < 2097152) return chr(240+(code>>18)) + chr(128+((code>>12)&63)) + chr(128+((code>>6)&63)) + chr(128+(code&63));
}

//it is a private function for internal use in utf8Encode function
function _utf8Encode(str)
{
	var utf8str = new Array();
	for (var i=0; i<str.length; i++) {
		utf8str[i] = code2utf(str.charCodeAt(i));
	}
	return utf8str.join('');
}

//--------------------------------------------------------------------------------------------
//Encodes a unicode string to UTF8 format.
function utf8Encode(str)
//--------------------------------------------------------------------------------------------
{
	var utf8str = new Array();
	var pos,j = 0;
	var tmpStr = '';

	while ((pos = str.search(/[^\x00-\x7F]/)) != -1) {
		tmpStr = str.match(/([^\x00-\x7F]+[\x00-\x7F]{0,10})+/)[0];
		utf8str[j++] = str.substr(0, pos);
		utf8str[j++] = _utf8Encode(tmpStr);
		str = str.substr(pos + tmpStr.length);
	}

	utf8str[j++] = str;
	return utf8str.join('');
}

//it is a private function for internal use in utf8Decode function
function _utf8Decode(utf8str)
{
	var str = new Array();
	var code,code2,code3,code4,j = 0;
	for (var i=0; i<utf8str.length; ) {
		code = utf8str.charCodeAt(i++);
		if (code > 127) code2 = utf8str.charCodeAt(i++);
		if (code > 223) code3 = utf8str.charCodeAt(i++);
		if (code > 239) code4 = utf8str.charCodeAt(i++);

		if (code < 128) str[j++]= chr(code);
		else if (code < 224) str[j++] = chr(((code-192)<<6) + (code2-128));
		else if (code < 240) str[j++] = chr(((code-224)<<12) + ((code2-128)<<6) + (code3-128));
		else str[j++] = chr(((code-240)<<18) + ((code2-128)<<12) + ((code3-128)<<6) + (code4-128));
	}
	return str.join('');
}

//--------------------------------------------------------------------------------------------
//Decodes a UTF8 formated string
function utf8Decode(utf8str)
//--------------------------------------------------------------------------------------------
{
	var str = new Array();
	var pos = 0;
	var tmpStr = '';
	var j=0;
	while ((pos = utf8str.search(/[^\x00-\x7F]/)) != -1) {
		tmpStr = utf8str.match(/([^\x00-\x7F]+[\x00-\x7F]{0,10})+/)[0];
		str[j++]= utf8str.substr(0, pos) + _utf8Decode(tmpStr);
		utf8str = utf8str.substr(pos + tmpStr.length);
	}

	str[j++] = utf8str;
	return str.join('');
}

//--------------------------------------------------------------------------------------------
function findDOM(objectID,withStyle) {
//--------------------------------------------------------------------------------------------
	if (withStyle == 1) {
		if (isID) { return (document.getElementById(objectID).style) ; }
		else {
			if (isAll) { return (document.all[objectID].style); }
		else {
			if (isLayers) { return (document.layers[objectID]); }
		};}
	}
	else {
		if (isID) { return (document.getElementById(objectID)) ; }
		else {
			if (isAll) { return (document.all[objectID]); }
		else {
			if (isLayers) { return (document.layers[objectID]); }
		};}
	}
}
//--------------------------------------------------------------------------------------------
function setClip(objectID, clipTop, clipRight, clipBottom, clipLeft) {
//--------------------------------------------------------------------------------------------
var dom = findDOM(objectID,1);
if (dom.clip.left) {
dom.clip.top = clipTop;
dom.clip.right = clipRight;
dom.clip.bottom = clipBottom;
dom.clip.left = clipLeft;}
dom.clip = 'rect(' + clipTop + ' ' + clipRight + ' ' + clipBottom + ' ' + clipLeft +')';
}

//--------------------------------------------------------------------------------------------
function findClipTop(objectID) {
//--------------------------------------------------------------------------------------------
var dom = findDOM(objectID,1);
if (dom.clip.top)
return dom.clip.top;
if (dom.clip !=null) {
var clip = findClipArray(dom.clip);
return (clip[0]) ;}
return (null);}

//--------------------------------------------------------------------------------------------
function findClipRight(objectID) {
//--------------------------------------------------------------------------------------------
var dom = findDOM(objectID,1);
if (dom.clip.right)
return dom.clip.right;
if (dom.clip !=null) {
var clip = findClipArray(dom.clip);
return (clip[1]) ;}
return (null);}

//--------------------------------------------------------------------------------------------
function findClipBottom(objectID) {
//--------------------------------------------------------------------------------------------
var dom = findDOM(objectID,1);
if (dom.clip.bottom)
return dom.clip.bottom;
if (dom.clip !=null) {
var clip = findClipArray(dom.clip);return (clip[2]) ;}
return (null);}

//--------------------------------------------------------------------------------------------
function findClipLeft(objectID) {
//--------------------------------------------------------------------------------------------
var dom = findDOM(objectID,1);
if (dom.clip.left)
  return dom.clip.left;
if (dom.clip !=null) {
  var clip = findClipArray(dom.clip);
  return (clip[3]) ;}
return (null);}

//--------------------------------------------------------------------------------------------
function findClipWidth(objectID) {
//--------------------------------------------------------------------------------------------
var dom = findDOM(objectID,1);
if (dom.clip.width)
return dom.clip.width;
if (dom.clip !=null) {
var clip = findClipArray(dom.clip);
return (clip[1] - clip[3]) ;}
return (null);}

//--------------------------------------------------------------------------------------------
function findClipHeight(objectID) {
//--------------------------------------------------------------------------------------------
var dom = findDOM(objectID,1);
if (dom.clip.height)
return dom.clip.height;
if (dom.clip !=null) {
var clip = findClipArray(dom.clip);
return (clip[2] - clip[0]) ;}
return (null);}

//--------------------------------------------------------------------------------------------
function findClipArray(clipStr) {
//--------------------------------------------------------------------------------------------
var clip = new Array();
var i;
i = clipStr.indexOf('(');
clip[0] = parseInt(clipStr.substring(i + 1, clipStr.length), 10);
i = clipStr.indexOf(' ', i + 1);
clip[1] = parseInt(clipStr.substring(i + 1, clipStr.length), 10);
i = clipStr.indexOf(' ', i + 1);
clip[2] = parseInt(clipStr.substring(i + 1 , clipStr.length), 10);
i = clipStr.indexOf(' ', i + 1);
clip[3] = parseInt(clipStr.substring(i + 1, clipStr.length), 10);
return clip;
}

//--------------------------------------------------------------------------------------------

