﻿$(document).ready(function() {

    Resize();
});
var _pageWidth = 0;
var _pageHeight = 0;
function Resize() {
    
    _browserH = parseInt($(window).height()) - 240;
    _browserW = parseInt($(window).width()) - 380;
    _bottom = _browserW / 2 - 267;
    _left = parseInt($(window).width()) - 385;
    $("#ResultsContainer").css("height", _browserH + "px");
    $("#ResultsContainer").css("left", _left + "px");
    $("#ResultsContainer").css("top", "170px");
    
    $(".Container").css("height", _browserH + "px");
    $(".RightContainer").css("height", _browserH + "px");
    $(".Container").css("width", _browserW + "px");

}
var _browserW = null;
function documentResize() {
    
    _browserH = parseInt($(window).height()) -130;
    _browserW = parseInt($(window).width()) - 43;
    $("#innerContent").hide();
    $("#BannerAdverts").hide();
    _mapWidth = _browserW - 10;
    _mapHeight = _browserH - 10;
    if (divLeftHidden == true) {
        _mapWidth = _browserW - 10;
        
    }
    else {
        _mapWidth = _browserW - 400;
    }


    _pageWidth = _mapWidth;
    _pageHeight = _mapHeight;
    
    $("#_mapContainer").css("width", _mapWidth + "px");
    $("#_mapContainer").css("height", _mapHeight + "px");
    $("#divRight").css("width", _browserW + "px");
    $("#divRight").css("height", _browserH + "px");
    $("#divLeft").css("height", _browserH + "px");
    $("#innerContent").css("height", _mapHeight-170+ "px");
    $("#expandarrow").css("margin-top", (_mapHeight / 2) + "px");

    if (g_map != null) {
        g_map.resize();
        mapwidth = parseInt($("#_mapContainer").css("width"));
	mapheight = parseInt($("#_mapContainer").css("height"));

        try {
            curvyCorners.adjust(document.getElementById("divRight"), "style.width", (mapwidth + 10) + "px");
	    curvyCorners.redraw();
	    curvyCorners.adjust(document.getElementById("divRight"), "style.height", (mapheight + 10) + "px");
            curvyCorners.redraw();

        }
        catch (er) {

        }
    }
    if (divLeftHidden == false) {
        $("#innerContent").show();
        $("#BannerAdverts").show();
    }

}
function HideShowDivLeft() {
    AG_tagCloud.CreateCloud("liClass");
    if (divLeftHidden == false) {
        divLeftHidden = true;
        $("#innerContent").hide();
        $("#BannerAdverts").hide();
        $("#divLeft").animate({
            width: '-=380'}, 600);
        $("#divLeftContent").animate({
            width: '-=380'}, 500,function()
            {
                 document.getElementById("expandarrow").src = "images/expanda_arrow_2.png";
            });
        $("#divRight").animate({
            width: '+=380'
        }, 1000);
        $("#_mapContainer").animate({
            width: '+=380'
        }, 1000, function () {
            g_map.resize();
             mapwidth = parseInt($("#_mapContainer").css("width"));

             try {
                 curvyCorners.adjust(document.getElementById("divRight"), "style.width", (mapwidth + 10) + "px");
                curvyCorners.redraw();
            }
            catch (er) {
            }
            $("#innerContent").hide();
            $("#BannerAdverts").hide();
        });

    }
    else {

        $("#innerContent").show();
        $("#BannerAdverts").show();
        mapwidth = parseInt($("#_mapContainer").css("width"));
        mapwidth = mapwidth - 380;
        $("#_mapContainer").css("width", mapwidth + "px");
        g_map.resize();
        divLeftHidden = false;
        $("#divLeft").animate({
            width: '+=380'            
        }, 800);
        $("#divLeftContent").animate({
            width: '+=380'}, 1000);
        $("#divRight").animate({
            width: '-=380'}, 500, function () {
        document.getElementById("expandarrow").src = "images/expanda_arrow.png";


        try {
            curvyCorners.adjust(document.getElementById("divRight"), "style.width", (mapwidth + 10) + "px");
            curvyCorners.redraw();
        }
        catch (er) {
        }
        $("#innerContent").show();
        $("#BannerAdverts").show();

            // Animation complete.
         //   $("#divLeft").css("width", "400px");
        });
    

//        $.getJSON("ashx/GetTopSearches.ashx", function (json) {
//            var _html = "";
//            _icnt = 50;
//            for (x in json) {
//                _random = Math.random();
//                if (_icnt < 49) {
//                    _name = x;
//                    _name = _name.replace("'", "");
//                    _html += "<a style=\"cursor:pointer\" onclick=\"doSearchPop('" + _name + "');\"  rel=\"" + _icnt * _random + "\" >" + _name + "</a>&nbsp;";
//                }
//                _icnt--;

//            }
//            $('#tagCload a').tagcloud();
//            $("#tagCload").html(_html);

//            $.fn.tagcloud.defaults = {
//                size: { start: 8, end: 15, unit: 'pt' },
//                color: { start: '#aba', end: '#000' }
//            };

//            $(function () {
//                   $('#tagCload a').tagcloud();
//            });

//            //   $("#tagCload").tagcloud({ type: "list", sizemin: 8, sizemax: 15 });
//            //$("#tagCload").tagCloud({ "direction": "horizontal", "easein": "easeOutBounce", "speed": 2000 });
//            //$("#tagCload").tagCloud({ "direction": "vertical", "easein": "easeOutBack", "speed": 2000 });
//        });
       
    }
}

