/*  
Theme Name: MistyLook
Theme URI: http://wpthemes.info
Description: A real clean WordPress Theme by <a href="http://wpthemes.info" title="Sadish">Sadish Bala</a>. Support is available at <a href="http://wprocks.com/forums/" title="Forums">Forums</a>.
Version: 3.7.2
Author: Sadish
Author URI: http://wprocks.com
Tags: fixed width, two columns, widgets, custom image header, Sadish
*/
* {
	padding: 0; 
	margin:0;
}
p {
	margin: 0.7em 0;
	line-height:1.8em;
}
dl {
	margin:1em 0;
}
dt 
{
	font-weight:bold;
}
dd 
{
	margin:0.5em;
	padding:0;
}
img 
{
	background:url(img/shadow.gif) no-repeat right bottom;
	padding:4px 10px 10px 4px;	
	border:0;
	border-top:#eee 1px solid;
	border-left:#eee 1px solid;	
}
img.right {
	float: right;
	margin:10px 0 0 10px;		
}
img.left {
	float: left; 
	margin:0 10px 10px 0;	
}
a:link img,
a:visited img,
a:hover img,
a:active img {
	border:none;
	background:none;
	padding:none;
	background:url(img/shadow.gif) no-repeat right bottom;
	padding:4px 10px 10px 4px;	
	border-top:#eee 1px solid;
	border-left:#eee 1px solid;		
}
img.wp-smiley, #wpstats, img.noborder, a img.noborder {
	background: none;
	border: 0;
	padding: 0;
}
.clear {
	clear:both;
	height:20px;
}
blockquote
{
	color:#666;
	margin: 1em;
	padding: 0 0 10px 50px;
	background: url(img/blockquote.gif) no-repeat left top;	
}
fieldset 
{
	border:0;
}
body 
{
	background: #03497e;
	margin: 0; 
	font: 76%/1.6em verdana, tahoma, arial,  sans-serif; 
	color: #333; 
	text-align: center;
}
a 
{
    text-decoration:none;
}
a:link, a:visited {
	color: #265e15;	
}
a:hover, a:active {
	border-bottom:#963 1px solid;
}
h1, h2, h3, h4, h5, h6 
{
	font-family:Georgia, Verdana, Arial, Serif;
}

