﻿/*------------------------------------
ZG9uZSBieSBqb+NvIG9saXZlaXJhIGoub2xpdmVpcmE4N0BnbWFpbC5jb20=
WIDE poghen poll
www.wide.pt
-----------------------------------*/
var slideshowp = new function () {
        var instance = this;
        this.pp = -1
        this.pc = 2;
        this.start = function () {
            var xx = $("ul#pjs").children();
            xx.hide();
            for (i = 0; i < 3; i++) {
                $(xx[i]).show();
            }
            $("#setapd").click(function () {
                var pd = xx.length - 1
                $("#setape").show();
                if (instance.pc < pd) {
                    var i = 0;
                    for (i = 0; i < 3; i++) {
                        instance.pp++;
                        $(xx[instance.pp]).css("display", "none");
                        instance.pc++;
						$(xx[instance.pc]).animate({
                            opacity: 'show'
                        }, 'fast');
                        if (instance.pc == instance.pd){
                            $("#setapd").hide();
                        }
                    }
                }
            });
            $("#setape").click(function () {
                $("#setapd").show();
                if (instance.pp >= 0) {
                    var i = 0;
                    for (i = 0; i <= 2; i++) {
                        $(xx[instance.pc]).css("display", "none");
                        $(xx[instance.pp]).animate({
                            opacity: 'show'
                        }, 'fast');
                        instance.pp--;
                        instance.pc--;
                        if (instance.pp == -1) {
                            $("#setape").hide();
                        }
                    }
                }
            });
            xzx = $("#setapd, #setape");
            (xzx).hover(function () {
                var ppc = $(this).attr('id');
                $(this).css("background", "url(images/" + ppc + "2o.png)");
            }, function () {
                var ppc = $(this).attr('id');
                $(this).css("background", "url(images/" + ppc + "2.png)");
            });
        }
    }
var hitpointshow = new function () {
        var instance = this;
        this.divactual = 0;
        this.conteudodiv;
        this.textdiv;
        this.subdiv;
        this.std;
		this.nsubdivs

        function shownext(current) {
            var nextone = $(current).next();
            if ($(nextone).length == 0) {
                current.css('display', 'none');
                current.parent().children().first().animate({
                    opacity: 'show'
                }, 'fast');
                nextone = $(current).parent().children().first();
                return nextone;
            } else {
                current.css('display', 'none');
                current.next().animate({
                    opacity: 'show'
                }, 'fast');
                return nextone;
            }
        }

        function voltainicio(current) {
            $(current).css('display', 'none');
            $(current).parent().children().first().animate({
                opacity: 'show'
            }, 'fast');
            var nextone = $(current).parent().children().first();
            return nextone;
        };
        this.reset = function (sld) {
            instance.divactual = 0;
            $('#hpbox, #xx').add(this.conteudodiv).animate({
                opacity: 'hide'
            }, 'fast');
            if (undefined != instance.subdiv && undefined != instance.textdiv) {
                voltainicio(instance.subdiv);
                voltainicio(instance.textdiv);
            }
            if (sld == 1) {
                $(instance.std).show();
            }
        }
		this.mfotos =function(axs) {
		var aux,ntext,imgdiv;
						aux=$("#" + instance.divactual).get();
						imgdiv = $("#" + $(aux).attr('id') + "img").get();
						this.nsubdivs = $(imgdiv).children().length;
						if (this.nsubdivs > 1) {
                        instance.subdiv = $(imgdiv).children().first();
                        $("#seta").css('display', 'inline');
						if (axs== undefined){
                        aux = $("#" + instance.divactual + "text").get();
                        ntext = $(aux).children().length;
                        instance.textdiv = $(aux).children().first();}
							$("#seta").click(function () {
                            instance.subdiv = shownext(instance.subdiv);
                            if (ntext > 1) {
                                instance.textdiv = shownext(instance.textdiv);
                            }
                        });
		}}
        this.start = function (sld, axs) {
            var imgdiv;
			if (axs == 1) {
			instance.divactual="hpc11";
			instance.mfotos(axs)}
            $(".hitpoints").children('div,img').click(function () { 
                $("#seta").unbind("click");
                if ($(this).attr('id') != instance.divactual) {
                    if (axs == 1) {
                        hoverfunc.sldcounter=1;
                        hoverfunc.reset(instance.divactual);
                        imgdiv = $("#" + $(this).attr('id') + "img").get();
                        $(imgdiv).children().not(":first-child").css('display', 'none');
                        $(imgdiv).children(":first-child").fadeIn();
                    }
                    if (axs == undefined)$("#hpbox").children().not("#xx").css('display', 'none');
                    instance.reset();
                    instance.divactual = $(this).attr('id');
                    this.conteudodiv = $("#" + $(this).attr('id') + "c").get();
                    $("#hpbox, #xx").add(this.conteudodiv).fadeIn("medium", function () {
                        $("#hpbox").css("visibility", "visible");
                    });
                    imgdiv = $("#" + $(this).attr('id') + "img").get();
                    nsubdivs = $(imgdiv).children().length;
				instance.mfotos(axs);
                }
                if (sld == 1) {
                    instance.std = $("#setape:visible, #setapd:visible");
                    $(instance.std).hide();
                }
                return false;
            });
            $('#xx, #background').click(function () {
                instance.reset(sld);
				if (ytplayer.stopVideo)	ytplayer.stopVideo();
				if (ytplayer2.stopVideo)	ytplayer2.stopVideo();
            });
        }
    }
