<?php 

add_action('widgets_init','Lioit_ads160');

function Lioit_ads160() {
	register_widget('Lioit_ads160');
	
	}

class Lioit_ads160 extends WP_Widget {
	function Lioit_ads160() {
			
		$widget_ops = array('classname' => 'Lioit_ads160','description' => __('Widget display 300*250 Ads','theme'));
		$this->WP_Widget('Lioit_ads160',__('( LioIT ) Ads 160*600','lioit'),$widget_ops);

		}
		
	function widget( $args, $instance ) {
		extract( $args );
		/* User-selected settings. */
		$title = apply_filters('widget_title', $instance['title'] );
		$img = $instance['img'];
		$link = $instance['link'];
		$code = $instance['code'];
		$show_bg = $instance['show_bg'];

		

		

		?>
		   	    <div class="widget bigAd160">
			  <?php if($code != '') { ?>
					<?php echo $code; ?>
			  <?php } else { ?>
			   <a href="<?php echo $link ?>"><img src="<?php echo $img ?>" alt="" /></a>
			  <?php } ?>
			  </div><!-- ads250 -->

			
<?php 
	

	}
	
	function update( $new_instance, $old_instance ) {
		$instance = $old_instance;

		/* Strip tags (if needed) and update the widget settings. */
		$instance['title'] = strip_tags( $new_instance['title'] );
		$instance['link'] = $new_instance['link'];
		$instance['img'] = $new_instance['img'];
		$instance['code'] = $new_instance['code'];
		$instance['show_bg'] = $new_instance['show_bg'];

		return $instance;
	}
	
function form( $instance ) {

		/* Set up some default widget settings. */
		$defaults = array( 'title' => __('advertisement', 'lioit'), 
			'img' => Lioit_IMG.'/ads160.png', 
			'link' => '#'
 			);
		$instance = wp_parse_args( (array) $instance, $defaults ); ?>
	

	

		

		<p>
		<label for="<?php echo $this->get_field_id( 'img' ); ?>"><?php _e('image:', 'lioit') ?></label>
		<input id="<?php echo $this->get_field_id( 'img' ); ?>" name="<?php echo $this->get_field_name( 'img' ); ?>"  type="text" value="<?php echo $instance['img']; ?>" class="widefat" />
		</p>
        
		<p>
		<label for="<?php echo $this->get_field_id( 'link' ); ?>"><?php _e('Link :', 'lioit') ?></label>
		<input id="<?php echo $this->get_field_id( 'link' ); ?>" name="<?php echo $this->get_field_name( 'link' ); ?>" type="text"  value="<?php echo $instance['link']; ?>" class="widefat" />
		</p>

 		<p>
		<label for="<?php echo $this->get_field_id( 'code' ); ?>"><?php _e('ad code :', 'lioit') ?></label>
		<textarea id="<?php echo $this->get_field_id( 'code' ); ?>" name="<?php echo $this->get_field_name( 'code' ); ?>" type="text"  class="widefat" cols="20" rows="16"><?php echo $instance['code']; ?></textarea>
		</p>
       
   <?php 
}
	} //end class