
function Reset() {
	for (i=0 ; i<=5 ; i++)
	{
		getObjFormField("Form1", "PolymerList"+i).selectedIndex = 0;
		getObjFormField("Form1", "property"+i).selectedIndex = 0;
	}
}

function Plot() {
	var form = getObjForm("Form1");
	var m_array = new Array(5);
	var i, check, obj;
	var idpol = "";
	var idprop = "";

	//------------------------
	// Polymers
	//------------------------
	// fill the array with selected values
	check = true;
	for (i=1; i<=5; i++) {
		m_array[i] = "";

		obj = getObjFormField("Form1", "PolymerList"+i);
		if (obj[obj.selectedIndex].value != "")
		{
			m_array[i] = obj[obj.selectedIndex].value;
			idpol += m_array[i] + ",";
		}

		// check if at least one polymer is selected
		if (m_array[i] != "")
		{
			check = false;
			// check that the selected item has not sublevel
			if (m_array[i] == "0")
			{
				alert("Please specify further the polymer.");
				obj.focus();
				return;
			}
		}

		// check if a polymer has been selected two times
		for (j=i-1; j>0; j--) {
			if (m_array[i] == m_array[j] && m_array[i] != "") {
				alert("You have entered several times the same polymer.");
				return;
			}
		}
	}
	if (check) {
		alert("Please choose one polymer.");
		getObjFormField("Form1", "PolymerList1").focus();
		return;
	}

	//------------------------
	// Properties
	//------------------------
	// fill the array with selected values
	check = true;
	for (i=1; i<=5; i++) {
		m_array[i] = "";

		obj = form["property"+i];
		if (obj[obj.selectedIndex].value != "")
		{
			m_array[i] = obj[obj.selectedIndex].value;
			idprop += m_array[i] + ",";
		}

		// check if at least one property is selected
		if (m_array[i] != "")
		{
			check = false;
			// check that the selected item has not sublevel
			if (p.Get(m_array[i]).QuantiProp == "0" && p.Get(m_array[i]).QualiProp.length == 0)
			{
				alert("Please specify further your property.");
				obj.focus();
				return;
			}
		}

		// check if a property has been selected two times
		for (j=i-1; j>0; j--) {
			if (m_array[i] == m_array[j] && m_array[i] != "") {
				alert("You have entered several times the same property.");
				return;
			}
		}
	}
	if (check) {
		alert("Please choose one property.");
		form["property1"].focus();
		return;
	}

	// Units
	ArrUnits = new Array(2);
	index = 0;
	for (i=0 ; i<form.length ; i++)
	{
		if (form[i].name.indexOf('Units') != -1)
		{
			ArrUnits[index] = form[i];
			index++;
		}
	}
	
	var us = 0;
	if (ArrUnits[1].checked)
		us = 1;

	idpol = idpol.substring(0,idpol.lastIndexOf(","));
	idprop = idprop.substring(0,idprop.lastIndexOf(","));
	var width = 720;							// define the popup's width;
	var height = 660;							// define the popup's height;
	login("/tc/polymerselector/comparedata.aspx?id="+idpol+"&p="+idprop+"&us="+us,width,height,false,false);
}