
function VWCreatePage()
{
    try {        
        OpenCreateWebPageDialog('/_layouts/createwebpage.aspx');
        window.setTimeout(IsDlgOpen, 500);        
	}
    catch (e) 
    {
		alert(e);
	}
}

function IsDlgOpen() {
    if (SP.UI.ModalDialog.get_childDialog() == null) {        
        window.document.location.href = window.document.location.href;
    }
    else {
        window.setTimeout(IsDlgOpen, 500);
    }    
}


function HandleLayout(numColumns, header, footer, sidebar) {
    var colTable = document.getElementsByTagName("TABLE");
    var objTable;
    var i = 0;
    while (i < colTable.length) {
        if (colTable[i].id.toLowerCase().indexOf("_layouts") > 0)
            objTable = colTable[i];
        i++;
    }

    switch (numColumns) {
        case 1: // IF ONE COLUMN OPTION IS SELECTED
            objTable.childNodes[0].childNodes[0].childNodes[0].setAttribute("style", "width: 100%;");
            break;
        case 2: // IF TWO COLUMN OPTION IS SELECTED
            if (sidebar) {
                objTable.childNodes[0].childNodes[0].childNodes[0].setAttribute("class", "sidebarcol_1_td");
                objTable.childNodes[0].childNodes[0].childNodes[1].setAttribute("class", "sidebarcol_2_td");
                objTable.childNodes[0].childNodes[0].childNodes[0].removeAttribute("style");
                objTable.childNodes[0].childNodes[0].childNodes[1].removeAttribute("style");
            }
            else {
                if (header) {
                    if (footer) {
                        objTable.childNodes[0].childNodes[1].childNodes[0].setAttribute("class", "twocol_1_td");
                        objTable.childNodes[0].childNodes[1].childNodes[1].setAttribute("class", "twocol_2_td");
                    }
                    else {
                        objTable.childNodes[0].childNodes[1].childNodes[0].setAttribute("class", "twocol_1_td");
                        objTable.childNodes[0].childNodes[1].childNodes[1].setAttribute("class", "twocol_2_td");
                    }
                    objTable.childNodes[0].childNodes[1].childNodes[0].removeAttribute("style");
                    objTable.childNodes[0].childNodes[1].childNodes[1].removeAttribute("style");
                }
                else {
                    objTable.childNodes[0].childNodes[0].childNodes[0].setAttribute("class", "twocol_1_td");
                    objTable.childNodes[0].childNodes[0].childNodes[1].setAttribute("class", "twocol_2_td");
                    objTable.childNodes[0].childNodes[0].childNodes[0].removeAttribute("style");
                    objTable.childNodes[0].childNodes[0].childNodes[1].removeAttribute("style");
                }
            }

            break;
        case 3: // IF THREE COLUMN OPTION IS SELECTED
            if (header) {
                if (footer) {
                    objTable.childNodes[0].childNodes[1].childNodes[0].setAttribute("class", "threecol_1_td");
                    objTable.childNodes[0].childNodes[1].childNodes[1].setAttribute("class", "threecol_2_td");
                    objTable.childNodes[0].childNodes[1].childNodes[2].setAttribute("class", "threecol_3_td");
                }
                else {
                    objTable.childNodes[0].childNodes[1].childNodes[0].setAttribute("class", "threecol_1_td");
                    objTable.childNodes[0].childNodes[1].childNodes[1].setAttribute("class", "threecol_2_td");
                    objTable.childNodes[0].childNodes[1].childNodes[2].setAttribute("class", "threecol_3_td");
                }
            }
            else {
                objTable.childNodes[0].childNodes[0].childNodes[0].setAttribute("class", "threecol_1_td");
                objTable.childNodes[0].childNodes[0].childNodes[1].setAttribute("class", "threecol_2_td");
                objTable.childNodes[0].childNodes[0].childNodes[2].setAttribute("class", "threecol_3_td");
                //objTable.childNodes[0].childNodes[0].childNodes[0].childNodes[0].setAttribute("class", "threecol_1_div");
                //objTable.childNodes[0].childNodes[0].childNodes[1].childNodes[0].setAttribute("class", "threecol_2_div");
                //objTable.childNodes[0].childNodes[0].childNodes[2].childNodes[0].setAttribute("class", "threecol_3_div");
                objTable.childNodes[0].childNodes[0].childNodes[0].removeAttribute("style");
                objTable.childNodes[0].childNodes[0].childNodes[1].removeAttribute("style");
                objTable.childNodes[0].childNodes[0].childNodes[2].removeAttribute("style");
                //objTable.childNodes[0].childNodes[0].childNodes[0].setAttribute("style", "width: 33.3%;padding-right: 42px; overflow: hidden");
                //objTable.childNodes[0].childNodes[0].childNodes[1].setAttribute("style", "width: 33.3%;padding-right: 49px; overflow: hidden");
                //objTable.childNodes[0].childNodes[0].childNodes[2].setAttribute("style", "width: 33.3%;padding-right: 0px; overflow: hidden");
            }
            break;
    }
}
