var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;

// resize fix for ns4
var origWidth, origHeight;
if (ns4) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

// avoid error of passing event object in older browsers
if (nodyn) { event = "nope" }

///////////////////////  CUSTOMIZE HERE   ////////////////////
// settings for tooltip 
// Do you want tip to move when mouse moves over link?
var tipFollowMouse= true;	
// Be sure to set tipWidth wide enough for widest image
var tipWidth= 250;
var offX= 20;	// how far from mouse to show tip
var offY= 12; 
var tipFontFamily= "Verdana, arial, helvetica, sans-serif";
var tipFontSize= "8pt";
// set default text color and background color for tooltip here
// individual tooltips can have their own (set in messages arrays)
// but don't have to
var tipFontColor= "#565656";
var tipBgColor= "#DDECFF"; 
var tipBorderColor= "#000000";
var tipBorderWidth= 1;
var tipBorderStyle= "ridge";
var tipPadding= 2;

// tooltip content goes here (image, description, optional bgColor, optional textcolor)
var messages = new Array();
// multi-dimensional arrays containing: 
// image and text for tooltip
// optional: bgColor and color to be sent to tooltip
messages[0] = new Array('images/rio-de.gif','Av. Das Americas 4200-Conj. 601 <br>Bloco 4, Barra da Tijuca<br>Rio de Janeiro, <br>Brazil CEP22640 -102<br>(5521) 3478 8888 - <br>Telephone (5521) 3150 2581<br>E-mail- rio@vinmar.com',"#FFFFFF");

messages[1] = new Array('images/lima.gif','Av. Manuel Olguin 571,<br>Monterrico - Surco<br>Lima - 33, <br>Peru<br>(511) 436 0143 - Telephone <br>(511) 435 6300 - Fax<br>E-mail- lima@vinmar.com',"#ffffff");

messages[2] = new Array('images/costa_text.gif','Hotel Quality Colon. 4to. <br>Piso Oficina # 403, <br> P.O.Box 1108-1007<br><Centro Colon<br>San Jose, Costa Rica<br>(506) 256-2527 - Telephone <br>(506) 258-0823 - Fax <br>E-mail- CostaRica@vinmar.com',"#ffffff");

messages[3] = new Array('images/mexico.gif','Pafnuncio Padilla No. 43 Local 17 y 19 <BR>Col. Cd. Satelite <BR> Naucalpan, Estado de México , <BR> C.P. 53100<BR>(52-55) 5374-7300 - Telephone <BR> (52-55) 5374-7331 or 33 - Fax <br>E-mail- mexicocity@vinmar.com',"#ffffff");

messages[4] = new Array('images/Guadalajara.gif','Fedor Dostoievski No.376<BR>Col. Patria Universidad<BR>Zapopan<BR>Jalisco, Mexico CP45120<BR>(52-33) 3642-5323 or 3641-9342 - Phone/Fax<BR> E-mail- Guadalajara@vinmar.com',"#ffffff");

messages[5] = new Array('images/monterrey.gif','Privada Aguilar 226<BR>Col. Deportivo Obispado<BR>Monterrey, Mexico 64040<BR>(52-81) 8348-1405 or 8346-4352 - Telephone<BR>(52-81) 8348-5590 - Fax<br>E-mail - monterrey@vinmar.com',"#ffffff");

messages[6] = new Array('images/corporate.gif','Vinmar International,Ltd.<BR>16800 Imperial Valley Drive, Suite 499 <BR>Houston, Texas 77060 U.S.A.<BR>(281) 618-1300 - Telephone<BR>(281) 618-1390 - Fax/Chemicals Group<br>(281) 618-1398/99 - Fax/Plastics Group<br><br>E-mail:<br>Houston@vinmar.com',"#ffffff");

messages[7] = new Array('images/netherland.gif','Neptunusstraat 27-29<BR>2132JA Hoofddorp, The Netherlands  <BR>(0031)-(0)23- 5543600 - Telephone <BR>(0031)-(0)23- 5543609 - Fax<BR>E-mail - amsterdam@vinmar.com',"#ffffff");


