	
    /* Function DisplaySwitch ver 1.0
	/* Author James Dalgarno
    /* Uses id to show or hide based on toggle switch */
	function DisplaySwitch(id){
        var DisplayElement = document.getElementById(id);
        var ControlElement = document.getElementById(id + '_ctrl'); // Generate reference to control image id
				
        if(DisplayElement.style.display == 'none'){ // If style is none then block style
			DisplayElement.style.display = 'block';
			ControlElement.src = 'Graphix/doc_ctrl_sign_block.png';
		}		
        else{ // Else handle style as block and set as none
			DisplayElement.style.display = 'none';
			ControlElement.src = 'Graphix/doc_ctrl_sign_none.png';
		}
	} 

	/* Function DisplayToggle ver 1.0
	/* Author James Dalgarno
    /* Uses id to show and hides others in same id group */
	function DisplayToggle(parent,group,id){
        var DisplayElement = document.getElementById(group + '_' + id);
        var ControlElement = document.getElementById(id + '_ctrl'); // Generate reference to control image id	
		var GroupIDLen = group.length;
		var DivArray = document.getElementById(parent).getElementsByTagName('div');
		
		for(var i = 0; i < DivArray.length; i ++){
			if(DivArray[i].id.substr(0,GroupIDLen) == group){
				DivArray[i].style.display = 'none';
				var ButtonID = DivArray[i].id.substr(GroupIDLen + 1); //always 1 greater to strip leading underscore
				document.getElementById(ButtonID + '_ctrl').src = 'Graphix/doc_ctrl_sign_none.png';	
			}
		}
		DisplayElement.style.display = 'block';
		ControlElement.src = "Graphix/doc_ctrl_sign_block.png";
	}

	/* Function DisplaySubMenu ver 1.0
	/* Author James Dalgarno
    /* Toggle control with group hide */	
	function DisplaySubMenu(parent,id){
        var DisplayElement = document.getElementById(id);
  	
		var DivArray = document.getElementById(parent).getElementsByTagName('div');
		
		for(var i = 0; i < DivArray.length; i ++){
			if(DivArray[i].id.substr(0,3) == 'Sub'){
				if(DivArray[i].id != id){
					DivArray[i].style.display = 'none';
				}
			}
		}
		
		if(DisplayElement.style.display == 'block'){
			DisplayElement.style.display = 'none';
		}
		else DisplayElement.style.display = 'block';
	}
	
	function generic_showhide(id)
	{
        var DisplayElement = document.getElementById(id);
				
        if(DisplayElement.style.display == 'none' || DisplayElement.style.display == ''){ // If style is none then block style
			DisplayElement.style.display = 'block';
		}		
        else{ // Else handle style as block and set as none
			DisplayElement.style.display = 'none';
		}		
	}
	
	/* Function MenuPop ver 1.0
	/* Author James Dalgarno
    /* Simple pop data into form elements */	
	function MenuPop(Index,mLabel,Type,LinkRef,RecType)
	{
		document.getElementById('index').value = Index;
		document.getElementById('mlabel').value = mLabel;
		document.getElementById('Record').value = RecType;
		
		var PageDropBox = document.getElementById('linkref');
		
        //loop through to id LinkRef index and apply as preselected
		for(var i = 0; i < PageDropBox.options.length; i ++){
            if(PageDropBox.options[i].value == LinkRef){
                PageDropBox.selectedIndex = i;   
            }
		}
		//radio checkbox (referencing the form name directly)
        if(document.menu_admin.type[0].value == Type) document.menu_admin.type[0].checked = true; 
        else if(document.menu_admin.type[1].value == Type) document.menu_admin.type[1].checked = true;
		
		document.getElementById('Modify_MenuItem').style.display = "block";
		document.getElementById('Modify_SubMenuItem').style.display = "none";		
		
    }
    function SubMenuPop(Index,MemberOf,mLabel,LinkRef,RecType)
    {
 		document.getElementById('index').value = Index;
		document.getElementById('mlabel').value = mLabel;
		document.getElementById('member_of').value = MemberOf;
		document.getElementById('Record').value = RecType;
		
		var PageDropBox = document.getElementById('linkref');
		
        //loop through to id LinkRef index and apply as preselected
		for(var i = 0; i < PageDropBox.options.length; i ++){
            if(PageDropBox.options[i].value == LinkRef){
                PageDropBox.selectedIndex = i;   
            }
		}
		document.getElementById('Modify_MenuItem').style.display = "none";
		document.getElementById('Modify_SubMenuItem').style.display = "block";		       
    }
	
	function SelectFile(SFile,SID)
	{
		document.getElementById('selected_file').value = SFile
		document.getElementById('selected_file_text').innerHTML = SFile
		
		var AllDivs = document.getElementsByTagName('div')
    	for(var i in AllDivs){
        	if(AllDivs[i].id != "" && AllDivs[i].id != null){
            	if(AllDivs[i].id.indexOf('fid') >= 0){ 
                	AllDivs[i].style.backgroundColor = "#FFFFFF";
					//alert(AllDivs[i].id);
				}//else alert(AllDivs[i].id.indexOf('fid'));
        	}
    	}
		
		document.getElementById(SID).style.backgroundColor = "#D2BEEF";		
	}

	function SelectFile_confirm_delete(){
		var users_file = document.getElementById('selected_file').value;
		var user_confirmation = confirm('Are you sure you wish to delete the file \''+users_file+'\'?');
		if(user_confirmation) return true;
		else return false;
	}
	
	function Generic_confirm_delete(){
		var user_confirmation = confirm('Are you sure you wish to delete?');
		if(user_confirmation) return true;
		else return false;
	}
	
	function nav_switch(Element,state)
	{
		Element.src = "/main/assets/graphix/nav_" + Element.id + "_o" + state + ".png";
	}

	function PrepareInt(StrInt)
	{
		StrInt = parseInt(StrInt,10);
		if(isNaN(StrInt))StrInt = 0;
		return(StrInt);
	}
	
	
	function showtooltip(event,id)
	{

		if(document.getElementById(id).style.width)	document.getElementById('tooltip').style.width = document.getElementById(id).style.width;
		else document.getElementById('tooltip').style.width = '300px' //default

		document.getElementById('tooltip_content').style.width = (PrepareInt(document.getElementById('tooltip').style.width) - 11) + 'px';
		document.getElementById('tooltip_content').innerHTML = document.getElementById(id).innerHTML;
		document.getElementById('tooltip').style.display = 'block';
		document.getElementById('tooltip').style.left = event.clientX + 'px';
		document.getElementById('tooltip').style.top = event.clientY - PrepareInt(document.getElementById('tooltip').offsetHeight) - 5 + 'px';
	
		if(IDBrowser != "IE"){
		document.addEventListener("mousemove", MoveToolTip, true);
		document.addEventListener("mouseout",HideToolTip, true);
		}
		else{
		document.attachEvent("onmousemove", MoveToolTip);
		document.attachEvent("onmouseout", HideToolTip);
		}
	}

	function MoveToolTip(event)
	{
		document.getElementById('tooltip').style.left = event.clientX + MeasureScroller('x') + 'px';
		document.getElementById('tooltip').style.top = event.clientY - PrepareInt(document.getElementById('tooltip').offsetHeight) - 2 + MeasureScroller('y') + 'px';
	}
	
	function HideToolTip(event)
	{
		document.getElementById('tooltip').style.display = 'none';
		if(IDBrowser != "IE"){
		document.removeEventListener("onmousemove", showtooltip, true);
		document.removeEventListener("mouseout", HideToolTip, true);
		}
		else{
		document.detachEvent("onmousemove", showtooltip);
		document.detachEvent("onmouseout", HideToolTip);
		}
	}
	
	function MeasureScroller(Axis)
	{
		if(IDBrowser != "IE"){
			if(Axis == "x") return(window.pageXOffset-5);
			if(Axis == "y") return(window.pageYOffset-5);
		}else{
			if(Axis == "x") return(document.documentElement.scrollLeft-5);
			if(Axis == "y") return(document.documentElement.scrollTop-5);
		}
	}
	
	function init_ToolTip()
	{
		var tooltip_code = '\n';
		tooltip_code += " <div id='tooltip' style='width:300px;'>\n";
		tooltip_code += "  <div class='tooltip_container'>\n";
		tooltip_code += "   <div id='tooltip_content'></div><br style='clear:both;'>\n";
		tooltip_code += "  </div>\n";
		tooltip_code += " </div>\n";
		document.body.innerHTML = tooltip_code + document.body.innerHTML;
	}
	
	function jump_drop(obj)
	{
		window.location = obj.options[obj.selectedIndex].value;
	}	

