/*
Steve's - lets reinvent the wheel - drop down boxes

The list box item is build from two DIV containers, the first is the faux select box and is always visible. 
The second is a floated DIV that emulates the select box items.
*/

//this contains the active menu name (0) and whether the cursor is inside or outside the container
var _Active_Menu = new Array("","");

//Set the default values for the drop boxes when the page is loaded
function init() {
	Update_Selected('selectBox1', 'I am');
	Update_Selected('selectBox2', 'I want');
}

//value1 is the name of the menu to make active, value2 is true/false depending 
//on whether you're switching the menu on or off
function Activate_Menu(value, value2) {
	_Active_Menu[0] = value;
	_Active_Menu[1] = value2;
}

//Checks the current visibility, and if the menu is no longer active closes the drop box
function Evaluate_Menu_Visibility(value) {
	if(findPos(document.getElementById(_Active_Menu[0]))[0] > 0 && _Active_Menu[1] == false) {
		document.getElementById(_Active_Menu[0]).style.top = '-200px';
		document.getElementById(_Active_Menu[0]).style.left = '-200px';
	}
}

//Opens and closes the drop box
function Switch_Menu(value) {
	if(findPos(document.getElementById(_Active_Menu[0]))[0] <= 0) {
		document.getElementById(_Active_Menu[0]).style.top = findPos(document.getElementById(value))[1] + 22 + 'px';
		document.getElementById(_Active_Menu[0]).style.left = findPos(document.getElementById(value))[0] + 'px';
	} else {
		document.getElementById(_Active_Menu[0]).style.top = '-200px';
		document.getElementById(_Active_Menu[0]).style.left = '-200px';
	}
}

//Displays the currently selected item in the select box
function Update_Selected(id, value) {
	document.getElementById(id).innerHTML = '<p align="left" valign="top" style="padding: 0; margin: 0; padding-top: 2px; padding-left: 2px;">' + value.substring(0, 17) + '...</p>';
}

//Controls the button on the right of the drop box, swaps image on button press
function Drop_Image_Swap(value, isOn) {
	if(isOn) {
		document.getElementById(value).style.backgroundImage = 'url(content/!RL06_SYSTEM/images/buttons/button-over.gif)';
	} else {
		document.getElementById(value).style.backgroundImage = 'url(content/!RL06_SYSTEM/images/buttons/button.gif)';
	}
}

//Creates the options in the drop box
function Create_ListItem_Link(theList, text, value) {
	var listItem = document.createElement('li');
	var anchorTag = document.createElement('a');
	
	var anchorHref = document.createAttribute('href');
	anchorHref.nodeValue = value;
	anchorTag.appendChild(document.createTextNode(text));
	anchorTag.setAttributeNode(anchorHref);
	listItem.appendChild(anchorTag);
	theList.appendChild(listItem);
}

//Removes all the items in the specified list
function Clear_List(value) {
	document.getElementById(value).innerHTML = '';
}

//Finds the absolute position of the given object
function findPos(obj) {
	var curleft = curtop = 0;
	if(obj) {
		if (obj.offsetParent) {
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) {
				   curleft += obj.offsetLeft
				   curtop += obj.offsetTop
			}
		}
		return [curleft,curtop];
	} else {
		return [0,0];
	}
}

