$(document).ready(function(){	
	setHeader();
	
	$("a#link0a, a#link0b, a#link0c").easyTooltip({
		useElement: "popup_what_this0"
	});
	
		$("a#link").easyTooltip({
			useElement: "popup_what_this"				   
		});
		$("a#link2").easyTooltip({
			useElement: "popup_what_this2"				   
		});
		$("a#link3").easyTooltip({
			useElement: "popup_what_this3"				   
		});
		$("a#link4").easyTooltip({
			useElement: "popup_what_this4"				   
		});
		$("a#link5").easyTooltip({
			useElement: "popup_what_this5"				   
		});
		$("a#link6").easyTooltip({
			useElement: "popup_what_this6"				   
		});
		$("a#link7").easyTooltip({
			useElement: "popup_what_this7"				   
		});
		$("a#link8").easyTooltip({
			useElement: "popup_what_this8"				   
		});
		$("a#link9").easyTooltip({
			useElement: "popup_what_this9"				   
		});
		$("a#link10").easyTooltip({
			useElement: "popup_what_this10"				   
		});

	//	Clear all the checked radios
	$(".plan_box .line1 input[type=radio], .plan_box .line6 input[type=radio]").removeAttr("checked");
	$(".plan_box .row input[type=radio]").removeAttr("checked");
	
	//	Select monthly radios
	$(".plan_box .row input[value=monthly]").attr("checked", "checked");

	$(".plan_box .line1 input[type=radio], .plan_box .line6 input[type=radio]").each(function(index){
		$(this).click(function(){
			toggleCol($(this), index);
		});
	});

	$(".select1 div:first-child").each(function(ind){$(this).bind('mouseenter', function(){
	var src = '/common/images/buy_it_now_btn.gif';
	$(".select1 div:last-child img").attr("src", src);
	$(".select1 div:last-child img").attr("class", 'cursor');	
	$(".bottom_payment_type:eq("+ind+")").hide();
	})
	});

	$(".select1 div:last-child").each(function(ind){$(this).bind('mouseenter', function(){
		var src = '/common/images/buy_it_now_btn_dis.gif';
		$(".select1 div:last-child img").attr("src", src);
		$(".select1 div:last-child img").attr("class", '');
	$(".bottom_payment_type:eq("+ind+")").show();
		var targetOffset = $(".select1 div:last-child").offset().top + 110;
		$('html,body').animate({scrollTop: targetOffset}, 1000);
	})
	});

	$(".line7").each(function(ind){$(this).bind('mouseleave', function(){
	var src = '/common/images/buy_it_now_btn.gif';
	$(".select1 div:last-child img").attr("src", src);
	$(".select1 div:last-child img").attr("class", 'cursor');
	$(".bottom_payment_type:eq("+ind+")").hide();
	})
	});
});

function inactiveRadio(i){
	$(".plan_box .line1 input[type=radio], .plan_box .line6 input[type=radio]").each(function(ind){		
		if(ind == i)
		{}
		else
		{
			$(this).parents("div").removeClass('plan_bg_hover').addClass('plan_bg');
			$(this).parents("ul").children("li.line7").children(".select1").css('display', 'none');
			$(this).parents("ul").children("li.line7").children(".select").css('display', 'block');		
		}
	})
}
function activeRadio(value){
	$(".plan_box .line1 input[type=radio], .plan_box .line6 input[type=radio]").each(function(ind){
	vn = $(this).val();
	if(value==vn)
		{
			$(this).parents("div").removeClass('plan_bg').addClass('plan_bg_hover');
		}
	
	})
}

function toggleCol(obj, index){	
	v = obj.val();
	if(obj.parents("div").hasClass('plan_bg'))
	{
		inactiveRadio(index);
		obj.parents("ul").children("li.line7").children(".select").css('display', 'none');
		obj.parents("ul").children("li.line7").children(".select1").css('display', 'block');
	}

	if(obj.parents("div").hasClass('plan_bg_hover'))
	{
		obj.parents("div").removeClass('plan_bg_hover').addClass('plan_bg');
		activeRadio(v);
	}
	else
	{
		obj.parents("div").removeClass('plan_bg').addClass('plan_bg_hover');
	}
	var noOfUsers = obj.parents("ul").children("li.line3").children(".pu-count").text().trim();
	selectCol(noOfUsers);
}
