function editProperty(S_ID, P_ID, RETURN_ID) {
    var URL = "properties.php?ACTION=edit&S_ID=" + S_ID + "&P_ID=" + P_ID + "&RETURN_ID=" + RETURN_ID;
    document.location.href = URL;
}

function publishProperty(S_ID, publishTo) {
    var URL = "properties.php?ACTION=PUBLISH&S_ID=" + S_ID + "&publishTo=" + publishTo;
    document.location.href = URL;
}

function saveProperty() {
    var editFrm = document.getElementById("editFrm");
    if ( editFrm != null ) {
        editFrm.submit();
    }
}

function savePropertyStay(S_ID, P_ID, RETURN_ID) {
    var oFrm = document.getElementById("editFrm");
    if ( oFrm != null ) {
        var SELFCLOSE = document.getElementById("SELFCLOSE");
        if (SELFCLOSE != null ) SELFCLOSE.value = "SELFCLOSE";

        oFrm.target = "win_" + P_ID;
        window.open("","win_" + P_ID,"top=0,left=0,resizable=1,height=1,width=1,status=no,toolbar=no,menubar=no,location=no,titlebar=no");
        oFrm.submit();
    }
    editProperty(S_ID, P_ID, RETURN_ID);
}

function savePage() {
    var editFrm = document.getElementById("editFrm");
    if ( editFrm != null ) {
        editFrm.submit();
    }
}

function onListLoaded() {
    var loadgraphic = document.getElementById("loadgraphic");
    var mainTbl = document.getElementById("mainTbl");

    if (loadgraphic != null && mainTbl != null) {
        mainTbl.style.visibility = "";
        loadgraphic.style.visibility = "hidden";
        loadgraphic.style.position = "absolute";
    }
}

function settingsPost(P_ID) {
    var oFrm = document.getElementById("frm_" + P_ID);
    if ( oFrm != null ) {
        oFrm.target = "win_" + P_ID;
        window.open("","win_" + P_ID,"top=0,left=0,resizable=0,height=1,width=1,status=no,toolbar=no,menubar=no,location=no,titlebar=no");
        oFrm.submit();
        var btnSave = document.getElementById("btnSave_" + P_ID);
        if ( btnSave != null ) {
            btnSave.src="images/website/saving.gif";
        }
    }
}

function viewPickedImage(o, imgName) {
    /*
    var oImg = document.getElementById("img"+imgName);
    if (oImg) {
        oImg.src = o.value;
    }
    */
}

function swfPub_flace(id, w, h){
    var o = document.getElementById(id);
    if ( o != null ) {
		var s = o.style;
		s.overflow = 'hidden';
		s.width = w+'px';
		s.height = h+'px';
    }
}


function orderMainList(PAGE, STR, RID) {
    var arr = STR.split(",");
    var cnt = arr.length - 2;

    if ( cnt > 0 ) {
        var ran_unrounded=Math.random()*cnt;
        var ran_number=Math.floor(ran_unrounded)+1; 
        var P_ID = arr[ran_number];
        var oPID = document.getElementById(PAGE + "_RPID_" + P_ID);
        var oRID = document.getElementById(PAGE + "_RID_" + RID);

        if (oRID != null && oPID != null) {
            oRID.innerHTML = oPID.innerHTML;
            var regExp = "/" + P_ID + ",/";
            STR = STR.replace(eval(regExp), "");
            orderMainList(PAGE, STR, ++RID)
        }
    } 
}