

function $(id)
{
	return document.getElementById(id);	
}
function hide(id)
{
	$(id).style.display = 'none';
}
function show(id)
{
	$(id).style.display = 'block';
}
function isHidden(id)
{
	if($(id).style.display == 'none')
		return true;
	else
		return false;
}
function V_switch(id)
{
	if(isHidden(id))
		show(id);
	else
		hide(id);
}
	
// references: album select
// main vars
var RGBG_base_url = "http://www.rubberfloors.be/";
var RGBG_album_nodes = 5;
var RGBG_news = false;
var RGBG_oldieflag = false;
var RGBG_array_descr1 = null;var RGBG_array_descr2 = null; var RGBG_array_src = null;   var RGBG_array_url = null; 
var RGBG_array_html = null;
var RGBG_imgurl = "";
var RGBG_current_id=1;
var timer = null;
var RGBG_nodescr = false;
var RGBG_urls = false;
var RGBG_urlstr = "";
var RGBG_activeurl;
var RGBG_timeout = 6000;
var RGBG_img_path = "";
var RGBG_empty_alt = false;
var RGBG_seq = null;
var RGBG_seq_active = false;

//
function RGBG_gotourl()
{
	if(RGBG_activeurl != "" && RGBG_urls)
	{
		if(RGBG_activeurl.indexOf("RGBG_news") == -1)
			window.location = RGBG_activeurl;
		else
			window.location = RGBG_activeurl;
	}
}
function RGBG_urlstrf()
{
	RGBG_urlstr = "";
	
	if(RGBG_urls)
	{
		RGBG_activeurl = RGBG_array_url[RGBG_current_id-1];
		if(RGBG_activeurl != "")
		{
			RGBG_urlstr = " style='cursor:pointer;' onclick='RGBG_gotourl()' ";
			$('descr_sub').style.cursor = 'pointer';
			$('descr').style.cursor = 'pointer';		
		}else
		{
			$('descr_sub').style.cursor = 'default';
			$('descr').style.cursor = 'default';	
		}
	}
	
}

function RGBG_showActiveGallery()
{
	RGBG_imgurl = RGBG_base_url+RGBG_img_path;
	// use  RGBG_array_descr1  RGBG_array_descr2  RGBG_array_src  to generate album :)
	var str = "";
	//show('preloader');
	
	
	RGBG_urlstrf();
	
	
	str = "<img onload='RGBG_done_loading(0);' "+RGBG_urlstr+" src='"+RGBG_imgurl+""+RGBG_array_src[0]+"'/>";
	$('empty').innerHTML = str;
	
	
	str = "";	
	
	str = "<ul>";
	
	var oldie_pngfix = "";
	if(RGBG_oldieflag) oldie_pngfix = "class='pngme'";
	
	for(var i = 1; i<= RGBG_array_src.length; i++)
		str = str + "<li id='RGBG_mylselect_"+i+"' onclick='RGBG_loadPicture("+i+", true)''>"+RGBG_array_html[i-1]+"<span style='display:none;' id='myselect_"+i+"' href=''>"+i+"</span></li>";
	
	
	
	
	str = str + "</ul>";
	
	$('selector').innerHTML = str;
	
	
	RGBG_setActive(1);
	
	
	clearTimeout(timer);
	
	
		
		
	
	// set timers
	timer = setTimeout("RGBG_loadPicture("+(((RGBG_current_id)%(RGBG_array_src.length))+1)+")",RGBG_timeout);
	
	//attempt preload
	nextimg = new Image(); 
	nextimg.src = ""+RGBG_imgurl+RGBG_array_src[(((RGBG_current_id)%(RGBG_array_src.length)))]+"";
	
}
function RGBG_done_loading(id)
{
	//hide('preloader');

}
function RGBG_setActive(id)
{
	for(var i = 1; i<= RGBG_array_src.length; i++)
	{
		$('myselect_'+i).className = '';
		$('RGBG_mylselect_'+i).className = '';
		
	}
	$('myselect_'+id).className = 'active';	
	$('RGBG_mylselect_'+id).className = 'active';	
	
	
	
	
	
	show('descr_sub');
	if(!RGBG_nodescr)
	{
	if(!RGBG_news)
		$('descr').innerHTML = "<div style='padding-left:5px; '>"+RGBG_array_descr1[id-1]+"</div><div style='text-align:center;'>"+RGBG_array_descr2[id-1]+"</div>";
	else
		$('descr').innerHTML = "<div class='ng_d1'>"+RGBG_array_descr1[id-1]+"</div><div  class='ng_d2'>"+RGBG_array_descr2[id-1]+"</div>";
	
	
	}
}
function RGBG_loadPicture(id, clicked)
{
	if(typeof clicked == 'undefined') clicked = false;
	if(clicked && RGBG_seq_active ) { return; }
	if(clicked && id == RGBG_current_id) {return;}
	
	RGBG_current_id = id;
	var str = "";
	//show('preloader');
	RGBG_urlstrf();
	
	if(RGBG_empty_alt)
	{
		oldc = 'empty_alt';
		newc = 'empty';
		RGBG_empty_alt = false;
	}else{
		
		oldc = 'empty';
		newc = 'empty_alt';
		RGBG_empty_alt = true;
		
		
	}
	str = "<img "+RGBG_urlstr+" onload='RGBG_done_loading("+id+");' src='"+RGBG_imgurl+RGBG_array_src[(id-1)]+"'/>";
	
	
	RGBG_seq = null;
	RGBG_seq = new Parallel();
	
	RGBG_seq.addChild(   new OpacityTween( $(oldc) ,Tween.regularEaseIn, 100, 0, 0.65)   );
	RGBG_seq.addChild(   new OpacityTween( $(newc) ,Tween.regularEaseIn, 0, 100, 0.65)  );
	RGBG_seq.children[0].onMotionFinished = function(){ RGBG_seq_active = false; };
	$(newc).innerHTML = str;
	RGBG_seq_active = true;
	
	RGBG_seq.start();
	
	$(newc).style.zIndex ="5";
	$(oldc).style.zIndex ="4";
	
	
	
	
	RGBG_setActive(id);
	clearTimeout(timer);
	
	
	// attempt preloading next pic
	nextimg = new Image(); 
	nextimg.src = ""+RGBG_imgurl+RGBG_array_src[(((RGBG_current_id)%(RGBG_array_src.length)))]+"";
	
	
	// RGBG_timeout
	timer = setTimeout("RGBG_loadPicture("+(((RGBG_current_id)%(RGBG_array_src.length))+1)+")",RGBG_timeout+1000);
	
}


// main gallery stuff
function RGBG_initGal(imgs)
{
	imgs = RGBG_base_url+"RGBG/gallery_news_layer2.png";
	if(RGBG_nodescr) RGBG_timeout = 3000;
	 PreLoad = new Image();
	 PreLoad.src = RGBG_base_url+"RGBG/preloader.gif";
	 PreLoad2 = new Image();
	 PreLoad2.src = imgs;

}

function RGBG_iefix(selectorid, descr_subid, switch_descr)
{
	version=0
	
	
	if (navigator.appVersion.indexOf("MSIE")!=-1){
	temp=navigator.appVersion.split("MSIE")
	version=parseFloat(temp[1])
	}
	
	if (version>=5.5 && version < 7) //NON IE browser will return 0
	{
		
		$(selectorid).className = selectorid+'_ie';
		RGBG_oldieflag = true;	
		
	}
}
