function open_function(url,width,height,options)
  {
    if ( height > screen.availHeight || width > screen.availWidth) {
      if ( options.indexOf( "scrollbars=") < 0) {
        if ( height > screen.availHeight)
          height = screen.availHeight;
        if ( width > screen.availWidth)
          width = screen.availWidth;
        options += ",scrollbars=yes";
      }
    }
    self.msgWindow = open(url, "Window", "width=" + width + ",height=" + height
      + ",screenX=" + (screen.width-width)/2
      + ",screenY=" + (screen.height-height)/2
      + ",dependent=yes"
      + ",left=" + (screen.width-width)/2
      + ",top=" + (screen.height-height)/2
      + options
      );

    if (self.msgWindow) {
      self.msgWindow.focus();
      if (self.msgWindow.opener == null) self.msgWindow.opener = self;
    }
  }

function get_url (url, k0 ,v0 ,k1 ,v1 ,k2 ,v2 ,k3 ,v3 ,k4 ,v4 ) 
{
  if (k0 && v0) url += "?" + k0 + "=" + escape(v0);
  if (k1 && v1) url += "&" + k1 + "=" + escape(v1);
  if (k2 && v2) url += "&" + k2 + "=" + escape(v2);
  if (k3 && v3) url += "&" + k3 + "=" + escape(v3);
  if (k4 && v4) url += "&" + k4 + "=" + escape(v4);
  return url;
}

// Easing equation, borrowed from jQuery easing plugin
// http://gsgd.co.uk/sandbox/jquery/easing/

/*jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};*/

jQuery(function( $ ){
	
	/**
	 * The call below, is just to show that you are not restricted to prev/next buttons
	 * In this case, the plugin will react to a custom event on the container
	 * You can trigger the event from the outside.
	 */
	
	var $news = $('#scroll_box_window');//we'll re use it a lot, so better save it to a var.
	$news.serialScroll({
		items:'p',
		duration: 4000,
		force:true,
        cycle:true,
		axis:'y',
		easing:'linear',
		lazy:true,
		interval: 7000, 
		step:1,
        exclude: 1
	});	
    
    // pause and play
        
    $('#scroll_box_control a.pp').click(function () { 
        if ($('#scroll_box_control a.pp').hasClass('play')) {
            $news.trigger( 'start' );
        } else {
            $news.trigger( 'stop' );
        }    
        $('#scroll_box_control a.pp').toggleClass('play');
        $('#scroll_box_control a.pp').toggleClass('pause');
    });        
    
    // prev
        
    $('#scroll_box_control a.prev').click(function () { 
        $news.trigger( 'stop' );
        $news.trigger( 'prev' );
        
        $('#scroll_box_control a.pp').removeClass('pause');
        $('#scroll_box_control a.pp').addClass('play');
    });    

    // next

    $('#scroll_box_control a.next').click(function () { 
        $news.trigger( 'stop' );
        $news.trigger( 'next' );
        
        $('#scroll_box_control a.pp').removeClass('pause');
        $('#scroll_box_control a.pp').addClass('play');
    });

});