messages[8] = new Array('images/moscow.gif','119049 Russia, Moscow <br> Mytnaya Street, Building 1<BR>Entrance 1, 3rd Floor, Office 4<BR>7495-935-8588 - Telephone<BR>7495-935-8589 - Fax<br>E-mail - moscow@vinmar.com',"#ffffff");

messages[9] = new Array('images/istanbul.gif','Inonu Cad., Turaboglu SK<BR>Hamdiye, Yazgan Ismerkezi<BR>Kat 5, Daire 4, Kozyatagi,<BR>Istanbul, Turkey<BR>(90) 5332 616536 - Telephone<br>(90) 2164-111085 - Fax<br>E-mail - Turkey@vinmar.com',"#ffffff");

messages[10] = new Array('images/kano.gif','157/159 Club Road<BR>Kano, Nigeria<BR>234 8023 449277 - Telephone<BR>234 8023 449277 - Fax<BR>E-mail - Kano@vinmar.com',"#ffffff");

messages[11] = new Array('images/lagos.gif','No-4, (Ground Floor)<BR>Shonny highway Shonibare Estate,<BR>Maryland, Lagos, Nigeria<br>(2341) 7730622 - Telephone<br>E-mail - lagos@vinmar.com',"#ffffff");

messages[12] = new Array('images/ghana.gif','No.5 Adzoate Street<BR>Behind Papaye, Osu<BR>(Off Oxford Street)<br>233 21 781 063 - Telephone / Fax <br>E-mail - Accra@vinmar.com',"#ffffff");

messages[13] = new Array('images/johansburg.gif','1, Eastgate Lane<BR>Bedford-view<BR>Johannesburg - 2007<BR>South Africa<br>(2711) 6225743/5 - Telephone<br>(2711) 6220337 - Fax<br>E-mail - joburg@vinmar.com',"#ffffff");

messages[14] = new Array('images/dubai.gif','Vinmar International, FZE<BR>LOB 19, Office 1208, JAFZA, PO BOX 262431, Dubai, U.A.E.<BR>+971 (4) 501-5666 - Telephone<br>+971 (4) 501-5690 - Fax<br>E-mail - dubai@vinmar.com',"#ffffff");

messages[15] = new Array('images/karachi.gif','Office No. 111<BR>1st Floor, Sabah Palace, <BR>Plot No. 29-A, Block-6, P.E.C.H.S,<br>Shahrah-e-Faisal, <br>Karachi Pakistan<br>(9221) 4322009 - Telephone<br>(9221) 4322008 - Fax<br>E-mail - karachi@vinmar.com',"#ffffff");

messages[16] = new Array('images/vinmar.gif','A-41, MIDC Rd. No. 2<BR>Andheri (E) Mumbai 400093<BR>INDIA<BR>(9122) - 67141900 - Telephone<br>(9122) - 28200022 - Fax<br>E-mail - mumbai@vinmar.com',"#ffffff");

messages[17] = new Array('images/delhi.gif','Vinmar International (India) Pvt. Ltd.<BR>802, 8th Floor, Mercantile House<BR>15-Kasturba Gandhi Marg<BR>New Delhi 110 001, India<br>(9111) 23356257/8/9 - Telephone<br>(9111) 23356256 - Fax<br>E-Mail-delhi@vinmar.com', "#ffffff");

messages[18] = new Array('images/belgium.gif','Battelsesteenweg 239<BR>2800 Mechelen, Belgium <br>(+32) 15 420 842 - Telephone<br>(+32) 15 420 849 - Fax<br>E-mail - belgium@vinmar.com',"#ffffff");

messages[19] = new Array('images/thailand.gif','Vinmar Thailand<BR>K-Building, 2nd Floor<BR>No. 22, Sukhumvit Soi 35<BR>Sukhumvit Road<br>Bangkok, Thailand 10110<br>66-2-662-2109 - Telephone<br>66-2-260-9130 - Fax<br>E-mail - bangkok@vinmar.com',"#ffffff");

