var closing=false;
$('document').ready(function(){
	setTimeout ( "openPage()", 700 );
	
	$('#hashtag').click(function(){$(this).attr({"value":""});});
	
	$('#follow img').hover(function(){
		var src=$(this).attr('src');
			src=src.replace("follow.jpg",'follow_alt.jpg');
			$(this).attr({'src' : src});
	},function(){
		var src=$(this).attr('src');
			src=src.replace("follow_alt.jpg",'follow.jpg');
			$(this).attr({'src' : src});
	
	}).click(function(){window.open('http://twitter.com/tweetonthewall','_blank');});
	
	$('#start').hover(function(){
		if (closing==false){
			var src=$(this).find('img').attr('src');
			src=src.replace("start.jpg", "start_alt.jpg");
			$(this).find('img').attr({'src' : src});
		}
	},function(){
		if (closing==false){
			var src=$(this).find('img').attr('src');
			src=src.replace("start_alt.jpg",'start.jpg');
			$(this).find('img').attr({'src' : src});
		}
	});
	
	$('#start').click(function(){
		if ($('#hashtag').attr('value')!="" && $('#hashtag').attr('value')!="Your hashtag here.." && $('#hashtag').attr('value')!="YOUR HASHTAG PLEASE !"){
		setTimeout ( "closePage()", 100 );
		closing=true;
		var src=$('#start').find('img').attr('src');
		src=src.replace("start.jpg", "start_alt.jpg");
		$('#start').find('img').attr({'src' : src});
			
		}else {
			
			$('#hashtag').css({borderColor:'RED'}).focus().attr({"value":"YOUR HASHTAG PLEASE !"});
		}
	});
	
	swfImplements();
	
	

});
function swfImplements(){
if ($(document).find('#flashMovie')){
var vars = $('#flashMovie').attr('rel');
var ar_vars=vars.split(',');
	if (ar_vars.length>0){
		var flashvars ={};
		flashvars.id=ar_vars[0];
		flashvars.domain=ar_vars[1];
		flashvars.document_path=ar_vars[2];
		
		//alert( vars[3]);
	}
	else {
	var flashvars ={};
	}
	 var params = {allowFullScreen:true};
	 var attributes = {};
	 var Twidth=$(document).height();
	if ($(document).height()-5<($(document).width()/16)*10){
		Twidth=(($(document).height()-5)/10)*16
		
	}
	if (ar_vars[3]=="me"){
		swfobject.embedSWF("http://"+ar_vars[1]+"/files/flash/publitwitty2.swf", "flashMovie", Twidth, $(document).height()-5, "9.0.0", "../files/flash/expressInstall.swf", flashvars, params, attributes);
	}else {
		swfobject.embedSWF("http://"+ar_vars[1]+"/files/flash/publitwitty.swf", "flashMovie", Twidth, $(document).height()-5, "9.0.0", "../files/flash/expressInstall.swf", flashvars, params, attributes);
	}
	 $('#flashContainer').css({width:Twidth,margin:'0 auto'});
 }

 
 }

function openPage ( )
{
  $('#right').animate({right:-162+"px"},400,'easeOutSine');
	$('#left').animate({left:-162+"px"},400,'easeOutSine');
	
	 $('#bigRight').animate({right:-($(this).width())+"px"},1200,'easeOutSine');
	$('#bigLeft').animate({left:-($(this).width())+"px"},1200,'easeOutSine');
}
function closePage ( )
{
	

	$('#right').animate({right:0+"px"},400,'easeOutBounce',function() {
      	$('#myForm').submit();
  });
	$('#left').animate({left:0+"px"},400,'easeOutBounce');
}

function sendForm(){
	$('#myForm').submit();
}
