// Simple function that makes the correct message popup.  

function add_email() {
	// Call the hidden text area to see how many emails were on the page already.
	cnt = document.getElementById('userinfo_email_count');

	if(cnt) {
		// The container that holds all the emails
		container = document.getElementById('email_container');

		// Add one to the total number of emails on the page, and set that in the hidden field too.
		counter = parseInt(cnt.value) + 1;
		cnt.value = counter;
		
		// Create a div and an input field
		var div = document.createElement("div");
		var input = document.createElement("input");
		var a = document.createElement("a");
		var spacer = document.createTextNode(' ');
		//var span = document.createElement("span");

		//span.id = 'email_status_'+ counter;
		//span.style.color = "#999999";

		// set href info
		a.href = "javascript:remove_email('" + counter + "')";
		a.innerHTML = "<em>Remove Email</em>";
		
		// set the div ID
		div.id = 'email_'+ counter;
		div.style.marginTop = "2px";
		
		// set the Name, ID, size, maxlength.
		input.name = 'userinfo_email_' + counter;
		input.id   = 'userinfo_email_' + counter;
		input.style.width = "200px";
		input.style.padding = "1px";
		input.maxLength = 64;
		
		// put the input into the div... and the div into the container.
		div.appendChild(input);
		div.appendChild(spacer);
		div.appendChild(a);
		//div.appendChild(spacer);
		//div.appendChild(span);
		container.appendChild(div);
		
	}
}

function remove_email(val) {
	if(document.getElementById('email_'+ val)) {
		document.getElementById('userinfo_email_'+ val).value = '';
		document.getElementById('email_'+ val).style.display = 'none';
	}
}

function add_product_category() {
	// Call the hidden text area to see how many emails were on the page already.
	cnt = document.getElementById('product_category_count');

	if(cnt) {
		// The container that holds all the emails
		container = document.getElementById('product_department_category');

		// Add one to the total number of objects on the page, and set that in the hidden field too.
		counter = parseInt(cnt.value);
		cnt.value = counter + 1;
		
		// Create a div and an input field
		var tr = document.createElement("tr");
		var td1 = document.createElement("td");
		var td2 = document.createElement("td");
		
		td1.className='form_data';
		td2.className='form_data';

		var select1 = document.createElement("select");
		select1.name = "product_department["+ counter +"]";
		select1.id = counter +"_options_1";
		select1.style.cssFloat = select1.style.styleFloat = 'left';
		
		var select2 = document.createElement("select");
		select2.name = "product_category["+ counter +"]";
		select2.id = counter +"_options_2";
		select2.style.display = "none";
		select2.style.cssFloat = select2.style.styleFloat = 'left';

		// put the input into the div... and the div into the container.
		td1.appendChild(select1);
		td2.appendChild(select2);
		tr.appendChild(td1);
		tr.appendChild(td2);
		container.appendChild(tr);
		attach_events(counter);
	}
}

function attach_events(counter) {
	dynamic_dropdown(drop_down_options1,this.value,counter +"_options_1");
	document.getElementById(counter +"_options_1").onchange = function ()  { dynamic_dropdown(drop_down_options2,this.value,counter +"_options_2"); }
}

/*
 // This is the old version. 
function add_product_category() {
	// Call the hidden text area to see how many emails were on the page already.
	cnt = document.getElementById('product_category_count');

	if(cnt) {
		// The container that holds all the emails
		container = document.getElementById('product_category_container');

		// Add one to the total number of objects on the page, and set that in the hidden field too.
		counter = parseInt(cnt.value);
		cnt.value = counter + 1;
		
		// Create a div and an input field
		var br = document.createElement("br");
		var div = document.createElement("div");
		div.style.marginTop = "10px";
		

		var select1 = document.createElement("select");
		select1.name = "product_division["+ counter +"]";
		select1.id = counter +"_options_1";
		//select1.onchange = function ()  { void(counter); dynamic_dropdown(drop_down_options1,this.value,counter +"_options_2"); }
		select1.style.cssFloat = select1.style.styleFloat = 'left';
		select1[0] = new Option("-Select Option-", '');
		select1[1] = new Option("Mens", 1);
		select1[2] = new Option("Womens", 2);
		select1[3] = new Option("Boys", 3);
		select1[4] = new Option("Girls", 4);
		select1[5] = new Option("Baby", 5);
		select1[6] = new Option("Home", 6);
		select1[7] = new Option("Accessories", 7);
		select1[8] = new Option("Jewelry", 8);
		select1[9] = new Option("Footwear", 9);
		select1[10] = new Option("Consignment", 10);

		var select2 = document.createElement("select");
		select2.name = "product_department["+ counter +"]";
		select2.id = counter +"_options_2";
		//select2.onchange = function ()  { dynamic_dropdown(drop_down_options2,this.value,counter +"_options_3"); }
		select2.style.display = "none";
		select2.style.cssFloat = select2.style.styleFloat = 'left';

		var select3 = document.createElement("select");
		select3.name = "product_category["+ counter +"]";
		select3.id = counter +"_options_3";
		select3.style.display = "none";
		select3.style.cssFloat = select3.style.styleFloat = 'left';

		// put the input into the div... and the div into the container.
		div.appendChild(select1);
		div.appendChild(select2);
		div.appendChild(select3);
		container.appendChild(br);
		container.appendChild(div);
		attach_events(counter);
	}
}
*/

/*
function parse_results(val,category) {
	if(val != '') {
		
		//update_save_status('complete');
		
		tbl = document.getElementById('user_notes');
		hdr = document.getElementById('user_notes_header');

//		first_data_row = document.getElementById('user_notes').getElementsByTagName("tr")[1];
//		first_data_row_parent = first_data_row.parentNode;

		var tr = document.createElement("tr");
		tr.style.backgroundColor = "#FEFFAA";
		
		var td1 = document.createElement("td");
		var td2 = document.createElement("td");
		var td3 = document.createElement("td");
		var td4 = document.createElement("td");

//		var catid = document.getElementById('pathnote_categoryid').value;

		td1.innerHTML = val;
		td2.innerHTML = document.getElementById('pathnote_categoryid').options[(category-1)].text;
		td3.innerHTML = document.getElementById('pathnote_user').value;
		td4.innerHTML = document.getElementById('pathnote_notetext').value;

		tr.appendChild(td1);
		tr.appendChild(td2);
		tr.appendChild(td3);
		tr.appendChild(td4);

		if(document.getElementById('user_notes').getElementsByTagName("tr")[1]) { 
			first_data_row = document.getElementById('user_notes').getElementsByTagName("tr")[1];
			first_data_row_parent = first_data_row.parentNode;
			first_data_row_parent.insertBefore(tr, first_data_row);
		} else { 
			tbl.appendChild(tr);
		}
		// reset values to original info
		document.getElementById('pathnote_notetext').value = "";

	}
}
*/