/*------------------------------------
  ZG9uZSBieSBqb+NvIG9saXZlaXJhIGoub2xpdmVpcmE4N0BnbWFpbC5jb20=
  WIDE Stopline
  www.wide.pt
  -----------------------------------*/
//resizer function made forking * Easy Background Image Resizer   Developed by J.P. Given (http://johnpatrickgiven.com)
var ntcslider = new function () {
        "use strict";
        var instance = this;
        this.bbgimg = undefined;
        this.width = undefined;
        this.height = undefined;
        this.thumbs = undefined;
        this.background = undefined;
        this.currentfilm = undefined;
        this.ntcbox = undefined;
        this.current = 1;
        this.lock = 0;
        this.cinebox = undefined;
        this.currentbg = undefined;
        this.currentvbox = undefined;
        this.trailerinfo = undefined;
        this.currentpicservices = undefined;
        this.getWindowHeight = function () {
            var windowHeight = 0;
            if (typeof (window.innerHeight) === 'number') {
                windowHeight = window.innerHeight;
            } else {
                if (document.documentElement && document.documentElement.clientHeight) {
                    windowHeight = document.documentElement.clientHeight;
                } else {
                    if (document.body && document.body.clientHeight) {
                        windowHeight = document.body.clientHeight;
                    }
                }
            }
            return windowHeight;
        };
        this.getWindowWidth = function () {
            var windowWidth = 0;
            if (typeof (window.innerWidth) === 'number') {
                windowWidth = window.innerWidth;
            } else {
                if (document.documentElement && document.documentElement.clientWidth) {
                    windowWidth = document.documentElement.clientWidth;
                } else {
                    if (document.body && document.body.clientWidth) {
                        windowWidth = document.body.clientWidth;
                    }
                }
            }
            return windowWidth;
        };
        this.resize = function (bbg, op) {
            this.background = document.getElementById(bbg);
            this.background.style.position = "fixed";
            this.background.style.zIndex = "-1";
            this.background.style.overflow = "hidden";
            if (op === 1) {
                this.background.style.width = (this.getWindowWidth() * 5) + "px";
            }
            this.background.style.height = this.getWindowHeight() + "px";
            this.bbgimg = this.background.children[0];
            this.bbgimg = this.bbgimg.children[0];
            var iw = this.bbgimg.width;
            var ih = this.bbgimg.height;
            var fRatio = 0;
            if (this.getWindowWidth() > this.getWindowHeight()) {
                if (iw > ih) {
                    fRatio = iw / ih;
                    this.width = this.getWindowWidth() + "px";
                    this.height = Math.round(this.getWindowWidth() * (1 / fRatio)) + "px";
                    var newIh = Math.round(this.getWindowWidth() * (1 / fRatio));
                    if (newIh < this.getWindowHeight()) {
                        fRatio = ih / iw;
                        this.height = this.getWindowHeight() + "px";
                        this.width = Math.round(this.getWindowHeight() * (1 / fRatio)) + "px";
                    }
                } else {
                    fRatio = ih / iw;
                    this.height = this.getWindowHeight() + "px";
                    this.width = Math.round(this.getWindowHeight() * (1 / fRatio)) + "px";
                }
            } else {
                fRatio = ih / iw;
                this.height = this.getWindowHeight() + "px";
                this.width = Math.round(this.getWindowHeight() * (1 / fRatio)) + "px";
            }
            var aux;
            for (var i = 0; i <= this.background.children.length - 1; i++) {
                aux = this.background.children[i];
                aux = aux.children[0];
                aux.style.width = this.width;
                aux.style.height = this.height;
            }
            this.background.style.height = this.height;
            if (op === 2) {
                if (instance.lock === 0) {
                    if (instance.currentbg) {
                        aux = -1 * (instance.current - 1) * instance.currentbg.width + 'px';
                    }
                    $(instance.background).css('left', aux);
                }
            }
        };

        function move(e) {
            var numt, aux;
            var target = (e.target) ? e.target : window.event.srcElement;
            if (instance.lock === 0 && instance.currentfilm !== target) {
                instance.lock = 1;
                if (!target.alt) {
                    instance.lock = 0;
                    return;
                }
                var reg = /[0-9]+/;
                numt = parseInt(target.alt.match(reg), 10);
                aux = -1 * (numt - 1) * instance.bbgimg.width + 'px';
                $(instance.background).animate({left: aux}, 1500, function () {
                    instance.lock = 0;
                });
                aux = document.getElementById("ntb" + instance.current);
                aux.className = "hidden banimate";
                aux.style.opacity = "0";
                instance.current = numt;
                instance.currentbg = document.getElementById("background").children[instance.current - 1].children[0];
                aux = document.getElementById("ntb" + instance.current);
                aux.className = "banimate";
                $(aux).animate({opacity: 1}, 1000);
                instance.currentfilm.style.opacity = "";
                instance.currentfilm = instance.thumbs.children[numt - 1];
                instance.currentfilm = instance.currentfilm.children[0];
                instance.currentfilm.style.opacity = "0.2";
            }
        }

        function next() {
            if (instance.lock === 0) {
                instance.lock = 1;
                var aux;
                if (instance.current === 4) {
                    $(instance.background).animate({
                        left: "0px"
                    }, 1500, function () {
                        instance.lock = 0;
                    });
                    aux = document.getElementById("ntb" + instance.current);
                    aux.className = "hidden banimate";
                    aux.style.opacity = "0";
                    instance.currentfilm.style.opacity = "";
                    instance.current = 1;
                    instance.currentfilm = instance.thumbs.children[0].children[0];
                    instance.currentbg = document.getElementById("background").children[0].children[0];
                    instance.currentfilm.style.opacity = "0.2";
                    aux = document.getElementById("ntb" + instance.current);
                    aux.className = "banimate";
                    $(aux).animate({opacity: 1}, 1000);
                } else {
                    aux = document.getElementById("ntb" + instance.current);
                    aux.className = "hidden banimate";
                    aux.style.opacity = "0";
                    aux = parseInt(instance.background.style.left, 10) - instance.bbgimg.width;
                    $(instance.background).animate({left: aux}, 1500, function () {
                        instance.lock = 0;
                    });
                    instance.currentfilm.style.opacity = "";
                    instance.current++;
                    instance.currentbg = document.getElementById("background").children[instance.current - 1].children[0];
                    instance.currentfilm = instance.thumbs.children[instance.current - 1].children[0];
                    instance.currentfilm.style.opacity = "0.2";
                    aux = document.getElementById("ntb" + instance.current);
                    aux.className = "banimate";
                    $(aux).animate({opacity: 1}, 1000);
                }
            }
        }

        function popup(e) {
            var vbox, strmatch, aux;
            if (document.getElementById("vbox") !== null) {
                vbox = document.getElementById('vbox');
            } else {
                vbox = document.getElementById('cinebox');
            }
            var target = (e.target) ? e.target : window.event.srcElement;
            strmatch = target.id.match("ntc")[0];
            if (strmatch !== "ntc") {
                return;
            }
            instance.currentvbox = target.id;
            document.getElementById("blackpane").className = "";
            vbox.className = "banimate";
            instance.currentvbox += "t";
            instance.currentvbox = document.getElementById(instance.currentvbox);
            aux = instance.currentvbox.className.replace("hidden", "");
            instance.currentvbox.className = aux;
            $(vbox).animate({opacity: 1},300);
        }

        function close() {
            instance.currentvbox.className = "hidden vv";
            document.getElementById("blackpane").className = "hidden";
            if (document.getElementById("vbox") !== null) {
                document.getElementById("vbox").className = "hidden";
            } else {
                document.getElementById("cinebox").className = "hidden";
            }
            var aux = instance.currentvbox.children[instance.currentvbox.children.length - 1];
            instance.currentvbox.removeChild(instance.currentvbox.children[instance.currentvbox.children.length - 1]);
            instance.currentvbox.appendChild(aux);
        }

        function disablecinetrailer() {
            instance.currentvbox.children[instance.currentvbox.children.length - 1].style.display = "none";
            var aux = instance.currentvbox.children[instance.currentvbox.children.length - 1];
            instance.currentvbox.removeChild(instance.currentvbox.children[instance.currentvbox.children.length - 1]);
            instance.currentvbox.appendChild(aux);
            $(instance.currentvbox.children[0]).fadeIn();
        }

        function togglevideoinfo(e) {
            var target = (e.target) ? e.target : window.event.srcElement,
                strmatch, aux;
            if (target.className.match("trtrailer")) {
                strmatch = target.className.match("trtrailer")[0];
            }
            if (strmatch === "trtrailer") {
                instance.currentvbox.children[0].style.display = "none";
                $(instance.currentvbox.children[instance.currentvbox.children.length - 1]).fadeIn();
            }
            if (target.className.match("trtinfo")) {
                aux = target.className.match("trtinfo")[0];
            }
            if (aux === "trtinfo") {
                disablecinetrailer();
            }
        }

        function rolling(opc) {
            var total = Math.ceil(instance.thumbs.children.length / 6);
            if (opc === 1) {
                instance.thumbs.children[((total - 1) * 6) - 1].style.marginRight = "";
                if (instance.current > 1) {
                    $("#thumbscine").animate({marginLeft: '+=775'}, 500, function () {
                        $("#setad").fadeIn("fast");
                    });
                    instance.current--;
                    if (instance.current === 1) {
                        $("#setae").fadeOut();
                    }
                }
            }
            if (opc === 0) {
                if (instance.current < total) {
                    instance.thumbs.children[((total - 1) * 6) - 1].style.marginRight = "50px";
                    $("#thumbscine").animate({marginLeft: '-=775'}, 500, function () {
                        $("#setae").fadeIn("fast");
                    });
                    instance.current++;
                    if (instance.current === total) {
                        $("#setad").fadeOut();
                    }
                }
            }
        }

        function newsletterfn() {
            if (document.getElementById("newsletter").addEventListener) {
                document.getElementById("newsletter").addEventListener('click', function () {
                    var newsletterbox = document.getElementById("newsletterbox");
                    newsletterbox.style.display = "inline";
                    document.getElementById("newslettersubmit").addEventListener('click', function () {
                        var emailtxt = document.getElementById("newslettertxtbox").value;
                        $.get("newsletter.php", {
                            email: emailtxt
                        });
                        newsletterbox.children[0].style.display = "none";
                        newsletterbox.children[1].className = "";
                        window.setTimeout(function () {
                            newsletterbox.style.display = "none";
                            newsletterbox.children[0].style.display = "";
                            newsletterbox.children[1].className = "hidden";
                        }, 1000);
                    });
                }, false);
            }
        }
        this.fader = function () {
            var bgchildren = instance.background.children,
                fadefn, currchild = 0;
            if (bgchildren.length > 1) {
                fadefn = function () {
                    if (currchild + 1 === instance.background.children.length) {
                        bgchildren[0].className = "next";
                    } else {
                        bgchildren[currchild + 1].className = "next";
                    }
                    $(bgchildren[currchild]).animate({opacity: 0}, 1400, function () {
                        bgchildren[currchild].className = "out";
                        bgchildren[currchild].style.opacity = 1;
                        if (currchild + 1 === instance.background.children.length) {
                            currchild = -1;
                        }
                        bgchildren[currchild + 1].className = "curr";
                        currchild++;
                        window.setTimeout(fadefn, 2000);
                    });
                };
                window.setTimeout(fadefn, 2000);
            }
        };
        this.startslider = function (thumbs, ntcbox) {
            this.thumbs = document.getElementById(thumbs);
            this.currentfilm = this.thumbs.children[0];
            this.currentfilm = this.currentfilm.children[0];
            this.ntcbox = document.getElementById(ntcbox);
            jQuery.easing.def = "easeOutCirc";
            newsletterfn();
            if (!this.thumbs.addEventListener) {
                this.thumbs.attachEvent('onclick', move);
                this.ntcbox.attachEvent('onclick', popup);
                document.getElementById("xx").attachEvent('onclick', close);
                document.getElementById("blackpane").attachEvent('onclick', close);
                document.getElementById("seta").attachEvent("onclick", next);
            } else {
                this.thumbs.addEventListener("click", move, false);
                this.ntcbox.addEventListener("click", popup, false);
                document.getElementById("seta").addEventListener("click", next, false);
                document.getElementById("xx").addEventListener('click', close, false);
                document.getElementById("blackpane").addEventListener('click', close, false);
            }
            $("#preload").fadeOut("slow");
        };
        this.startpubind = function () {
            newsletterfn();
        };
        this.startpub = function (thumbs) {
            $("#preload2").fadeOut("slow");
            $('#menug').animate({height: 250}, 1000);
            newsletterfn();
            this.thumbs = document.getElementById(thumbs);
            if (!this.thumbs.addEventListener) {
                this.thumbs.attachEvent('onclick', popup);
                document.getElementById("xx").attachEvent('onclick', close);
                document.getElementById("blackpane").attachEvent('onclick', close);
            } else {
                this.thumbs.addEventListener("click", popup, false);
                document.getElementById("xx").addEventListener('click', close);
                document.getElementById("blackpane").addEventListener('click', close);
            }
        };
        this.startcine = function (thumbs) {
            $("#preload2").fadeOut("slow");
            $('#menug').animate({height: 300}, 1000);
            $('#rollerbox').fadeIn();
            newsletterfn();
            this.thumbs = document.getElementById(thumbs);
            if (!this.thumbs.addEventListener) {
                this.thumbs.attachEvent('onclick', popup);
                document.getElementById("xx").attachEvent('onclick', function () {
                    close();
                    disablecinetrailer();
                });
                document.getElementById("blackpane").attachEvent('onclick', function () {
                    close();
                    disablecinetrailer();
                });
                document.getElementById("setad").attachEvent('onclick', function () {
                    rolling(0);
                });
                document.getElementById("setae").attachEvent('onclick', function () {
                    rolling(1);
                });
                document.getElementById("cinebox").attachEvent('onclick', togglevideoinfo);
            } else {
                this.thumbs.addEventListener("click", popup, false);
                document.getElementById("xx").addEventListener('click', function () {
                    close();
                    disablecinetrailer();
                });
                document.getElementById("blackpane").addEventListener('click', function () {
                    close();
                    disablecinetrailer();
                });
                document.getElementById("setad").addEventListener('click', function () {
                    rolling(0);
                });
                document.getElementById("setae").addEventListener('click', function () {
                    rolling(1);
                });
                document.getElementById("cinebox").addEventListener('click', togglevideoinfo);
            }
        };
        this.back = function (op) {
            if (!document.getElementById("xx").addEventListener) {
                document.getElementById("xx").attachEvent('onclick', function () {
                    window.history.go(-1);
                });
                if (!op) {
                    document.getElementById("blackpane").attachEvent('onclick', function () {
                        window.history.go(-1);
                    });
                }
            } else {
                document.getElementById("xx").addEventListener('click', function () {
                    window.history.go(-1);
                });
                if (!op) {
                    document.getElementById("blackpane").addEventListener('click', function () {
                        window.history.go(-1);
                    });
                }
            }
        };
        this.about = function () {
            newsletterfn();
            $("#preload2").css("display", "none");
            $("#blackpane").fadeIn();
            $("#tbox").fadeIn();
        };
        //standarts compilant browsers scrub
        function nextprevpic(e) {
            var target = (e.target) ? e.target : window.event.srcElement;
            if (target.id === "setasrvcd") {
                if (instance.currentpicservices.nextElementSibling) {
                    document.getElementById("setasrvce").style.display = "inline";
                    instance.currentpicservices.style.display = "none";
                    instance.currentpicservices = instance.currentpicservices.nextElementSibling;
                    $(instance.currentpicservices).fadeIn();
                    if (!instance.currentpicservices.nextElementSibling) {
                        $("#setasrvcd").fadeOut();
                    }
                }
            }
            if (target.id === "setasrvce") {
                if (instance.currentpicservices.previousElementSibling) {
                    document.getElementById("setasrvcd").style.display = "inline";
                    instance.currentpicservices.style.display = "none";
                    instance.currentpicservices = instance.currentpicservices.previousElementSibling;
                    $(instance.currentpicservices).fadeIn();
                    if (!instance.currentpicservices.previousElementSibling) {
                        $("#setasrvce").fadeOut();
                    }
                }
            }
        }
        //IE8 and earlier browsers compatible with module
        function slideshowpicsmoudleconstructor() {
                var picsarray = document.getElementById("picsul").children;
                var pic = 0;
                return {
                    nextprevpic: function (e) {
                        var target = (e.target) ? e.target : window.event.srcElement;
                        if (target.id === "setasrvcd") {
                            if (picsarray[pic + 1]) {
                                document.getElementById("setasrvce").style.display = "inline";
                                picsarray[pic].style.display = "none";
                                pic++;
                                $(picsarray[pic]).fadeIn();
                                if (!picsarray[pic + 1]) {
                                    $("#setasrvcd").fadeOut();
                                }
                            }
                        }
                        if (target.id === "setasrvce") {
                            if (picsarray[pic - 1]) {
                                document.getElementById("setasrvcd").style.display = "inline";
                                picsarray[pic].style.display = "none";
                                pic--;
                                $(picsarray[pic]).fadeIn();
                                if (!picsarray[pic - 1]) {
                                    $("#setasrvce").fadeOut();
                                }
                            }
                        }
                    }
                };
            }
        this.services = function () {
            ntcslider.fader();
            ntcslider.back(1);
            $("#blackpane").fadeIn();
            $("#tbox").fadeIn();
            var newdomelement;
            for (var i = 2; i <= 24; i++) {
                newdomelement = document.createElement('img');
                newdomelement.setAttribute('src', 'http://' + window.location.host + '/img/imgservices' + i + '.jpg');
                newdomelement.setAttribute('style', 'display:none');
                document.getElementById("picsul").appendChild(newdomelement);
            }
            var slideshowpicsmoudle = slideshowpicsmoudleconstructor();
            if (!document.getElementById("setassrvc").addEventListener) {
                document.getElementById("setassrvc").attachEvent('onclick', slideshowpicsmoudle.nextprevpic, false);
            } else {
                document.getElementById("setassrvc").addEventListener('click', slideshowpicsmoudle.nextprevpic, false);
            }
        };
    };
