var height;

$(window).load(function() {

	height = $(".resultsComparison table thead").height();
	height+=47;
	$(".resultsHeaderFrame, .resultsHeaderFrameIns, .resultsHeaderFrameEnergy, .resultsHeaderFrameTv, .resultsHeaderFrameInternet").css("height", height+"px");

/* Table results compare & table send form  & table forum */

    $(".resultsComparison table tbody tr:nth-child(odd), .askAbout table tbody tr:nth-child(odd)").addClass("striped");
	
	$("#similarOffer tbody tr:nth-child(odd)").removeClass("striped");
	$("#similarOffer tbody tr:nth-child(odd)").addClass("stripedDark");
	$("#similarOffer tbody tr:nth-child(even)").addClass("stripedLight");
	
	$("td:first",".resultsComparison table tbody tr:nth-child(odd), .askAbout table tbody tr:nth-child(odd)").addClass("first");
	$("td:last",".resultsComparison table tbody tr:nth-child(odd), .askAbout table tbody tr:nth-child(odd)").addClass("last");

	if ($("tr:last").attr("class") == "") {
		$("tr:last td",".resultsComparison table tbody, .askAbout table tbody").addClass("borderNone");
	}
	
	if ($(".offerListTv tbody tr:last").attr("class") == "") {
		$("tr:last td",".resultsComparison table.offerListTv tbody").addClass("borderNone");
	}
	
	

	$(".boxForum table tr:last td").addClass("borderNone");

/* Table product details */

	$("table.stripedTable tbody tr:nth-child(odd) td, table.stripedTable tbody tr:nth-child(odd) th").addClass("striped");

/* Table compare & table calculate */

	$("#compareProducts table tbody tr td:nth-child(even), .calculateForm table tbody tr td:nth-child(even)").addClass("striped");
    
});

/* Show hint mouseover */

$(document).ready(function() {

/* Fix default */

    $(".resultsComparison table tbody tr").each(function() {
        var el = $(this);
        if (el.hasClass("defaultTariff")) {
            el.addClass("defaultTariffFix");
        }
    });

/* Show hint mouseover */
 
	$("a.showHint, span.datePriceGuarantee, span.monthlyPrice, img.formHint, img.calcHint, img.formMultiOpHint, img.consolidationHint, p.errodHintInfo, .tvBalloon img, .dataFormTv p img, .descOfferSponsored a, .descOfferOfItem a, img.toolTip").mouseover( function() { 
		$(this).next(".balloon, .balloon, .balloon, label.balloonForm, label.balloonForm, .balloon, .balloon, .balloonError, .balloon, label.balloonForm, .balloon, .balloon, .balloonTip").css("display","block");
	} );
	
	
	$("a.showHint, span.datePriceGuarantee, span.monthlyPrice, img.formHint, img.calcHint, img.formMultiOpHint, img.consolidationHint, p.errodHintInfo, .tvBalloon img, .dataFormTv p img, .descOfferSponsored a, .descOfferOfItem a, img.toolTip").mouseout( function() { 
		$(this).next(".balloon, .balloon, .balloon, label.balloonForm, label.balloonForm, .balloon, .balloon, .balloonError, .balloon, label.balloonForm, .balloon, .balloon, .balloonTip").css("display","none");
	} );
	
	}

);

/* Buttons hints */

$(function () {
	$('.compareButton1, .compareButton2, .compareButton3, .compareButton4').each(function () {
		var distance = 10;
		var time = 250;
		var hideDelay = 100;

		var hideDelayTimer = null;

		var beingShown = false;
		var shown = false;
		var trigger = $('.trigger', this);
		var info = $('.popup, .popup2 ', this).css('opacity', 0);


		$([trigger.get(0), info.get(0)]).mouseover(function () {
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			if (beingShown || shown) {
				// don't trigger the animation again
				return;
			} else {
				// reset position of info box
				beingShown = true;

				info.css({
					top: -80,
					left: 0,
					display: 'block'
				}).animate({
					top: '-=' + distance + 'px',
					opacity: 1
				}, time, 'swing', function() {
					beingShown = false;
					shown = true;
				});
			}

			return false;
		}).mouseout(function () {
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			hideDelayTimer = setTimeout(function () {
				hideDelayTimer = null;
				info.animate({
					top: '-=' + distance + 'px',
					opacity: 0
				}, time, 'swing', function () {
					shown = false;
					info.css('display', 'none');
				});

			}, hideDelay);

			return false;
		});
	});
});