﻿$(document).ready(function () {
    $("div.form-new div.formbutton-right div.field input").wrap("<span class='btn'></span>");
    $("div.form-new div.formbutton-extra div.field input").wrap("<span class='btn'></span>");

    $('div.eccolumns-subindex div.image-left').parent("div.block-image").addClass('left');
    $('div.eccolumns-subindex div.column-right:has(div.image-left)').addClass('imgtxt');

    $('div.eccolumns-subindex div.column-right:has("div.image-subindex")').each(function () {
        $(this).children('div.block-paragraph').hide();
        $(this).children('div.block-image.left').hide();

        $(this).mouseover(function () {
            $(this).children('div.block-paragraph').show();
            $(this).children('div.block-image.left').show();
            $(this).addClass('selected');
        });

        $(this).mouseout(function () {
            $(this).children('div.block-paragraph').hide();
            $(this).children('div.block-image.left').hide();
            $(this).removeClass('selected');
        });
 
    })

    $(".RadioYesNo").dgStyle();

    $("#datepickerBgNormalNoLabel").datepicker({ showOn: "button", buttonImage: "_images/ui/calendar.gif", buttonImageOnly: true });
    $("#datepickerBgNormalLabel").datepicker({ showOn: "button", buttonImage: "_images/ui/calendar.gif", buttonImageOnly: true });
    $("#datepickerBgNormalLabelError").datepicker({ showOn: "button", buttonImage: "_images/ui/calendar.gif", buttonImageOnly: true });
    $("#datepickerGrayBgNormalNoLabel").datepicker({ showOn: "button", buttonImage: "_images/ui/calendar.gif", buttonImageOnly: true });
    $("#datepickerGrayBgNormalLabel").datepicker({ showOn: "button", buttonImage: "_images/ui/calendar.gif", buttonImageOnly: true });
    $("#datepickerGrayBgNormalLabelError").datepicker({ showOn: "button", buttonImage: "_images/ui/calendar.gif", buttonImageOnly: true });
    $("#datepickerBgNormalSmallLabelError").datepicker({ showOn: "button", buttonImage: "_images/ui/calendar.gif", buttonImageOnly: true });
    $("#datepickerBgNormalWideLabelError").datepicker({ showOn: "button", buttonImage: "_images/ui/calendar.gif", buttonImageOnly: true });
    $("#datepickerGrayBgNormalSmallLabelError").datepicker({ showOn: "button", buttonImage: "_images/ui/calendar.gif", buttonImageOnly: true });
    $("#datepickerGrayBgNormalWideLabelError").datepicker({ showOn: "button", buttonImage: "_images/ui/calendar.gif", buttonImageOnly: true });
})

function DoJQuery() {
	$('div.form-new div.formbutton-right div.field span.btn').mouseover(function () { $(this).addClass('selected') })
	$('div.form-new div.formbutton-right div.field span.btn').mouseout(function () { $(this).removeClass('selected') })
	$('div.form-new div.formbutton-extra div.field span.btn').mouseover(function () { $(this).addClass('selected') })
	$('div.form-new div.formbutton-extra div.field span.btn').mouseout(function () { $(this).removeClass('selected') })
}

//input hover icm met jquery
$(document).ready(function () {
	DoJQuery();
})

var HideElement = null
var Number = 0
var Timeouts = new Array()
var Elements = new Array()
var Visible = new Array()
var HidingQueue = new Array()
var MenuOpened = false


$(document).ready(function () {
    // homepage
    $('.navigation-home ul li').mouseout(function () { showPopup(this, false) });
    $('.navigation-home ul li').mouseover(function () { showPopup(this, true) });


    //boxinsur homepage
    //    $('.boxinsur').mouseover(function () { showSubindex(this, true) });
    //    $('.boxinsur').mouseout(function () { showSubindex(this, false) });

})


