// JavaScript Document to help hide/show div forms
// Used in content pages form and nav
function ShowMenu(num, menu, max)
        {
                //starting at one, loop through until the number chosen by the user
                for(i = 1; i <= num; i++){
                        //add number onto end of menu
                        var menu2 = menu + i;
                        //change visibility to block, or 'visible'
                        document.getElementById(menu2).style.display = 'block';
                }
                //make a number one more than the number inputed
                var num2 = num;
                num2++;
                //hide it if the viewer selects a number lower
                //this will hide every number between the selected number and the maximum
                //ex.  if 3 is selected, hide the <div> cells for 4, 5, and 6
                //loop until max is reached
                while(num2 <= max){
                        var menu3 = menu + num2;
                        //hide 
                        document.getElementById(menu3).style.display = 'none';
                        //add one to loop
                        num2=num2+1;
                }
    }
    
function nav_toggle(cat_id, cat_status) { 
	if(cat_id) {
		document.content_form.nav_cat_status.value = cat_status;
		document.content_form.nav_id.value = cat_id;
		document.content_form.action.value = 'manage_nav';
		document.content_form.command.value = 'toggle_cat_status';
		document.content_form.submit();
	}		
}

function content_add_new_nav(nav_name) { 
	var new_content_nav_name = window.prompt("Add new Navigation:");
	if(new_content_nav_name) {
		document.content_form.nav_label.value = new_content_nav_name;
		document.content_form.nav_level.value = 0;
		document.content_form.nav_type.value = 0;
		document.content_form.action.value = 'add_new_nav';		
		document.content_form.submit();
	}		
}

function content_update_nav(nav_id, nav_name) { 
	var new_content_nav_name = window.prompt("Rename Navigation\n\n - "+nav_name+"\n\nto:");
	if(new_content_nav_name) {		
		document.content_form.nav_label.value = new_content_nav_name;
		document.content_form.nav_id.value = nav_id;
		document.content_form.action.value = 'update_nav';		
		document.content_form.submit();
	}
}


function content_remove_nav(nav_id, nav_label, nav_children) { 	
	if(nav_children == 0) {
		if(confirm("Are you sure you want to PERMANENTLY delete this navigation item:\n\n - "+nav_label)) {
			document.content_form.nav_id.value = nav_id;	
			document.content_form.parent_id.value = 0;
			document.content_form.action.value = 'delete_nav';			
			document.content_form.submit();
		}
	}else{
		alert("You can only delete navigation items that have no content pages under them.\n\nRemove all content pages from this navigation item then remove it.");
	}
}

function yes() {
					eval(pre + 'linkinput1' + post).visibility='visible';
					eval(pre + 'linklabel1' + post).visibility='visible';
					eval(pre + 'linkinput1' + post).display='block'; 
					eval(pre + 'linklabel1' + post).display='block';
					eval(pre + 'linkinput2' + post).visibility='hidden';
					eval(pre + 'linklabel2' + post).visibility='hidden';
					eval(pre + 'linkinput2' + post).display='none';
					eval(pre + 'linklabel2' + post).display='none';
				}
				
function no() {
					eval(pre + 'linkinput1' + post).visibility='hidden';
					eval(pre + 'linklabel1' + post).visibility='hidden';
					eval(pre + 'linkinput1' + post).display='none';
					eval(pre + 'linklabel1' + post).display='none';
					eval(pre + 'linkinput2' + post).visibility='visible';
					eval(pre + 'linklabel2' + post).visibility='visible';
					eval(pre + 'linkinput2' + post).display='block';
					eval(pre + 'linklabel2' + post).display='block';
				}

// message information about uploading an image
function image_alert(alert_msg) { 

	alert("Now that you have selected an image to upload, simply type "+alert_msg+" \n\nin the page content box below where you want the this image to appear.");
	


}
				
// a links function

function open_link_preview() { 
			
		url = document.links.link_url.value;
		
		if(!url) { alert("You need to enter a link to test first!"); }
			else { window.open('http://'+url); }

}