#container {
	border: #ccc 1px solid; 
	background: #fff; 
	margin: 0 auto; 
	width: 780px; 	
	position: relative; 
	text-align: left;
}
#navigation {
	background: transparent; 
	margin: 20px auto 0; 
	overflow: hidden; 
	width: 760px; 
	position: relative; 
	text-align: left;
	font-family: Trebuchet MS,Tahoma, Verdana, Arial, Serif;
}
 html #navigation {
	height: 1%;
}
#navigation ul li {
	float: left; 
	margin: 0 5px 0 0; 
	list-style-type: none;
}
#navigation ul li a {
	border: #ccc 1px solid; 
	border-bottom:none;
	padding: 2px 12px; 
	display: block; 
	font-weight:bold;
	color:#333;		
	text-decoration: none;
	background:#dedede;
	letter-spacing:0px;
}
#navigation ul li a:hover, #navigation ul li a:active, #navigation ul li.current_page_item a {
	background: #fff;
	color: #333;	
	border: #ccc 1px solid; 
	border-bottom:none;		
}
#navigation ul li.search {
	font-size: 0.9em; 
	right: 0; 
	position: absolute; 
	top: 0;
}
#navigation ul li.search input#searchsubmit {
	border: #999 1px solid; 
	font-size: 0.9em; 
	background: #ddd; 
	margin: 0 0 0 2px; 
	color: #265e15; 
	padding: 2px; 		
}
#header {
	clear: both; 
	float: left; 
	margin: 10px 5px; 
	width: 500px;
}
#header h1 
{
	font-size:1.8em;
	margin:10px 0 0 10px;
	font-variant:small-caps;
	letter-spacing:0px;
	font-weight:normal;
}
#header h1 a {
	
	text-decoration:none;	
	border:0;
}
#header h1 a:hover,
#header h1 a:active {
	border-bottom:#963 1px solid;
}
#header #desc 
{
	margin:5px 0 0 10px;
	font-size:1em;
	font-weight:normal;
	font-family:Tahoma, Verdana, Arial, Serif;
	letter-spacing:0px;	
}
#feedarea {
	padding:10px 10px 0 0; 
	float: right; 	
	text-align: right;
}
html #feedarea {
	padding-top: 10px;
}
#feedarea dl dt {
	display: inline; 
	margin-right: 5px; 
	height: 45px;
}
#feedarea dl dd {
	display: inline; 
	margin-right: 5px; 
	height: 45px;
	background:url(img/icon_feed.gif) no-repeat left center;
	padding-left:16px;
}
#headerimage {
	clear: both; 
	background: #fff url(img/misty.jpg) no-repeat 0 0 center;
	margin: 10px; 
	color: #fff; 	
	height: 200px;
}
 html #headerimage {
	margin-top: 0;
}
#content {
	margin: 0 10px 0 30px;
}
 html #content {
	height: 1%;
}
#content h4 {
	font-size: 1.1em; 
	margin: 1em 0 0 0;
}
#content h5 {
	font-size: 1em; 
	margin: 1em 0;
}
#content-main ul 
{
    margin:0 1em;
    padding:0 1em;
    list-style-image:url(img/bullet.png);
}
#content-main ul.asides 
{
	margin:0;
	padding:2em;
	border-bottom:#ddd 1px dashed;
}
#content ol 
{
    list-style-type:decimal;
    margin:1em;
    padding-left:2em;
}
#content-main {
	float: left; 
	width: 520px; 
	margin-right: 20px;
}
 html #section-index #content-main {
	margin-right: 20px;
}
#content .post 
{
	clear:both;
	padding:0 0 2em 0;
	border-bottom:#dcc 1px dashed;
}
#content h2,
#content h3 
{
	font-size: 1.5em; 
	margin: 1em 0 0;	
	font-weight:normal;
	line-height:1.4em;	
	letter-spacing:0px;
}
#content .entry 
{
    clear:both;
    margin:1em 0;
    padding-right:1em;    
}
#content .entry a:link, #content .entry a:visited
{
    border-bottom:#963 1px dashed;    
}
#content .entry a:hover, #content .entry a:active
{
    border-bottom:#963 1px solid;    
}
#content .entry li 
{
	margin:0 0 0.3em 0;
	padding:0;
	line-height:1.6em;
}
#content .post-info , #content .postmetadata
{
	clear:both;
	font-size:0.9em;
	color:#999;
	margin:0;
	padding:0;	
}
#content .post-info, 
#content h2.pagetitle 
{
	background:url(img/underline1.jpg) no-repeat left bottom;
	padding-bottom:15px;	
}
.postnav {
	display: block;
	margin: 10px 0 60px;
	
}
.alignleft 
{
	float:left;
	text-align:left;	
}
.alignright
{
	float:right;
	text-align:right;	
}
/* Sidebar */
#sidebar {
	float: left; 
	width: 200px;
	font-size:0.9em;
}
#sidebar ul
{
	list-style:none;
	margin:0;
	padding:0;
}
#sidebar li 
{
	margin-bottom:8px;
}
#sidebar ul ul
{
	list-style:none;
	margin:0.5em 0 0 1em;
}
#sidebar ul ul ul
{
	margin:0 0 0 1em;
}
#sidebar li.sidebox {
	padding:1px 10px;
	margin:0 0 1em 0;
	background: #ededed url(img/sideheadtop.gif) no-repeat left top; 		
}
li#sidelinks ul
{
	margin:0;
	padding:0;
}
#sidebar li.sidebox p img {
	margin:0;
	padding:3px;
	border:#ccc 1px solid;
	background:none;
}

