prototypeAvail = !(Prototype=='undefined');
scriptaculousAvail = !(Scriptaculous=='undefined');
var agt=navigator.userAgent.toLowerCase();
var agt_major = parseInt(navigator.appVersion);
var is_moz = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_webkit = (agt.indexOf('webkit') != -1);
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)) && (document.all);
var is_op = ((agt.indexOf("msie") == -1) && (document.all) && (agt.indexOf("opera") != -1)) && !is_ie;
var is_safari = (agt.indexOf("safari") != -1);
var is_legacy = (is_ie && (agt_major < 8 || (agt.indexOf("msie 6.")!=-1) || (agt.indexOf("msie 7.")!=-1))) ||
				(is_op && agt_major < 10) ||
				(is_safari && agt_major < 4) ||
				(is_webkit && agt_major < 3) ||
				(is_moz && agt_major < 3);
function str_replace(what,to,into,maxreplaces) {
	var antiloop = 0;
	if (!maxreplaces) maxreplaces = 100;
	while (into.indexOf(what)!=-1 && antiloop++<=maxreplaces) {
		into = into.substring(0,into.indexOf(what)) + to + into.substring(into.indexOf(what) + what.length);
	}
	return into;
}
function ereg(text,mask) {
	MyRegExp = new RegExp(mask);
	return MyRegExp.test(text);
}
function getAnchor() {
	regexp = new RegExp('([^#]*)#((.*))');
	r = regexp.exec(window.location.href);
	if (r==null) return "";
	else return r[2];
}
function querySt(ji) {
	hu = window.location.search.substring(1);
	gy = hu.split("&");
	for (i=0;i<gy.length;i++) {
		ft = gy[i].split("=");
		if (ft[0] == ji) {
			return ft[1];
		}
	}
}
function parseajax(ajaxobj,receiverDiv) { // use as callback on ajax to get scripts
  try {
	  if (ajaxobj.responseText)
	  	  var dados=ajaxobj.responseText;
	  else
		  dados=ajaxobj;
	  dados = " " + dados; // <-- to diferentiate indexOf 0 
	  posa = dados.indexOf("<script type=\"text/javascript\">");
	  posb = dados.indexOf("</script>");
	  if (posa>0 && posb>0) {
		js = dados.substring(posa+31,posb);
    	if (js != "") {
    		dados = dados.substring(1,posa) + "" + dados.substring(posb+9,dados.length);
    		if (receiverDiv) receiverDiv.innerHTML = dados;
	    	eval(js);
	    	return dados;
		}
	  }
	  dados = dados.substring(1,dados.length);
	  if (receiverDiv) receiverDiv.innerHTML = dados;
	  return dados;
  } catch (ee) {
    alert("AFF/AJAX error: " + ee);
    return ajaxobj;
  }
}
function str_count(what,where) {
	var temp = where;
	found = 0;
	while (temp.indexOf(what) != -1 && found++<100) { // 100 replaces sounds like loop, abort
		temp = temp.substring(temp.indexOf(what) + what.length);
	}
	return found;
}
function findPosX(obj) { // get the X (left) position of an element. Note these elements (and parents) should be positioned relative
   	var curleft = 0;
   	if(obj.offsetParent) {
       	while(obj.nodeType < 6) {
       		curleft += obj.offsetLeft;
     		if(!obj.offsetParent)
       	   		break;
   			obj = obj.offsetParent;
       	}
   	} else if(obj.offsetLeft)
       	curleft += obj.offsetLeft;
   	return curleft;
}
function findPosY (obj) { // get the Y (top) position of an element. Note these elements (and parents) should be positioned relative
   	var curtop = 0;
   	if(obj.offsetParent) {
       	while(obj.nodeType < 6) {
       		curtop += obj.offsetTop;
       		if(!obj.offsetParent)
   	       		break;
       		obj = obj.offsetParent;     		
      	}
   	} else if(obj.offsetTop)
       	curtop += obj.offsetTop;
   	return curtop;
}
function explode(separator,items) {
	var output = new Array();
	var size = items.length;
	var outputpos = 0;
	var buffer = '';
	for (var c=0;c<size;c++) {
		if (items.charAt(c) == separator) {
			output[outputpos] = buffer;
			outputpos++;
			buffer = '';
		} else
			buffer += items.charAt(c);
	}
	if (buffer != '') {
		output[outputpos] = buffer;
	}
	return output;
}

