function set_position(w_width, w_height){return function(){
    //show-hide becouse jquery not calculate w/h if parent holder is hidden
    jQuery('.opasity').css('display','block');
    var left = Math.floor((w_width - jQuery(this).width())/2);
    if (jQuery.browser.msie && jQuery.browser.version == '6.0') {
        var top = Math.floor((w_height - jQuery(this).height())/2);
    } else {
        var top = Math.floor((w_height - jQuery(this).height())/2);
    }
    jQuery('.opasity').css('display','none');
    if (top<25) top = 25;
    jQuery(this).css("left",left+"px");
    jQuery(this).css("top",top+"px");
}}
function choose_test(link){
    var link_id = jQuery(link).attr("id");
    var test_id = link_id.substr(9,link_id.length-9);
    jQuery(".quote p").css('display','none');
    jQuery("#test_text"+test_id).css('display','block');
    jQuery("span.autor").css('display','none');
    jQuery("#test_title"+test_id).css('display','block');
    clearInterval(switch_interval);
    switch_interval = setInterval("switch_test_right()", 5000);
}
var options2 = {
    speed: 20,
    delay: 3000,
    list: [
        "ParliamentToday is the Internet portal for the tailored Parliamentary monitoring service operated by Parliamentary News Service ...",
        "The Members Lobby contains the contact and biographical details of all Parliamentarians and others.",
        "Have your own eyes and ears at Westminster, the European institutions and the devolved assemblies.",
        "Our interactive diary helps you plan ahead and never be taken by surprise."
    ]
}
var images = new Array();
var smarty_host = 'www.parliamenttoday.com';
var arguments = new Array(
    "http://"+smarty_host+"/images/banner-green-hov.jpg",
    "http://"+smarty_host+"/images/button-fill-hov.gif",
    "http://"+smarty_host+"/images/more-blue-hover.png",
    "http://"+smarty_host+"/images/more-green-hover.png",
    "http://"+smarty_host+"/images/more-red-hover.png",
    "http://"+smarty_host+"/images/btn-news-hover.png",
    "http://"+smarty_host+"/images/btn-diary-hover.png",
    "http://"+smarty_host+"/images/btn-members-lobby-hover.png",
    "http://"+smarty_host+"/images/click-left-hov.gif",
    "http://"+smarty_host+"/images/click-right-hov.gif"
);
function preload(arguments) {
for (var i = 0; i < arguments.length; i++) {
 images[i] = new Image();
 images[i].src = arguments[i];
}
}
preload(arguments);

jQuery(document).ready(function() {
    /*if (jQuery.browser.msie && jQuery.browser.version == '6.0') {
        if (document.documentElement.clientWidth < 1400) {
          document.body.style.width = 1400;
          jQuery('div.ie6').width('1400px');
          jQuery('div.ie6').css('min-width','1400px');
        }
    }*/
    var w_height = jQuery(window).height();
    var w_width = jQuery(window).width();
    jQuery("#wpt_1, #wpt_2, #wpt_3, #wpt_advantages, #wpt_services, #wpt_pricing, #wpt_support,"
         +" .popup-box-diary, .popup-box-news, .popup-box-lobby").each(set_position(w_width, w_height));

    //news-diary-lobby show more
    jQuery('a.show_news, a.show_diary, a.show_lobby').click(
    function banner_popup_show(){
        var container = ".popup-box-"+jQuery(this).attr('class').substring(5);
        if (jQuery.browser.msie && jQuery.browser.version == '6.0') {
            jQuery(".opasity").css('display','block');
            jQuery(".opasity").height(jQuery(document).height()+'px');
            var top = document.documentElement.scrollTop + 50;
            if (top+jQuery(container).height()>jQuery(document).height())
                top = jQuery(document).height() - jQuery(container).height() - 25;
            jQuery(".popup-box-diary, .popup-box-news, .popup-box-lobby").css("top",top+"px");
        } else {
            jQuery(".opasity").css('display','block');
        }
        jQuery(container).css('display','block');
    });
    jQuery('a#hide_news, a#hide_diary, a#hide_lobby').click(
    function banner_popup_hide(){
        jQuery(".popup-box-"+jQuery(this).attr('id').substring(5)).css('display','none');
        jQuery(".opasity").css('display','none');
    });

    //why-pt buttons
    jQuery('a#show_wpt_1, a#show_wpt_2, a#show_wpt_3, a#show_wpt_support,'
         +' a#show_wpt_advantages, a#show_wpt_services, a#show_wpt_pricing').click(
    function wpt_show(){
        var container = "#wpt_"+jQuery(this).attr('id').substring(9);
        if (jQuery.browser.msie && jQuery.browser.version == '6.0') {
            jQuery(".opasity").css('display','block');
            jQuery(".opasity").height(jQuery(document).height()+'px');
            var top = document.documentElement.scrollTop + 50;
            if (top+jQuery(container).height()>jQuery(document).height())
                top = jQuery(document).height() - jQuery(container).height() - 25;
            jQuery("#wpt_1, #wpt_2, #wpt_3, #wpt_advantages, #wpt_services, #wpt_pricing, #wpt_support")
                .css("top",top+"px");
        } else {
            jQuery(".opasity").css('display','block');
        }
        jQuery(container).css('display','block');
    });
    jQuery('a#hide_wpt_1, a#hide_wpt_2, a#hide_wpt_3, a#hide_wpt_support,'
         +' a#hide_wpt_advantages, a#hide_wpt_services, a#hide_wpt_pricing').click(
    function wpt_hide(){
        jQuery("#wpt_"+jQuery(this).attr('id').substring(9)).css('display','none');
        jQuery(".opasity").css('display','none');
    });

    if (jQuery('div.pagedSlider-container').length !== 0) {
        jQuery('div.pagedSlider-container').pagedSlider(options);
    }
    if (jQuery('.single-news div').length !== 0) {
        jQuery('.selector a.news-select').addClass('active');
        timer = setTimeout(function(){switchSlide('')},6000);
    }
    if (jQuery('div.news-main > span').length !== 0) {
        jQuery('div.news-main > span').listTypewriter(options2);
    }
});