#footer {
	clear: both; 	
	background: transparent; 
	margin: 0 auto; 
	width: 760px; 	
	text-align: left;
}
 html #footer {
	height: 1%;
}
#footer p {
	float: left; 
	width: 50%; 
	line-height: 1.2em;
}
#footer p.right {
	float: right; 
	margin: 1em 0; 
	width: 50%; 
	text-align: right;
	font-size: 0.9em; 
	color:#999;
}
#comments, #respond{
	margin: 0;
	padding:1em 0 0 0;
}
#commentform 
{
	margin:10px 0;	
	padding:10px;
	background:#f9fcfc;
	border-top: #ddd 1px solid;
	border-bottom: #ddd 1px solid;
}
.commentnum 
{
	font-size:1.5em;
	font-weight:bold;	
	margin:0 5px 0 0;
}
.nocomments 
{
	text-align:center;
	color:#999;
	font-size:0.9em;
}
#container .commentlist {
	margin: 1em 0;
	padding: 0;		
	border-top: #ddd 1px solid;
}
#container .commentlist li 
{
	list-style:none;
	margin: 0;
	padding: 0.5em 0.5em 2em;	
	background:#fff url(img/shadow_top.gif) repeat-x top;
	border-bottom: #ddd 1px solid;
}
#container .commentlist li.alt 
{
    background:#f9f9f9;    
}
#container .commentlist li.authorcomment, #container .commentlist li.bypostauthor 
{
    border:#fc9 1px solid;      
}

#container .commentlist li .cmtinfo 
{
	font-size:1em;			
}
#container .commentlist li cite 
{
	font-style:normal;
	font-weight:bold;
}
#container .commentlist li .cmtinfo em 
{
	float:right;
	margin:0;
	padding:0;
	font-style:normal;
	font-size:0.9em;
	color:#999;
}
#container .commentlist .avatar
{
	float:right;	
}
#container .commentlist .commentmetadata
{
	font-size:0.9em;
}
#content .commentsfeed 
{
	background:url(img/icon_feed.gif) no-repeat left center;
	padding-left:16px;
}
#content .trackback 
{
	background:url(img/link.gif) no-repeat left center;
	padding-left:20px;
}
input.textbox, textarea, input[type="text"]
{
	border:#ccc 1px solid;
	background:#fff url(img/shadow_top.gif) repeat-x top;
	font:1em Verdana, Arial, Serif;
	padding:4px;
	width:200px;
}
#s
{
	width:150px;
}
textarea{
	width: 90%;
	padding:10px;
	line-height:2em;
	height: 20em;
}
input.textbox:focus, textarea:focus, input[type="text"]:focus
{
	background:#fff url(img/shadow_top.gif) repeat-x top;
	border:#999 1px solid;
}
#submit 
{
	padding:3px 5px;
}
.post h4 
{
	font-size:1em;
	font-weight:normal;
	font-family:Verdana, Tahoma, Arial, Serif;
}
.post h4 em
{
	font-style:normal;
	float:right;
	font-weight:normal;
	color:#999;
}
#header, #content, #sidebar, #footer, .widget {
    overflow: hidden;
}

img.left, img.alignleft, div.alignleft
{
	float:left;
	margin:1em 1em 1em 0;
}
img.right, img.alignright, div.alignright
{
	float:right;
	margin:0 0 1em 1em;
}
img.aligncenter, div.aligncenter
{
	text-align:center;
	margin:0 auto;
}
.wp-caption {
	border: 1px solid #ddd;
	text-align: center;
	background-color: #f3f3f3;
	padding-top: 4px;
	margin: 10px;
	/* optional rounded corners for browsers that support it */
	-moz-border-radius: 3px;
	-khtml-border-radius: 3px;
	-webkit-border-radius: 3px;
	border-radius: 3px;
}
.wp-caption img {
	margin: 0;
	padding: 0;
	border: 0 none;
}
.wp-caption p.wp-caption-text {
	font-size: 11px;
	line-height: 17px;
	padding: 0 4px 5px;
	margin: 0;
}

