var itemsX = 165;				// x co-ordinate of center 
var itemsY = 210;				// y co-ordinate of center 
var a = 320/2;
var b = 250/2;
var items = 10;				// number of items
var stepsPerItem = 10;		// speed of rotation
var plusDeg = 360/items;
var startDeg = 135;
var steps = items*stepsPerItem;			// number of steps in rotation
var pointX = new Array();
var pointY = new Array();
var pathX = new Array();
var pathY = new Array();
var p = 0;
var stop = 1;
var timer = 10;
var whichObj = new Object();
var siteItems = new Array();
var lastClicked = 0;
var prevClicked = 0;
var hotspot = 0;

var pathPos = new Array();

var linksTop = 190;
var linksLeft = 430;
var linksHeight = 10
var linksoffset = 30;
var styleShow = (nav)?'show':'visible';
var styleHide = (nav)?'hide':'hidden';
var styleTop = (nav)?'.top':'.pixelTop';
var styleLeft = (nav)?'.left':'.pixelLeft'

var EXPANDED = 1;
var COLLAPSED = 0;

var linksMain = new Array();

linksMain[0] = new Array(
  "<br><li>FARSONSDIRECT.COM provides a range of services to Simonds Farsons Cisk plc retail customers only. The various services are shown on this page.</li><br><br><li> If you are a retail customer of SFC and you would like to become a registered user of FARSONSDIRECT.COM click on the signup button above.</li>", "", COLLAPSED);
  			  
linksMain[1] = new Array(
  "<br>FARSONSDIRECT.COM accepts orders from its registered users in the same way as the sales persons of SFC accept orders offline.<br><br>Discounts are automatically calculated by the system.", "", COLLAPSED);
  
linksMain[2] = new Array(
  "<br>At FARSONSDIRECT.COM your orders and information are processed, stored and delivered in a secure and efficient manner. Site policies cover <br><br><li><a href='policies.asp#sales' target='_blank'>Sales & Distribution</a></li><li><a href='policies.asp#security' target='_blank'>Security</a></li><li><a href='policies.asp#privacy' target='_blank'>Privacy</a></li>", "", COLLAPSED);
  
linksMain[3] = new Array(
  "<br>Using leading credit cards, payments can be made online using standard SSL security. <br><br>Payment can be raised against orders, overdue transactions and on account.", "", COLLAPSED);
  
linksMain[4] = new Array(    
  "<br>FARSONSDIRECT.COM offers the full range of Simonds Farsons Cisk plc products...<li>beers</li><li>soft drinks<li>juices and nectars</li><li>mixers</li><li>squashes</li><li>table waters</li>", "", COLLAPSED);
  
linksMain[5] = new Array(
  "<br>The search facility of FARSONSDIRECT.COM gives you a quick access to the full range of Simonds Farsons Cisk plc products", "", COLLAPSED);
  
linksMain[6] = new Array(
  "<br>Updated every 24 hours, two statements are available... <br> <br><li>overdue transactions</li><li>full statement</li><br><br> Drilldown to individual invoices & credit notes also available.", "", COLLAPSED);

linksMain[7] = new Array(
  "<br>The ‘My Account’ features the following information<li>statements</li><li>invoices and credit notes</li><li>trading information</li><li>facility to make online payments</li><li>outstanding orders</li><li>overdue transactions</li><li>facility to make ‘repeat orders’</li>", "", COLLAPSED);
  
linksMain[8] = new Array(
  "<br>FARSONSDIRECT.COM does not provide home delivery services since it is solely restricted to trade customers of Simonds Farsons Cisk plc.<br><br>For home deliveries please visit our <a href='http:\\\\www.farsonsdirect.com'>home customer portal</a> - operated by Farsons Beverage Imports Company Ltd. - a subsidiary of Simonds Farsons Cisk plc.", "", COLLAPSED);  
  
linksMain[9] = new Array(
  "<br>You can contact us <li> by phone on 23814497</li><li> by fax  on 23814165</li><li>by e-mail on webmaster@farsonsdirect.com</li>", "", COLLAPSED);
  

  
