<?php

	

	class gob_widget extends WP_Widget {
		function __construct() {
				parent::__construct('gob_widget',__('Tools', 'gob_widget_domain'), array('description' => __( 'Safethree Widget Tools', 'gob_widget_domain' ),) );
		}
		
		public function widget( $args, $instance ) {
			$url=get_bloginfo('template_url');			
			$title = apply_filters( 'widget_title', $instance['title'] );			
			
			echo "<div id='safethree_tool'>".$args['before_widget'];
				echo $args['before_title'] . $title . $args['after_title'];
				echo "<script type='text/javascript' src='".$url."/js/widget.js'></script>";			
				echo "<div class='searchform'>";
					get_search_form();
				echo "</div>";
				echo "<div class='btn-group menuform'>";						
					echo "<input data-toggle='popover' data-content='to Previous Page...' type='button' onclick='prev()' class='btn' value='<' id='prevbutton'   />";
					echo "<button data-toggle='popover' data-content='Print article' class='btn btn-info' onclick='printing()' id='printbutton'><i class='icon-white icon-print'></i> Print</button>";
					echo "<button data-toggle='popover' data-content='Switch to simple Mode...' class='btn btn-success hidesimple' onclick='readmode(1)' id='simplebutton'><i class='icon-white icon-th'></i> Simple</button>";						
					echo "<button class='btn btn-danger' onclick=\"jQuery('#example').modal('show');\" id='help'><i class='icon-white icon-globe'></i> Help</button>";	
					echo "<input data-toggle='popover' data-content='To Next Page...' type='button' onclick='next()' class='btn' value='>' id='nextbutton'   />";
				echo "</div>";
			echo $args['after_widget']."</div>";
		}
		
		public function form( $instance ) {
			$title=isset( $instance[ 'title' ] )?$instance[ 'title' ]:"Tools";	
			echo "<p>";
				echo "<label for='".$this->get_field_id('title')."'> Title : </label>";	
				echo "<input 
						class='widefat' 
						id='".$this->get_field_id('title')."' 
						name='".$this->get_field_name('title')."' 
						type='text' 
						value='".$title."'/>";				
			echo "</p>";	
		}

		public function update( $new_instance, $old_instance ) {
			$instance = array();
			$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
			return $instance;
		}
	}
	function gob_load_widget() {
		register_widget( 'gob_widget' );
	}
	add_action( 'widgets_init', 'gob_load_widget' );
	
	function add_widget_help(){
		get_template_part('functions/safethree-widget-help');
	}
	add_action('wp_footer', 'add_widget_help');
 ?>