<?php

   /*

   Plugin Name: WP CSS Dropdown Menu
   Plugin URI: http://zackdesign.biz
   Description: Creates a navigation menu of pages with dropdown menus for child pages. Uses ONLY cross-browser friendly CSS, no Javascript.
   Version: 2.3.6
   Author: Isaac Rowntree
   Author URI: http://www.zackdesign.biz

   */





	function curPageURL() {
	   $pageURL = 'http';
	   if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
	   $pageURL .= "://";
	   if ($_SERVER["SERVER_PORT"] != "80") {
	    $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
	   } else {
	   $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
	   }
	  return $pageURL;
	}

   function wp_css_dropdownmenu($no_html = false, $before_plugin = '<div class="menu"><ul>', $after_plugin = '</ul></div>')
   {
     $before = '<ul>';
	   $after = '</ul>';		
		 $articles = get_pages_from_DB();
		 $no_urls = get_option('wp_css_menu_urls');
		 $urls = explode(',',$no_urls);
     
    $start_parent = get_option('wp_css_start_page');
    if (empty($start_parent))
        $start_parent = 0;
        
    if (is_home() || is_page('home'))
        $class="current_page";
     
     if (get_option('wp_css_menu_home'))
     {
         $text = get_option('wp_css_menu_hometext');
	 if (!empty($text))
             $result = '<li class="menu_item '.$class.'"><a href="'.get_bloginfo('url').'" rel="bookmark" title="'.get_bloginfo('name').'">'.$text.'</a></li>';
	 else
             $result = '<li class="menu_item '.$class.'"><a href="'.get_bloginfo('url').'" rel="bookmark" title="'.get_bloginfo('name').'">Home</a></li>';
    }
    else
         $result = '';
     
     $result = build_CSSDropDown_menu($articles, $start_parent, $urls, $result);
     
     if (empty($result))
         $result = '<li>No page posts to display.</li>';
     
		  //	Show the results
		 echo $before_plugin.$result.$after_plugin;	      
  }


function get_pages_from_DB ( $parent = -1 )
{
    global $wpdb; // Global wordpress variables
    
    if ($parent > -1)
        $parent = " AND $wpdb->posts.post_parent = '$parent'";
    else
        $parent = '';

     $pages = get_option('excluded_css_dropdown_pages');

     $remove = '';
     if ($pages)
     {
         $pages = explode(',',$pages);
         foreach ($pages as $page)
             $remove .= ' AND ID != ' . $page;
     }
     
      
     
      $postSQL =  "SELECT 
			$wpdb->posts.ID, 
			$wpdb->posts.post_title,
			$wpdb->posts.post_parent";
			
		$postSQL	.=	" FROM $wpdb->posts WHERE $wpdb->posts.post_status = 'publish' $parent AND $wpdb->posts.post_type = 'page'" . $remove;
      
      $sorting = get_option('wp_css_menu_sort');
      
      if ($sorting == 'alpha')
          $postSQL	.=	" ORDER BY $wpdb->posts.post_title";
      else
          $postSQL	.=	" ORDER BY $wpdb->posts.menu_order";

		  //	Get the results
		  return $wpdb->get_results($postSQL);
}

function css_dropdownmenu_css() {

    $dynamic = get_option('wp_css_menu_dynamic');
    $start_parent = get_option('wp_css_start_page');
    if (empty($start_parent))
        $start_parent = 0;
    $extra_pages = get_option('wp_css_extra');
    if (empty($extra_pages))
        $extra_pages = 0;
        
    if (get_option('wp_css_menu_home'))
        $extra_pages++;
        
    if ($dynamic)
    {
        $pages = sizeof(get_pages_from_DB($start_parent)) + $extra_pages;
        $width = get_option('wp_css_menu_width');
        $class = get_option('wp_css_menu_class');
        if (!$class || ($class == ''))
            $class = 'menu';
        
        // Li is the full width divided by the number of pages - the a width is li less a seemingly arbitrary number??
        $li = ($width - 1) / $pages ;
        $a  = $li - 10;
        
        $lili = 128;
        // Now the second level widths...
        $lili = 128;
        if ($li > $lili)
            $lili = $li - 21;
        $aa = $lili + 22;
            
        
        echo '
        <!-- wp_css_menu_dropdown dynamic menu widths -->
        <style type=\'text/css\' media=\'screen\'>
            .'.$class.' {width: '.$width.'px}
            * html .'.$class.' {width:'.$width.'px; w\idth:'.$width.'px;}
            .'.$class.' li {width:'.$li.'px; }
            .'.$class.' a, .'.$class.' a:visited {width:'.$a.'px; }
            * html .'.$class.' a, * html .'.$class.' a:visited {width:'.$a.'px; w\idth:'.$a.'px;}
            .'.$class.' ul ul a, .'.$class.' ul ul a:visited {width:'.$lili.'px;}
            * html .'.$class.' ul ul a, * html .'.$class.' ul ul a:visited {width:'.$aa.'px;w\idth:'.$lili.'px;}       
            .'.$class.' ul ul ul {width:'.$li.'px; left:'.$li.'px}
            .'.$class.' ul ul {width:'.$li.'px;}                     
        </style>
        <!-- /dynamic menu widths -->
        
        ';
    }
}