// subindex
//var subindexTimeout;
//var activeSubindex;
//function showSubindex(obj, show) {
//    clearTimeout(subindexTimeout);
//    if (show) {
//        hideActiveSubindex();
//        $(obj).addClass("selected");
//        activeSubindex = obj;
//    }
//    else {
//        subindexTimeout = setTimeout("hideActiveSubindex()", 100);
//    }
//}

//function hideActiveSubindex() {
//    if (activeSubindex != null) {
//        $(activeSubindex).removeClass("selected");
//    }
//}

// Tooltip
var tooltip

function MouseOver(id, evnt) {
    tooltip = document.getElementById(id)
    if (!tooltip) return
    evnt = evnt || event
    LocateTooltip(evnt)
    tooltip.style.display = 'block'
}

function MouseOut(id, evnt) {
    if (!tooltip) return
    tooltip.style.display = 'none'
    tooltip = null
}

function Mousemove(evnt) {
    if (!tooltip) return
    evnt = evnt || event
    LocateTooltip(evnt)
}

function LocateTooltip(evnt) {
    mx = evnt.clientX + 16 + document.documentElement.scrollLeft
    my = evnt.clientY + document.documentElement.scrollTop
    var tooltipWidth = tooltip.clientWidth
    if (tooltipWidth == 0) tooltipWidth = 250;

    if (mx + tooltipWidth > document.body.offsetWidth + document.body.scrollLeft) {
        var x = (document.body.clientWidth - mx + 32) + 'px'
        tooltip.style.right = x
        tooltip.style.left = ''
    }
    else {
        tooltip.style.left = mx + 'px'
    }
    tooltip.style.top = my + 'px'
}


// popup menu code 
var activePopup = null;
var popupTimeout;
var activeMenu;
function showPopup(obj, show) {
    clearTimeout(popupTimeout);
    if (show) {
        hideActivePopup();
        thisPopup = $(obj).children("ul");
        $(obj).addClass("selected");
        thisPopup.show();
        activePopup = thisPopup;
        activeMenu = obj;
    }
    else {
        popupTimeout = setTimeout("hideActivePopup()", 100);
    }
}

function hideActivePopup() {
    if (activePopup != null) {
        $(activePopup).hide();
        $(activeMenu).removeClass("selected");
    }
}
// end of popup menu code 


$(document).ready(function () {
	$('.formradio-yesno').each(function () {
		var buttonYes = jQuery('.RadioYes', $(this));
		var buttonNo = jQuery('.RadioNo', $(this));


		//PreCondition (toggle div on/off)
		if (jQuery('.RadioYes', $(this)).hasClass('precondition')) {
			var preYes = jQuery('.preConditionYes', $(this));
			preYes.css('display', 'none');
			buttonYes.mouseup(function () { preYes.css('display', 'block'); });
			buttonNo.mouseup(function () { preYes.css('display', 'none'); });
		}

		if (jQuery('.RadioNo', $(this)).hasClass('precondition')) {
			var preNo = jQuery('.preConditionNo', $(this));
			preNo.css('display', 'none');
			buttonNo.mouseup(function () { preNo.css('display', 'block'); });
			buttonYes.mouseup(function () { preNo.css('display', 'none'); });
		}

		//Anchor internal
		if (jQuery('.RadioYes', $(this)).hasClass('anchor')) {
			var ayes = jQuery('.yes-anchor', $(this)).attr('href');

			//Check of external
			if (jQuery('.yes-anchor', $(this)).attr('target') != '_blank') {
				buttonYes.mouseup(function () { location.href = ayes });
			} else {
				buttonYes.mouseup(function () { window.open(ayes); });
			}
		}

		if (jQuery('.RadioNo', $(this)).hasClass('anchor')) {
			var ano = jQuery('.no-anchor', $(this)).attr('href');

			//Check if external
			if (jQuery('.no-anchor', $(this)).attr('target') != '_blank') {
				buttonNo.mouseup(function () { location.href = ano });
			} else {
				buttonNo.mouseup(function () { window.open(ano); });
			}
		}

	});
});


