// Replaces getElementById
function get_obj(id)
{
	return document.getElementById(id);
}

function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				req = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
function _set_gallery(gallery_id,key) {		
	
	for(i=0;i<7;i++)
	{
		if(document.getElementById('gall'+i))
			document.getElementById('gall'+i).className='galerie-thumb';
	}
	document.getElementById('gall'+key).className='galerie-thumb-hl';
	var strURL="/get-gallery/"+gallery_id;
	var req = getXMLHTTP();
	
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {
					if(document.getElementById('real_gallery'))
					{
						//initialize_scroll();
						
						document.getElementById('real_gallery').innerHTML=req.responseText;	
						re_initialize_scroll();
					}
					else alert('hack attempt');
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}		
}

function set_gallery(gallery_id,key)
{	
	for(i=0;i<7;i++){
		if(document.getElementById('gall'+i))
			document.getElementById('gall'+i).className='galerie-thumb';
	}
	
	document.getElementById('gall'+key).className='galerie-thumb-hl';
	var strURL= '/get-gallery/'+ gallery_id;
	
	var ajax = new Ajax.Updater('real_gallery',strURL, {method: 'get',evalScripts:true});	
}

function re_initialize_scroll() 
{
	var content = document.getElementById("galerie-Content");
	var scrollb = document.getElementById("galerie-Scrollbar");

	scrollbar = new Scrolling.Scrollbar (
		scrollb,
		new Scrolling.Scroller (content, 400, 180),
		new Scrolling.ScrollTween()
	);
	
	scrollbar.onMouseDown = scrollbarPressed;
	scrollbar.onMouseUp   = scrollbarReleased;
}


function laightbox(url)
{
	if(document.getElementById('link_acuns'))
	{
		var objLink = document.getElementById('link_acuns');
		objLink.setAttribute('href',url);
		var a = document.getElementById("link_acuns");
		myLightbox.start(a);
	}
}