if (document.images){
	imgItem_off = new Image();
	imgItem_off.src = "pics/siteitem_off.gif"
	
	imgItem_on = new Image();
	imgItem_on.src = "pics/siteitem_on.gif";
	
	imgItem0_off = new Image();
	imgItem0_off.src = "pics/siteitem01_off.gif"; 
	imgItem0_on = new Image();
	imgItem0_on.src = "pics/siteitem01_on.gif"; 
	
	imgItem1_off = new Image();
	imgItem1_off.src = "pics/siteitem02_off.gif";
	imgItem1_on = new Image();
	imgItem1_on.src = "pics/siteitem02_on.gif";
	
	imgItem2_off = new Image();
	imgItem2_off.src = "pics/siteitem03_off.gif";
	imgItem2_on = new Image();
	imgItem2_on.src = "pics/siteitem03_on.gif";
	
	imgItem3_off = new Image();
	imgItem3_off.src = "pics/siteitem04_off.gif";
	imgItem3_on = new Image();
	imgItem3_on.src = "pics/siteitem04_on.gif";
	
	imgItem4_off = new Image();
	imgItem4_off.src = "pics/siteitem05_off.gif";
	imgItem4_on = new Image();
	imgItem4_on.src = "pics/siteitem05_on.gif";
	
	imgItem5_off = new Image();
	imgItem5_off.src = "pics/siteitem06_off.gif";
	imgItem5_on = new Image();
	imgItem5_on.src = "pics/siteitem06_on.gif";
	
	imgItem6_off = new Image();
	imgItem6_off.src = "pics/siteitem07_off.gif";
	imgItem6_on = new Image();
	imgItem6_on.src = "pics/siteitem07_on.gif";
	
	imgItem7_off = new Image();
	imgItem7_off.src = "pics/siteitem08_off.gif";
	imgItem7_on = new Image();
	imgItem7_on.src = "pics/siteitem08_on.gif";
	
	imgItem8_off = new Image();
	imgItem8_off.src = "pics/siteitem09_off.gif";
	imgItem8_on = new Image();
	imgItem8_on.src = "pics/siteitem09_on.gif";
	
	imgItem9_off = new Image();
	imgItem9_off.src = "pics/siteitem10_off.gif";
	imgItem9_on = new Image();
	imgItem9_on.src = "pics/siteitem10_on.gif";
	
	imgItem0_header = new Image();
	imgItem0_header.src = "pics/head_0.gif";
	
	imgItem1_header = new Image();
	imgItem1_header.src = "pics/head_1.gif";
	
	imgItem2_header = new Image();
	imgItem2_header.src = "pics/head_2.gif";
	
	imgItem3_header = new Image();
	imgItem3_header.src = "pics/head_3.gif";
	
	imgItem4_header = new Image();
	imgItem4_header.src = "pics/head_4.gif";
	
	imgItem5_header = new Image();
	imgItem5_header.src = "pics/head_5.gif";
	
	imgItem6_header = new Image();
	imgItem6_header.src = "pics/head_6.gif";
	
	imgItem7_header = new Image();
	imgItem7_header.src = "pics/head_7.gif";
	
	imgItem8_header = new Image();
	imgItem8_header.src = "pics/head_8.gif";

	imgItem9_header = new Image();
	imgItem9_header.src = "pics/head_9.gif";
	
	imgArrow_open = new Image();
	imgArrow_open.src = "pics/dummy.gif";
	
	imgArrow_close = new Image();
	imgArrow_close.src = "pics/dummy.gif";
}

function siteItem(n){
	this.name = "siteItem" + n;
	this.pos = n;
	this.pathPos = n*stepsPerItem;
	this.objRef = (nav)?"document.layerSiteItem"+n:"document.all.layerSiteItem"+n+".style";
	if (n!=hotspot){
		this.off_src = eval('imgItem'+n+'_off.src');
	} else {
		this.off_src = imgItem_on.src;
	}
	this.on_src = eval('imgItem'+n+'_on.src');
	this.header_src = eval('imgItem'+n+'_header.src');
	this.moveIt = b_moveIt;
		
	pathPos[n] = n*stepsPerItem;
		
	if (nav){
		content = '<a href="javascript:selectItem('+n+');" onmouseover="mouseoverItem('+n+')" onmouseout="mouseoutItem('+n+')"><img name="imgItem'+n+'" src="'+this.off_src+'" width=89 height=52 alt="" border="0"></a>'
	} else {
		content = '<img name="imgItem'+n+'" src="'+this.off_src+'" width=89 height=52 alt="" border="0">';
	}
	
	layerMakeWrite(('layerSiteItem'+n), 64, 39, pointX[n], pointY[n], 10, 'siteItem', 1, content, '', 'onclick="selectItem('+n+');" onmouseover="mouseoverItem('+n+')" onmouseout="mouseoutItem('+n+')"');
	this.css = (nav)?eval('document.layerSiteItem'+n):eval('document.all.layerSiteItem'+n+'.style');
	siteItems[siteItems.length] = this;
}

