﻿var zoom = 0;
var picture = false;

var is_ie6 = (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1) && (navigator.userAgent.toLowerCase().indexOf('msie 7') == -1)


function FontLarger() {
    if (!picture) {
        if (zoom <= 4) {
            zoom++;
            document.getElementById('ContentPanel').style.fontSize = ((100 + (zoom * 10)) + '%');
        }
    }
    else {
        if (!is_ie6) {
            //        zoom++;
            var factor = 1;  //(1 + zoom * 0.1);
            var clientWidth = document.body.clientWidth;
            var clientHeight = document.body.clientHeight;
            var pic = dd.elements.DISPLAYEDPIC;
            var newWidth = imgwidth * factor;
            var newHeight = imgheight * factor;
            if (newWidth <= imgwidth && newHeight <= imgheight) {
                dd.elements.DISPLAYEDPIC.resizeTo(newWidth, newHeight);
                if (pic.x + pic.w < 50 || pic.y + pic.h < 50 || pic.x > clientWidth - 50 || pic.y > clientHeight - 50) {
                    pic.moveTo(50, 50);
                }
            }
        }
    }
}


function FontSmaller() {
    if (!picture) {
        if (zoom > 0) {
            zoom--;
            document.getElementById('ContentPanel').style.fontSize = ((100 + (zoom * 10)) + '%');
        }
    }
    else {
        if (!is_ie6) {
//            //        zoom--;
//            var factor = (1 + zoom * 0.1);
//            var clientWidth = document.body.clientWidth;
//            var clientHeight = document.body.clientHeight;
//            var pic = dd.elements.DISPLAYEDPIC;
//            var newWidth = imgwidth * factor;
//            var newHeight = imgheight * factor;
//            if (newWidth > 50) {
//                //            pic.moveTo(pic.x + (clientWidth / 2 - pic.x) * factor, pic.y + (clientHeight / 2 - pic.y) * factor);
//                dd.elements.DISPLAYEDPIC.resizeTo(newWidth, newHeight);
//                if (pic.x + pic.w < 50 || pic.y + pic.h < 50 || pic.x > clientWidth - 50 || pic.y > clientHeight - 50) {
//                    pic.moveTo(50, 50);
//                }
//            }
            if (imgwidth > document.body.clientWidth) {
                var pic = dd.elements.DISPLAYEDPIC;
                var factor = (document.body.clientWidth * .90) / pic.w;
                var newWidth = pic.w * factor;
                var newHeight = pic.h * factor;
                zoom = Math.floor((factor - 1) * 10);
                pic.moveTo(pic.x * (1 + zoom * 0.1), pic.y * (1 + zoom * 0.1));
                if (newWidth > 50) {
                    pic.resizeTo(newWidth, newHeight);
                }
            }
        }
    }
}

function PrintWindow() {
    window.print();
}

function ChangeSearchPageDisplayMode(newMode) {
    if (newMode == "pic") {
        var currentUrl = document.location.href;

        var newUrl = currentUrl.replace("format=details", "format=pic");

        document.location = newUrl;
    }
    else {
        var currentUrl = document.location.href;

        var newUrl = currentUrl.replace("format=pic", "format=details");

        document.location = newUrl;
    }

}