// JavaScript Document
function $(id)
{
	nid=document.getElementById(id)
	return nid;
}

function showOffices(content)
{
	xmlhttp=loadXMLDoc(content);
	if(xmlhttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function loadXMLDoc(content)
{
//	url='/shireplc/templates_shireplc/assets/files/location_html/'+content+'.html';
	if(content.indexOf('pds_')!=-1)
	{
		nContent=content.substring(4,content.length)
		url='/shireplc/products_map.jsp?product='+nContent;
	}else{
		url='/shireplc/location_map.jsp?country='+content;
	}
	if(window.XMLHttpRequest)
	{
		return new XMLHttpRequest();
	}
	if(window.ActiveXObject)
	{
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}

function stateChanged()
{
	if (xmlhttp.readyState==4)
	{
		$("cnt").innerHTML=xmlhttp.responseText;
	}
}

function movetoOffice(office)
{
	window.location.href='#'+office;
}

/*	smooth scroll	*/
var scrollSpeed=10;
function pageScroll(aPos,n){
	if(n<aPos)
	{
		window.scrollBy(0,scrollSpeed);
	}
	n++;
	scrolldelay = setTimeout('pageScroll('+aPos+','+n+')',1);
}
var p=0;
function movetoOffice(office)
{
	if(navigator.userAgent.indexOf('MSIE')!=-1)
	{
		dfltScrollTop=document.documentElement.scrollTop;
	}else{
		dfltScrollTop=window.pageYOffset;
	}
	if(dfltScrollTop)
	{
		dfltScroll=(dfltScrollTop/scrollSpeed)+2;
	}else{
		dfltScroll=1;
	}
	a=$('wrapperCnt').getElementsByTagName('a');
	for(i=0;i<a.length;i++)
	{
		if(a[i].name==office)
		{
			aPos=(a[i].offsetTop/scrollSpeed)-dfltScroll;
			pageScroll(aPos,0);
		}
	}
}