function CSSDropDownMenu_options () {

     echo '<div class="wrap"><h2>Wordpress CSS Drop-Down Menu</h2>';

     if ($_REQUEST['submit_css_content']) {
          update_CSSDropDownMenu_options();
     }

     displayCSSDropDownMenuAdminPage();

     echo '</div>';

}



  function update_CSSDropDownMenu_options()

  {

     $updated = false;
     
     if (!$_REQUEST['dynamic'])
         $_REQUEST['dynamic'] = 0;
         
     update_option('wp_css_menu_dynamic', $_REQUEST['dynamic']);
     update_option('wp_css_menu_class', $_REQUEST['cssclass']);
     update_option('wp_css_start_page', $_REQUEST['start_page']);
     update_option('wp_css_menu_width', $_REQUEST['menu_width']);
     update_option('wp_css_extra', $_REQUEST['extra_pages']);
     update_option('wp_css_menu_urls', $_REQUEST['urls']);
     update_option('wp_css_menu_home', $_REQUEST['home']);
     update_option('wp_css_menu_parent_urls', $_REQUEST['parent_url']);
     update_option('wp_css_menu_sort', $_REQUEST['sort']);
     update_option('wp_css_menu_hometext', $_REQUEST['home_text']);

          update_option('excluded_css_dropdown_pages', $_REQUEST['pages']);
     $updated = true;


     if ($updated) {

           echo '<div id="message" class="updated fade">';

           echo '<p>Options Updated</p>';

           echo '</div>';

      } else {

           echo '<div id="message" class="error fade">';

           echo '<p>Unable to update options</p>';

           echo '</div>';

      }

  }

	

	function displayCSSDropDownMenuAdminPage()

	{

	    $pages = get_option('excluded_css_dropdown_pages');
	    $class = get_option('wp_css_menu_class');
	    $width = get_option('wp_css_menu_width');
	    $page = get_option('wp_css_start_page');
	    $extra = get_option('wp_css_extra');
	    $urls = get_option('wp_css_menu_urls');
	    $sorting = get_option('wp_css_menu_sort');	    
	    $home = get_option('wp_css_menu_hometext');
	    if (empty($home))
	        $home = 'Home';   
	    
	    if (get_option('wp_css_menu_dynamic'))
        $checked = 'checked="checked"';
      else
        $checked = '';
      if (get_option('wp_css_menu_home'))
        $hchecked = 'checked="checked"';
      else
        $hchecked = '';
      if (get_option('wp_css_menu_parent_urls'))
        $pchecked = 'checked="checked"';
      else
        $pchecked = '';

?>



	<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">

		<h3>Home Page Button? <input type="checkbox" name="home" value="1" <?php echo $hchecked; ?>> </h3>
		<p>Button text:  <input type="text" value="<?php echo $home; ?>" name="home_text" /></p>
		
		<h3>No URLs for Menu Parents? <input type="checkbox" name="parent_url" value="1" <?php echo $pchecked; ?>></h3>

    <h3>Exclude Pages by ID</h3>

		<p><b>Pages: </b><input type="text" name="pages" value="<?php echo $pages; ?>"></p>
		
		<p>Seperate by commas if putting in multiple pages, e.g. 12,23,43.</p>
		
		<h3>Remove URLs by ID</h3>

		<p><b>Pages: </b><input type="text" name="urls" value="<?php echo $urls; ?>"></p>

    <p>Seperate by commas if putting in multiple pages, e.g. 12,23,43.</p>
    
    <h3>Starting Root Page ID</h3>
    
    <p><b>Page: </b><input type="text" name="start_page" value="<?php echo $page; ?>"></p>
    
    <h3>Page Ordering</h3>
    
       <p><b>Choose:</b> <select name="sort"><option value="alpha" <?php if ($sorting == 'alpha' ) echo 'selected ="selected"'; ?>>Alphabetically</option><option value="menu" <?php if ($sorting == 'menu' ) echo 'selected ="selected"'; ?>>Menu Order</option></select></p>
    
    <h3>Dynamic Menu Width</h3>


		<p><b>Dynamic? </b><input type="checkbox" name="dynamic" value="1" <?php echo $checked; ?>></p>
		<p><b>Dynamic class (to be used if you set something other than .menu): </b>
     <b>.</b><input type="text" name="cssclass" value="<?php echo $class; ?>"></p>
    <p><b>Width: </b><input type="text" name="menu_width" value="<?php echo $width; ?>"></p>
    <p><b>Extra Pages: </b><input type="text" name="extra_pages" value="<?php echo $extra; ?>"></p>
    <p>Extra pages are the pages you have added in when creating your own 'wrapping' HTML. Expected is the number of extra pages. This will be used to 
    decide how wide to make each list element.</p>
  


		<div class="submit">

			<input type="submit" name="submit_css_content" value="<?php _e('Save', 'CSSDropDownMenu') ?>" />

		</div></form>



<?php

	}

