$(document).ready(function(){
	setHeader();
	
	$("a#link0a, a#link0b, a#link0c").easyTooltip({
		useElement: "popup_what_this0"
	});
	
		$("a#link1").easyTooltip({
			useElement: "popup_what_this1"				   
		});
		$("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);
		});
	});

	//	Buy / Try Now button click event assignment
	$("img[group='try-btns']").each(function(index){
		$(this).click(function(){
			proceedToReg('trial');
		});
	});
	$("img[group='buy-btns']").each(function(index){
		$(this).click(function(){
			proceedToReg('buy');
		});
	});
});

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);
}