var bckslide = new function () {
        var instance = this;
        this.ult;
        this.lock = 0;
        this.cact = 1;
        this.ncozinhas;
        this.timerid = 0;

        function showdivact() {
            $("#showdivactual").empty();
            $("#showdivactual").append(instance.cact + "/6");
        }

        function nextorprev(nop, sld, vv) {
            if (instance.lock == 0) {
                if (vv == 1) {
                    vel = 1500
                } else {
                    vel = "fast"
                }
                instance.lock = 1;
                if (sld == 1) {
                    $("#setad").show();
                    $("#setae").hide();
                    if (instance.cact >= instance.ncozinhas) {
                        instance.cact = 0;
                    }
                }
                $("#background").css("display", "none");
                hitpointshow.reset.call();
                $("#cozinha" + instance.cact).children().hide();
                var x = "#cozinha" + instance.cact;
                if (nop == 1) {
                    instance.cact++;
                    if (instance.cact >= instance.ncozinhas) {
                        $("#setad").hide();
                    }
                    $("#setae").show();
                } else {
                    instance.cact--;
                    $("#setad").show();
                }
                if (instance.cact <= 1) {
                    $("#setae").hide();
                }
                $("#background").children('img').attr("src", "images/" + instance.ult + "bg" + instance.cact + ".jpg");
                conteudoc = $("#cozinha" + instance.cact).get();
                $(conteudoc).children().show();
                $("#background").children('img').attr("src", "images/" + instance.ult + "bg" + instance.cact + ".jpg");
                conteudoc = $("#cozinha" + instance.cact).get();
                $(conteudoc).children().show();
                $("#background").animate({
                    opacity: 'show'
                }, vel);
                if (sld == 1) {
                    showdivact();
                    $("#logocc").children('img').attr("src", "images/" + instance.ult + "l" + instance.cact + ".jpg");
                    $("#setad").show();
                    if (instance.cact == 1) {
                        $("#revistas").css("display", "inline");
                    } else {
                        $("#revistas").css("display", "none");
                    }
                }
            }
            instance.lock = 0;
        }
        this.start = function (sld) {
            if (sld == 1) {
                instance.startslide();
                showdivact();
            }
            this.ncozinhas = $("#cozinhas").children().length;
            this.ult = $('body').children().first().attr("id");
            $("#setad, #setadireita").click(function () {
                nextorprev(1, sld);
                if (sld == 1) {
                    instance.resetslide();
                }
            });
            $("#setae").click(function () {
                nextorprev(0, sld);
                if (sld == 1) {
                    instance.resetslide();
                }
            });
            xx = $("#setad, #setae, #setadireita");
            (xx).hover(function () {
                var ppc = $(this).attr('id');
                $(this).css("background", "url(images/" + ppc + "2.png)");
            }, function () {
                var ppc = $(this).attr('id');
                $(this).css("background", "url(images/" + ppc + "2o.png)");
            });
        }
        this.startslide = function () {
            instance.timerId = window.setInterval(function () {
                nextorprev(1, 1, 1)
            }, 2500);
        }
        this.resetslide = function () {
            clearInterval(instance.timerId);
            instance.timerId = window.setInterval(function () {
                nextorprev(1, 1, 1)
            }, 2500);
        }
    }
