﻿
	/* Description : Locate Popup page to center. */
	function Popup(pURL, pH, pW) {
	    //if (typeof pH == "undefined") pH = "default value";
	    if (!pW) {
	        pW = 320;
	    }
	    if (!pH) {
	        pH = 250;
	    }

	    //window.status = '';
	    var winleft = (screen.width - pW) / 2;
	    var wintop = (screen.height - pH) / 2;

	    var args = "top=" + wintop + ", left=" + winleft + ", width=" + pW + ", height=" + pH + ", toolbar=0, menubar=0, scrollbars=-1, status=-1, resizable=-1";

	    var wForm = window.open(pURL, "wndPopup", args);
	    wForm.focus();

	    return wForm;
	}


	/* Description : Locate Popup page to center. */
	function PopIn(pURL, pH, pW) {
	    //if (typeof pH == "undefined") pH = "default value";
	    if (!pW) {
	        pW = "100%";
	    }
	    if (!pH) {
	        pH = "250px";
	    }

	    var div = document.getElementById("divPopIn");
	    var strHTML = "<center><a href='#' onclick='RemovePopIn();'><b>Kapat</b></a></center>";
	    strHTML += "<center><iframe src='" + pURL + "' style='width:" + pW + "; height:" + pH + ";' frameborder='0'></iframe></center>";	    
	    if (!div) {
	        alert("divPopIn elemanı bulunamadı!");
	    } else {
	    div.innerHTML = strHTML;
	    div.style.height = pH;	   
	    }
	    
	}

	function RemovePopIn() {
	    var div = document.getElementById("divPopIn");
	    var strHTML = "";
	    if (!div) {
	     //   alert("divPopIn elemanı bulunamadı!")
	    } else {
	    //alert(div.style.height);
	        div.style.height = "1px";
	        div.innerHTML = strHTML;
	    }
	}



/* Description : İlgili elemanın görünüp, gizlenmesini sağlar. */
function ToggleDisplay(pID) {

    var obj=document.getElementById(pID);
    
    if (obj==null) return;
    
    if (obj.style.display==''){
        obj.style.display='none';
    }else{
    obj.style.display = '';
    window.location = "#" + pID;
    }
}


/*İlgili nesnenin işlem yaptığını gösteren bir simge ekler */
function InProgress(pIDSource) {
    var objSource = document.getElementById(pIDSource);
    if (objSource != null) {
        objSource.className = "cssInProgress";
        objSource.disabled = true;
    }
}



function CheckEnterKey(e, btnId) {
    var evt = e ? e : window.event;
    var btn = document.getElementById(btnId);
    if (btn) {
        if (evt.keyCode == 13) {
            btn.click();
            return false;
        }
    }
}






/*Büyük resimleri otomatik olarak küçültür */
function Resize_All_Big_Images() {
    var MaxWidth = 750;

    var Container = document.getElementById("MainContentCell");
    if (Container == null) { return; }
    
    var All_Images = Container.getElementsByTagName("img");
    //All_Images = document.images;
    
    for (var i = 0; i < All_Images.length; i++) {
        var TheImg = All_Images[i];  //document.images[x];

        var iHeight = TheImg.height;
        var iWidth = TheImg.width;

        if (iWidth > MaxWidth) {
            var Ratio = MaxWidth / iWidth;
            var NewHeight = Ratio * iHeight;
            var NewWidth = MaxWidth;
            TheImg.height = NewHeight;
            TheImg.width = NewWidth;
            //alert(Ratio);

            TheImg.style.cursor = 'crosshair';
            TheImg.onclick = function() {
                var picture = window.open(this.src);
                picture.focus();
                return false;
            }
        }
    }
}

window.onload = function() {Resize_All_Big_Images();}

