


function handle_error(msg,url,l){return false;}

var on_load_fct=new Array();
var startTime=new Date();
var preload_i=new Array();
var loading=new Array();
var engine;
var session=ie_times=no=0;
var debug=false;
var content=new Array;
var timeouts=new Array;
//debug=true;

function $$(id){return document.getElementById(id);}
function $(id){return document.getElementById(id);}
function body_onload()
	{
	
	/*initAjaxEngine();
	var c=on_load_fct.length;
	for (var i=0;i<c;i++)
		eval(on_load_fct[i]);*/
	}
	
	
function addEvent(obj,evType,fn)
	{if(obj.addEventListener)
		{obj.addEventListener(evType,fn,false);
		return true; 
		}
	else 
		if(obj.attachEvent)
			{var r=obj.attachEvent("on"+evType, fn); 
			return r; 
			}
		else
			return false; 
	}





function swap_img(item,w,type)
	{if(!type)
		type="img";
	if(item)
		if(type=="img")
			item.src=w;
		else 
			if(browserdetect!='ie')
				item.style.background="url("+w+")";
			else
				item.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+w+"',sizingMethod='scale')";
		
	}
	
function alpha_elem(id,alpha) {if (id){if (browserdetect) switch(browserdetect) {case "opera": id.style.opacity=alpha/100;break; case "mozilla": id.style.MozOpacity=alpha/100;break; case "ie": id.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+alpha+")";break;case "ie7": id.style.filter="alpha(opacity="+alpha+")";break;}}}

function addOnLoad(w)
	{if(w)
		on_load_fct[on_load_fct.length]=w;
	}




function swap_img_bg(item,w)
	{
	if(item)
		item.style.backgroundPosition=w==undefined?'bottom':'top';
	}


function initAjaxEngine()
	{if(!engine)
		{if(debug)
			document.body.innerHTML+='<iframe id="engine" name="engine" frameborder="0" height="300" width="100%" marginheight="0" marginwidth="0"  scrolling="yes" src="engine.php?idle" style="background:#FFF"></iframe>';
		else
			document.body.innerHTML+='<iframe id="engine" name="engine" frameborder="0" height="0" width="0" marginheight="0" marginwidth="0"  scrolling="no" src="engine.php?idle" style="visibility:hidden"></iframe>';
		return engine=$('engine');
		}
	return true;
	}
	window.onload=initAjaxEngine;
function rbetAjax(inElement,script,opt,loading)
	{if(!session)
		{if(!engine)
			{initAjaxEngine();
			if(!engine)
				{alert('Failed initAjaxEngine!');
				return false;
				}
			}
		session=1;
		if(loading)
			loading_show(inElement);
		var query="engine.php?cmd=get&in_element="+inElement+"&script="+script+'&'+opt;
		if(browserdetect!="ie")
			engine.src=query;
		else 
			{ie_times++;
			engine.src=query+"&"+ie_times;
			}
		}
	return false;
	}

	



	
var _gal1_swap_img_img=_gal1_t=false;
function gal1_swap_img(w,item,t)
	{
	
	if(w&&item)
		{item=$$(item);
		$$('gal_loading').style.visibility='visible';
		var newimg=self.document.createElement('img');
		_gal1_swap_img_img=item.id;
		newimg.onload=function()
			{changeOpac(0,'gal_img');
			opacity('gal_img',0,100,1000);
			$$(_gal1_swap_img_img).style.background="url("+this.src+")";
			$$('gal_loading').style.visibility='hidden';
			}
		newimg.src=w;
		var a=$$('gal1_a');
		
		if(a)
			{a.href="?loc="+t;
			_gal1_t=t;
			a.onclick=function()
				{
				loadPage(_gal1_t);
				if(browserdetect=='ie')
					{event.returnValue=false;}
				return false;
				}
				
			}
		
		}
	}
	
	var _a=_id=_v=0;
	
document.onmouseup=function()
	{
	if(_id)
		scroll(_id,0);
	}
_tts=new Array;	

function clearTimeOuts()
	{
	var c=_tts.length;
	for(var i=0;i<c;i++)
		{
		clearTimeout(_tts[i]);
		}
	}


function scroll(id,v,a)
	{
	
	var id1=$$(id+"_1");
	var id2=$$(id+"_2");
	 clearTimeOuts();
	if(id)
		if(v=='0')
			{clearTimeout(timeouts['scroll']);
			var i=0;
			
			if(_a<0)
				{_a=Math.abs(_a);
				_v=-1;
				}
			else
				_v=1;
				
			var t=parseInt(id1.scrollTop);
			while(_a>1)
				{i++;
				_a-=2;
				t+=_a*_v;
				_tts[_tts.length]=setTimeout('$("'+id1.id+'").scrollTop='+t,i*35);
				_tts[_tts.length]=setTimeout('$("'+id2.id+'").scrollTop='+t,i*35);
				}
			_id='';
			_a=0;
			_v=0;
			a=0;
			}
		else
			{if(!a)
				a=0;
			if(a<20&&a>=-20)
				a+=1*v;
			_a=a;
			_id=id;
			id1.scrollTop=parseInt(id1.scrollTop)+parseInt(v)+a;
			id2.scrollTop=parseInt(id2.scrollTop)+parseInt(v)+a;
			timeouts['scroll']=setTimeout('scroll("'+id+'","'+v+'",'+a+')',35);
			}
	
	
	return false;
	}

