/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$(document).ready(function() {

    //resize ();

    $(window).resize (function(){
	//resize();
    });


    $(".searchInput").focus(function(){
        if($(".searchInput").val() == "Suchbegriff eingeben")
        {
            $(".searchInput").val("");
        }
    });

    $(".searchInput").blur(function(){
        if($(".searchInput").val() == "")
        {
            $(".searchInput").val("Suchbegriff eingeben");
        }
    });

    $("#certificate").change(function(){
        if($("#certificate:checked").length)
        {
            $("#searchForm").attr("action", "http://www.climatepartner.de/zertifikate/suche.php?sprache=Zertifikatsuchen");
            $("#searchForm").attr("target", "_cert");
            $("#searchForm").attr("onsubmit", "openRemoteSearch");
        }
        else
        {
            $("#searchForm").attr("action", "index.php?part=search");
            $("#searchForm").removeAttr("target");
            $("#searchForm").removeAttr("onsubmit");
        }
    });
});


function showGalleryImage(id, caption)
{
    if (id)
    {
        $("#galleryImage").html('<img src="image.php?id=' + id + '&name=gallery" />');
        $("#galleryCaption").html('' + caption);
        resize();
    }
}

function openRemoteSearch ()
{
    window.open('http://www.climatepartner.de/zertifikate/suche.php?searchValue='+document.getElementById('searchInput'),'_cert','width=710,height=680');
}

function resize ()
{
        if(!$.browser.safari)
        {
            var dHeight = $("#contentContainer").height();
            var wHeight = $(document).height();

            if ((dHeight + 241) < wHeight)
            {
                    if ($.browser.msie)
                    {
                            newHeight = wHeight-241;
                    }
                    else
                    {
                            newHeight = wHeight-241;
                    }
                    $("#contentContainer").height (newHeight);
            }
        }       
}

