// JavaScript Document

var curitem = null;

window.addEvent('domready', function() {
	var togglers = $$('a.menu_act');
	var elements = $$('div.submenu');
	var act_finder = -1;
	var act_cnt = 0;
	$$('div.submenu').each( function (a) {
			if(a.getElement('a.active'))
				act_finder = act_cnt;
			act_cnt++;
		});
	//alert(act_finder);

	var options = {
		opacity: false,
		show: act_finder,
		onActive: function(toggler, element){
			toggler.setAttribute('id','active');
		},
 
		onBackground: function(toggler, element){
			toggler.setAttribute('id','');
		}
	}

	var accordion = new Accordion(togglers, elements, options , $('smenu'));
	
	$$('a').each(function(el){
			el.addEvent('click',function(el) {
			//new Event(el).stop(); 

	var http = this.href.indexOf("/portfoliorecovery.com");
	var www = this.href.indexOf("w.portfoliorecovery.com");


	if( (http < 0 && this.href.indexOf("javascript:") == -1 && this.href.indexOf("mailto:") == -1) && (www < 0 && this.href.indexOf("javascript:") == -1 && this.href.indexOf("mailto:") == -1) )
		{
		if(confirm("You are now leaving portfoliorecovery.com.\nPRA is not responsible for content or privacy policies on other sites."))
			return true;
		else
			el.preventDefault();
		}
	
	});
						  });

	

	
	//This will set the IR Overview page to active if the referer is
	// the IR Contacts page or the RSS Feeds page...
	var ir_contacts_page = "http://phx.corporate-ir.net/phoenix.zhtml?c=135456&p=irol-contact&t=&id=&";
	var ir_rss_page = "http://phx.corporate-ir.net/phoenix.zhtml?c=135456&p=rssSubscription&t=&id=&";
	var ir_email_page = "http://phx.corporate-ir.net/phoenix.zhtml?c=135456&p=irol-alerts&t=&id=&";

	if(window.location.href == ir_contacts_page) {
		// This is the IR Contacts Page
		// Find the menu element we want and make it's id = 'active'
		var correct_element = $$('div.item .submenu')[2];
		correct_element.setProperty('style', 'height:100%');
	}
	if(window.location.href == ir_rss_page) {
		// This is the RSS page
		// Find the menu element we want and make it's id = 'active'
		var correct_element = $$('div.item .submenu')[2];
		correct_element.setProperty('style', 'height:100%');
	}
	if(window.location.href == ir_email_page) {
		// This is the RSS page
		// Find the menu element we want and make it's id = 'active'
		var correct_element = $$('div.item .submenu')[2];
		correct_element.setProperty('style', 'height:100%');
	}
	
});
 
 
 function photo_init() {
	 var curimg = 0;
	 $$('#rotater td').each( function (a) {	
		a.setStyle('background-image','url(' + photos[curimg] + ')');
		curimg++;
		a.setHTML('<img src="' + photos[curimg] + '" />');
		curimg++;
										   });
	 setTimeout('startFades()',1000);
	 
	 
 }
 
 var lastfade = 0;
 
 function startFades() {
	if(lastfade > 3)
		lastfade = 0;
	var els =  $$('#rotater td');
	//alert(els.length);
	//alert(els[lastfade].getElement('img').getAttribute('src'));
	var getopacity = els[lastfade].getElement('img').getStyle('opacity');
	
 	var fader = new Fx.Style(els[lastfade].getElement('img'), 'opacity', {duration:1000,
	onComplete: function(){						  
		lastfade++;
		setTimeout('startFades()', 1000);
		}
	}
	);
	if(getopacity == 1)
		fader.start(0);
	else
		fader.start(1);
	}
 
 
 //function fader (el) {
//	var fader = new Fx.Styles(el,{'opacity' : 0 ,'duration' : 500);
//	fader.start();
// }
 

 
