window.addEvent('domready', function(){
	
	//subscribe function
	if($chk($('subscribe_form')))
	{
		tf = $('subscribe_form');
		tf.addEvent('submit', function(e) {
		e.stop();
		this.set('send', {onComplete: function(response) {
			$('subscribe_mess').innerHTML=response;
			setTimeout("$('subscribe_mess').innerHTML=''", 3000);
		}.bind(this) });
		this.send();
	});
		
	}
	
	
	
	var ffx_comm = new cc_fx_comments('the_comments');
	
	
		new cc_fx_tabs($('fx_share'),$$('#fx_triggers a'), 'fx_hidd_');
		new cc_fx_tabs($('fx_resp'),$$('#post_resp_trigger a.trigger'), 'fx_resp_');
	
	
	/*var vrSlide = new Fx.Slide('video_responses_videos');
	vrSlide.hide();
	$('video_responses_videos').fade(0);
	$('video_responses').addEvent('click', function(e){
		e.stop();
		
		if(vrSlide.open)
		{	
			$('video_responses_videos').fade(0);
			vrSlide.toggle();
			
		}
		else
		{
			vrSlide.toggle().chain(function(){$('video_responses_videos').fade(1)});
		}
		
		
	});*/
	
	var pcSlide = new Fx.Slide('fx_comment_form');
	pcSlide.hide();
	$('fx_comment_form').fade(0);
	/*try{$('fx_comment_form_trigger');}
	catch(ee){alert(ee);}*/
	
	//alert($('fx_comment_form_trigger'));
	if($('fx_comment_form_trigger')!=null)
	{
		$('fx_comment_form_trigger').addEvent('click', function(e){
			e.stop();
			;
			if(pcSlide.open)
			{
				$('fx_comment_form').fade(0);
				pcSlide.toggle();
			}
			else{
				pcSlide.toggle().chain(function(){$('fx_comment_form').fade(1)});
			}
		});
	}
	else
	{
		//alert($('fx_comment_form_trigger'));
	}
	
	//ajax send comments form
	
	if($chk($('fx_comment_form').getElements('form')[0]))
	{
	$('fx_comment_form').getElements('form')[0].addEvent('submit', function(e) {
			//Prevents the default submit event from loading a new page.
			e.stop();
			//Empty the log and show the spinning indicator.
			//var log = $('log_res').empty().addClass('ajax-loading');
			//Set the options of the form's Request handler. 
			//("this" refers to the $('myForm') element).
			this.set('send', {onComplete: function(response) { 
				//log.removeClass('ajax-loading');
				$('fx_comment_message').innerHTML = response;
				var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
		var string_length = 8;
		var randomstring = '';
		for (var i=0; i<string_length; i++) {
			var rnum = Math.floor(Math.random() * chars.length);
			randomstring += chars.substring(rnum,rnum+1);
		}
				ffx_comm.load($('base_url').href+randomstring);
				pcSlide.toggle().chain(function(){$('fx_comment_form').fade(1)});
				$('comment_content').set('value', '');
				//slide out
				
				
				
			} } );
			
			
			
			//Send the form.
			//alert(response);
			this.send();
		});
	}	
	$('vr_ajax_form').addEvent('submit', function(e) {
		e.stop();
		this.set('send', {onComplete: function(response) {
			this.innerHTML=response;
		}.bind(this) });
		this.send();
	});
	
	//new cc_fx_related_drop('related_videos_fx_trigger', 'related_video_scroll');
	//new cc_fx_related_drop('more_from_user_fx_trigger', 'more_video_scroll');
	

});