var toolTipPlease = { // h sunarthsh pou ftiaxnei ta tooltips mas
	makeToolTips: function(whichToolTip, toolTipTrigger, topPositie, leftPositie, hideDelay) {
		$(toolTipTrigger).livequery(function(){
            var distance = 10;
            var bdistance = 30;
            var time = 250;
            var btime = 750;
            var hideDelayTimer = null;

            var beingShown = false;
            var shown = false;
            var trigger = $(toolTipTrigger);
            var info = $(whichToolTip).css('opacity', 0);
            $(trigger).click(function() {
                return false;
            });

            $(whichToolTip + ' a').click(function(){
                info.animate({
                        right: '-=' + bdistance + 'px',
                        opacity: 0
                    }, btime, 'swing', function () {
                        shown = false;
                        info.css('display', 'none');
                });
            });

            $([trigger.get(0), info.get(0)]).mouseover(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                if (beingShown || shown) {
                    // don't trigger the animation again
                    return;
                } else {
                    // reset position of info box
                    beingShown = true;
                    info.css({
                        top: topPositie,
                        left: leftPositie,
                        display: 'block'
                    }).animate({
                        top: '-=' + distance + 'px',
                        opacity: 1
                    }, time, 'swing', function() {
                        beingShown = false;
                        shown = true;
                    });
                }
            }).mouseout(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                hideDelayTimer = setTimeout(function () {
                    hideDelayTimer = null;
                    info.animate({
                        top: '-=' + distance + 'px',
                        opacity: 0
                    }, time, 'swing', function () {
                        shown = false;
                        info.css('display', 'none');
                    });
                    }, hideDelay);
                return false;
            });
        });
	}
};

var heightAdj ={
    setSize: function(){
        var h = $(window).height(); // des to upsos ths o8onhs tou xrhsth ki pesto h
        var w = (h*4)/3;            // basei tou h 8ese to width ths eikonas tou background
        var wp = (h*13)/16;
        var wt = (h*95)/150;
        var hf = (w*36)/48;
        $('#mainImg').attr({'height': h, 'width': w}); // phgaine bres thn eikona kai th main kai dwse ta swsta mege8h
        $('#main').css({'height': h, 'width': w});
        $('#mainImgP').css({'height': h, 'width': wp});
        $('#tomhkatopsh').css({'height': h, 'width': wt});
        $('#facade').css({'height': hf, 'width': w});
        $('.introtext').css({'width': wp});
        $('#next').css({'width': wp});

    },
    init: function(){
        this.setSize();
    }
}

$(document).ready(function() {
//    edw mpainoun ta kainouria tooltips
//    toolTipPlease.makeToolTips('pio tooltip 8A emfanistei?', 'pios einai o trigger tou pou to emfanizei?', poia h 8esh tou apo panw?, poia h 8esh tou apo aristera?, ti diarkeia se ms na exei to effe?);
//    prosoxh sta typos! :)
    toolTipPlease.makeToolTips('#tooltip1', '#tetragwnaki1', 60, 730, 500);
    toolTipPlease.makeToolTips('#tooltip2', '#tetragwnaki2', 276, 800, 500);
    toolTipPlease.makeToolTips('#tooltip3', '#tetragwnaki3', 150, 730, 500);

//    kai merika tooltips gia thn arxikh selida.. tsekare an einai kai ok sta resizes ths o8onhs ki an einai kane adjust.
//    (shm: to paketo edw einai oti den mporoume na dwsoume %pososta gia th 8esh kai paizei na xei mikres apokliseis sth 8esh to tooltip apo o8onh se o8onh
//    ...an xreiazetai omws mporoume na orisoume th 8esh tou tooltip me mia js function opws me thn eikona. to blepoume)
    toolTipPlease.makeToolTips('#tooltipCV', '#cvtext', 90, 200, 500);
    toolTipPlease.makeToolTips('#tooltipcontact', '#contacttext', 60, 700, 500);
//    to kolpo me to mege8os ths eikonas
    heightAdj.init();
});