//Generates a dynamic navigation
function Generate_Navigation(value) {
	var list = document.getElementById('iWant');
	Clear_List('iWant');
	Create_ListItem_Link(list, "I want...", "");
	Update_Selected('selectBox2', 'I want');
	
	if(value == 1) {
		Create_ListItem_Link(list, "To make a claim", "/default.asp?docId=15151");
		Create_ListItem_Link(list, "To change my details", "/default.asp?docId=14943");
		Create_ListItem_Link(list, "To increase my cover", "/default.asp?docId=14943");
		Create_ListItem_Link(list, "To reduce my cover", "/default.asp?docId=14943");
		Create_ListItem_Link(list, "To cancel my cover", "/default.asp?docId=14943");  
		Create_ListItem_Link(list, "To find an IFA", "/default.asp?docId=15152");    		     
	} else if(value == 2) {
		Create_ListItem_Link(list, "To make a claim", "/default.asp?docId=15154");
		Create_ListItem_Link(list, "To change my details", "/default.asp?docId=15154");
		Create_ListItem_Link(list, "To increase my cover", "/default.asp?docId=15154");
		Create_ListItem_Link(list, "To reduce my cover", "/default.asp?docId=15154");
		Create_ListItem_Link(list, "To cancel my cover", "/default.asp?docId=15154");  
		Create_ListItem_Link(list, "To find an IFA", "/default.asp?docId=15152");   
	} else if(value == 3) {
		Create_ListItem_Link(list, "To set up a new agency with you", "/default.asp?docId=14985");
		Create_ListItem_Link(list, "A life cover quote", "/default.asp?docId=15218");
		Create_ListItem_Link(list, "A life and critical illness quote", "/default.asp?docId=15218");
		Create_ListItem_Link(list, "An income protection quote", "/default.asp?docId=15218");
		Create_ListItem_Link(list, "A data capture form (all benefits)", "/default.asp?docId=15086");  
		Create_ListItem_Link(list, "A data capture form (LTA, DTA, FIB & WOP)", "/default.asp?docId=15086");    
		Create_ListItem_Link(list, "A key facts document (all benefits)", "/default.asp?docId=15086");    
		Create_ListItem_Link(list, "A key facts document (LTA, DTA, FIB & WOP)", "/default.asp?docId=15086");
		Create_ListItem_Link(list, "More details of your products", "/default.asp?docId=14742");
		Create_ListItem_Link(list, "More details of your underwriting processes", "/default.asp?docId=15078");
		Create_ListItem_Link(list, "To speak to my local relationship manager", "/default.asp?docId=14847");
		Create_ListItem_Link(list, "To contact you with a specific request not listed here", "/default.asp?docId=14943"); 
	} else if(value == 4) {
		Create_ListItem_Link(list, "A life cover quote", "http://www.ifaprogress.com");
		Create_ListItem_Link(list, "A life and critical illness quote", "http://www.ifaprogress.com");
		Create_ListItem_Link(list, "An income protection quote", "http://www.ifaprogress.com");
		Create_ListItem_Link(list, "A data capture form (all benefits)", "/default.asp?docId=15086");  
		Create_ListItem_Link(list, "A data capture form (LTA, DTA, FIB & WOP)", "/default.asp?docId=15086");      
		Create_ListItem_Link(list, "A key facts document (all benefits)", "/default.asp?docId=15086");
		Create_ListItem_Link(list, "A key facts document (LTA, DTA, FIB & WOP)", "/default.asp?docId=15086");
		Create_ListItem_Link(list, "More details of your products", "/default.asp?docId=14742");      
		Create_ListItem_Link(list, "More details of your underwriting processes", "/default.asp?docId=15078");
		Create_ListItem_Link(list, "A new extranet ID & password, we've lost the original", "/default.asp?docId=14943");       
		Create_ListItem_Link(list, "Details of the latest regulatory changes", "/default.asp?docId=14911");          
		Create_ListItem_Link(list, "To speak to my local relationship manager", "/default.asp?docId=14847");    
		Create_ListItem_Link(list, "To contact you with a specific request not listed here", "/default.asp?docId=14943");    
	} else if(value == 5) {
		Create_ListItem_Link(list, "A life cover quote", "http://www.ifaprogress.com");
		Create_ListItem_Link(list, "A life and critical illness quote", "http://www.ifaprogress.com");
		Create_ListItem_Link(list, "An income protection quote", "http://www.ifaprogress.com");
		Create_ListItem_Link(list, "A data capture form (all benefits)", "/default.asp?docId=15086");  
		Create_ListItem_Link(list, "A data capture form (LTA, DTA, FIB & WOP)", "/default.asp?docId=15086");      
		Create_ListItem_Link(list, "A key facts document (all benefits)", "/default.asp?docId=15086");
		Create_ListItem_Link(list, "A key facts document (LTA, DTA, FIB & WOP)", "/default.asp?docId=15086");
		Create_ListItem_Link(list, "More details of your products", "/default.asp?docId=14742");      
		Create_ListItem_Link(list, "More details of your underwriting processes", "/default.asp?docId=15078");
		Create_ListItem_Link(list, "A new extranet ID & password, we've lost the original", "/default.asp?docId=14943");      
		Create_ListItem_Link(list, "Details of the latest regulatory changes", "/default.asp?docId=14911");          
		Create_ListItem_Link(list, "To speak to my local relationship manager", "/default.asp?docId=14847");    
		Create_ListItem_Link(list, "To contact you with a specific request not listed here", "/default.asp?docId=14943");    
	} else if(value == 6) {
		Create_ListItem_Link(list, "Details of your products", "/default.asp?docId=14742");
		Create_ListItem_Link(list, "Details of your underwriting processes", "/default.asp?docId=15078");
		Create_ListItem_Link(list, "Details of the latest regulatory changes", "/default.asp?docId=14911");
		Create_ListItem_Link(list, "To speak to my relationship manager", "/default.asp?docId=14847");      
		Create_ListItem_Link(list, "To contact you with a specific request not listed here", "/default.asp?docId=14943");    
	} else if(value == 7) {
		Create_ListItem_Link(list, "To see your latest press release", "/default.asp?docId=14848");
		Create_ListItem_Link(list, "To contact Mike Warr (The Boss)", "/default.asp?docId=14953");
		Create_ListItem_Link(list, "To contact Mike Farrell (Distribution & Marketing)", "/default.asp?docId=14953");
		Create_ListItem_Link(list, "To download photo's/logo's/imagery", "/default.asp?docId=14953");  
	} else if(value == 8) {
		Create_ListItem_Link(list, "To visit the virtual company secure site for employees (private)", "/default.asp?docId=15053");
		Create_ListItem_Link(list, "To access the progress online brand bible (private)", "/default.asp?docId=15053");
		Create_ListItem_Link(list, "To see our latest press releases", "/default.asp?docId=14848");
		Create_ListItem_Link(list, "To download or email literature", "/default.asp?docId=15086");  
		Create_ListItem_Link(list, "To see what's happening in the marketplace (private)", "/default.asp?docId=15053");      
		Create_ListItem_Link(list, "To use the sales toolkit (private)", "/default.asp?docId=15053");    
	}
}










