//...............................................................................................................
function changeRate(divObject,postName,rate)
{
  var content = "";
  for (i=0; i<=9; i++) {
		if (i<=rate) 
		  content += '<img src="img/rateOn.png" border="0" onClick="javascript:changeRate(\''+divObject+'\',\''+postName+'\','+i+')" style="cursor:pointer">';
		else
		  content += '<img src="img/rateOff.png" border="0" onClick="javascript:changeRate(\''+divObject+'\',\''+postName+'\','+i+')" style="cursor:pointer">';
		content += '</a>';
	}
	content += '<input type="hidden" name="'+postName+'" value="'+rate+'">';
	content += ' ('+(rate+1)+'/10)';
	document.getElementById(divObject).innerHTML = content;
	return;
}
//...............................................................................................................
function checkPDF(_balise)
{
		var _data = document.getElementById(_balise);
		var _dot = _data.value.lastIndexOf("."); 
		var _ext = _data.value.substr(_dot + 1,_data.value.length); 
		if (_ext.toLowerCase() != "pdf")
		{
			alert("Please ensure you're importing a pdf file !");
			_data.value = "";
			return false;
		}
}
//...............................................................................................................
function changeCheckStyle(idCheckBox,idTD,content)
{
  var cb = idCheckBox;
	var td = document.getElementById(idTD);
	if (cb.checked) td.innerHTML='<font color="#FF0000"><strong>'+content+'</strong></font>';
	           else td.innerHTML=content;
	return;
}
//...............................................................................................................
function updateLoginFrom(idLoginBox,idTextFrom)
{
	 var login = document.getElementById(idLoginBox).value;
	 var text  = document.getElementById(idTextFrom).value;
	 var temp  = "";
	 text = text.toLowerCase();
	 if (login.length>0) return;
	 for (i=0; i<text.length; i++) if ((text.substr(i,1)>='a') && (text.substr(i,1)<='z')) temp = temp+text.substr(i,1);
	 document.getElementById(idLoginBox).value = temp;
	 return;
}
//..............................................................................................................................
//:: used to clear a text field. needed params are the fields itself and the normal text inside it ::
function clearBox(field,originalText)
{
  var zoneText = field; // document.getElementById(field);
  if (zoneText.value==originalText) { zoneText.value=""; }
}
//..............................................................................................................................
//:: this will return the keycode of the keypressed on IE AND Firefox ::

function myKeyCode(myEvent)
{
  for (prop in myEvent)
    { if (prop == 'which') return(myEvent.which); }  // netscape/firefox
  return(myEvent.keyCode);                           // internet explorer
}
//...............................................................................................................
//:: this will accept only A-Z a-z & 0-9 ::
function charsNumbersOnly(myEvent)
{
        var validChars = /\w/;
        var specialChars = /[\x00\x08\x0D]/;
        var decimal  = myKeyCode(myEvent);
        var car = String.fromCharCode(decimal);
        var authorized = validChars.test(car) || specialChars.test(car);
        return authorized;
}
//...............................................................................................................
// used to determine the left/top position of an object

function findPos(obj) {
  var curLeft = curTop = 0;
  if (obj.offsetParent) {
    curLeft = obj.offsetLeft;
    curTop = obj.offsetTop;
    while (obj = obj.offsetParent) {
      curLeft += obj.offsetLeft;
      curTop += obj.offsetTop;
    }
  }
  return [curLeft,curTop];
}

//................................................................................................................................

function print_r(x, max, sep, l) {
	l = l || 0;
	max = max || 10;
	sep = sep || ' ';
	if (l > max) {
		return "[WARNING: Too much recursion]\n";
	}
	var
		i,
		r = '',
		t = typeof x,
		tab = '';

	if (x === null) {
		r += "(null)\n";
	} else if (t == 'object') {

		l++;

		for (i = 0; i < l; i++) {
			tab += sep;
		}

		if (x && x.length) {
			t = 'array';
		}

		r += '(' + t + ") :\n";

		for (i in x) {
			try {
				r += tab + '[' + i + '] : ' + print_r(x[i], max, sep, (l + 1));
			} catch(e) {
				return "[ERROR: " + e + "]\n";
			}
		}

	} else {

		if (t == 'string') {
			if (x == '') {
				x = '(empty)';
			}
		}

		r += '(' + t + ') ' + x + "\n";

	}

	return r;

};
var_dump = print_r;
