// ccccccccccccccccccc copyright© 1996-2006 Grevillea Software cccccccccccccccccccccc 
var NewWindowName = "wGSlinks";
var URLLocal = "http://localhost/grevillea";
var URLWWW   = "http://grevilleasoft.com";

function subPageLoad(pID)  {
    var URLIndex=URLWWW + "?pid=home";
    window.onload = frameResize;
	//alert("parent=" + (window.parent == window));
	//alert("pid=" + pID);
	//alert("parent=" + window.parent.parent.location);
	//test if this page has been loaded outside the preferred frame in index.htm
	if (window.name != NewWindowName && window.parent == window)  {
		if (document.domain == "localhost")  {
			URLIndex = URLLocal ;
		}  else  {
			URLIndex = URLWWW;
		}
		window.location = URLIndex + "?pid=" + pID;
	}
}
function frameResize() {
	var fwidth, url;	//alert("Resize");
	if (top.window.frames.length != 0) {
		//alert("Resizing----");
		top.window.document.getElementById("fBody").height = (top.window.document.body.clientHeight - 80) //+ "px"; 
		
		if (document.body.attributes["framesize"])   {
			if (document.body.attributes["framesize"].value == "max")  {
				fwidth = (top.window.document.body.clientWidth - 165);
			}  else  {  fwidth = 540;  }
		}  else  {  fwidth = 540;  }
		if(document.all)  {//detect the type of DOM model
			fwidth = fwidth + 5;
		}
		top.window.document.getElementById("fBody").width = fwidth;
	}	//alert("Resized=====" + window.frames[0].document.location);//body.clientWidth);
}

function validateGPsetup()  {
    var s = top.window.document.getElementById("AppState").innerHTML;
/*	if(document.all)  {//detect the type of DOM model
        s = document.getElementById("AppState").innerText;
	}  else  {   //Mozilla
        s = document.getElementById("gpDocState").textContent = "loaded";
	}
*/
    if (s == 'Ready')  {
        top.window.document.getElementById("DocState").innerHTML = "Loading";
        return true;
    } else {
        alert("Can't save this until the process has finished");
        return false;
    }
}
function gpOnLoad()  {
    //alert("----onload ");
    top.window.document.getElementById("DocState").innerHTML = "Loaded";

    //if its not a gp page,  don't do anything
    if (document.getElementById("gpState") == null) { return true;} //>>>>>>>>>>>>>>>>>>>>>>>>>>not a gp page
    // get the state returned from the server. It might be finished.
	var gpState   = document.getElementById("gpState").innerHTML;
    var oAppState = top.window.document.getElementById("AppState");
    var AppState  = oAppState.innerHTML;
    
    //alert("gpstate=" + gpState + ", appstate=" + AppState + " in onload ");
    //the previous request is completed, so update the state
    if         (gpState == 'ready')  { //finished the current series of pops
               AppState  = 'Ready';
    } else if (AppState == 'Evolving...')  {
    
    } else if (AppState == 'Finishing...')  {
               // AppState  = 'Ready';
    } else if (AppState == 'Pausing...')  {
               AppState  = 'Paused';
    } else if (AppState == 'Doing one step...')  {
               AppState  = 'Paused';
    }
    oAppState.innerHTML = AppState;
    //alert("about to do pending request");
    top.window.document.getElementById("DocState").onclick(); //sends request to do any pending request
    
    
/*    //if (typeof(top.window.frames[0].AppState) == "undefined" ) top.window.frames[0].AppState  = "Ready";
    //var AppState = top.window.frames[0].attributes["AppState"].value;
    var AppState = top.window.document.getElementById("AppState").innerHTML;
    var AppStateNew = 'Ready';
    var s;
    // get the state returned from the server. It might be finished.
    if (document.getElementById("gpState") == null) return true; //>>>>>>>>>>>>>>>>>>>>>>>>>>not a gp page
	s = document.getElementById("gpState").innerHTML;
    //alert("=======gpState in onload=" + s);
    if                 (s == 'ready')  {
               AppStateNew = 'Ready';
    }  else if (AppState  == 'Ready')  {
               AppStateNew = 'Ready';
    }  else if (AppState  == 'Finishing...')  {
               AppStateNew = 'Ready';
    }  else if (AppState  == 'Pausing...')  {
               AppStateNew = 'Paused';
    }  else if (AppState  == 'Paused')  {
               AppStateNew = 'Paused';
    }  else if (AppState  == 'Evolving one step...')  {
               AppStateNew = 'Paused';
    }  else if (AppState  == 'Evolving...')  {
               AppStateNew = 'Running';
    }  else if (AppState  == 'Running') {
               AppStateNew = 'Running';
    }  else  { //unknown
        alert("Unknown AppState in gpOnLoad: " + AppState);
               AppStateNew = 'Ready';
    }    
    top.window.document.getElementById("AppState").innerHTML = AppStateNew;    
    //alert("onGPLOad new appstate=" + top.window.document.getElementById("AppState").innerHTML);
    if (document.getElementById("DisplayState") != null)    document.getElementById("DisplayState").innerHTML = AppStateNew;   
*/
}
window.onload = gpOnLoad;

function hello(b,a)  {
    //alert(a);
    var d = "&#6" + "4;"
    var e = "'m" + "a" + "i" + "&#108;&#116;"  +  "o" + ":"
    var c = a + d + b;
    document.write("<A HREF=" + e + c + "' >" + c + "</A>");
}