function build_CSSDropDown_menu($pages, $cur_level, $no_urls, $result = '')
{    
    foreach ($pages as $page)
    {      
        if ($page->post_parent == $cur_level)
        {
            $listTitle	=	stripslashes(str_replace('"', '', $page->post_title));
	    
	    // Go through list of 'no urls' and check this one
            if (is_array($no_urls))
            {
                foreach ($no_urls as $u)
                {
                    if ($page->ID == $u)
                    {
                        $url = false;
                        break;
                    }
                    else
                        $url = post_permalink($page->ID);
		}
            }
	    
	    // Get children
            $children = build_CSSDropDown_menu($pages,$page->ID,$no_urls);
	    
	    // If menu parents can't be clicked also check to see if there are children present
	    if (get_option('wp_css_menu_parent_urls') && !empty($children))
	    {
		$url = false;
	    }
            
            if (strstr($children, 'current_page'))
                $parent = 'current_parent';
            else if (!empty($children))
                $parent = 'parent';
	    else
	        $parent = '';
            
            // Need to find the current page the user is visiting and add the class accordingly
            global $post;
            if ($post->ID == $page->ID)
            {
                $class="class='menu_item menu_item_$page->ID current_page $parent'";
                $aclass="class='menu_item_link menu_item_link_$page->ID current_page_link $parent'";
            }
            else
            {
                $class="class='menu_item menu_item_$page->ID $parent'";
                $aclass="class='menu_item_link menu_item_link_$page->ID $parent'";
            }
            
	    $title = apply_filters( 'the_title', htmlspecialchars($listTitle) );
	    
	    if (!$url)
	        $result .= '
		<li '.$class.'><a '.$aclass.' rel="bookmark" title="' . $title . '">' . $title;
	    else
	        $result .= '
		<li '.$class.'><a href="' . $url . '" '.$aclass.' rel="bookmark" title="' . $title . '">' . $title;
            
            if (!empty($children))
                $result .= '<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]-->
		<ul>'.$children.'</ul><!--[if lte IE 6]></td></tr></table></a><![endif]--></li>';
            else
                $result .= '</a></li>';
        }
    }
    
    return $result;
}
	

	function setupCSSDropDownMenuAdminPanel()

	{

			add_options_page('CSS Drop-down Menu', 'CSS Drop-down Menu', 9, basename(__FILE__), 'CSSDropDownMenu_options');

	}



	add_action('wp_head', 'css_dropdownmenu_css', 1);

	add_action('admin_menu', 'setupCSSDropDownMenuAdminPanel');


?>