
//return a formatted price
function formatCurrency(price, currencyFormat, currencySign, currencyBlank)
{
	//if you modified this function, don't forget to modify the PHP function displayPrice (in the Tools.php class)

	blank = '';
	if (currencyBlank > 0)
		blank = ' ';
    if (price == 0)
    return 'CONSULTAR'; 
	if (currencyFormat == 1)
		return currencySign + blank + formatNumber(price, priceDisplayPrecision, ',', '.');
	if (currencyFormat == 2)
		return (formatNumber(price, priceDisplayPrecision, ' ', ',') + blank + currencySign);
	if (currencyFormat == 3)
		return (currencySign + blank + formatNumber(price, priceDisplayPrecision, '.', ','));
	if (currencyFormat == 4)
		return (formatNumber(price, priceDisplayPrecision, ',', '.') + blank + currencySign);
	return price;
}

//return a formatted number
function formatNumber(value, numberOfDecimal, thousenSeparator, virgule)
{
	value = value.toFixed(numberOfDecimal);
	var val_string = value+'';
	var tmp = val_string.split('.');
	var abs_val_string = (tmp.length == 2) ? tmp[0] : val_string;
	var deci_string = ('0.' + (tmp.length == 2 ? tmp[1] : 0)).substr(2);
	var nb = abs_val_string.length;

	for (var i = 1 ; i < 4; i++)
		if (value >= Math.pow(10, (3 * i)))
			abs_val_string = abs_val_string.substring(0, nb - (3 * i)) + thousenSeparator + abs_val_string.substring(nb - (3 * i));

	if (parseInt(numberOfDecimal) == 0)
		return abs_val_string;
	return abs_val_string + virgule + (deci_string > 0 ? deci_string : '00');
}

//change the text of a jQuery element with a sliding effect (velocity could be a number in ms, 'slow' or 'fast', effect1 and effect2 could be slide, fade, hide, show)
function updateTextWithEffect(jQueryElement, text, velocity, effect1, effect2, newClass)
{
	if(jQueryElement.text() != text)
		if(effect1 == 'fade')
			jQueryElement.fadeOut(velocity, function(){
				$(this).addClass(newClass);
				if(effect2 == 'fade') $(this).text(text).fadeIn(velocity);
				else if(effect2 == 'slide') $(this).text(text).slideDown(velocity);
					else if(effect2 == 'show')	$(this).text(text).show(velocity, function(){});
			});
		else if(effect1 == 'slide')
			jQueryElement.slideUp(velocity, function(){
				$(this).addClass(newClass);
				if(effect2 == 'fade') $(this).text(text).fadeIn(velocity);
				else if(effect2 == 'slide') $(this).text(text).slideDown(velocity);
					else if(effect2 == 'show')	$(this).text(text).show(velocity);
			});
			else if(effect1 == 'hide')
				jQueryElement.hide(velocity, function(){
					$(this).addClass(newClass);
					if(effect2 == 'fade') $(this).text(text).fadeIn(velocity);
					else if(effect2 == 'slide') $(this).text(text).slideDown(velocity);
						else if(effect2 == 'show')	$(this).text(text).show(velocity);
				});
}

//show a JS debug
function dbg(value)
{
	var active = false;//true for active
	var firefox = true;//true if debug under firefox

	if (active)
		if (firefox)
			console.log(value);
		else
			alert(value);
}

/**
* Function : print_r()
* Arguments: The data  - array,hash(associative array),object
*            The level - OPTIONAL
* Returns  : The textual representation of the array.
* This function was inspired by the print_r function of PHP.
* This will accept some data as the argument and return a
* text that will be a more readable version of the
* array/hash/object that is given.
*/
function print_r(arr, level)
{
	var dumped_text = "";
	if (!level)
		level = 0;

	//The padding given at the beginning of the line.
	var level_padding = "";
	for (var j = 0 ; j < level + 1; j++)
		level_padding += "    ";

	if (typeof(arr) == 'object')
	{ //Array/Hashes/Objects 
		for (var item in arr)
		{
			var value = arr[item];
			if (typeof(value) == 'object') { //If it is an array,
				dumped_text += level_padding + "'" + item + "' ...\n";
				dumped_text += dump(value,level+1);
			}
			else
			{
				dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
			}
		}
	}
	else
	{ //Stings/Chars/Numbers etc.
		dumped_text = "===>" + arr + "<===("+typeof(arr)+")";
	}
	return dumped_text;
}

