﻿/*************************************************/
/** Fundatia EOS Romania						**/
/** Author: O.B. 								**/
/*************************************************/
/*  Main javascript file                         */
/*************************************************/
/*  Required:                                    */
/*      - jquery-1.4.1.min.js                    */
/*************************************************/
/*  [1] Run onload
/*  [2] Main functions
/*  [3] Util functions
/*************************************************/

/*  [1] Run onload
/*************************************************/
    $(document).ready(function(){
        eos.setBackground();
        eos.searchToogle();
        //eos.footerRoundCorners();
        eos.createRightThumb();
        eos.correctNewsColHeight();
    });


/*  [2] Main functions
/*************************************************/

/*  [3] Util functions
/*************************************************/
var utils = {
    includeCSSfile      : function(href) {
        var head_node = document.getElementsByTagName('head')[0];
        var link_tag = document.createElement('link');
        link_tag.setAttribute('rel', 'stylesheet');
        link_tag.setAttribute('type', 'text/css');
        link_tag.setAttribute('href', href);
        head_node.appendChild(link_tag);
    },
    includeJavascript   : function(src) {
        if (document.createElement && document.getElementsByTagName) {
        var head_tag = document.getElementsByTagName('head')[0];
        var script_tag = document.createElement('script');
            script_tag.setAttribute('type', 'text/javascript');
            script_tag.setAttribute('src', src);
            head_tag.appendChild(script_tag);
        }
    }
}

var eos = {
    windowWidth     : $(window).width(),
    windowHight     : $(window).height(),
    onWinResize     :  function(){
        eos.setBackground();
    },
    setBackground   :  function(){
        var newWindowWidth = $(window).width();
        var newWindowHeight = $(window).height();
        if(newWindowWidth < 1280){
            $("#bgLeft").css("background-position", (newWindowWidth - eos.windowWidth)/2 - 2 + "px bottom");
            $("#bgRight").css("background-position", newWindowWidth/2 + "px bottom");
            $("#bgRight").css("min-height", newWindowHeight + "px");
        }else{
            $("#bgLeft").css("background-position", "left bottom");
            $("#bgRight").css("background-position", "right bottom");
            $("#bgRight").css("min-height", eos.windowHight + "px");
        }
    },
    clearSearch     : function(){
        $("#txtSearch").val("");
    },
    searchToogle    : function(){
         // create search text watermark
         $("#txtSearch").css("color", "#666666");
         if($("#txtSearch").val() == ""){
             $("#txtSearch").val(" Caută ...");
             // hide/show search text watermark
             $("#txtSearch").focus(function () {
                if($(this).val() == " Caută ..." || $(this).val() == "") $(this).val("");
             });
             $("#txtSearch").blur(function () {
                if($("#txtSearch").val() == "") $("#txtSearch").val(" Caută ...");
             });
         }
    },
    footerRoundCorners : function(){
        $("#footer").corner("bottom");
        //$("#btnHome").corner("top").parent().css('padding-right', '1px').corner("top");
        //$(".navBtn").corner("tr").parent().corner("tr");
    },
    createRightThumb : function (){
        $("img", "#pageRight").css("width", "85px").css("max-height", "60px").css("margin","3px");
    },
    correctNewsColHeight : function(){
        var rightHeight = $("#pageRight").height();
        var leftHeight = $("#pageLeft").height();
        if(rightHeight < leftHeight) $("#pageRight").height(leftHeight+"px");
    }
}

