function checklists() {

	var showalert = 0;
	var list1 = document.getElementById('number_1').value;
	var list2 = document.getElementById('number_2').value;
	var list3 = document.getElementById('number_3').value;
	var list4 = document.getElementById('number_4').value;
	var list5 = document.getElementById('number_5').value;

	var msg = "please choose 5 different numbers";
	
	if (list1 == list2 || list1 == list3 || list1 == list4 || list1 == list5) {
		showalert = 1;
	}
	
	if (list2 == list3 || list2 == list4 || list2 == list5) {
		showalert = 1;
	}
	
	if (list3 == list4 || list3 == list5) {
		showalert = 1;
	}
	
	if (list4 == list5) {
		showalert = 1;
	}
	
	if (showalert == 1) {
		alert(msg);
		return false;
	} else {
		return true;
	}

}


function slideSwap(e) {
	
	var element;
	
	// cross browser method of finding out who is calling this function
	// this is the IE way
	if (window.event && window.event.srcElement) {
		element = window.event.srcElement;
	}
	if (e && e.target) {
		element = e.target;
	}
	
	// make sure we get an anchor tag
	while (element != document.body && element.nodeName.toLowerCase() != 'a') {
		element = element.parentNode;
	}
	
	// get the value of the element
	//var src = element.src;
	// change the src of the main image
	//var mainImage = document.getElementById("imagePlaceholder");
	//mainImage.src = src;
	
	// get the id of the div to toggle (found in the rel attribute of the anchor)
	var toggleDiv = element.getAttribute("rel");
	//alert(toggleDiv);
	
	var toggleDivs = new Array('slide_1', 'slide_2', 'slide_3', 'slide_4', 'slide_5');
	for (var i = 0; i < toggleDivs.length; i++) {
		
		var tempToggleDiv = toggleDivs[i];
		if (document.getElementById(tempToggleDiv)) {
			//alert(element);
			if (tempToggleDiv == toggleDiv) {
				document.getElementById(tempToggleDiv).style.display = '';
			} else {
				document.getElementById(tempToggleDiv).style.display = 'none';
			}
		}
	}
	
	// turn off all borders first
	var image_anchors = document.getElementById("slide_selector").getElementsByTagName("a");
	for (var i = 0; i < image_anchors.length; i++) {
		var anchor = image_anchors[i];
		// unhighlight all other anchors
		anchor.className = anchor.className.replace(/\b ?selected\b/,'');
	}
	
	// highlight clicked anchor
	element.className += 'selected';
	
	// cancel default anchor link
	if (window.event) {
		window.event.returnValue = false;
	} else {
		e.preventDefault();
	}
}

function ini_slideSwap() {	
	if (document.getElementById) {
		if (document.getElementById("slide_selector")) {
			var anchors = document.getElementById("slide_selector").getElementsByTagName("a");
			for (var i = 0; i < anchors.length; i++) {
				var element = anchors[i];
				addEvent(element, 'click', slideSwap, false);
				element.onclick = cancelClick; // for the benefit of Safari
			}
		}
	}	
}


function ini_uRLJumperSelect() {
	// get all select elements with the class 'url_jump_select'
	var selects = getElementsByClass('url_jump_select', document, 'SELECT');
	// loop through, add event on change
	for (var i = 0; i < selects.length; i++) {
		selectElement = selects[i];
		// attach onclick function
		addEvent(selectElement, 'change', urlJumpSelect, false);
	}	
}

function urlJumpSelect(e) {
	// find the target
	var target = findTarget(e);
	var path = target.value;
	if (path.length > 0) {
		document.location.href = path;
	}
}

function ini_radiosAndCheckboxes() {
	// get all select elements with the class 'url_jump_select'
	var inputs = document.getElementsByTagName('INPUT');
	// loop through, add class 'radio' if they are a radio or checkbox
	for (var i = 0; i < inputs.length; i++) {
		inputElement = inputs[i];
		if (inputElement.getAttribute('type') == 'checkbox' || inputElement.getAttribute('type') == 'radio') {
			// add class
			inputElement.className += ' radio';
		}
	}	
}