function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x;this.css.top=this.y}

function buildSiteItems(){
	for (i=0; i<items; i++){
		deg = startDeg + i*plusDeg;
		rad = 2*Math.PI*(deg)/360;
		r = Math.sqrt((a*a*b*b)/(a*a*(1-(Math.cos(rad))*(Math.cos(rad)))+b*b*(1-(Math.sin(rad))*(Math.sin(rad)))));
		pointX[i] = itemsX + Math.floor(r*Math.cos(rad));
		pointY[i] = itemsY - Math.floor(r*Math.sin(rad));
		new siteItem(i);
	}
	for (i=0; i<steps; i++){
		deg = startDeg+i*(plusDeg/stepsPerItem);
		rad = 2*Math.PI*(deg)/360;
		r = Math.sqrt((a*a*b*b)/(a*a*(1-(Math.cos(rad))*(Math.cos(rad)))+b*b*(1-(Math.sin(rad))*(Math.sin(rad)))));
		pathX[i] = itemsX + Math.floor(r*Math.cos(rad));
		pathY[i] = itemsY - Math.floor(r*Math.sin(rad));
	}
}

function startRotate(){
	if (pathPos[lastClicked]==0) stop=1;
	if (!stop){
		// Re-calculate siteItem path points. 
		for (i=0;i<items;i++){
			myPos = pathPos[i];
			if (myPos==0){
				myPos = steps-1;
			} else {
				myPos--;
			}
			// Move each item to the re-calculated path point. 
			siteItems[i].moveIt(pathX[myPos],pathY[myPos]);
			pathPos[i] = myPos; 
		}
		stop = 0;
		setTimeout("startRotate()",timer);
	} else {
		// Change header graphic. 
		inHotspot(lastClicked);
	}
}

function selectItem(obj){
	if ((obj!=-1)&&(lastClicked!=-1)){
		prevClicked = lastClicked;
		layRef = (nav)?"layerSiteItem"+prevClicked:"";
		rollover(layRef,'imgItem'+prevClicked, eval('imgItem'+prevClicked+'_off.src'))
	}
	lastClicked = obj;
	whichObj = siteItems[lastClicked];
	stop = 0;
	collapseAll();
	hideMainLinks();
	startRotate();
}
  
function buildMainLinks(){
	for (i=0;i<linksMain.length;i++){
		for (j=0; j<linksMain[i].length; j+=3){
			k=j+1;
			content = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="mainText">'+linksMain[i][k]+'<img name="imgLinksMain'+i+(j/3)+'" src="'+imgArrow_close.src+'" width=13 height=200 alt="" border="0" align=left>'+linksMain[i][j]+'</td></tr></table>'
			show=(i==0)?1:0;
			layerMakeWrite('linksMain'+i+(j/3), 325, 10, linksLeft, linksTop+(j/3)*2*linksHeight, 30, '', show, content, '', '')
		}
	}
}

function showMainLinks(n){
	//alert(prevClicked+":"+n);
	hideMainLinks()
	//alert(prevClicked+":"+n);	
	for (i=0;i<linksMain[n].length;i+=3){
		//if (n==0) alert('document.'+coll+'linksMain'+n+(i/3)+styleObj+'.visibility="'+styleShow+'"')
		eval('document.'+coll+'linksMain'+n+(i/3)+styleObj+'.visibility="'+styleShow+'"')
	}
}

function hideMainLinks(){
	for (j=0;j<linksMain[prevClicked].length;j+=3){
		//alert('document.'+coll+'linksMain'+prevClicked+(j/3)+styleObj+'.visibility="'+styleHide+'"')
		eval('document.'+coll+'linksMain'+prevClicked+(j/3)+styleObj+'.visibility="'+styleHide+'"');
	}
}		

