var arrow = "images/arrow.png";
var arrow_right = "images/arrow_over.png";
var arrow_down = "images/arrow_down.jpg";
var toggle=0;

var preco_unidade = 49;

/* 
 * START Mouseover and Mouseout Funtions
 */
function mouseover_img(imagem){
	document.getElementById(imagem).src=arrow_right;
}

function mouseout_img(imagem){
	document.getElementById(imagem).src=arrow;
}

/* 
 * START Toggle Faq Text
 */
function faq_toggle(obj_id,img_id){
	
	if(toggle==1){
		document.getElementById(obj_id).style.display = 'none';
		document.getElementById(img_id).src=arrow;
		toggle=0;
	}
	else{
		document.getElementById(obj_id).style.display = 'block';
		document.getElementById(img_id).src=arrow_down;
		toggle=1;
	}
}

function update_price()
{
	var quantidade = parseInt($('#num_licenses').val());
	/*var desconto = 0;
	
	if (quantidade >= 3 && quantidade <= 5)
	{
		desconto = 0.10;
	}
	else if (quantidade > 5)
	{
		desconto = 0.15;
	}*/
	var total = quantidade*preco_unidade;
	//total = desconto > 0 ? total-(total*desconto) : total;
	$('#total').html(total);
}

function check_message()
{
	var quant = parseInt($('#num_licenses').val());
	
	if (quant >= 3 && quant <= 5)
	{
		$('#discount_msg').html('10% discount will be applied during checkout.');
	}
	else if (quant >= 5)
	{
		$('#discount_msg').html('15% discount will be applied during checkout.');
	}
	else
	{
		$('#discount_msg').empty();
	}
}

$(document).ready(function(){
	
	update_price();
	
	$('.linkMenos').click(function(){
		var quant = parseInt($('#num_licenses').val());
		if (quant > 1)
		{
			$('#num_licenses').val(quant-1);
			update_price();
			check_message();
		}
	});
	
	$('.linkMais').click(function(){
		var quant = parseInt($('#num_licenses').val());
		if (quant < 100)
		{	
			$('#num_licenses').val(quant+1);
			update_price();
			check_message();
		}
	});

	$('.featuresMenuItem').click(function(){
		var ownlink = $(this).attr("href").split("/");
		var articleId = ownlink[ownlink.length-1];
		var newlink = "http://"+window.location.hostname+"/templates/site_features_content_obj.php/"+articleId+"___nocache=1";
		$(".features_right").load(newlink);
		return false;
	});

});