/*
	domEl() function - painless DOM manipulation
	written by Pawel Knapik  //  pawel.saikko.com
*/

var domEl = function(e,c,a,p,x) {
if(e||c) {
	c=(typeof c=='string'||(typeof c=='object'&&!c.length))?[c]:c;	
	e=(!e&&c.length==1)?document.createTextNode(c[0]):e;	
	var n = (typeof e=='string')?document.createElement(e) : !(e&&e===c[0])?e.cloneNode(false):e.cloneNode(true);	
	if(e.nodeType!=3) {
		c[0]===e?c[0]='':'';
		for(var i=0,j=c.length;i<j;i++) typeof c[i]=='string'? ((c[i] =='') ? '': n.appendChild(document.createTextNode(c[i]))):n.appendChild(c[i].cloneNode(true));
		if(a) {
			for (var i in a) i=='class'?n.className=a[i]:(i == 'style')?n.style.cssText=a[i]:n.setAttribute(i,a[i]);}
	}
}
	if(!p)return n;
	p=(typeof p=='object'&&!p.length)?[p]:p;
	for(var i=(p.length-1);i>=0;i--) {
		if(x){while(p[i].firstChild)p[i].removeChild(p[i].firstChild);
			if(!e&&!c&&p[i].parentNode)p[i].parentNode.removeChild(p[i]);}
		if(n){
			if(!document.all){
				p[i].appendChild(n.cloneNode(true));
				} else {
				if(n.canHaveChildren){
					p[i].appendChild(n.cloneNode(true));
				} else if(p[i].canHaveChildren) {
				p[i].appendChild(n.cloneNode(false));			
				} else {
					p[i].parentNode.appendChild(n);
					}
				}
			} 
	}	
}
var makeSignup = {
	init:function(){
		if($('signUpEmailButton')){
			Event.observe($('signUpEmailButton'), 'click', this.run);
		}
		},
	run:function(e){
		Event.stop(e);
									var email = $F('signupEmail');
									email = email.replace(/^\s+/g, '');
									if(email == ''){
										alert('Please enter in an email address');
										return;
										}
									var options = {
										method : 'post',
										parameters : 'email='+email+'&submit=Sign up',
										onComplete : function(request) {
										  $('signUp').innerHTML = '<div id="output">'+request.responseText+'</div>';
										}
					
									  };
 
									new Ajax.Request('/maillist/index.php', options);
		}
	};
var buttonHover = {
	init:function(){
		if($('donateBtn')){
			Event.observe($('donateBtn'), 'mouseover', this.over);
			Event.observe($('donateBtn'), 'mouseout', this.out);
			}
		},
	over : function(){
		$('donateBtn').src='/wp-content/themes/transfatty/images/donatebtn_over.jpg';
		},
	out : function(){
		$('donateBtn').src='/wp-content/themes/transfatty/images/donatebtn_out.jpg';
		}
	};
var fixTable = {
	init : function(){
		var tb = document.getElementsByTagName('table');
		tb = $A(tb);
		tb.each(function(t){
						 t.setAttribute('cellspacing', '0');
						 });
		}
	}
var flash = {
init: function(){
if(!$('flashTicker')){return;var re = new RegExp('(http://[A-Za-z0-9.]+)(\/[A-Za-z0-9.-]+)');var loc = location.href; var serverPath = loc.replace(re, '$1');}
		var fo = new FlashObject("/ticker_170x45.swf", "ticker", "170", "45", "8", "#000000");
		fo.addParam("scale", "noscale");
		fo.addVariable("serverPath", 'http://'+$F('serverPath')+'/');
		fo.write("flashTicker");
}
};
/*
Page loading functions


*/

var page = {
	init : function(){
		if (arguments.callee.done) return;
    	arguments.callee.done = true;
		/*
		List onload functions here ¬
		*/
		buttonHover.init();
		makeSignup.init();
		fixTable.init();
		flash.init();
		/*End onload functions*/
		}
	};
/*
------------------------------------------------------------------------
What's this do?
Well, it turns out that you can do an onload handler
that runs when the DOM is loaded, not just after EVERY image
has loaded. Why is this important?
Because you want to run the onload once the elements become ready,
not when you're 10MB bitmap finally downloads.
Of course, this only works for IE/PC and Firefox.
Sorry Safari and Opera :(
Thanks, of course, go to the ever awesome Dean Edwards.
------------------------------------------------------------------------
*/
	/* Moz in tha house */
		if (document.addEventListener) {
		   document.addEventListener("DOMContentLoaded", page.init, null);
	   }
   /* IE in tha house */
   /*@cc_on @*/
   /*@if (@_win32)
       document.write('<script defer="defer" src="/wp-content/themes/transfatty/javascript/ie_onload.js"></script>');
   /*@end @*/
   /* Another browser, in tha house */
	   Event.observe(window, 'load', page.init);