function generateselect (name, optionsarray, valuetype, defaultselect, pario) {
/*@cc_on @if (@_jscript)
var selectelement =
document.createElement("<select name='"+name+"'>");
@else */
	var selectelement = document.createElement('select');
	/* @end @*/
	selectelement.setAttribute('name', name);
	selectelement.name = name;
	if(pario) pario.appendChild(selectelement);
	selectelement.id = name;
	selectelement.name = name;
	selectelement.setAttribute('name', name);
	generateoptions(selectelement, optionsarray, valuetype, defaultselect);
	return selectelement;
}
function generateoptions (selectelement, optionsarray, valuetype, defaultselect) {//adds created options elements to element in var called cselectelement
		//debug(optionsarray + '; ' + valuetype + '; ' + defaultselect);
		optionsarraycount = optionsarray.length;
		for (c = 0; c < optionsarraycount; c ++) {
			cselectoption = document.createElement('option');
			if (valuetype == "num") {
			cselectoption.value = c;
			defaultvaluecomp = "num";
			//defaultvaluecomp says what defaultselect
			//should be compared with
			//to see if the select option
			//is the one that should be selected by default
			}
			else if (valuetype == "txt") {
			cselectoption.value = optionsarray[c];
			defaultvaluecomp = "txt";
			}
			
			if ((defaultvaluecomp == "txt" && defaultselect == optionsarray[c]) || (defaultvaluecomp == "num" && defaultselect == c)) {
				
				cselectoption.selected = "selected";
				cselectoption.setAttribute('selected', 'selected');
			}
			optiontextnode = document.createTextNode(optionsarray[c]);
			cselectoption.appendChild(optiontextnode);
			selectelement.appendChild(cselectoption);
		}
}

function toggledisplayel (elementid, show) {
	var el = document.getElementById(elementid);
	if (show == 0) {
		el.style.display='none';
	}
	else {
		el.style.display='block';
	}
}

function changeframetypeel(selecte) {
	if (selecte.options[selecte.selectedIndex].value.toLowerCase() == 'image') {
		toggledisplayel('imagefileupload', 1);
		toggledisplayel('textset', 0);
	}
	if (selecte.options[selecte.selectedIndex].value.toLowerCase() == 'text') {
		toggledisplayel('textset', 1);
		toggledisplayel('imagefileupload', 0);

	}
}

function setupframetypesel () {
	var iconcreatef = document.getElementById('iconcreateform');
	var frameoptse = document.getElementById('frameoptions');
	var optionsarray = new Array('Image', 'Text');
	
	ftypeselect = generateselect('frametype', optionsarray, 'txt', window.defaultframetype ? window.defaultframetype : 'Image');
	ftypeselect.onchange = function() {changeframetypeel(this)};
	
	var labelforselect = document.createElement('label');
	labelforselect.appendChild(document.createTextNode("Frame Type: "));
	labelforselect.htmlFor="frametype";
	
	//var elforselect = document.createElement('p');
	//elforselect.appendChild(labelforselect);
	//elforselect.appendChild(ftypeselect);
	
	frameoptse.insertBefore(labelforselect, frameoptse.getElementsByTagName('label')[0]);
	frameoptse.insertBefore(ftypeselect, frameoptse.getElementsByTagName('label')[1]);
	frameoptse.insertBefore(document.createElement('br'), frameoptse.getElementsByTagName('label')[1]);
	
}

window.onload = function () {
	if (window.defaultframetype == 'Text') {
		toggledisplayel('imagefileupload', 0);
	}
	else {
	toggledisplayel('textset', 0);
	}

	setupframetypesel();
}