messages[20] = new Array('images/Guangzhou.gif','Rm 1704, Yian Plaza<BR>No 33 Jianshe Sixth Road<BR>Guangzhou P.R. China<BR>(8620) 836 33145 - Telephone<br>(8620) 836 33406 - Fax<br>E-mail - guangzhou@vinmar.com',"#ffffff");

messages[21] = new Array('images/taipei.gif','15F-3, No. 59, Tun Hwa S.Road,<BR>Sec. 2,<BR>Taipei, Taiwan<BR>(886-2) 23256626 - Telephone<br>(886-2) 23256636 - Fax<br>E-mail - taipei@vinmar.com',"#ffffff");

messages[22] = new Array('images/shanghai.gif','1103-1105 Lippo Plaza<BR>222 Huai Hai Road, Shanghai,<BR>P R CHINA - 200 021.<BR>(8621) 5396 5858 - Telephone<br>(8621) 5396 6616 - Fax<br>E-mail - shanghai@vinmar.com',"#ffffff");

messages[23] = new Array('images/beijing-text.gif','Room 1809, Building No. A<BR>No.16 Jian Guo Men Wai Street,<BR>Chao Yang District<BR>Beijing 100022, P.R. China <br>(8610) 6569-6710/1/2/3 - Telephone<br>(8610) 6569-6715 - Fax<br>E-mail - beijing@vinmar.com',"#ffffff");

messages[24] = new Array('images/seoul.gif','Dongsung Bldg. 12F<BR>17-7, Namdaemunno 4-ga, Jung-gu,<BR>Seoul, Korea(100-094)<BR>82-2-757-2430 - Telephone<br>82-2-757-2434 - Fax<br>E-mail - seoul@vinmar.com',"#ffffff");

messages[25] = new Array('images/tokyo.gif','3-10-1-302,Higashijujo,Kita-ku<BR>Tokyo 114-0001<BR>Japan<BR>81-3-3911-7462 - Telephone<br>81-3-3911-7460 - Fax<br>81-9027397314 - Fax<br>E-mail - tokyo@vinmar.com',"#ffffff");

messages[26] = new Array('images/Bucharest.gif','Blvd. Unirii, nr 18, Bloc 5B, sc.2, <BR>ap.44, sector 4, <BR>040107 Bucharest,<BR>Romania<BR>(40) 314 160 226 - Telephone<br>(40) 213 364 908  - Fax<br>E-mail - Romania@vinmar.com',"#ffffff");

messages[27] = new Array('images/colombia.gif','Oficina de Representación, <BR>Calle 5A  43B-25 <BR> Edificio Meridian <BR> El Poblado -Medellín <BR>Colombia<BR>(57)  (4)  266 55 65 - Telephone<br>(57)  (4)  312  74 71  - Fax<br>E-mail - colombia@vinmar.com',"#ffffff");

////////////////////  END OF CUSTOMIZATION AREA  ///////////////////

// preload images that are to appear in tooltip
// from arrays above
if (document.images) {
	var theImgs = new Array();
	for (var i=0; i<messages.length; i++) {
  	theImgs[i] = new Image();
		theImgs[i].src = messages[i][0];
  }
}

// to layout image and text, 2-row table, image centered in top cell
// these go in var tip in doTooltip function
// startStr goes before image, midStr goes between image and text
var startStr = '<table width="' + tipWidth + '"><tr><td align="left" width="100%"><img src="';
var midStr = '" border="0"></td></tr><tr><td valign="top">';
var endStr = '</td></tr></table>';