var hoverfunc = new function (hvv) {
        var instance=this;
        this.div;
        this.sldlock=0;
        this.ss;
		this.play=0;
        this.sldcounter=1;
        this.start = function (hw, lli) {
            hw = $(hw).get();
            $(hw).children('a').children().hover(function () {
                var pp, cc;
                pp = $(this).attr("alt") + "o.png";
                $(this).attr("src", "images/" + pp);
                cc = $(this).attr("alt");
                if ($(this).parent().parent().attr("id") == "menus") {
                    cc = $("#" + cc + "p").get();
                    $(cc).css("display", "inline");
                }
                instance.div = $(this)
            }, function () {
                if (lli == 1) {
                    if ($(this).attr("id") != hitpointshow.divactual) {
                        var pp, cc;
                        pp = $(this).attr("alt") + ".png";
                        $(this).attr("src", "images/" + pp);
                        cc = $(this).attr("alt");
                        if ($(this).parent().parent().attr("id") == "menus") {
                            cc = $("#" + cc + "p").get();
                            $(cc).css("display", "none");
                        }
                    }
                } else {
                    var pp, cc;
                    pp = $(this).attr("alt") + ".png";
                    $(this).attr("src", "images/" + pp);
                    cc = $(this).attr("alt");
                    if ($(this).parent().parent().attr("id") == "menus") {
                        cc = $("#" + cc + "p").get();
                        $(cc).css("display", "none");
                    }
                }
            });
			$("#slseta").click(function(){
			if (instance.play==0){
			hoverfunc.sldshw(1);
			$(this).attr("src", "images/pause.png" );
			$(this).attr("alt", "pause" );
			instance.play=1;
			}else{
			hoverfunc.sldshw(0);
			$(this).attr("src", "images/hdir.png" );
			$(this).attr("alt", "hdir" );
			instance.play=0;}
			});return false;
        }
        this.reset = function (divact) {
            var pp;
            divact = document.getElementById(divact);
            pp = $(divact).attr("alt") + ".png";
            $(divact).attr("src", "images/" + pp);
            pc = $(divact).attr("id");
            pc = document.getElementById(pc+"c")
            $(pc).fadeOut("slow");
        };
        this.sldshw= function (ppc){
            if (ppc==1){
            if (instance.ss==undefined){   
            instance.sldlock=1;    
            instance.ss = setInterval(function(){
            if (instance.sldcounter< hitpointshow.nsubdivs){
            $("#seta").trigger('click');
            instance.sldcounter++;    
            }else{
            instance.nextyear();
            instance.sldcounter=1;    
            }       
           },3000);}}
           if (ppc==0){
             clearInterval(instance.ss);
             instance.ss=undefined;
             instance.sldlock=0;
             instance.sldcounter=1;     
           } 
        }
        this.nextyear= function(){
            var divact,divprev,pp;
           divprev = document.getElementById(hitpointshow.divactual);
           divact= $(divprev).next()
           if ($(divact).length == 0){
            pp = $(divprev).parent().children().first().attr("alt") + "o.png";
            $(divprev).parent().children().first().attr("src", "images/" + pp); 
             $(divprev).parent().children().first().trigger('click');
           }
           else{
            pp = $(divact).attr("alt") + "o.png";
            $(divact).attr("src", "images/" + pp);
            $(divact).trigger('click');}    
        }          
    }

function looppog() {
    $("img#plv1").fadeIn(1000, function () {
        $("img#plv2").fadeIn(2000, function () {
            $("img#plv3").fadeIn(2000);
        });
    });
    $("img#plv1").fadeOut(2000, function () {
        $("img#plv2").fadeOut(2000, function () {
            $("img#plv3").fadeOut(2000);
        });
    });
    window.setInterval(function () {
        $("img#plv1").fadeIn(1000, function () {
            $("img#plv2").fadeIn(2000, function () {
                $("img#plv3").fadeIn(2000);
            });
        });
        $("img#plv1").fadeOut(2000, function () {
            $("img#plv2").fadeOut(2000, function () {
                $("img#plv3").fadeOut(2000);
            });
        });
    }, 4000);
}
var interrupt = new function (xx) {
        var instance = this;
        this.ind = 2;
        this.ult = $('body').children().first().attr("id");
        this.start = function (xx) {
            $(xx).click(function () {
                $("#background").children('img').attr("src", "images/entbg" + instance.ind + ".jpg");
                if (instance.ind == 2) instance.ind = 0;
                instance.ind++;
            });
        }
    }

function mCustomScrollbars() {
    $("#mcs_container").mCustomScrollbar("vertical", 300, "easeOutCirc", 1.05, "auto", "yes", "yes", 15);
}

/* function to fix the -10000 pixel limit of jquery.animate */
$.fx.prototype.cur = function () {
    if (this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null)) {
        return this.elem[this.prop];
    }
    var r = parseFloat(jQuery.css(this.elem, this.prop));
    return typeof r == 'undefined' ? 0 : r;
}

function LoadNewContent(id, file) {
    $("#" + id + " .customScrollBox .content").load(file, function () {
        mCustomScrollbars();
    });
}
