function roll_over(img_name, img_src)
{
//element = document.getElementById(img_name);
//element.src='images/'+img_src;
   document[img_name].src = 'images/'+img_src;
}
function otworz(adres) {
noweOkno = window.open(adres, 'okienko', 'menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no, width=500, height=500')
}


function roll_over_id(img_id, img_src){
	$(img_id).src=img_src;
	var myFx = new Fx.Style(img_id, 'opacity').start(0.1,1);
}


function getElement(id){
    if(document.getElementById){
        getElement = function(id){ return document.getElementById(id); }
    }else if(document.all){
        getElement = function(id){ return document.all[id]; };
    }else if(document.layers){
        getElement = function(id){ return document.layers[id]; };
    }else{
        getElement = function() { return null; }
    }

    // When we get here, the getElement function has been replaced.
    // So we return the result of the new function.
    return getElement(id);
}


function IsNumeric(sText){
   var ValidChars = "-0123456789.";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
	Char = sText.charAt(i); 
	if (ValidChars.indexOf(Char) == -1) 
    {
      IsNumber = false;
    }
   }
   return IsNumber;
}

function change(id, num){
 $(id).value=Math.max(parseInt($(id).value)+parseInt(num),0);
}

function submitform(id){
 $(id).submit();
}

function sendNote(note){
	$('formNote').value=note;
	$('sendNote').submit();
}

function changeDisp(className){
 $$('.'+className).each(function(e){
 	if(e.style.display=="none"){
 		e.setStyle('display','block');
 	}else{
 		e.setStyle('display','none');
 	}
 });
}


/*
Property: numberFormat
	Format a number with grouped thousands.

Arguments:
	decimals, optional - integer, number of decimal percision; default, 2
	dec_point, optional - string, decimal point notation; default, '.'
	thousands_sep, optional - string, grouped thousands notation; default, ','

Returns:
	a formatted version of number.

Example:
	>(36432.556).numberFormat()  // returns 36,432.56
	>(36432.556).numberFormat(2, '.', ',')  // returns 36,432.56
*/

function numberFormat(number, decimals, dec_point, thousands_sep, int_digits) {
	decimals = Math.abs(decimals) + 1 ? decimals : 2;
	int_digits = isNaN(int_digits)? 1: int_digits;
	int_digits = Math.max(Math.ceil(Math.log(Math.abs(number+1))/Math.log(10)), int_digits);
	dec_point = dec_point || '.';
	thousands_sep = thousands_sep || ',';

	var matches = /(-)?(\d+)(\.\d+)?/.exec((isNaN(number) ? 0 : number) + ''); // returns matches[1] as sign, matches[2] as numbers and matches[2] as decimals
	var zeros = '';
	for(i=0; i<int_digits-matches[2].length; i++){
		zeros += '0';
	}
	var remainder = matches[2].length > 3 ? matches[2].length % 3 : 0;
	return zeros + (matches[1] ? matches[1] : '') + (remainder ? matches[2].substr(0, remainder) + thousands_sep : '') + matches[2].substr(remainder).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep) + 
			(decimals ? dec_point + (+matches[3] || 0).toFixed(decimals).substr(2) : '');
}



