// JavaScript Document

function doNot() {
	return false;	
}

function doOption(obj,cls) {
	$$(cls).invoke('removeClassName', 'active');
	$(obj).addClassName('active');
}

function selectCVV(id,img) {
	var option = $(id).selectedIndex;
	
	if (option == 1 | option == 2) {
		$(img).style.backgroundPosition = 'left top';
	} else if (option == 3) {
		$(img).style.backgroundPosition = 'left -100px';
	} else if (option == 4) {
		$(img).style.backgroundPosition = 'left -200px';
	} else {
		$(img).style.backgroundPosition = 'left 100px';
	}
	
}

var gAutoPrint = true; // Flag for whether or not to automatically call the print function

function printSpecial()
{
	if (document.getElementById != null)
	{
		var html = '<html>\n<head>\n';

		if (document.getElementsByTagName != null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML.stripScripts();
		}
		
		html += '\n<link href="/_media/_css/printview.css" rel="stylesheet" type="text/css" media="all">';
		html += '\n</he' + 'ad>\n<body>\n';
		
		var printReadyElem = document.getElementById("printable");
		
		if (printReadyElem != null)
		{
				html += printReadyElem.innerHTML;
		}
		else
		{
			alert("Could not find the printReady section in the HTML");
			return;
		}
			
		html += '\n</bo' + 'dy>\n</ht' + 'ml>';
		
		var printWin = window.open("","printSpecial");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		alert("Sorry, the print ready feature is only available in modern browsers.");
	}
}


function extpop(){ // v1.0 | www.TJKDesign.com
  var e = document.getElementsByTagName('body')[0];
  if (e){
    var a=e.getElementsByTagName('a');
    for (var i=0;i<a.length;i++){
    if (a[i].getAttribute('href') != null && a[i].getAttribute('href').indexOf("://") >= 0 && a[i].getAttribute('href').toUpperCase().indexOf(document.domain.toUpperCase()) == -1){
        a[i].className+=a[i].className?' extlink':'extlink';
        a[i].title+=' (opens in new window)';
        a[i].onclick=function(){newWin=window.open(this.href,'TJKWin');if(window.focus){newWin.focus()} return false;}
//      a[i].onkeypress=function(){newWin=window.open(this.href,'TJKWin');if(window.focus){newWin.focus()} return false;}
      }
    }
  }
}

function popAppPdf(){ // v1.0 | www.TJKDesign.com
var zA=document.getElementsByTagName("a");
	for (var i=0;i<zA.length;i++){
	// if the type value contains "application/pdf" or if the href value contains "PDF" or if the file is in a "PDF" folder then we have a winner
		if (zA[i].getAttribute("href") != null && (zA[i].getAttribute("type") == "application/pdf" || zA[i].getAttribute("href").toUpperCase().indexOf(".PDF") >= 0 || zA[i].getAttribute("href").toUpperCase().indexOf("PDF/") >= 0)){
		zA[i].title+=" (opens in new window)";
		zA[i].className+=zA[i].className?" pdfFile":"pdfFile";
		// This spawns multiple windows, but works fine with popup blockers
		// zA[i].target="_blank";
		// This opens a unique window and brings it in front of the opener each time the user clicks on the link
		// Note that the new window opens without a toolbar. This is to avoid further conusion for the visitor 
		zA[i].onclick=function() {newWin=window.open(this.href,"TJKWin","toolbar=no");if( window.focus){newWin.focus()} return false;}
		}
	}
}

function initDonationAccordian() {
	new Accordian('help-form',4,'current');
	$$('div.option-hdr').invoke('observe', 'click', function(event){try{event.element().down().onclick(event)}catch(e){}});		
}

function getRadioValue(form,name) {
	var input = form.getInputs('radio',name).find(function(input){return input.checked});
	return (input ? input.value : '');
}


// Home Page Notification
var Notifier = Class.create({
	
	initialize: function() {
		
		this.durationOpen =   0.6;
		this.durationClose =  0.4;
		this.delayOpen =      1.2;
		this.autoClose =      10.0;
		this.isOpen =         false;
		this.container =      $('notification');
		this.closer =         this.container.select( 'a.close' )[0];
		this.height =         this.container.getHeight() + 2;
		
		this.container.setStyle({
			'display': 'block',
			'top': -this.height + 'px'
		});
		
		this.open();
		
		this.closer.observe( 'click', function( e ) {
			e.stop();
			this.close();
		}.bind( this ));
		
		this.close.bind( this ).delay( this.autoClose );
		
	
	},
	
	open: function() {
		
		new Effect.Move( this.container, { 
			duration: this.durationOpen,
			y:        this.height,
			delay:    this.delayOpen
		});
		
		this.isOpen = true;
			
	},
	
	close: function() {
		
		if( this.isOpen ) {
		
			new Effect.Move( this.container, { 
				duration: this.durationClose, 
				y:        -this.height, 
				afterFinish: function() { 
					this.container.remove(); 
				}.bind(this) 
			});
			
			this.isOpen = false;

		}
	
	}

});

document.observe("dom:loaded", function() 
{
 
	new Notifier();	
	
});



