<?php $d = 0; // search depth;
while (!file_exists(str_repeat('../', $d) . 'wp-config.php')) if (++$d > 99) exit;
$wp_config = str_repeat('../', $d) . 'wp-config.php';
require_once($wp_config);
$url_base = get_bloginfo('template_directory');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Exclude Pages</title>
<style>
body {font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;font-size:12px;}
h2{display:block;font-size:1.5em;font-weight:bold;margin:.83em 0;}
h2{font:italic normal normal 24px/29px Georgia,"Times New Roman","Bitstream Charter",Times,serif;margin:0;padding:14px 15px 3px 0;line-height:35px;text-shadow:rgba(255,255,255,1) 0 1px 0;}
input{margin-right:9px;}
</style>
<script type="text/javascript"> var Shadowbox = window.parent.Shadowbox; </script>
<script type="text/javascript">
function checkstr(mystr){
  var outstr = ((mystr.charAt(mystr.length-1,1) == ",") ? mystr.substring(0,mystr.length-1) : mystr);
  return outstr;
}
function getpostsandpages() {
	var total="";
for(var i=0; i < document.postform.x.length; i++){
if(document.postform.x[i].checked) {
total += document.postform.x[i].value + ",";
}
}


finalvalue = checkstr(total);
parent.document.flexibilityoptions.flex_nav_exclude.value = finalvalue; 
Shadowbox.close();

}

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}

function checkboxes() {
	var setoptions = parent.document.flexibilityoptions.flex_nav_exclude.value;
	
	if (setoptions) {
	
	var splitpages = setoptions.split(",");
	
	var cbs = document.postform.elements["x"];
	

 for(var i=0; i < splitpages.length; i++)
    {
        document.getElementById(splitpages[i]).checked = true;
        
    }
	}

}
</script>
</head>

<body style="background-color:#fff;margin:20px;" onload="checkboxes();">
<?php
    $nonce=$_REQUEST['_wpnonce'];

    if (!wp_verify_nonce($nonce, 'fs_exclude') ) { echo 'You cannot access this page'; } else { ?>

<form name="postform">
<p>Choose the pages you wish to exclude from your navigation menu and click the 'Apply' button below. </p>
<input name="submit" type="submit" value="Apply" onclick="getpostsandpages();"/>
<p><input type="button" onclick="SetAllCheckBoxes('postform', 'x', true);" value="Check all">
&nbsp;&nbsp;
<input type="button" onclick="SetAllCheckBoxes('postform', 'x', false);" value="Uncheck all">
</p>
<table width="100%" border="0" cellpadding="10">
  <tr>
    <td><h2>Pages</h2></td>
  </tr>
  <tr>
    <td valign="top"><?php
$mypages = get_pages();

foreach($mypages as $mypage) {

setup_postdata($mypage);

echo'<input type="checkbox" id="' . $mypage->ID . '" name="x" value="' . $mypage->ID . '" />' . $mypage->post_title . '<br />';
}
?></td>
  </tr>
</table>


</form>
<?php } ?>
</body>
</html>