function SetupTranslations(cfg,id)
{
	var names='';
	var s='';
	var	img, div;
	
	div=document.createElement('div');
	div.className='transbar';
	div.id="transbar"+id;
	if(!$(id))
		return;
	$(id).appendChild(div);
	div=$('transbar'+id);
	var iAdded=0;
	for(var name in cfg){
		if(div.up('div').up('div').down('div.'+cfg[name].langname))
		{
			iAdded++;
			img=new Image();
			img.src=cfg[name].image;
			img.setAttribute('original',cfg[name].image);
			img.setAttribute('hover',cfg[name].hover);
			img.style.cursor='pointer';
			img.alt=cfg[name].langname;
			img.onmouseover=function() { this.src=this.getAttribute('hover');}
			img.onmouseout=function() { this.src=this.getAttribute('original');}
			img.id=id+'_'+name;
	
			img.onclick=function() {
				TranslateShow($(this).up('div').up('div').up('div').down('div.'+this.alt));
			}
			div.appendChild(img);
			div.up('div').up('div').down('div.'+cfg[name].langname).hide();
		}
	}
	if(iAdded==0)
		div.hide();
	div.style.width=((iAdded*29))+'px';
}

function SetupTranslationDiv()
{
	var contactuswindow=$('contactuswindow');
	if(!contactuswindow)
	{
		var content;
		contactuswindow=document.createElement('div');
		contactuswindow.id='contactuswindow';
		$('body').appendChild(contactuswindow);

		content=document.createElement('div');
		content.innerHTML='<img src="/primo/pimg/closelabel.jpg" />';
		content.className="contactusheader";
		contactuswindow.appendChild(content);

		content=document.createElement('div');
		content.className='content';
		contactuswindow.appendChild(content);

		content=document.createElement('div');
		var img=new Image();
		img.src='/primo/pimg/closelabel.gif';
		img.onclick=function() { CloseWindow(1) ; }
		content.appendChild(img);
		content.className="contactusfooter";
		contactuswindow.appendChild(content);
		contactuswindow.className='contactuswindow';
		contactuswindow=$('contactuswindow');
		contactuswindow.hide();

		if(!$('overlaylwd'))
		{
			var objOverlay = document.createElement("div");
			objOverlay.setAttribute('id','overlaylwd');
			objOverlay.style.display = 'none';
			objOverlay.onclick = function() { CloseWindow(1); return false; }
			$('body').appendChild(objOverlay);
		}
	}
}


function TranslateShow(contentdiv)
{
	SetupTranslationDiv();
	var contactuswindow=$('contactuswindow');
	$('contactuswindow').down('div.content').innerHTML=contentdiv.innerHTML;
	var a;
	a=document.viewport.getScrollOffsets();
	contactuswindow.style.top=(((document.viewport.getHeight()-400)/2)+a['top']).toString()+'px';
	contactuswindow.style.left=(((document.viewport.getWidth()-500)/2)+a['left']).toString()+'px';
	new Effect.BlindDown(contactuswindow,{duration: '1.0'});
	HideBG();
}
function CloseWindow(e)
{
	var contactuswindow=$('contactuswindow');
	if(e.responseText)
	{
		contactuswindow.down('div').innerHTML=contactuswindow.down('div').innerHTML+'<p>'+e.responseText+'</p>';
	}
	new Effect.BlindUp(contactuswindow,{duration: '0.3'});
	ShowBG();
}
function HideBG()
{
		var arrayPageSize = getPageSizeLWD();
		$('overlaylwd').style.height=arrayPageSize[1]+'px';
		new Effect.Appear('overlaylwd', { duration: 0.2, from: 0.0, to: 0.8 });

}
function ShowBG()
{
	new Effect.Fade('overlaylwd', { duration: 0.2});

}


function getPageSizeLWD(){
	
	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;
}

