$(document).ready(function() {
	$('body').addClass('js');

	$('a[class=login]').click(function(){
		$('#login').slideToggle('fast');
		return false;
	});


	$('.ciwire').click(function(){
		location.href="http://www.ciwire.com"
	});



	$('#logo a').cycle({speed:500,timeout: 4000});

	$('#upload,#protect,#share').hover(
		function(){
				$(this).addClass('hover')
				$('body').removeClass('upload protect share').addClass($(this).attr('id'));
		},
		function(){
				$(this).removeClass('hover')
		}
	);

	if (jQuery.support.opacity != true) {
		$('#logo').flash({swf:'/swf/logo.swf',width:396,height:148,wmode:'transparent',flashvars: {	clickthru: '/'}});
	}

	$('#upload,#protect,#share').click(function(){
		var link = $(this).children('.more').children('a').attr('href');
		location.href = link;
	});

	$("#planswitcher a").click(function(){
		$("#planswitcher").removeClass().addClass($(this).attr("class"));
		$("#monthly,#year1,#year2").hide();
		id = $(this).attr("href");
		$(id).fadeIn();
		return false;
	});

	if ($('.flash-messages').size() > 0) {
		$('.messages').append("<span id='close'></span>");
		$('#close').click(function(){
			$(this).remove();
			$('.messages').fadeOut();
		});
	}

	$("#plans li").hover(
		function(){$(this).children(".hint").fadeIn();},
		function(){$("#plans .hint").hide();}
	);

	$("#poolpass a").click(function(){
		href =$(this).attr("href") + " #section .content";
		$('#modal').load(href,function(){
			$('#modal').jqm().jqmShow();
		});
		return false;
	});

	$("#poollogin a").click(function(){
		href =$(this).attr("href") + " #section .content";
		$('#modal').load(href,function(){
			FB.init({
				appId:'222510864477050',
				cookie:true,
				status:true,
				xfbml:true
			});

			FB.getLoginStatus(function(response) {
				if (response.status == 'connected')
				{
					// redirect to movie detail
					location.href = movieDetailUrl;
				}
			});

			FB.Event.subscribe('auth.login', function(response) {
				if (response.status == 'connected')
				{
					// redirect to movie detail
					location.href =  movieDetailUrl;
				}
			});

			$('#modal').jqm().jqmShow();
		});
		return false;
	});

	$("#poolpay a").popup({width: 720,height: 600,left:20,top:20});
	
	$("#home .item1 a").click(function(){
		clipsanPlayerScriptIncluded = false;
		$('#modal').jqm({ajax:$(this).attr("href")+'?popup=1', onLoad:function(hash){
			hash.w.jqmAddClose($('.modal-close'));
		}})
		.jqmShow();
		return false;
	});
	
	/*if (document.cookie.indexOf('valentine-message=true') == -1)
	{
        var year = 1000*60*60*24*365;
        var expires = new Date((new Date()).valueOf() + year);
        document.cookie = 'valentine-message=true;expires=' + expires.toUTCString();
        $('#valentine-home-message').jqm().jqmShow();
    }
    */
});
