﻿var True = new Object();
var False = new Object();

function CloseLaw() {
	$("#lawContainer").hide();
	$("#mainContainer").show();

	$("#lawDescrContainer iframe").attr("src", "Controls/Portal/LawView.aspx");
}

function GetLaw(idLaw, trueorfalse) {
	if (trueorfalse == False) {
		$("#lawContainer").show();
		$("#mainContainer").hide();

		$("#lawDescrContainer iframe").attr("src","Controls/Portal/LawView.aspx?id=" + idLaw);

		$.ajax({
			type: "POST",
			url: "Services/Web.asmx/GetLaw",
			data: "{'idLaw':'" + idLaw + "'}",
			contentType: "application/json; charset=utf-8",
			dataType: "json",
			timeout: 2000,
			success: function(msg) {
				var res = eval('(' + msg.d + ')');

				var c = 0;

				for (var post in res) {
					switch (c) {
						case 0:
							$("#lawContainer").append(res[post]);
							break;
					}
					c++;
				}

			}
		});
	}
}


function getIFrameElement() {
    return document.getElementById("lawDescrContainer").childNodes.item(0);
}

function getIFrameDocument() {
    var rv = null;
    var frame = getIFrameElement;
    // if contentDocument exists, W3C compliant (e.g. Mozilla)

    if (frame.contentDocument)
        rv = frame.contentDocument;
    else // bad IE  ;)
    {
        rv = document.frames["lawDescrContainer"].document;
        alert(rv);
    }
    return rv;
}

function adjustMyFrameHeight() {
    var frame = getIFrameElement();
    var frameDoc = getIFrameDocument();
    
    frame.height = frameDoc.body.offsetHeight;
    alert(frameDoc.body.scrollHeight);
}