//verify if value is in the array
function in_array(value, array)
{
	for (var i in array)
		if (array[i] == value)
			return true;
	return false;
}

// CODIGO JS CUBI
function setFocus(ID,t){//Main function
function $(id) {return document.getElementById(id);}
function $$(tag,obj){return (typeof obj=='object'?obj:$(obj)).getElementsByTagName(tag);}
var n='';//Mark
function showPics(num){
if(n===num) return true;
if(n==='') n=0;
else n=num;
var pics=$$('ul',ID)[0];
var tit=$$('div',pics)[num];
if (!pics.style.left){pics.style.left = 0+'px';}
if (!tit.style.bottom||parseInt(tit.style.bottom)>-34){tit.style.bottom = -34+'px';}
var endX=-num*$$('div',ID)[0].clientWidth;
endX-=40;
var goimg=function(){
X=parseInt(pics.style.left);
if (pics.movement){clearTimeout(pics.movement);}
if(parseInt(pics.style.left)==endX) return true;
if((endX-X)>0) X+=Math.ceil((endX-X) / 10);
else X+=Math.floor((endX-X) / 10);
pics.style.left=X+'px';
pics.movement = setTimeout(goimg, 5);
}
var gotit=function(){
var y=parseInt(tit.style.bottom);
if (tit.movement){clearTimeout(tit.movement);}
if(y==0) return true;
y+=Math.ceil((0-y) / 10);
y+=20;
if(parseInt(pics.style.left)==endX) tit.style.bottom=y+'px';
if(y<0) tit.movement = setTimeout(gotit, 16);
}
goimg();
gotit();
}
function classNormal() {//Clear Digital Label Style
var focusBtnList = $$('li',$$('ul',ID)[1]);
for (var i = 0; i < focusBtnList.length; i++) {
focusBtnList[i].className = '';
}
}
function focusChange() {//Interactive Switch
var focusBtnList = $$('li',$$('ul',ID)[1]);
for (var i = 0; i < focusBtnList.length; i++) {
focusBtnList[i].I=i;
focusBtnList[i].onmouseover = function(){
showPics(this.I);
classNormal();
focusBtnList[this.I].className = 'current';
}
}
}
var autoFocusChange=function() {//Automatically
if (atuokey) return;
var focusBtnList = $$('li',$$('ul',ID)[1]);
for (var i = 0; i < focusBtnList.length; i++) {
if (focusBtnList[i].className == 'current') {
var currentNum = i;
}
}
if(currentNum<focusBtnList.length-1){
showPics(currentNum+1);
classNormal();
focusBtnList[currentNum+1].className = 'current';
}else if(currentNum==focusBtnList.length-1){
showPics(0);
classNormal();
focusBtnList[0].className = 'current';
}
}
var atuokey = '';
function init(){//Initialization 
var ul=$$('ul',ID)[0];
var li=$$('li',ul);
var NUM=li.length;
var wid=$('myloading')?$$('div',ID)[1].clientWidth:$$('div',ID)[0].clientWidth;ul.style.width=wid*NUM+'px';
for(var i=0;i<NUM;i++){
var a=li[i].getElementsByTagName('a')[0];
var img=li[i].getElementsByTagName('img')[0];
li[i].innerHTML=li[i].innerHTML+'<div><span></span><a href="'+a+'">'+img.alt+'</a></div>';
}
var s='<div class="mybtn"><ul>';
for(var i=0;i<NUM;i++){s+='<li>'+(i+1)+'</li>'}
s+='</ul></div>';
$(ID).innerHTML+=s;
showPics(0);
classNormal();
$$('li',$$('ul',ID)[1])[0].className = 'current';
$(ID).onmouseover = function() {
atuokey = true;
clearInterval(auto);
}
$(ID).onmouseout = function() {
atuokey = false;
auto=setInterval(autoFocusChange, T);
}
}
var T=t*1000;//Each frame image will stay?1000=1 Second
var auto='';
init();
focusChange();
auto=setInterval(autoFocusChange, T);
};
window.onload=function(){
setFocus('myfocus',4);
}

// FIN CODIGO JS CUBI
