/**
 * Declare local variables
 * 
 */
var id = 1;
var dogs = 6;  // initiate the number of dogs to loop

/**
 * @function: PeriodicalExecuter
 * @library: Prototype
 * @sub-library: Scriptaculous
 * @description:  loops through featured dog pics/details
 * @author: Scott Watkins
 *  
 */
var pe = new PeriodicalExecuter(function(){
				showdog('featured-pic-'+id, false);
				if (id <= 5) {
					id++;
				} else {
					id = 1;
				}
			}, 2);
			
			
			
var Popup = {
  open: function(options)
  {
    this.options = {
      url: '#',
      width: 800,
      height: 595,
      name:"_blank",
      location:"no",
      menubar:"no",
      toolbar:"no",
      status:"yes",
      scrollbars:"yes",
      resizable:"yes",
      left:"",
      top:"",
      normal:false
    }
    Object.extend(this.options, options || {});

    if (this.options.normal){
    this.options.menubar = "yes";
    this.options.status = "yes";
    this.options.toolbar = "yes";
    this.options.location = "yes";
    }

    this.options.width = this.options.width < screen.availWidth?this.options.width:screen.availWidth;
    this.options.height=this.options.height < screen.availHeight?this.options.height:screen.availHeight;
    var openoptions = 'width='+this.options.width+',height='+this.options.height+',location='+this.options.location+',menubar='+this.options.menubar+',toolbar='+this.options.toolbar+',scrollbars='+this.options.scrollbars+',resizable='+this.options.resizable+',status='+this.options.status
    if (this.options.top!="")openoptions+=",top="+this.options.top;
    if (this.options.left!="")openoptions+=",left="+this.options.left;
    window.open(this.options.url, this.options.name,openoptions );
    return false;
  }
}


/**
 * @function: showdog
 * @library: Prototype
 * @sub-library: Scriptaculous
 * @dependencies: PeriodicalExecuter()
 * @param {Int} id
 * @param {Bool} stop
 * @author: Scott Watkins
 * 
 */
 
function showdog(id, stop){
	if (stop){
		pe.currentlyExecuting = true; // setting this to true stops the PeriodicalExecuter
	}
	var el = $(id);
	var origid = el.getAttribute('id');
	for (i=1; i<=dogs; i++){
		if (origid == 'featured-pic-'+i) {
			$('featured-pic-'+i).show();
			$('featured-'+i).addClassName('featured-hover');
		} else {
			$('featured-pic-'+i).hide();
			$('featured-'+i).removeClassName('featured-hover');
		}
	}
}

/**
 * @function: startshow
 * @library: Prototype
 * @sub-library: Scriptaculous
 * @dependencies: PeriodicalExecuter()
 * @dependencies: showdog()
 * @author: Scott Watkins
 * 
 */
function startshow(getid){
	id = getid;
	pe.currentlyExecuting = false; // setting this to false restarts the PeriodicalExecuter
}