function expand3Level(expandMe){
	expandMe = expandMe.split(".");	
	m = parseInt(expandMe[0]);
	o = parseInt(expandMe[1]*3+2);
	n = parseInt(expandMe[1]*3+3);	
	
	if (linksMain[m][o]==EXPANDED){		
		collapse3Level(expandMe);	
		return
	}
	
	mainObj = eval('document.'+coll+'linksMain'+expandMe[0]+expandMe[1]);	
	subObj = eval('document.'+coll+'linksSub'+expandMe[0]+expandMe[1]);
	
	mainObj_Top = (nav)?mainObj.top:mainObj.style.pixelTop;
	mainObj_Height = (nav)?mainObj.document.height:mainObj.clientHeight;
		
	subObj_Top = mainObj_Top + mainObj_Height + 5;
	subObj_Height = (nav)?subObj.document.height:subObj.clientHeight;
	refTop = (nav)?'.top':'.pixelTop';
	for (i=n;i<linksMain[m].length;i+=3){
		eval('document.'+coll+'linksMain'+expandMe[0]+(i/3)+styleObj+refTop+'+='+(subObj_Height+5));
		if (eval('document.'+coll+'linksSub'+expandMe[0]+(i/3))) eval('document.'+coll+'linksSub'+expandMe[0]+(i/3)+styleObj+refTop+'+='+(subObj_Height+5));
	}
	eval('document.'+coll+'linksSub'+expandMe[0]+expandMe[1]+styleObj+refTop+'='+subObj_Top)
	eval('document.'+coll+'linksSub'+expandMe[0]+expandMe[1]+styleObj+'.visibility="'+styleShow+'"')
	rollover('linksMain'+expandMe[0]+expandMe[1],'imgLinksMain'+expandMe[0]+expandMe[1],imgArrow_open.src);
	
	linksMain[m][o] = EXPANDED;
}	
			
function collapse3Level(collapseMe){
	m = parseInt(collapseMe[0]);
	n = parseInt(collapseMe[1]*3+3);	
	
	mainObj = eval('document.'+coll+'linksMain'+collapseMe[0]+collapseMe[1]);
	subObj = eval('document.'+coll+'linksSub'+collapseMe[0]+collapseMe[1]);
	
	mainObj_Top = (nav)?mainObj.top:mainObj.style.pixelTop;
	mainObj_Height = (nav)?mainObj.document.height:mainObj.clientHeight;
	
	subObj_Height = (nav)?subObj.document.height:subObj.clientHeight;
	
	refTop = (nav)?'.top':'.pixelTop';
	for (i=n;i<linksMain[m].length;i+=3){
		eval('document.'+coll+'linksMain'+collapseMe[0]+(i/3)+styleObj+refTop+'-='+(subObj_Height+5));
		if (eval('document.'+coll+'linksSub'+collapseMe[0]+(i/3))) eval('document.'+coll+'linksSub'+collapseMe[0]+(i/3)+styleObj+refTop+'-='+(subObj_Height+5));
	}
	eval('document.'+coll+'linksSub'+collapseMe[0]+collapseMe[1]+styleObj+'.visibility="'+styleHide+'"')
	rollover('linksMain'+collapseMe[0]+collapseMe[1],'imgLinksMain'+collapseMe[0]+collapseMe[1],imgArrow_close.src);
	
	linksMain[m][o] = COLLAPSED;
}

function collapseAll(){
	refTop = (nav)?'.top':'.pixelTop';
	for (i=0;i<linksMain[prevClicked].length;i+=3){		
		//alert('linksMain'+prevClicked+i);
		eval('document.'+coll+'linksMain'+prevClicked+(i/3)+styleObj+refTop+' = '+(linksTop+(i/3)*2*linksHeight));
		rollover('linksMain'+prevClicked+(i/3),'imgLinksMain'+prevClicked+(i/3),imgArrow_close.src);
		if (eval('document.'+coll+'linksSub'+prevClicked+(i/3))) eval('document.'+coll+'linksSub'+prevClicked+(i/3)+styleObj+'.visibility="'+styleHide+'"')
	}
}

function inHotspot(i){
	//alert(i);
	rollover('laySiteItemTitle', 'imgSiteItemTitle', whichObj.header_src);
	rollover('layerSiteItem'+i, 'imgItem'+i, imgItem_on.src);
	showMainLinks(i)
}

function mouseoverItem(i){
	if ((stop==1)&&(i!=lastClicked)) rollover("layerSiteItem"+i,"imgItem"+i, eval("imgItem"+i+"_on.src"));
}

function mouseoutItem(i){
	if ((stop==1)&&(i!=lastClicked)) rollover("layerSiteItem"+i,"imgItem"+i, eval("imgItem"+i+"_off.src"));
}

function initSiteMap(){
	buildSiteItems()
	buildMainLinks();
	document.write('<div id="linker" style="position:absolute; left:75px; top:118px; width:55px; height:40px; z-index:99"><a href="http://www.farsons.com/" target="_blank"><img src="pics/dummy.gif" width="55" height="40" border="0"></a></div>')
}