////////////////////////////////////////////////////////////
//  initTip	- initialization for tooltip.
//		Global variables for tooltip. 
//		Set styles for all but ns4. 
//		Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
var tooltip, tipcss;
function initTip() {
	if (nodyn) return;
	tooltip = (ns4)? document.tipDiv.document: (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
	tipcss = (ns4)? document.tipDiv: tooltip.style;
	if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
		tipcss.width = tipWidth+"px";
		tipcss.fontFamily = tipFontFamily;
		tipcss.fontSize = tipFontSize;
		tipcss.color = tipFontColor;
		tipcss.backgroundColor = tipBgColor;
		tipcss.borderColor = tipBorderColor;
		tipcss.borderWidth = tipBorderWidth+"px";
		tipcss.padding = tipPadding+"px";
		tipcss.borderStyle = tipBorderStyle;
	}
	if (tooltip&&tipFollowMouse) {
		if (ns4) document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = trackMouse;
	}
}

window.onload = initTip;

/////////////////////////////////////////////////
//  doTooltip function
//			Assembles content for tooltip and writes 
//			it to tipDiv
/////////////////////////////////////////////////
var t1,t2;	// for setTimeouts
var tipOn = false;	// check if over tooltip link
function doTooltip(evt,num) {
	if (!tooltip) return;
	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	tipOn = true;
	// set colors if included in messages array
	if (messages[num][2])	var curBgColor = messages[num][2];
	else curBgColor = tipBgColor;
	if (messages[num][3])	var curFontColor = messages[num][3];
	else curFontColor = tipFontColor;
	if (ns4) {
		var tip = '<table bgcolor="' + tipBorderColor + '" width="' + tipWidth + '" cellspacing="0" cellpadding="' + tipBorderWidth + '" border="0"><tr><td><table bgcolor="' + curBgColor + '" width="100%" cellspacing="0" cellpadding="' + tipPadding + '" border="0"><tr><td>'+ startStr + messages[num][0] + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr + '</td></tr></table></td></tr></table>';
		tooltip.write(tip);
		tooltip.close();
	} else if (ie4||ie5||ns5) {
		var tip = startStr + messages[num][0] + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr;
		tipcss.backgroundColor = curBgColor;
	 	tooltip.innerHTML = tip;
	}
	if (!tipFollowMouse) positionTip(evt);
	else t1=setTimeout("tipcss.visibility='visible'",100);
}

var mouseX, mouseY;
function trackMouse(evt) {
	mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
	mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
	if (tipOn) positionTip(evt);
}

/////////////////////////////////////////////////////////////
//  positionTip function
//		If tipFollowMouse set false, so trackMouse function
//		not being used, get position of mouseover event.
//		Calculations use mouseover event position, 
//		offset amounts and tooltip width to position
//		tooltip within window.
/////////////////////////////////////////////////////////////
function positionTip(evt) {
	if (!tipFollowMouse) {
		mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
		mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
	}
	// tooltip width and height
	var tpWd = (ns4)? tooltip.width: (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
	var tpHt = (ns4)? tooltip.height: (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
	// document area in view (subtract scrollbar width for ns)
	var winWd = (ns4||ns5)? window.innerWidth-20+window.pageXOffset: document.body.clientWidth+document.body.scrollLeft;
	var winHt = (ns4||ns5)? window.innerHeight-20+window.pageYOffset: document.body.clientHeight+document.body.scrollTop;
	// check mouse position against tip and window dimensions
	// and position the tooltip 
	if ((mouseX+offX+tpWd)>winWd) 
		tipcss.left = (ns4)? mouseX-(tpWd+offX): mouseX-(tpWd+offX)+"px";
	else tipcss.left = (ns4)? mouseX+offX: mouseX+offX+"px";
	if ((mouseY+offY+tpHt)>winHt) 
		tipcss.top = (ns4)? winHt-(tpHt+offY): winHt-(tpHt+offY)+"px";
	else tipcss.top = (ns4)? mouseY+offY: mouseY+offY+"px";
	if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
}

function hideTip() {
	if (!tooltip) return;
	t2=setTimeout("tipcss.visibility='hidden'",100);
	tipOn = false;
}

//-->