// ATV Namespace
atv = {};
atv.home = {};
$(document).ready(function(){
	// Loop through initalitation object
	for(var i in atv.init){
		atv.init[i]();
	}
});

// Setup Main options
atv.options = {};
atv.options.gateway = "/com/remote/mailinglist.cfc";

/* Prepare Serivces */
atv.services = {};

// Setup Init object
atv.init = {};

atv.init.browser = function(){
	if(jQuery.browser.mozilla){
		if(jQuery.browser.version.substring(0,3) == "1.8"){
			$("body").addClass("firefox2");
		} else {
			$("body").addClass("firefox3")
		};
	};
	if(jQuery.browser.msie){
		$("body").addClass("ie"+parseInt(jQuery.browser.version));
	};
	if(jQuery.browser.safari){
		$("body").addClass("safari");
	};
}

// Setup Main Cufon options
atv.init.cufon = function(){
	if(atv.language == "jp"){
		atv.cufon = false;
	} else {
		atv.cufon = true;
	};
	if(atv.cufon){
		Cufon.set({
			fontFamily: 'Adobe Clean',
			fontWeight: 700
		}).replace('#freshfollow, idRequired div, #denotion div, #title h3, #close,.bold,.cufon,h1,h3,.cleantext, .share a, .left_col .morevideos,#updates .update .updatedetails .title,#followus .list .listtitle, #followus .list .title,.left_col .nowplaying, #header #topnav div')('.button');
		Cufon.set({
			fontFamily: 'Adobe Clean',
			fontWeight: 300
			}).replace('.fresh')('.signin')('h2');
	};
};
Cufon('h3#findtime', {
	hover: {
		color: '#fbb034'
	}
});


atv.init.setTopLinks = function(){
	$("#topnav #lang li").click(function(){
		window.location = $(this).find("a").attr("href");
	});
	$("#signout").live('click',function(){
		window.location = $("#logout").find("a").attr("href");
	});
};


// Setup Global Forms
atv.init.forms = function(){
	$("input.nocomplete").attr("autocomplete","off");
};

// Setup User
atv.user = { id : -1 };
atv.strings = {};

atv.init.langFlag = function() {
	
	$('#' + atv.language).css({opacity:1});
	
	$('#header .banner #topnav #lang li').mouseover(function() {
		$(this).fadeTo('fast',1);
	}).mouseout(function() {
		if ($(this).attr('id') != atv.language) {
			$(this).fadeTo('fast',.50);
		};
	});
	if (typeof atv.ap == 'undefined') {
		$('.button').css({
	        opacity: .80
	    }).mouseenter(function(){
	        $(this).fadeTo('fast', 1);
	    }).mouseleave(function(){
	        $(this).fadeTo('fast', .80);
	    });
	}
	$('#ap-link').fadeTo(0,.35);
	$('#ap-link').hover(function() {
		$(this).fadeTo('fast',1);
	},function() {
		$(this).fadeTo('fast',.35);
	});
	
}


atv.init.zFixIE6 = function(){
	if($.browser.msie && $.browser.version=="6.0"){
		DD_belatedPNG.fix('#header .banner .logo,.right_col .shareicons li a,#followus .list .user .details .social li a,#footer .links .link,#counter div');
	};
};
