<?xml version="1.0"?> 
<?xml-stylesheet href="common.css" type="text/css"?> 

<!DOCTYPE window>


<window
  xmlns:html="http://www.w3.org/TR/REC-html40"
  xmlns:rdf="http://www.w3.org/TR/WD-rdf-syntax#"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  title="CreateProfile Wizard"> 


<html:script>
var profName = "";
var profDir = "";
var fullName = "";
var emailAddr = "";
var smtpVal = "";

var toolkitCore;
nameGlobal = new Array();
nameArray = new Array();
var count = 0;
var dataCount = 0;

function Startup()
{
	//dump("Doing Startup...\n");
	toolkitCore = XPAppCoresManager.Find("toolkitCore");
	if (!toolkitCore) {
		toolkitCore = new ToolkitCore();
		
		if (toolkitCore) {
			toolkitCore.Init("toolkitCore");
		}
	}
}

function SetValue(name, value)
{
	//dump("Inside SetValue\n");
	var found = false;
	for (i = 0; i !=dataCount; i++) {
		if (nameArray[i] == name) {
			//dump("Name exists: "+nameGlobal[i]+"\n");
			nameGlobal[i] = name+"="+value+"%";
			//dump("New values: "+name+"	"+value+"\n");
			found = true;
			break;
		}
	}


	if (!found) {
		//dump("Name does not exist\n");
		nameGlobal[dataCount] = name+"="+value+"%";
		//dump("Name Value: "+name+"	"+value+"\n");

		nameArray[dataCount] = name;
		dataCount++;
	}
}

function Finish()
{
	var data = "";
	var i = 0;
    //dump("before for loop\n");
	for (i = 0; i !=dataCount; i++) {
		data = data+nameGlobal[i];		
	}
    dump("DATA IS: "+data+"\n");


    //dump("calling javascript reflection\n");
    var profileCore = XPAppCoresManager.Find("ProfileCore");
    if (!profileCore)
    {
	    //dump("!profileCore\n");
		profileCore = new ProfileCore();
		//dump("!profileCore\n");

		if (profileCore) {
			//dump("after ! yes profileCore in if loop\n");
			profileCore.Init("ProfileCore");
		}
		else {
			dump("profile not created\n");
		}
	}

	if (profileCore) {
	    //dump("yes profileCore\n");
		profileCore.CreateNewProfile(data);
		profileCore.StartCommunicator(profName);
	}
	
	toolkitCore = XPAppCoresManager.Find("toolkitCore");
	if (!toolkitCore) {
		toolkitCore = new ToolkitCore();
		
		if (toolkitCore) {
			toolkitCore.Init("toolkitCore");
		}
	}
	if (toolkitCore) {
		toolkitCore.CloseWindow(parent);
	}
}

</html:script>

<html:iframe src="content1.xul" name="frame1" width="100%" height="350px"> </html:iframe>
<html:iframe src="navigationStart.xul" name="frame2" width="100%" height="100px"> </html:iframe>

</window>
