function init(){
	if($('content').hasClassName('press')){
		ticker();
	}
	pImage();
}

function pImage(){
	$$('p img').each(function(i){
		i.align = 'right';
	});
}

function buttonReplace(){
	var spans = $$('span.button');
	if(!Prototype.Browser.WebKit){
		for (var i = 0; i < spans.length; ++i) {
		  var item = spans[i];
		  if($(item).firstDescendant().match('input')){
			var b_name = $(item).firstDescendant().readAttribute('name');
			var b_onclick = $(item).firstDescendant().readAttribute('onclick');
			var b_type = $(item).firstDescendant().readAttribute('type');
			var b_value = $(item).firstDescendant().readAttribute('value');
			$(item).innerHTML = ('<button type="'+b_type+'" name="'+b_name+'" onclick="'+b_onclick+'" value="'+b_value+'">'+b_value+'</button>');
		  }
		}
	}else{
		for (var i = 0; i < spans.length; ++i) {
		  	var item = spans[i];
		  	if($(item).firstDescendant().match('input')){
		  		$(item).addClassName('safaributton');
		  		$(item).removeClassName('button');
		  	}
		}
	}
	if(Prototype.Browser.Gecko && !$('cartshell')){
		//console.log('firefox');
		$$('a.button span, span.button button, span.button input, del.button span').each(function(s) {
			$(s).addClassName('firefoxspan');
		});
	}else if(Prototype.Browser.IE && !$('cartshell')){
		$$('a.button span, span.button button, del.button span').each(function(s) {
			$(s).addClassName('iespan');
		});
	}
}

function archive(){
	Effect.toggle('archive','slide',{
		duration:.4
	});
}

function resetMail(){
	$('join').innerHTML = '<form method="get" action="join_mail.php" id="join_form"><ul id="mailinglist"><li>Join My Mailing List</li><li><input type="text" class="text" name="join_email" id="join_email" /></li><li><a href="javascript:void(null);" class="submit" onclick="greet();" />Join</a></li></ul></form>';

}

/*
function greet(){
     var url = 'libs/join_mail.php';
     var pars = 'join_email='+escape($F('join_email'));
     var target = 'join';
     new Ajax.Updater(target, url, {
     	method: 'get', 
     	parameters: pars,
     	onLoading: function(transport){
     		$('join').innerHTML = '<span>Sending...</span>';
     	}
     });
}
*/

function greet(){
     var url = 'libs/join_mail_CM.php';
     var pars = 'join_email='+escape($F('join_email'));
     var target = 'join';
     new Ajax.Updater(target, url, {
     	method: 'get', 
     	parameters: pars,
     	onLoading: function(transport){
     		$('join').innerHTML = '<span>Sending...</span>';
     	}
     });
}

function ticker(){

	//get rid of any HTML tags that could mess it up
	

	//use replay to know if it is replaying, set 'tock' to before the length of the container and play animation in loop.

	var speed = 6;

	new Effect.Move('tock',{ x: 686, y: 0, mode: 'absolute', duration: 0 });

	var distance = $('tack').getWidth()+10;
	/*
if(replay){
		new Effect.Move('tock',{ x: 686, y: 0, mode: 'relative', duration: 0 }); 
		distance += $('ticker').getWidth();
		console.log('replay');
	}

*/	var dur = distance/(200/speed);
	distance = distance*-1;
	new Effect.Move('tock',{ 
		x: distance, 
		y: 0, 
		mode: 'absolute', 
		duration: dur, 
		transition: Effect.Transitions.linear,
		afterFinish: function(){
			ticker();
		}
	});
}



FastInit.addOnLoad(init);

