/* Page
----------------------------------------------- */
var Page = {
   init: function () {

   	Page.tabs();
   	 Page.rotateImg();
   },
 
	header: function () {
		if (Flash.hasVersion (6)) {
			//tag = new Flashtag(6, '/flash/header-normal.swf', 780, 60) OR (6, '/flash/header-winter.swf', 750, 110);
			tag = new Flashtag(6, '/flash/header-normal.swf', 780, 60);
			tag.addProperty('wmode', 'transparent');
			$('header').innerHTML = tag.render();
		}
	},

	tabs: function () {
		if (selectedTab = $('p1_tab')){
		county = 1;
		while( $(n = 'p'+ county ) ){
			$(n +'_tab').p = n;
			$(n +'_tab').clicky = function () {
				 selectedTab.className = '';
				 Element.setStyle(this.p, {zIndex: '2'});
				 Element.setStyle(selectedTab.p, {zIndex: '100'});
			  Element.show( this.p );
			  Effect.Fade( selectedTab.p );
			  this.className = 'on';
					selectedTab = this;
			  return false;
    }
			$(n +'_tab').onclick = function () { 
					clearTimeout( slideshowlio );
					this.clicky();
					return false;
				}
			if (county > 1) Toggle.display( n );
			county++;
		}
		selectedTab.className = 'on';
		// set timer
		numTabs = county - 1;
		slideshowlio = setInterval( "$('p'+((county++ % numTabs) + 1)+'_tab').clicky();", 11000 );
		}
	},
	
	pig: function () {
	   if (Flash.hasVersion (6)) {
			tag = new Flashtag(6, '/flash/pig.swf', 515, 400);
			tag.addProperty('wmode', 'transparent');
         $('pig').innerHTML = tag.render();
		}
	},
	
	rotateImg: function () {
  numPhotos = 4; // global
  PicCurrentNum = 1; // global
  setInterval("$('changing_pix').src = '/images/recipebox' + (( (PicCurrentNum++) % numPhotos ) + 1 )  + '.jpg';", 5000);
	},
	
	// Popup Method
	popup: function () {
	   var anchors = document.getElementsByTagName("a");
	   var i, href;
      	for(i=0; i < anchors.length; i++){
      		if(!anchors[i].href) continue;
      		href = anchors[i].href;
      		if(href.indexOf(location.host) == -1){ // Href is not a file on my server
      			if(href.indexOf("javascript:") == -1){ // Href is not a javascript call
      				if(!anchors[i].onclick){ // Href does not have an onclick event
      					if(href.indexOf("mailto:") == -1){ // Href is not a mailto:
      						if(href.indexOf("http://") != -1){ // Href is not relative (for Safari)
      							anchors[i].setAttribute("target","_blank");
      						}
      					}
      				}
      			}
      		}
      	}
	}
}

/* -------------------------------------------- */

window.onload = function () {
	Page.init();
}