function toggleList(e) {
	
	// get a reference to the anchor and it's parentNode (the <li> element)
	if (window.event) {
		// IE does it differently... stores the event in a window.event object
		var thisA = window.event.srcElement;
		//alert(thisA);
		var thisLI = thisA.parentNode;
	} else {
		var thisA = this;
		var thisLI = this.parentNode;
	}
	// if this li has nested ul elements...
	if (thisLI.getElementsByTagName('ul').length > 0) {
		
		var toggleListTarget = thisLI.getElementsByTagName('ul')[0];
		//...toggle visibility of first ul
		if (toggleListTarget.style.display != 'none' ) {
			toggleListTarget.style.display = 'none';
			//thisA.style.color = '';
			thisA.style.backgroundImage = 'url(../images/arrowright.gif)';
			//closeListArrow();
		} else {
			toggleListTarget.style.display = '';
			//thisA.style.color = 'white';
			thisA.style.backgroundImage = 'url(../images/arrowdown.gif)';
			//expandListArrow();
		}
		// cancel bubble and href of this anchor
		cancelClick(e);
		// hack for Safari (stops browser following href link)
		thisA.onclick = function() { return false; }
	}
}

function ini_collapsingList() {

	// find the toggle list
	var lists = getElementsByClass('collapsible_list', document, 'ul');
	
	for (var x = 0; x < lists.length; x++) {
		//list = document.getElementById('collapsingList');
		list = lists[x];
		// find all it's child UL elements
		var childLists = list.getElementsByTagName('ul');
		// hide them all
		for (var i = 0; i < childLists.length; i++) {
			var childList = childLists[i];
			childList.style.display = 'none';
		}
		
		// attach toggleList function to onclick of each anchor
		var childAnchors = list.getElementsByTagName('a');
		// hide them all
		for (var i = 0; i < childAnchors.length; i++) {
			var childAnchor = childAnchors[i];
			// attach toggleList function to onclick of each anchor
			addEvent(childAnchor, 'click', toggleList, false);
		}
	}
}

function tabPanel(e) {
	var target = findTarget(e);
	var keyword = target.getAttribute('rel');
	var activeTabPanelID = 'tab_panel_' + keyword;
	
	var tabPanelGroup = findParent(target, 'tab_panel_group');
	
	// get all tab panels
	var tabPanels = getElementsByClass('tab_panel', tabPanelGroup);
	for (var i = 0; i < tabPanels.length; i++) {
		tabPanel = tabPanels[i];
		// hide all
		tabPanel.style.display = 'none';
	}
	
	if (document.getElementById(activeTabPanelID)) {
		document.getElementById(activeTabPanelID).style.display = '';
	}
	
	// remove class from other anchors in same group
	var anchors = tabPanelGroup.getElementsByTagName('a');
	for (var k = 0; k < anchors.length; k++) {
		var anchor = anchors[k];
		anchor.className = anchor.className.replace(/\b ?selected\b/,'');
	}
	
	// add class to anchor
	target.className += 'selected';
	
}

function ini_tabPanel() {
	// add click event to all links in tab_panel_group element
	var groups = getElementsByClass('tab_panel_group', document, 'DIV');
	for (var i = 0; i < groups.length; i++) {
		var group = groups[i];
		var lists = group.getElementsByTagName('ul');
		for (var j = 0; j < lists.length; j++) {
			var list = lists[j];
			// get the anchors
			var anchors = list.getElementsByTagName('a');
			// attach toggleList function to onclick of each anchor
			for (var k = 0; k < anchors.length; k++) {
				var anchor = anchors[k];
				addEvent(anchor, 'click', tabPanel, false);
			}
		}
	}
}

function toggle(key) {

	var toggleContentElm = 'toggled_content_' + key;
	var toggleContentButtonElm = 'toggled_button_' + key;
	
	if (document.getElementById(toggleContentElm) && document.getElementById(toggleContentButtonElm)) {
	
		var toggleContent = document.getElementById(toggleContentElm);
		var toggleContentButton = document.getElementById(toggleContentButtonElm);
		
		if (toggleContent.style.display == 'none') {
			toggleContent.style.display = '';
			toggleContentButton.style.backgroundImage = 'url(../images/arrow_down.png)';
		} else {
			toggleContent.style.display = 'none';
			toggleContentButton.style.backgroundImage = 'url(../images/arrow_right.png)';
		}
	}
}

function showToggledContent() {
	var hash = document.location.hash;
	if (hash.length > 0) {
		hash = hash.replace(/#/i, ''); // remove the # from the hash
		toggle(hash);
	}
}

addLoadEvent(ini_uRLJumperSelect);
addLoadEvent(ini_radiosAndCheckboxes);
addLoadEvent(ini_collapsingList);
addLoadEvent(ini_slideSwap);
addLoadEvent(ini_tabPanel);
addLoadEvent(showToggledContent);