﻿Shadowbox.init({
players: ["flv"],
    autoplayMovies: true,
    displayNav: true,
    displayCounter: false,
    viewportPadding: 0,
    autoDimensions: true
});

document.staticClass = new String();

$(document).ready(function() {
    $('.navigation ul li:first').addClass("navigationHome");
    $('h2.image img').each(function() { $(this).parent().css('background-image', 'url(' + $(this).attr('src') + ')') });
    $('.navigation>ul>li:has(ul)').append('<img src="/Images/nav-top.png" class="navtop" />');
    $('.jscroll').jScrollPane({ scrollbarMargin: 10, scrollbarWidth: 15, showArrows: true });
    if (typeof (toolTips) == 'function') { toolTips(); }
    if (typeof (popup) == 'function') { popup(); }

    $('.btnPrivacyNewsLetterSignUp > input').addClass('greenBtn');

    $('input:submit').addClass('greenBtn');

    var staticClass = $("#pactHeader h2").attr("class");
    $("#pactHeader h1 a").bind('mouseover mouseout', function(e) {
        $("#pactHeader h2").toggleClass(staticClass);
        $("#pactHeader h2").toggleClass(this.title.replace(' ', ''));
    });

    if ($('.commentList').is(':visible')) {
        $('div.postComments div:first').addClass('commentsheaderChangePos');
        $('div#tags').addClass('tagsChangePos');
        /* $('.blogPost #tags').css({'margin-top' : '60px'});
        $('.commentsHeader').css({'position' : 'relative', 'margin-top' :'-50px', 'z-index ' : '90'});
        $('.commentList').css({'position' : 'relative', 'margin-top' :'40px', 'z-index ' : '90'});
        */
    }

    $(function() {
        // Add a click handler to all the items in the list to toggle their divs open or closed
        $(".silver h3").click(function() {
            $(this.parentNode.getElementsByTagName("div")).toggle('fast');
        });


    });
    heightleftBlock1 = $(".box285Block1 .box285Left .box285Content").height();
    heightRightBlock1 = $(".box285Block1 .box285Right .box285Content").height();
    if (heightleftBlock1 > heightRightBlock1) {
        heightMaxBlock1 = heightleftBlock1;
    } else {
        heightMaxBlock1 = heightRightBlock1;
    }
    $(".box285Block1 .box285Left .box285Content").css("height", heightMaxBlock1 + "px");
    $(".box285Block1 .box285Right .box285Content").css("height", heightMaxBlock1 + "px");

    heightleftBlock2 = $(".box285Block2 .box285Left .box285Content").height();
    heightRightBlock2 = $(".box285Block2 .box285Right .box285Content").height();
    if (heightleftBlock2 > heightRightBlock2) {
        heightMaxBlock2 = heightleftBlock2;
    } else {
        heightMaxBlock2 = heightRightBlock2;
    }
    $(".box285Block2 .box285Left .box285Content").css("height", heightMaxBlock2 + "px");
    $(".box285Block2 .box285Right .box285Content").css("height", heightMaxBlock2 + "px");

});


function toolTips() {
    document.tTitle = new String();
    $("a.tooltip")
	    .hover(function() {
	        var tip = $("#tooltip");
	        var elm = $(this);
	        var variantTop=-22;
	            var bro = $.browser.msie;
	           /* alert(jQuery.browser.version);*/
                if(bro==true){
                    variantTop=-24;
                }
	        if (!tip.length) {
	            tip = $('<div id="tooltip"></div>').insertAfter("#center");
	            oWidth = tip.width();
	        }
	        tip.width(elm.attr("rel") || oWidth);
	        document.tTitle = elm.attr("title");
	        elm.attr("title", '');
	        reposLeft = 0;
	        if(elm.offset().left < 170){
	            reposLeft = 10;
	        } else {
	            reposLeft = parseInt(elm.offset().left) - ((tip.width() / 2) + 15) + (elm.width() / 2);
	        }
	        	        
	        tip
			    .html(document.tTitle + '<span></span>')
                .css({
                   top: elm.offset().top - tip.height() + variantTop,
			       left: reposLeft
			       
			   })
			   
			   .show();
			   
	    },
	    function() {
	        //$("#tooltip").hide();
	        $("#tooltip").css("left","-9999px");
	        this.title = document.tTitle;
	    })
	    .click(function(evt) {
	        evt.preventDefault();
	    });
}


function SetUniqueRadioButton(nameregex, current) {
    re = new RegExp(nameregex);
    for (i = 0; i < document.forms[0].elements.length; i++) {
        elm = document.forms[0].elements[i]
        if (elm.type == 'radio') {
            if (re.test(elm.name)) {
                elm.checked = false;
            }
        }
    }
    current.checked = true;
}

function LoadVideo(videoPlayerId, videoFile, videoImage) {
    var so = new SWFObject('/Swf/player.swf', 'playerswf', '100%', '100%', '9', '#FFFFFF');
    so.addVariable('path', '/');
    so.addParam('scale', 'noscale');
    so.addParam('salign', 'lt');
    so.addParam('wmode', 'transparent');
    so.addVariable('file', videoFile);
    so.addVariable('previewImage', videoImage);
    so.addVariable('skinColor', '#3b3b3b');
    so.addVariable('iconColor', '#ffffff');
    so.addVariable('actionColor', '#99CC63');
    so.addVariable('textColor', '#ffffff');
    so.addVariable('backgroundColor', '#000000');

    var videoPlayer = document.getElementById(videoPlayerId);

    if (deconcept.SWFObjectUtil.getPlayerVersion()['major'] >= 9) {
        so.write(videoPlayer);
    }

    videoPlayer.style.display = 'block';
}

/*Pool*/
$(document).ready(function() {
    if ($("div.surveyResultsLine").length == 0)
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(poll_EndRequestHandler);
    else
        poll_EndRequestHandler();
});

function poll_EndRequestHandler() {
    var r = '<ul>';
    $("div.surveyResultsLine").each(function() {
        var el = $(this);

        var title = el.find("span.surveyResultsName").text();
        var percent = el.find("span.surveyResultsPercent").text();

        r += '<li><span style="color: #589fd6; opacity: 0; width: 0; display: block;">' + percent + '</span> ' + title + '</li>';
    });
    r += '</ul>';

    $("div.surveyResults").html(r);

    $("div.surveyResults ul li span").each(function() {
        $(this).animate({
            opacity: 1,
            width: this.innerHTML
        }, 2000, null, function() {
            $(this).css('color', '#fff');
        });
    });
}

function popup() {
    $('a.popup').click(function(evt) {
        evt.preventDefault();
        window.open(this.href, "popupWindow", "height=600,width=800,menubar=no,toolbar=no,scrollbars=yes,location=no");
    });
}


function displayLoginForm() {
    var obj = $('#ctl00_ContentPlaceHolderRight_FamilyChallengeBox1_FloatingLogin1_PopupPanel');
    obj.show();
    var ext = $('#ctl00_ContentPlaceHolderRight_FamilyChallengeBox1_FloatingLogin1_ModalPopupExtender1_backgroundElement')
    ext.css('display', 'block');
    ext.addClass('modalBackground');
    ext.width($(window).width());
    ext.height($(window).height());
    obj.css('left', '400px');
    obj.css('position', 'fixed');
    obj.css('top', '200px');
    obj.css('z-index', '100001');
}

