<!--
//document.onload = rnRotAndDroplist(); //with () parantheses for ie/mozilla
//document.onmousedown = toggleDroplist; //without () parantheses for ie (will not work with parantheses)

var dlArray = new Array("dlForms", "dlRates", "dlTools", "dlLifestyle", "dbs_idealformsdropdown");

function rnRotAndDroplistNoBnr() {
	swapDroplist();
}

function rnRotAndDroplist() {
	//swapDroplist();
	bnrCycle(); //rotate rightnav banners
}

function detectBrowser() {
	if (document.childNodes && !document.all && !navigator.taintEnabled && !accentColorName) browser='saf';
	else if (navigator.product=='Gecko') browser='nn'; //nn6+, mozilla and other gecko
	else if (document.all) browser='ie';
	//browser='saf';
	return browser;
}
function swapDroplist() {

	if (detectBrowser()!='ie') return;
		
	var droplistImage_pleaseSelect = 'src="/img/sg/personal/common/droplist/droplist_pleaseselect.gif" alt=""';
	var droplistImage_applicationForms = 'src="/img/sg/personal/common/droplist/droplist_applicationforms.gif" alt=""';
	
	var droplistImageDimensions = ' width="117" height="17" border="0"';
		
	if (document.getElementById('dlFormsHolder')) document.getElementById('dlFormsHolder').innerHTML = '<img ' + droplistImage_pleaseSelect + droplistImageDimensions + ' id="dlForms" />';
	if (document.getElementById('dlRatesHolder')) document.getElementById('dlRatesHolder').innerHTML = '<img ' + droplistImage_pleaseSelect + droplistImageDimensions + ' id="dlRates" />';
	if (document.getElementById('dlToolsHolder')) document.getElementById('dlToolsHolder').innerHTML = '<img ' + droplistImage_pleaseSelect + droplistImageDimensions + ' id="dlTools" />';
	if (document.getElementById('dlLifestyleHolder')) document.getElementById('dlLifestyleHolder').innerHTML = '<img ' + droplistImage_pleaseSelect + droplistImageDimensions + ' id="dlLifestyle" />';
	if (document.getElementById('idealFormsDroplistHolder')) document.getElementById('idealFormsDroplistHolder').innerHTML = '<img ' + droplistImage_applicationForms + droplistImageDimensions + ' id="dbs_idealformsdropdown" />';
}
function toggleDroplist(e) {
	if (detectBrowser()!='ie') return;
	/*alert(e.target.id);
	var trg;
	//var e = window.event;
	if (e.target) trg = e.target;
	else if (e.srcElement) trg = e.srcElement;
	if (trg.nodeType == 3) // defeat Safari bug
		trg = trg.parentNode;
	var imgId = trg.id;
	*/
		
		
	var imgId = window.event.srcElement.id; //find the id of the item the user clicked on

	if (!getDroplistImage(imgId)) { //if the item clicked on is not a drop list img
		hideAllDroplist();		
		return;
	}
	else {
		var dropListId = imgId+'Lyr';
		hideAllDroplist(dropListId); //hide all drop lists except the one clicked on
		
		//get absolute position of dropdownlist image
		var selectedPosX = 0, selectedPosY = 0;
		var el = document.getElementById(imgId);
		while(el != null){
			selectedPosX += el.offsetLeft;
			selectedPosY += el.offsetTop;
			el = el.offsetParent;
		}
		//set position and visibility of iframe
		var lyr = document.getElementById(dropListId);
		lyr.style.left=selectedPosX;
		lyr.style.top=selectedPosY+17;
		lyr.style.visibility = (lyr.style.visibility=='hidden') ? 'visible':'hidden'; //toggle layer visibility
	}
}
//checks for a match on drop list img id, returns false if not found
function getDroplistImage(imgId) {
	for (var i=0; i<dlArray.length; i++) {
		if (dlArray[i]==imgId) return true;
	}
	return false;
}
//hides all drop down lists except 'exception', if any
function hideAllDroplist(exception) {
	//var aryLyr = new Array('dlFormsLyr', 'dlRatesLyr', 'dlToolsLyr' ,'dlLifestyleLyr', 'dbs_idealformsdropdownlyr');
	for (var i=0; i<dlArray.length; i++) {
		var dlLyr = dlArray[i] + "Lyr";
		if (document.getElementById(dlLyr))
			if (dlLyr!=exception) document.getElementById(dlLyr).style.visibility='hidden';
	}
}
function jumpToIframe(url,target) {
	if (target=='_blank') window.open(url,''); //if menu elm has target="_blank"
	else parent.location=url;
}
document.onmousedown = toggleDroplist;
//-->