function opacity(id,opacStart,opacEnd,millisec)
	{var speed=Math.round(millisec/100);
	var timer=0;
	if(opacStart>opacEnd)
		{for(var i=opacStart;i>=opacEnd;i--)
			{setTimeout("changeOpac("+i+",'"+id+"')",(timer*speed));
			timer++;
			}
		}
	else
		if(opacStart<opacEnd)
			{for(var i=opacStart;i<=opacEnd;i++)
				{setTimeout("changeOpac("+i+",'"+id+"')",(timer*speed));
				timer++;
				}
			}
	}
function changeOpac(opacity,id)
	{var object=document.getElementById(id).style; 
	object.opacity=(opacity/100);
	object.MozOpacity=(opacity/100);
	object.KhtmlOpacity=(opacity/100);
	if(browserdetect=='ie')
		object.filter="alpha(opacity="+opacity+")";
	else
		object.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+opacity+")";
	}

function loadPage(w)
	{session=1;
	if(browserdetect!="ie")
		engine.src="engine.php?cmd=page&w="+w;
	else
		{ie_times++;
		engine.src="engine.php?cmd=page&w="+w+"&rand_ie="+ie_times;
		}
	return false;	
	}



function getPageSizeWithScroll(){var yScroll,xScroll;if (window.innerHeight && window.scrollMaxY) {xScroll = document.body.scrollWidth;yScroll = window.innerHeight + window.scrollMaxY;} else if (document.body.scrollHeight > document.body.offsetHeight){xScroll = document.body.scrollWidth;yScroll = document.body.scrollHeight;} else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){xScroll = document.documentElement.scrollWidth;yScroll = document.documentElement.scrollHeight;} else {xScroll = document.body.offsetWidth;yScroll = document.body.offsetHeight;}return {x:xScroll,y:yScroll};}	

var _change_img_t1,_change_img_id=false;
function change_img(full,t1,id)
	{if(t1&&full&&id)
		{var t;
		var newimg=self.document.createElement('img');
		_change_img_id='gal_'+id+'_t1';
		_change_img_t1=t1
		changeOpac(0,_change_img_id);
		newimg.onload=function()
			{$$(_change_img_id).src=_change_img_t1;
			opacity(_change_img_id,0,100,500);
			}
		newimg.src=t1;
		if(t=$$('gal_'+id+'_a'))
			{$$('gal_'+id+'_a').href=full;
			t.onmousedown=function()
				{
				gallery2(this.href);
				return false;
				}
			t.onclick = function () 
				{gallery2(this.href);
				if(browserdetect=='ie')
					{event.returnValue=false;}
				return false;
				}
			}
		}
	return false;
	}

function gallery2(w)
	{if(w)
		{var height=getPageSizeWithScroll().y;
		var h=self.document.createElement('div');
		h.id="gal_h";
		h.onclick=function() {this.parentNode.removeChild(this);}
		document.body.appendChild(h);
		var bg=self.document.createElement('div');
		bg.className="galllery_img_bg";
		bg.style.height=height?(height+"px"):"100%";
		bg.id="gal_bg";
		alpha_elem(bg,0);
		opacity(bg.id,0,85,350);
		$$('gal_h').appendChild(bg);
		var loading=self.document.createElement('img');
		loading.src="server_files/images/global/loading.gif";
		loading.id="loading_gal";
		loading.className="galllery_img_loadings";
		loading.style.top=document.documentElement.scrollTop+50+"px";
		loading.style.marginLeft="-75px";
		$$('gal_h').appendChild(loading);
		var img=self.document.createElement('img');
		img.className="galllery_img_full";
		img.style.top=document.documentElement.scrollTop+20+"px";
		img.id="img_full";
		alpha_elem(img,0);
		img.onload=function()
			{this.style.marginLeft="-"+parseInt(this.width/2)+"px";
			$$('gal_h').appendChild(this);
			opacity(this.id,0,100,500);		
			if(t=$$('loading_gal'))
				$$('gal_h').removeChild(t);
			}
		img.src=w;
		}
	}
	
	
function createFlashMarkup(width,height,uri)
	{
	document.write('<embed width="'+width+'" height="'+height+'" src="'+uri+'" wmode="transparent"></embed>');
	}

var _next_preload_img_a=_gal_id=false;
function preloadImg(id,img_link)
	{
	
	if(img_link&&img_link.title)
		{alpha_elem(img_link,50);
		var img=document.createElement('img');
		
		_next_preload_img_a=getNextImg(id,img_link);
		img.onload=function()
			{
			alpha_elem(img_link,100);
			if(_next_preload_img_a)
				preloadImg(_gal_id,_next_preload_img_a);
			
		//	$('ddd').innerHTML=parseInt($('ddd').innerHTML)+1;
			
			}
		img.src=img_link.title;
		
		}
	}

	
function getNextImg(id,item)
	{var a=id.getElementsByTagName('a');
	var c=a.length;
	
	for(var i=0;i<=c;i++)
		if(a[i]==item)
			return (i+1<c)?a[i+1]:null;
	return false;
	}
	
function registerGal(id)
	{
	/*
	var d=document.createElement('div');
	d.style.position="absolute";
	d.style.top="0px";
	d.style.left="0px";
	d.style.background="black";
	d.style.color="white";
	d.style.fontSize="30px";
	d.innerHTML="0";
	d.id="ddd";
	
	$$('dd').appendChild(d);
	*/
	
	
/*	id=$$(id);
	if(id&&browserdetect!='ie')
		{
		var a=id.getElementsByTagName('a');
		_gal_id=id;
		a[0].id="temp_gal_id";
		
		on_load_fct[on_load_fct.length]="preloadImg( $$('"+id.id+"'),$$('"+a[0].id+"'))";
		}
	*/
	
	}