function setVisible(nr,state)
	{
		if (document.layers)
		{
			vista = (state) ? 'show' : 'hide'
			document.layers[nr].visibility = vista;
		}
		else if (document.all)
		{
			vista = (state) ? 'visible'	: 'hidden';
			document.all[nr].style.visibility = vista;
		}
		else if (document.getElementById)
		{
			vista = (state) ? 'visible' : 'hidden';
			document.getElementById(nr).style.visibility = vista;
	
		}
	}
	
function dump(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;
} 
	
function getBrowser()
	{
	var name = navigator.appName;

	if(name.indexOf('Netscape') != -1)
		{ return 'NS'; }
	else if(name.indexOf('Explorer') != -1)	
		{ return 'IE'; }
	else if(name.indexOf('Safari') != -1)	
		{ return 'S'; }
	else 
		{ return null; }
	}
	
function findPos(obj)
	{
	var curleft=curtop=scrolltop=scrollleft=0;
	if(obj==null)return;	
	if(obj.offsetParent)
		{
		curleft=obj.offsetLeft;
		curtop=obj.offsetTop;
		scrolltop=obj.scrollTop;
		scrollleft=obj.offsetLeft;

		while(obj=obj.offsetParent)
			{
			curleft+=obj.offsetLeft;
			curtop+=obj.offsetTop;
			if(scrolltop<obj.scrollTop)
				scrolltop+=obj.scrollTop;
			if(scrollleft<obj.offsetLeft)
				scrollleft+=obj.offsetLeft;
			}
		}
	if(getBrowser == 'S')
		{
		scrolltop=0;
		}
	
	return[curleft,curtop,scrollleft,scrolltop];
	}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

/**
 * Function for encoding arrays in url 
 * Warning: Problem with arrays value null
 */
function simpleUrlArrayEncode(arr) {
	var url = '';
	
	for(var key in arr)  { 
		if(arr[key] instanceof Array) {// CONTAIN SUB ARRAY
			var subArr = arr[key];
			
			for(var subKey in subArr)
				{ 
				if(subArr[subKey] instanceof Array) 
					{
					var subSubArr = subArr[subKey];
					
					for(subSubKey in subSubArr)
						{ url += ('&args[' + key + '][' + subKey + '][' + subSubKey + ']=' + (subSubArr[subSubKey] == undefined ? 'null' : subSubArr[subSubKey])  ); }
					}
				else 
					{	
					url += ('&args[' + key + '][' + subKey + ']=' + subArr[subKey]); 
					}
				}
		}
		else // NORMAL VALUE
			{ url += ('&args[' + key + ']=' + arr[key]); }
		}
		
		return url;
} 
