j = 2;
var c;
var need_enable=true;
var a = new Array();
var is_addon_stripe_active;

if (ajaxurl.indexOf("://") != -1) {
  var url_for_ajax = ajaxurl;
}
else {
  var url_for_ajax = location.protocol + '//' + location.host + ajaxurl;
}

function active_reset(val, id) {
	if(val) {
		document.getElementById(id+'_element_resetform_id_temp').style.display = "inline";
	}
	else {
		document.getElementById(id+'_element_resetform_id_temp').style.display = "none";
	}
}

function check_required() {
	alert('"Submit" and "Reset" buttons are disabled in back end.');
}

function isNumber(n) {
  return !isNaN(parseFloat(n)) && isFinite(n);
}

function change_field_name(id, x) {
	value = x.value;
	if (value == parseInt(value)) {
		alert('The name of the field cannot be a number.');
		x.value="";
		document.getElementById(id+'_elementform_id_temp').name='';
		document.getElementById(id+'_element_labelform_id_temp').innerHTML='';
    document.getElementById(id+'_hidden_nameform_id_temp').innerHTML='';
		return;
	}
		
	if (value==id+"_elementform_id_temp") {
		alert('"Field Name" should differ from "Field Id".')
		x.value="";
	}
	else {
		document.getElementById(id+'_elementform_id_temp').name=value;
		document.getElementById(id+'_element_labelform_id_temp').innerHTML=value;
    document.getElementById(id+'_hidden_nameform_id_temp').innerHTML=value;
	}
}

function change_field_value(id, value) {
	document.getElementById(id+'_elementform_id_temp').value=value;
  document.getElementById(id+'_hidden_valueform_id_temp').innerHTML=value;
}

function chnage_icons_src(img,icon) {
  if (img.src.indexOf("hover")!=-1) {
    img.src =  plugin_url + "/images/" + icon + ".png?ver=1.8.0";
  }
  else {
    img.src =  plugin_url + "/images/" + icon + "_hover.png?ver=1.8.0";
  }
}

function return_attributes(id) {
	attr_names= new Array();
	attr_values= new Array();
	var input=document.getElementById(id);
	if(input) {
		atr=input.attributes;
			for(i=0;i<30;i++)
				if(atr[i] )
				{
				
					if(atr[i].name.indexOf("add_")==0)
					{
				
						attr_names.push(atr[i].name.replace('add_',''));
						attr_values.push(atr[i].value);
					}
				}
	}

	return Array(attr_names, attr_values);
}

function refresh_attr(x,type)
{
	switch(type)
	{
		case "type_text":
			
		{
			id_array=Array();
			id_array[0]=x+'_elementform_id_temp';
			break;
		}
		
		case "type_paypal_price":
		{
			id_array=Array();
			id_array[0]=x+'_element_dollarsform_id_temp';
			id_array[1]=x+'_element_centsform_id_temp';
			break;
		}
		
		case "type_star_rating":
		{
			id_array=Array();
			id_array[0]=x+'_elementform_id_temp';
			
			break;
		}
		
		case "type_scale_rating":
		{
			id_array=Array();
			id_array[0]=x+'_elementform_id_temp';
			
			break;
		}
		
		case "type_spinner":
		{
			id_array=Array();
			id_array[0]=x+'_elementform_id_temp';
			
			break;
		}
		
		case "type_slider":
		{
			id_array=Array();
			id_array[0]=x+'_elementform_id_temp';
			
			break;
		}
		
		case "type_range":
		{
			id_array=Array();
			id_array[0]=x+'_elementform_id_temp0';
			id_array[1]=x+'_elementform_id_temp1';
			
			break;
		}
		
		case "type_grading":
		{
			id_array=Array();
			id_array[0]=x+'_elementform_id_temp';
			
			
			break;
		}
		
		case "type_matrix":
		{
			id_array=Array();
			id_array[0]=x+'_elementform_id_temp';
			
			break;
		}
		case "type_name":
			
		{
			id_array=Array();
			id_array[0]=x+'_element_firstform_id_temp';
			id_array[1]=x+'_element_lastform_id_temp';
			id_array[2]=x+'_element_titleform_id_temp';
			id_array[3]=x+'_element_middleform_id_temp';
			break;
		}
		
		case "type_address":
			
		{
			id_array=Array();
			id_array[0]=x+'_street1form_id_temp';
			id_array[1]=x+'_street2form_id_temp';
			id_array[2]=x+'_cityform_id_temp';
			id_array[3]=x+'_stateform_id_temp';
			id_array[4]=x+'_postalform_id_temp';
			id_array[5]=x+'_countryform_id_temp';
			break;
		}
		
		case "type_checkbox":
			
		{
			id_array=Array();
			for(z=0;z<50;z++)
				id_array[z]=x+'_elementform_id_temp'+z;
			break;
		}
		
		case "type_time":
			
		{
			id_array=Array();
			id_array[0]=x+'_hhform_id_temp';
			id_array[1]=x+'_mmform_id_temp';
			id_array[2]=x+'_ssform_id_temp';
			id_array[3]=x+'_am_pmform_id_temp';
			break;
		}
		case "type_date":
			
		{
			id_array=Array();
			id_array[0]=x+'_elementform_id_temp';
			id_array[1]=x+'_buttonform_id_temp';
			break;
		}
		
		case "type_date_fields":
			
		{
			id_array=Array();
			id_array[0]=x+'_dayform_id_temp';
			id_array[1]=x+'_monthform_id_temp';
			id_array[2]=x+'_yearform_id_temp';
			break;
		}
		
		case "type_captcha":
			
		{
			id_array=Array();
			id_array[0]='_wd_captchaform_id_temp';
			id_array[1]='_wd_captcha_inputform_id_temp';
			id_array[2]='_element_refreshform_id_temp';
			break;
		}
		case "type_arithmetic_captcha":
		{
			id_array=Array();
			id_array[0]='_wd_arithmetic_captchaform_id_temp';
			id_array[1]='_wd_arithmetic_captcha_inputform_id_temp';
			id_array[2]='_element_refreshform_id_temp';
			break;
		}
		case "type_recaptcha":
			
		{
			id_array=Array();
			id_array[0]='wd_recaptchaform_id_temp';
			break;
		}
		
		case "type_submit_reset":
			
		{
			id_array=Array();
			id_array[0]=x+'_element_submitform_id_temp';
			id_array[1]=x+'_element_resetform_id_temp';
			break;
		}
		
		case "type_page_break":
			
		{
			id_array=Array();
			id_array[0]='_div_between';
			break;
		}
	}
		
	for(q=0; q<id_array.length;q++)
	{
		id=id_array[q];
		var input=document.getElementById(id);
		if(input)
		{
			atr=input.attributes;
			for(i=0;i<30;i++)
				if(atr[i])
					{
						if(atr[i].name.indexOf("add_")==0)
						{
							input.removeAttribute(atr[i].name);
							i--;
						}
					}
				
			for(i=0;i<10;i++)
				if(document.getElementById("attr_name"+i))
				{
					try{input.setAttribute("add_"+document.getElementById("attr_name"+i).value, document.getElementById("attr_value"+i).value)}
					catch(err)
					{
						alert('Only letters, numbers, hyphens and underscores are allowed.');
					}
				}
		}
	}
}

function add_id_and_name(i,type)
{
	switch(type) {
		case 'type_text':{
			var	edit_main_table = document.getElementById("edit_main_table");
			var edit_main_tr0 = document.createElement('tr');
			var edit_main_td0 = document.createElement('td');
			var edit_main_td0_1 = document.createElement('td');
				
			var br 	= document.createElement('br');
			var br1 = document.createElement('br');
			
			var field_id = document.createElement('label');
				field_id.setAttribute("class", "fm-field-label");
				field_id.innerHTML = "Field id ";
			
			var field_id_text = document.createElement('input');
				field_id_text.setAttribute("size", "50");
				field_id_text.setAttribute("type", "text");
				field_id_text.setAttribute("disabled", "disabled");
				field_id_text.setAttribute("value", "wdform_"+i+"_elementform_id_temp");
			
			var field_name = document.createElement('label');
				field_name.setAttribute("class", "fm-field-label");
				field_name.innerHTML = "Field name ";
			
			var field_name_text = document.createElement('input');
				field_name_text.setAttribute("size", "50");
				field_name_text.setAttribute("type", "text");
				field_name_text.setAttribute("disabled", "disabled");
				field_name_text.setAttribute("value", "wdform_"+i+"_elementform_id_temp");
				
			edit_main_td0.appendChild(field_id);
			edit_main_td0.appendChild(br);
			edit_main_td0.appendChild(field_name);
			
			edit_main_td0_1.appendChild(field_id_text);
			edit_main_td0_1.appendChild(br1);
			edit_main_td0_1.appendChild(field_name_text);
			edit_main_tr0.appendChild(edit_main_td0);
			edit_main_tr0.appendChild(edit_main_td0_1);
			edit_main_table.insertBefore(edit_main_tr0,edit_main_table.childNodes[0]);		
			break;
		}
	
		case 'type_address': {
			var	edit_main_table = document.getElementById("edit_main_table");
			var edit_main_tr0 = document.createElement('tr');
			var edit_main_td0 = document.createElement('td');
				edit_main_td0.setAttribute("colspan", "2");
				
			var br = document.createElement('br');
			var br1 = document.createElement('br');
			
			var field_id = document.createElement('label');
				field_id.setAttribute("class", "fm-field-label");
				field_id.style.cssText = 'margin-right: 42px;';
				field_id.innerHTML = "Fields id ";
			
			var field_id_text = document.createElement('input');
				field_id_text.setAttribute("type", "text");
				field_id_text.setAttribute("disabled", "disabled");
				field_id_text.setAttribute("style", "width:380px");
				field_id_text.setAttribute("value",  "wdform_"+i+"_street1form_id_temp, wdform_"+i+"_street2form_id_temp, wdform_"+i+"_cityform_id_temp, wdform_"+i+"_stateform_id_temp, wdform_"+i+"_postalform_id_temp, wdform_"+i+"_countryform_id_temp");
			
			var field_name = document.createElement('label');
				field_name.setAttribute("class", "fm-field-label");
				field_name.innerHTML = "Fields name ";
			
			var field_name_text = document.createElement('input');
				field_name_text.setAttribute("type", "text");
				field_name_text.setAttribute("id", "field_name");
				field_name_text.setAttribute("disabled", "disabled");
				field_name_text.setAttribute("style", "width:380px");
				field_name_text.setAttribute("value", "wdform_"+i+"_street1form_id_temp, wdform_"+i+"_street2form_id_temp, wdform_"+i+"_cityform_id_temp, wdform_"+i+"_stateform_id_temp, wdform_"+i+"_postalform_id_temp, wdform_"+i+"_countryform_id_temp");
			
			edit_main_td0.appendChild(field_id);
			edit_main_td0.appendChild(field_id_text);
			edit_main_td0.appendChild(br);
			edit_main_td0.appendChild(field_name);
			edit_main_td0.appendChild(field_name_text);
			edit_main_tr0.appendChild(edit_main_td0);
			edit_main_table.insertBefore(edit_main_tr0,edit_main_table.childNodes[0]);	
			break;
		}
	
		case 'type_name': {
			var	edit_main_table = document.getElementById("edit_main_table");
			var edit_main_tr0 = document.createElement('tr');
			var edit_main_td0 = document.createElement('td');
				edit_main_td0.setAttribute("colspan", "2");
				
			var br = document.createElement('br');
			var br1 = document.createElement('br');
			
			var field_id = document.createElement('label');
				field_id.setAttribute("class", "fm-field-label");
				field_id.style.cssText = 'margin-right: 42px;';
				field_id.innerHTML = "Fields id ";
			
			var field_id_text = document.createElement('input');
				field_id_text.setAttribute("type", "text");
				field_id_text.setAttribute("id", "field_id");
				field_id_text.setAttribute("disabled", "disabled");
				field_id_text.setAttribute("style", "width:380px");
			
			var field_name = document.createElement('label');
				field_name.setAttribute("class", "fm-field-label");
				field_name.innerHTML = "Fields name ";
			
			var field_name_text = document.createElement('input');
				field_name_text.setAttribute("type", "text");
				field_name_text.setAttribute("id", "field_name");
				field_name_text.setAttribute("disabled", "disabled");
				field_name_text.setAttribute("style", "width:380px");
				
			edit_main_td0.appendChild(field_id);
			edit_main_td0.appendChild(field_id_text);
			edit_main_td0.appendChild(br);
			edit_main_td0.appendChild(field_name);
			edit_main_td0.appendChild(field_name_text);
			edit_main_tr0.appendChild(edit_main_td0);
			edit_main_table.insertBefore(edit_main_tr0,edit_main_table.childNodes[0]);
			refresh_id_name(i, type);
			break;
		}
	
		case 'type_radio': {
			var	edit_main_table = document.getElementById("edit_main_table");
			var edit_main_tr0  = document.createElement('tr');
			var edit_main_td0 = document.createElement('td');
				edit_main_td0.setAttribute("colspan", "2");
				
			var br = document.createElement('br');
			var br1 = document.createElement('br');
			
			var field_id = document.createElement('label');
				field_id.setAttribute("class", "fm-field-label");	
				field_id.style.cssText = 'margin-right: 42px;';
				field_id.innerHTML = "Fields id ";
			
			var field_id_text = document.createElement('input');
				field_id_text.setAttribute("type", "text");
				field_id_text.setAttribute("id", "field_id");
				field_id_text.setAttribute("disabled", "disabled");
				field_id_text.setAttribute("style", "width:350px");
				field_id_text.setAttribute("value",  '');
			
			var field_name = document.createElement('label');
				field_name.setAttribute("class", "fm-field-label");	
				field_name.innerHTML = "Fields name ";
			
			var field_name_text = document.createElement('input');
				field_name_text.setAttribute("type", "text");
				field_name_text.setAttribute("id", "field_name");
				field_name_text.setAttribute("disabled", "disabled");
				field_name_text.setAttribute("style", "width:350px");
				field_name_text.setAttribute("value", '');
				
			edit_main_td0.appendChild(field_id);
			edit_main_td0.appendChild(field_id_text);
			edit_main_td0.appendChild(br);
			edit_main_td0.appendChild(field_name);
			edit_main_td0.appendChild(field_name_text);
			edit_main_tr0.appendChild(edit_main_td0);
			edit_main_table.insertBefore(edit_main_tr0,edit_main_table.childNodes[0]);
			refresh_id_name(i, type);
			break;
		}
	
		case 'type_checkbox': {
			var	edit_main_table = document.getElementById("edit_main_table");
			var edit_main_tr0 = document.createElement('tr');
			var edit_main_td0 = document.createElement('td');
				edit_main_td0.setAttribute("colspan", "2");
				
			var br = document.createElement('br');
			var br1 = document.createElement('br');
			
			var field_id = document.createElement('label');
				field_id.setAttribute("class", "fm-field-label");	
				field_id.style.cssText = 'margin-right: 42px;';				
				field_id.innerHTML = "Fields id ";
			
			
			var field_id_text = document.createElement('input');
				field_id_text.setAttribute("type", "text");
				field_id_text.setAttribute("id", "field_id");
				field_id_text.setAttribute("disabled", "disabled");
				field_id_text.setAttribute("style", "width:350px");
				field_id_text.setAttribute("value",  '');
			
			var field_name = document.createElement('label');
				field_name.setAttribute("class", "fm-field-label");		
				field_name.innerHTML = "Fields name ";
			
			var field_name_text = document.createElement('input');
				field_name_text.setAttribute("type", "text");
				field_name_text.setAttribute("id", "field_name");
				field_name_text.setAttribute("disabled", "disabled");
				field_name_text.setAttribute("style", "width:350px");
				field_name_text.setAttribute("value", '');
				
			edit_main_td0.appendChild(field_id);
			edit_main_td0.appendChild(field_id_text);
			edit_main_td0.appendChild(br);
			edit_main_td0.appendChild(field_name);
			edit_main_td0.appendChild(field_name_text);
			edit_main_tr0.appendChild(edit_main_td0);
			edit_main_table.insertBefore(edit_main_tr0,edit_main_table.childNodes[0]);
			refresh_id_name(i, type);
			break;
		}
	
		case 'type_time': {
			var	edit_main_table = document.getElementById("edit_main_table");
			var edit_main_tr0 = document.createElement('tr');
			var edit_main_td0 = document.createElement('td');
			var edit_main_td0_1 = document.createElement('td');
				
			var br = document.createElement('br');
			var br1 = document.createElement('br');
			
			var field_id = document.createElement('label');
				field_id.setAttribute("class", "fm-field-label");			
				field_id.innerHTML = "Fields id ";
			
			
			var field_id_text = document.createElement('input');
				field_id_text.setAttribute("size", "50");
				field_id_text.setAttribute("type", "text");
				field_id_text.setAttribute("id", "field_id");
				field_id_text.setAttribute("disabled", "disabled");
				field_id_text.setAttribute("value", "wdform_"+i+"_hhform_id_temp, wdform_"+i+"_mmform_id_temp, wdform_"+i+"_ssform_id_temp");
			
			var field_name = document.createElement('label');
				field_name.setAttribute("class", "fm-field-label");			
				field_name.innerHTML = "Fields name ";
			
			var field_name_text = document.createElement('input');
				field_name_text.setAttribute("size", "50");
				field_name_text.setAttribute("type", "text");
				field_name_text.setAttribute("id", "field_name");
				field_name_text.setAttribute("disabled", "disabled");
				field_name_text.setAttribute("value", "wdform_"+i+"_hhform_id_temp, wdform_"+i+"_mmform_id_temp, wdform_"+i+"_ssform_id_temp");
				
			edit_main_td0.appendChild(field_id);
			edit_main_td0.appendChild(br1);
			edit_main_td0.appendChild(field_name);
			edit_main_td0_1.appendChild(field_id_text);
			edit_main_td0_1.appendChild(br);
			edit_main_td0_1.appendChild(field_name_text);
			
			edit_main_tr0.appendChild(edit_main_td0);
			edit_main_tr0.appendChild(edit_main_td0_1);
			edit_main_table.insertBefore(edit_main_tr0,edit_main_table.childNodes[0]);		
			break;
		}
	
		case 'type_date_fields':{
			var	edit_main_table = document.getElementById("edit_main_table");
			var edit_main_tr0 = document.createElement('tr');
			var edit_main_td0 = document.createElement('td');
			var edit_main_td0_1 = document.createElement('td');
				
			var br = document.createElement('br');
			var br1 = document.createElement('br');
			
			var field_id = document.createElement('label');
				field_id.setAttribute("class", "fm-field-label");	
				field_id.innerHTML = "Fields id ";
			
			var field_id_text = document.createElement('input');
				field_id_text.setAttribute("size", "50");
				field_id_text.setAttribute("type", "text");
				field_id_text.setAttribute("id", "field_id");
				field_id_text.setAttribute("disabled", "disabled");
				field_id_text.setAttribute("value", "wdform_"+i+"_dayform_id_temp, wdform_"+i+"_monthform_id_temp, wdform_"+i+"_yearform_id_temp");
			
			var field_name = document.createElement('label');
				field_name.setAttribute("class", "fm-field-label");	
				field_name.innerHTML = "Fields name ";
			
			var field_name_text = document.createElement('input');
				field_name_text.setAttribute("size", "50");
				field_name_text.setAttribute("type", "text");
				field_name_text.setAttribute("id", "field_name");
				field_name_text.setAttribute("disabled", "disabled");
				field_name_text.setAttribute("value", "wdform_"+i+"_dayform_id_temp, wdform_"+i+"_monthform_id_temp, wdform_"+i+"_yearform_id_temp");
				
			edit_main_td0.appendChild(field_id);
			edit_main_td0.appendChild(br);
			edit_main_td0.appendChild(field_name);
			
			edit_main_td0_1.appendChild(field_id_text);
			edit_main_td0_1.appendChild(br1);
			edit_main_td0_1.appendChild(field_name_text);
			
			edit_main_tr0.appendChild(edit_main_td0);
			edit_main_tr0.appendChild(edit_main_td0_1);
			edit_main_table.insertBefore(edit_main_tr0,edit_main_table.childNodes[0]);	
			break;
		}
	
		case 'type_captcha': {
			var	edit_main_table = document.getElementById("edit_main_table");
			var edit_main_tr0 = document.createElement('tr');
			var edit_main_td0 = document.createElement('td');
			var edit_main_td0_1 = document.createElement('td');
				
			var br = document.createElement('br');
			var br1 = document.createElement('br');
			
			var field_id = document.createElement('label');
				field_id.setAttribute("class", "fm-field-label");	
				field_id.innerHTML = "Fields id ";
			
			var field_id_text = document.createElement('input');
				field_id_text.setAttribute("size", "50");
				field_id_text.setAttribute("type", "text");
				field_id_text.setAttribute("id", "field_id");
				field_id_text.setAttribute("disabled", "disabled");
				field_id_text.setAttribute("value", "wd_captcha_inputform_id_temp");
			
			var field_name = document.createElement('label');
				field_name.setAttribute("class", "fm-field-label");		
				field_name.innerHTML = "Fields name ";
			
			var field_name_text = document.createElement('input');
				field_name_text.setAttribute("size", "50");
				field_name_text.setAttribute("type", "text");
				field_name_text.setAttribute("id", "field_name");
				field_name_text.setAttribute("disabled", "disabled");
				field_name_text.setAttribute("value", "captcha_inputform_id_temp");
				
			edit_main_td0.appendChild(field_id);
			edit_main_td0.appendChild(br1);
			edit_main_td0.appendChild(field_name);
			edit_main_td0_1.appendChild(field_id_text);
			edit_main_td0_1.appendChild(br);
			edit_main_td0_1.appendChild(field_name_text);
			edit_main_tr0.appendChild(edit_main_td0);
			edit_main_tr0.appendChild(edit_main_td0_1);
			edit_main_table.insertBefore(edit_main_tr0,edit_main_table.childNodes[0]);		
			break;
		}
	
	    case 'type_spinner': {
			var	edit_main_table = document.getElementById("edit_main_table");
			var edit_main_tr0 = document.createElement('tr');
			var edit_main_td0 = document.createElement('td');
			var edit_main_td0_1 = document.createElement('td');
				
			var br = document.createElement('br');
			var br1 = document.createElement('br');
			
			var field_id = document.createElement('label');
				field_id.setAttribute("class", "fm-field-label");
				field_id.innerHTML = "Field id ";
			
			var field_id_text = document.createElement('input');
				field_id_text.setAttribute("size", "50");
				field_id_text.setAttribute("type", "text");
				field_id_text.setAttribute("disabled", "disabled");
				field_id_text.setAttribute("value", "wdform_"+i+"_elementform_id_temp");
			
			var field_name = document.createElement('label');
				field_name.setAttribute("class", "fm-field-label");
				field_name.innerHTML = "Field name ";
			
			var field_name_text = document.createElement('input');
				field_name_text.setAttribute("size", "50");
				field_name_text.setAttribute("type", "text");
				field_name_text.setAttribute("disabled", "disabled");
				field_name_text.setAttribute("value", "wdform_"+i+"_elementform_id_temp");
				
			edit_main_td0.appendChild(field_id);
			edit_main_td0.appendChild(br);
			edit_main_td0.appendChild(field_name);
			
			edit_main_td0_1.appendChild(field_id_text);
			edit_main_td0_1.appendChild(br1);
			edit_main_td0_1.appendChild(field_name_text);
			
			edit_main_tr0.appendChild(edit_main_td0);
			edit_main_tr0.appendChild(edit_main_td0_1);
			edit_main_table.insertBefore(edit_main_tr0,edit_main_table.childNodes[0]);		
			break;
		}
		
		case 'type_slider': {
			var	edit_main_table = document.getElementById("edit_main_table");
			var edit_main_tr0 = document.createElement('tr');
			var edit_main_td0 = document.createElement('td');
			var edit_main_td0_1 = document.createElement('td');
				
			var br = document.createElement('br');
			var br1 = document.createElement('br');
			
			var field_id = document.createElement('label');
				field_id.setAttribute("class", "fm-field-label");
				field_id.innerHTML = "Field id ";
			
			
			var field_id_text = document.createElement('input');
				field_id_text.setAttribute("size", "50");
				field_id_text.setAttribute("type", "text");
				field_id_text.setAttribute("disabled", "disabled");
				field_id_text.setAttribute("value", "wdform_"+i+"_elementform_id_temp");
			
			var field_name = document.createElement('label');
				field_name.setAttribute("class", "fm-field-label");
				field_name.innerHTML = "Field name ";
			
			var field_name_text = document.createElement('input');
				field_name_text.setAttribute("size", "50");
				field_name_text.setAttribute("type", "text");
				field_name_text.setAttribute("disabled", "disabled");
				field_name_text.setAttribute("value", "wdform_"+i+"_elementform_id_temp");
				
			edit_main_td0.appendChild(field_id);
			edit_main_td0.appendChild(br);
			edit_main_td0.appendChild(field_name);
			
			edit_main_td0_1.appendChild(field_id_text);
			edit_main_td0_1.appendChild(br1);
			edit_main_td0_1.appendChild(field_name_text);
			edit_main_tr0.appendChild(edit_main_td0);
			edit_main_tr0.appendChild(edit_main_td0_1);
			edit_main_table.insertBefore(edit_main_tr0,edit_main_table.childNodes[0]);		
			break;
		}
		
		case 'type_range': {
			var	edit_main_table = document.getElementById("edit_main_table");
			var edit_main_tr0 = document.createElement('tr');
			var edit_main_td0 = document.createElement('td');
			var edit_main_td0_1 = document.createElement('td');
				
			var br = document.createElement('br');
			var br1 = document.createElement('br');
			
			var field_id = document.createElement('label');
				field_id.setAttribute("class", "fm-field-label");
				field_id.innerHTML = "Fields id ";
			
			var field_id_text = document.createElement('input');
				field_id_text.setAttribute("type", "text");
				field_id_text.setAttribute("id", "field_id");
				field_id_text.setAttribute("disabled", "disabled");
				field_id_text.setAttribute("style", "width:350px");
				field_id_text.setAttribute("value",  '');
			
			var field_name = document.createElement('label');
				field_name.setAttribute("class", "fm-field-label");
				field_name.innerHTML = "Fields name ";
			
			var field_name_text = document.createElement('input');
				field_name_text.setAttribute("type", "text");
				field_name_text.setAttribute("id", "field_name");
				field_name_text.setAttribute("disabled", "disabled");
				field_name_text.setAttribute("style", "width:350px");
				field_name_text.setAttribute("value", '');
				
			edit_main_td0.appendChild(field_id);
			edit_main_td0.appendChild(br);
			edit_main_td0.appendChild(field_name);
			
			edit_main_td0_1.appendChild(field_id_text);
			edit_main_td0_1.appendChild(br1);
			edit_main_td0_1.appendChild(field_name_text);
			edit_main_tr0.appendChild(edit_main_td0);
			edit_main_tr0.appendChild(edit_main_td0_1);
			edit_main_table.insertBefore(edit_main_tr0,edit_main_table.childNodes[0]);			
			refresh_id_name(i, type);
			break;
		}	
			
		case 'type_grading': {
			var	edit_main_table = document.getElementById("edit_main_table");
			var edit_main_tr0 = document.createElement('tr');
			var edit_main_td0 = document.createElement('td');
				edit_main_td0.setAttribute("colspan", "2");
				
			var br = document.createElement('br');
			var br1 = document.createElement('br');
			
			var field_id = document.createElement('label');
				field_id.setAttribute("class", "fm-field-label");
				field_id.style.cssText = 'margin-right: 42px;';
				field_id.innerHTML = "Fields id ";
			
			var field_id_text = document.createElement('input');
				field_id_text.setAttribute("type", "text");
				field_id_text.setAttribute("id", "field_id");
				field_id_text.setAttribute("disabled", "disabled");
				field_id_text.setAttribute("style", "width:350px");
				field_id_text.setAttribute("value",  '');
			
			var field_name = document.createElement('label');
				field_name.setAttribute("class", "fm-field-label");
				field_name.innerHTML = "Fields name ";
			
			var field_name_text = document.createElement('input');
				field_name_text.setAttribute("type", "text");
				field_name_text.setAttribute("id", "field_name");
				field_name_text.setAttribute("disabled", "disabled");
				field_name_text.setAttribute("style", "width:350px");
				field_name_text.setAttribute("value", '');
				
			edit_main_td0.appendChild(field_id);
			edit_main_td0.appendChild(field_id_text);
			edit_main_td0.appendChild(br);
			edit_main_td0.appendChild(field_name);
			edit_main_td0.appendChild(field_name_text);
			edit_main_tr0.appendChild(edit_main_td0);
			edit_main_table.insertBefore(edit_main_tr0,edit_main_table.childNodes[0]);	
			refresh_id_name(i, type);
			break;
		}	
	}
}


function refresh_id_name(i, type)
{
	switch(type)
	{
		case 'type_radio':
		{
			document.getElementById('field_id').value='';
			jQuery('.change_pos').each(function() {
				var idi = jQuery(this)[0].id;
				document.getElementById('field_id').value	+='wdform_'+i+'_elementform_id_temp'+idi+', ';
			});
			a=document.getElementById('field_id').value.slice(0,-2);
			document.getElementById('field_id').value=a;
			document.getElementById('field_name').value	=i+'_element';

			break
		}
		case 'type_checkbox':
		{
			document.getElementById('field_id').value='';
			jQuery('.change_pos').each(function() {
				var idi = jQuery(this)[0].id;
				document.getElementById('field_id').value	+='wdform_'+i+'_elementform_id_temp'+idi+', ';
			});

			a=document.getElementById('field_id').value.slice(0,-2);
			document.getElementById('field_id').value	=a;
			document.getElementById('field_name').value	=a;

			break
		}
		case 'type_name':
		{
			document.getElementById('field_id').value = 'wdform_'+i+'_element_firstform_id_temp, wdform_'+i+'_element_lastform_id_temp';
			document.getElementById('field_name').value = 'wdform_'+i+'_element_firstform_id_temp, wdform_'+i+'_element_lastform_id_temp';
			
			if(document.getElementById(i+'_element_titleform_id_temp')) {
				document.getElementById('field_id').value = 'wdform_'+i+'_element_titleform_id_temp, ' + document.getElementById('field_id').value;
				document.getElementById('field_name').value = 'wdform_'+i+'_element_titleform_id_temp, ' + document.getElementById('field_name').value;
				
			}	
			
			if(document.getElementById(i+'_element_middleform_id_temp')) {
				document.getElementById('field_id').value	= document.getElementById('field_id').value + ',  wdform_'+i+'_element_middleform_id_temp';
				document.getElementById('field_name').value	= document.getElementById('field_name').value + ',  wdform_'+i+'_element_middleform_id_temp';
		
			}
			
			break;
		}
		case 'type_range':
		{
			document.getElementById('field_id').value='';
			for(k=0; k<2;k++)
			{
						
					document.getElementById('field_id').value	+='wdform_'+i+'_elementform_id_temp'+k+', ';
				
			}
			a=document.getElementById('field_id').value.slice(0,-2);
			document.getElementById('field_id').value	=a;
			document.getElementById('field_name').value	=a;

			break;
		}
		case 'type_grading':
		{
			document.getElementById('field_id').value='';
			for(k=0; k<50;k++)
			{
			
				if(document.getElementById(i+'_elementform_id_temp_'+k))
				{	
				
					document.getElementById('field_id').value	+='wdform_'+i+'_elementform_id_temp_'+k+', ';
				}
			}
			a=document.getElementById('field_id').value.slice(0,-2);
			document.getElementById('field_id').value	=a;
			document.getElementById('field_name').value	=a;

			break;
		}

	}

}

function add_attr(i, type)
{
	var el_attr_table=document.getElementById('attributes');
	j=parseInt(el_attr_table.lastChild.getAttribute('idi'))+1;
	w_attr_name[j]="attribute";
	w_attr_value[j]="value";
	var el_attr_tr = document.createElement('tr');
		el_attr_tr.setAttribute("id", "attr_row_"+j);
		el_attr_tr.setAttribute("idi", j);
	var el_attr_td_name = document.createElement('td');
		el_attr_td_name.style.cssText = 'width:100px';
	var el_attr_td_value = document.createElement('td');
		el_attr_td_value.style.cssText = 'width:100px';
	
	var el_attr_td_X = document.createElement('td');
	var el_attr_name = document.createElement('input');
		el_attr_name.setAttribute("type", "text");
		el_attr_name.setAttribute("class", "fm-field-choice");
		el_attr_name.setAttribute("value", w_attr_name[j]);
		el_attr_name.setAttribute("id", "attr_name"+j);
		el_attr_name.setAttribute("onChange", "change_attribute_name('"+i+"', this, '"+type+"')");	
		
	var el_attr_value = document.createElement('input');
		el_attr_value.setAttribute("type", "text");
		el_attr_value.setAttribute("class", "fm-field-choice");
		el_attr_value.setAttribute("value", w_attr_value[j]);
		el_attr_value.setAttribute("id", "attr_value"+j);
		el_attr_value.setAttribute("onChange", "change_attribute_value('"+i+"', "+j+", '"+type+"')");
	
	var el_attr_remove = document.createElement('img');
		el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
		el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
		el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
		
		el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", '"+type+"')");
	el_attr_table.appendChild(el_attr_tr);
	el_attr_tr.appendChild(el_attr_td_name);
	el_attr_tr.appendChild(el_attr_td_value);
	el_attr_tr.appendChild(el_attr_td_X);
	el_attr_td_name.appendChild(el_attr_name);
	el_attr_td_value.appendChild(el_attr_value);
	el_attr_td_X.appendChild(el_attr_remove);
	refresh_attr(i, type);

	jQuery('#edit_table').scrollTop( jQuery("#attributes").offset().top );	
}

function change_attribute_value(id, x, type)
{
	if(!document.getElementById("attr_name"+x).value)
	{
		alert('The name of the attribute is required.');
		return
	}
	
	if(document.getElementById("attr_name"+x).value.toLowerCase()=="style")
	{
		alert('Sorry, you cannot add a style attribute here. Use "Class name" instead.');
		return
	}
	
	refresh_attr(id, type);
}

function change_attribute_name(id, x, type)
{
	value=x.value;
	if(!value)
	{
		alert('The name of the attribute is required.');
		return;
	}
	
	if(value.toLowerCase()=="style")
	{
		alert('Sorry, you cannot add a style attribute here. Use "Class name" instead.');
		return;
	}
	
	if(value==parseInt(value))
	{
		alert('The name of the attribute cannot be a number.');
		return;
	}
	
	if(value.indexOf(" ")!=-1)
	{	
		var regExp = /\s+/g;
		value=value.replace(regExp,''); 
		x.value=value;
		alert("The name of the attribute cannot contain a space.");
		refresh_attr(id, type);
		return;
	}	
	
	refresh_attr(id, type);
	
}

function remove_attr(id, el_id,type)
{
	tr=document.getElementById("attr_row_"+id);
	tr.parentNode.removeChild(tr);
	refresh_attr(el_id, type);
}

function change_attributes(id, attr)
{
	
var div = document.createElement('div');
var element=document.getElementById(id);
	element.setAttribute(attr, '');
}

function add_button(i)
{
	edit_main_td4=document.getElementById('buttons');
	if(edit_main_td4.lastChild)
		j=parseInt(edit_main_td4.lastChild.getAttribute("idi"))+1;
	else
		j=1;
	var table_button = document.createElement('table');
	
	table_button.setAttribute("width", "100%");
	table_button.setAttribute("border", "0");
	table_button.setAttribute("id", "button_opt"+j);
	table_button.setAttribute("idi", j);
	var tr_button = document.createElement('tr');
	var tr_hr = document.createElement('tr');
	
	var td_button = document.createElement('td');
	var td_X = document.createElement('td');
	var td_hr = document.createElement('td');
	td_hr.setAttribute("colspan", "3");
	
	tr_hr.appendChild(td_hr);
	tr_button.appendChild(td_button);
	tr_button.appendChild(td_X);
	table_button.appendChild(tr_hr);
	table_button.appendChild(tr_button);
	
	var br1 = document.createElement('br');
	var hr = document.createElement('hr');
		hr.setAttribute("id", "br"+j);
	
	var el_title_label = document.createElement('label');
		el_title_label.setAttribute("class", "fm-field-label");
		el_title_label.setAttribute("for", "el_title"+j);
		el_title_label.innerHTML = "Button name";
	
	var el_title = document.createElement('input');
		el_title.setAttribute("id", "el_title"+j);
		el_title.setAttribute("type", "text");
		el_title.setAttribute("value", "Button");
		el_title.style.cssText = "width:140px; margin-left:33px;";
		el_title.setAttribute("onKeyUp", "change_label('"+i+"_elementform_id_temp"+j+"', this.value);");

	var el_func_label = document.createElement('label');
		el_func_label.setAttribute("class", "fm-field-label");
		el_func_label.setAttribute("for", "el_func"+j);
		el_func_label.innerHTML = "OnClick function";
	
	var el_func = document.createElement('input');
		el_func.setAttribute("id", "el_func"+j);
		el_func.setAttribute("type", "text");
		el_func.setAttribute("value", "");
		el_func.style.cssText =   "width:140px; margin-left:11px;";
		el_func.setAttribute("onKeyUp", "change_func('"+i+"_elementform_id_temp"+j+"', this.value);");
	
	var el_choices_remove = document.createElement('img');
		el_choices_remove.setAttribute("id", "el_button"+j+"_remove");
		el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
		el_choices_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
		el_choices_remove.setAttribute("align", 'top');
		el_choices_remove.setAttribute("onClick", "remove_button("+j+","+i+")");
	
	
	td_hr.appendChild(hr);
	td_button.appendChild(el_title_label);
	td_button.appendChild(el_title);
	td_button.appendChild(br1);
	td_button.appendChild(el_func_label);
	
	td_button.appendChild(el_func);
	td_X.appendChild(el_choices_remove);
	edit_main_td4.appendChild(table_button);
	
	element='button';	type='button'; 
	
	td2=document.getElementById(i+"_element_sectionform_id_temp");
	var adding = document.createElement(element);
		adding.setAttribute("type", type);
		adding.setAttribute("id", i+"_elementform_id_temp"+j);
		adding.setAttribute("name", i+"_elementform_id_temp"+j);
		adding.setAttribute("value", "Button");
		adding.innerHTML =  "Button";
		adding.setAttribute("onclick", "");
		
	td2.appendChild(adding);
	refresh_attr(i,'type_checkbox');
}

function remove_button(j,i)
{
	table=document.getElementById('button_opt'+j);
	button=document.getElementById(i+'_elementform_id_temp'+j);
	table.parentNode.removeChild(table);
	button.parentNode.removeChild(button);
}

function change_date_format(value, id, element)
{
	var input_p = document.getElementById(id+'_buttonform_id_temp');
	if(element == 'format') {
		var dis_past_days =  document.getElementById(id+'_dis_past_daysform_id_temp').value == 'yes' ? true : false;
		input_p.setAttribute("format", value);
	}
	else {
		document.getElementById(id+'_dis_past_daysform_id_temp').value = (value == true ? 'yes' : 'no');
		var dis_past_days = value == true ? true : false;
		var value = document.getElementById('date_format').value;
	}
	input_p.setAttribute("onclick", "return showCalendar('"+id+"_elementform_id_temp' , '"+value+"', "+dis_past_days+")");
		
}

function disable_past_days(value, id)
{
	var dis_past_days = value == true ? true : false;
	
	alert(dis_past_days);
	alert(document.getElementById(id+'_buttonform_id_temp'));
	var input_p = document.getElementById(id+'_buttonform_id_temp');
		input_p.setAttribute("onclick", "return showCalendar('"+id+"_elementform_id_temp' , '"+value+"')");
		input_p.setAttribute("format", value);
}

function set_send(id)
{	
if(document.getElementById(id).value=="yes")
	document.getElementById(id).setAttribute("value", "no")
else
	document.getElementById(id).setAttribute("value", "yes")
}

function change_class(x,id)
{
	if(document.getElementById(id+'_label_sectionform_id_temp'))
	document.getElementById(id+'_label_sectionform_id_temp').setAttribute("class",x);
	if(document.getElementById(id+'_element_sectionform_id_temp'))
	document.getElementById(id+'_element_sectionform_id_temp').setAttribute("class",x);
}

function set_required(id)
{	
	if(document.getElementById(id+"form_id_temp").value=="yes")
	{
		document.getElementById(id+"form_id_temp").setAttribute("value", "no");
		document.getElementById(id+"_elementform_id_temp").innerHTML="";
	}	
	else
	{
		document.getElementById(id+"form_id_temp").setAttribute("value", "yes")
		document.getElementById(id+"_elementform_id_temp").innerHTML=" *";
	}
}

function disable_fields(id,field)
{	
	var div = document.getElementById(id+"_div_address");
	if(field) {
		if(document.getElementById("el_"+field).checked==true)
			document.getElementById(id+"_disable_fieldsform_id_temp").setAttribute(field, "yes");
		else
			document.getElementById(id+"_disable_fieldsform_id_temp").setAttribute(field, "no");
	}
	
	
	if(document.getElementById(id+"_disable_fieldsform_id_temp").getAttribute("state")=='yes')
		document.getElementById("el_us_states").disabled =true;	
	else {
		document.getElementById("el_us_states").disabled =false;
		if(field=='us_states')
		{		
			change_state_input(id,'form_id_temp');
			return;
		}
		
	}
	
	div.innerHTML='';

	var hidden_labels = new Array();
	var address_fields =['street1','street2','city','state','postal','country']
	var left_right=0;
		
	for(l=0; l<6; l++)
	{
		if(document.getElementById(id+'_disable_fieldsform_id_temp').getAttribute(address_fields[l])=='no')	
		{
			if(address_fields[l]=='street1' || address_fields[l]=='street2')    
			{  
				var street = document.createElement('input');
					street.setAttribute("type", 'text');
					street.style.cssText = "width:100%";
					street.setAttribute("id", id+"_"+address_fields[l]+"form_id_temp");
					street.setAttribute("name", (parseInt(id)+l)+"_"+address_fields[l]+"form_id_temp");
					street.setAttribute("onChange", "change_value('"+id+"_"+address_fields[l]+"form_id_temp')");
						
				var street_label = document.createElement('label');
					street_label.setAttribute("class", "mini_label");	
					street_label.setAttribute("id", id+"_mini_label_"+address_fields[l]);
					street_label.style.cssText = "display:block;";
					street_label.innerHTML=document.getElementById('el_'+address_fields[l]+"_label").innerHTML;
					w_mini_labels[l] = document.getElementById('el_'+address_fields[l]+"_label").innerHTML;
					
				var span_addres = document.createElement('span');
					span_addres.style.cssText = "float:left; width:100%;  padding-bottom: 8px; display:block";	
				
				span_addres.appendChild(street);
				span_addres.appendChild(street_label);
				div.appendChild(span_addres);				
					
			}	
			else
			{
			left_right++;
			
				if(address_fields[l]!='country')
				{

				
					var field = document.createElement('input');
						field.setAttribute("type", 'text');
						field.style.cssText = "width:100%";
						field.setAttribute("id", id+"_"+address_fields[l]+"form_id_temp");
						field.setAttribute("name", (parseInt(id)+l)+"_"+address_fields[l]+"form_id_temp");
						field.setAttribute("onChange", "change_value('"+id+"_"+address_fields[l]+"form_id_temp')");

					var field_label = document.createElement('label');
						field_label.setAttribute("class", "mini_label");		
						field_label.setAttribute("id", id+"_mini_label_"+address_fields[l]);
						field_label.style.cssText = "display:block;";
						field_label.innerHTML=document.getElementById('el_'+address_fields[l]+"_label").innerHTML;
						w_mini_labels[l] = document.getElementById('el_'+address_fields[l]+"_label").innerHTML;
						
					
				}
				else
				{
						var field = document.createElement('select');
							field.setAttribute("type", 'text');
							field.style.cssText = "width:100%";
							field.setAttribute("id", id+"_countryform_id_temp");
							field.setAttribute("name", (parseInt(id)+l)+"_countryform_id_temp");
							field.setAttribute("onChange", "change_state_input('"+id+"', 'form_id_temp')");

						var field_label = document.createElement('label');
							field_label.setAttribute("class", "mini_label");	
							field_label.setAttribute("id", id+"_mini_label_country");
							field_label.style.cssText = "display:block;";
							field_label.innerHTML=document.getElementById('el_'+address_fields[l]+"_label").innerHTML;
							w_mini_labels[l] = document.getElementById('el_'+address_fields[l]+"_label").innerHTML;
							
						var option_ = document.createElement('option');
							option_.setAttribute("value", "");
							option_.innerHTML="";
						field.appendChild(option_);
						
						coutries=["Afghanistan","Albania",	"Algeria","Andorra","Angola","Antigua and Barbuda","Argentina","Armenia","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bhutan","Bolivia","Bosnia and Herzegovina","Botswana","Brazil","Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde","Central African Republic","Chad","Chile","China","Colombia","Comoros","Congo (Brazzaville)","Congo","Costa Rica","Cote d'Ivoire","Croatia","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","East Timor (Timor Timur)","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Fiji","Finland","France","Gabon","Gambia, The","Georgia","Germany","Ghana","Greece","Grenada","Guatemala","Guinea","Guinea-Bissau","Guyana","Haiti","Honduras","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Israel","Italy","Jamaica","Japan","Jordan","Kazakhstan","Kenya","Kiribati","Korea, North","Korea, South","Kuwait","Kyrgyzstan","Laos","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Mauritania","Mauritius","Mexico","Micronesia","Moldova","Monaco","Mongolia","Morocco","Mozambique","Myanmar","Namibia","Nauru","Nepal","Netherlands","New Zealand","Nicaragua","Niger","Nigeria","Norway","Oman","Pakistan","Palau","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Poland","Portugal","Qatar","Romania","Russia","Rwanda","Saint Kitts and Nevis","Saint Lucia","Saint Vincent","Samoa","San Marino","Sao Tome and Principe","Saudi Arabia","Senegal","Serbia and Montenegro","Seychelles","Sierra Leone","Singapore","Slovakia","Slovenia","Solomon Islands","Somalia","South Africa","Spain","Sri Lanka","Sudan","Suriname","Swaziland","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Togo","Tonga","Trinidad and Tobago","Tunisia","Turkey","Turkmenistan","Tuvalu","Uganda","Ukraine","United Arab Emirates","United Kingdom","United States","Uruguay","Uzbekistan","Vanuatu","Vatican City","Venezuela","Vietnam","Yemen","Zambia","Zimbabwe"];	
						for(r=0;r<coutries.length;r++)
						{
						var option_ = document.createElement('option');
							option_.setAttribute("value", coutries[r]);
							option_.innerHTML=coutries[r];
						field.appendChild(option_);
						}
				
				}	

				if(left_right%2!=0)	
				{
					var span_addres = document.createElement('span');
						span_addres.style.cssText = "float:left; width:48%; padding-bottom: 8px;";
				}
				else
				{
					var span_addres = document.createElement('span');
						span_addres.style.cssText = "float:right; width:48%; padding-bottom: 8px;";
				}	
					
				span_addres.appendChild(field);
				span_addres.appendChild(field_label);
				div.appendChild(span_addres);
				
			}
		}
		else
		{
			var hidden_field = document.createElement('input');
				hidden_field.setAttribute("type", 'hidden');
				hidden_field.setAttribute("id", id+"_"+address_fields[l]+"form_id_temp");
				hidden_field.setAttribute("value", document.getElementById("el_"+address_fields[l]+"_label").innerHTML);
				hidden_field.setAttribute("id_for_label", parseInt(id)+l); 
				
				hidden_labels.push(hidden_field);
		
		}
		
		
		for(k=0; k<hidden_labels.length; k++)
		{
		div.appendChild(hidden_labels[k]);

		}
		
	}
	
	
	if(document.getElementById(id+"_disable_fieldsform_id_temp").getAttribute("state")=='no' && document.getElementById(id+"_disable_fieldsform_id_temp").getAttribute("country")=='yes')
		change_state_input(id,'form_id_temp');
		
	jQuery(document).ready(function() {		
		jQuery("label#"+id+"_mini_label_street1").click(function() {			
			if (jQuery(this).children('input').length == 0) {				
				var street1 = "<input type='text' class='street1' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";
				jQuery(this).html(street1);					
				jQuery("input.street1").focus();		
				jQuery("input.street1").blur(function() {	
					var value = jQuery(this).val();			
					jQuery("#"+id+"_mini_label_street1").text(value);		
					document.getElementById('el_street1_label').innerHTML=	value;	
				});		
			}	
		});		
	
	jQuery("label#"+id+"_mini_label_street2").click(function() {		
	if (jQuery(this).children('input').length == 0) {		
	var street2 = "<input type='text' class='street2'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";
		jQuery(this).html(street2);					
		jQuery("input.street2").focus();		
		jQuery("input.street2").blur(function() {	
	var value = jQuery(this).val();			
		jQuery("#"+id+"_mini_label_street2").text(value);
		document.getElementById('el_street2_label').innerHTML=	value;		
	});		
	}	
	});	
	
	
	jQuery("label#"+id+"_mini_label_city").click(function() {	
	if (jQuery(this).children('input').length == 0) {	
	var city = "<input type='text' class='city'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";
		jQuery(this).html(city);			
		jQuery("input.city").focus();				
		jQuery("input.city").blur(function() {			
	var value = jQuery(this).val();		
		jQuery("#"+id+"_mini_label_city").text(value);	
		document.getElementById('el_city_label').innerHTML=	value;		
	});		
	}	
	});	
	
	jQuery("label#"+id+"_mini_label_state").click(function() {		
	if (jQuery(this).children('input').length == 0) {	
	var state = "<input type='text' class='state'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
		jQuery(this).html(state);		
		jQuery("input.state").focus();		
		jQuery("input.state").blur(function() {		
	var value = jQuery(this).val();			
		jQuery("#"+id+"_mini_label_state").text(value);
		document.getElementById('el_state_label').innerHTML=	value;		
	});	
	}
	});		

	jQuery("label#"+id+"_mini_label_postal").click(function() {		
	if (jQuery(this).children('input').length == 0) {			
	var postal = "<input type='text' class='postal'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";
		jQuery(this).html(postal);			
		jQuery("input.postal").focus();			
		jQuery("input.postal").blur(function() {			
	var value = jQuery(this).val();		
		jQuery("#"+id+"_mini_label_postal").text(value);	
		document.getElementById('el_postal_label').innerHTML=	value;		
	});	
	}
	});	
	
	
	jQuery("label#"+id+"_mini_label_country").click(function() {		
		if (jQuery(this).children('input').length == 0) {		
		var country = "<input type='text' class='country'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";
			jQuery(this).html(country);		
			jQuery("input.country").focus();	
			jQuery("input.country").blur(function() {		
		var value = jQuery(this).val();			
			jQuery("#"+id+"_mini_label_country").text(value);
			document.getElementById('el_country_label').innerHTML=	value;				
			});	
		}	
	});
	});	

	refresh_attr(id,type);
}

function enable_name_fields(id, field)
{
	var index = field == 'title' ? 2 : 3;
	tr_name1 = document.getElementById(id+'_tr_name1');
    tr_name2 = document.getElementById(id+'_tr_name2');
	first_input = document.getElementById(id+'_td_name_input_first');
    first_label = document.getElementById(id+'_td_name_label_first');

	var input_width = field == 'title' ? '40' : document.getElementById('edit_for_input_size').value;
	if(document.getElementById("el_"+field).checked==true)
		document.getElementById(id+"_enable_fieldsform_id_temp").setAttribute(field, "yes");
	else
		document.getElementById(id+"_enable_fieldsform_id_temp").setAttribute(field, "no");
		
	if(document.getElementById(id+'_enable_fieldsform_id_temp').getAttribute(field)=='yes') {
		var name_field_td = document.createElement('div');
			name_field_td.setAttribute("id", id+"_td_name_input_"+field);
			name_field_td.style.cssText = "display:table-cell";
			
		var name_field = document.createElement('input');
			name_field.setAttribute("type", 'text');
			if(w_title[index]==w_first_val[index]) {
				name_field.setAttribute("class", "input_deactive");
				name_field.setAttribute("value", w_first_val[index]);
			}	
			else {
				name_field.setAttribute("class", "input_active");
				name_field.setAttribute("value", w_first_val[index]);
			}	
			name_field.setAttribute("id", id+"_element_"+field+"form_id_temp");
			name_field.setAttribute("name", id+"_element_"+field+"form_id_temp");
			name_field.setAttribute("value", w_first_val[index]);
			name_field.setAttribute("title", w_title[index]);
			name_field.setAttribute("onfocus", "delete_value('"+id+"_element_"+field+"form_id_temp')");
			name_field.setAttribute("onblur", "return_value('"+id+"_element_"+field+"form_id_temp')");
			name_field.setAttribute("onChange", "change_value('"+id+"_element_"+field+"form_id_temp')");
			name_field.style.cssText = "margin-right: 10px; width: "+input_width+"px";
		
		var name_field_label_td = document.createElement('div');
			name_field_label_td.setAttribute("id", id+"_td_name_label_"+field);
			name_field_label_td.style.cssText = "display:table-cell";
		
		var name_field_label = document.createElement('label');
			name_field_label.setAttribute("class", "mini_label");	
			name_field_label.setAttribute("id", id+"_mini_label_"+field);
			name_field_label.innerHTML=document.getElementById('el_'+field+"_label").innerHTML;
		//	w_mini_labels[0] = document.getElementById('el_'+field+"_label").innerHTML;
			
		name_field_td.appendChild(name_field);
		name_field_label_td.appendChild(name_field_label);
		if(field == 'title') {
			tr_name1.insertBefore(name_field_td, first_input);
			tr_name2.insertBefore(name_field_label_td, first_label);
		}	
		else {
			tr_name1.appendChild(name_field_td);
			tr_name2.appendChild(name_field_label_td);
		}	
	}
	else{
		if(document.getElementById(id+'_td_name_input_'+field)) {
			tr_name1.removeChild(document.getElementById(id+'_td_name_input_'+field));
			tr_name2.removeChild(document.getElementById(id+'_td_name_label_'+field));
		}
	}
	
	var gic1 = document.createTextNode("-");
	var gic2 = document.createTextNode("-");

	value_if_empty_width = field == 'title' ? '60' : '95';
	var el_first_value= document.createElement('input');
		el_first_value.setAttribute("id", "el_first_value_"+field);
		el_first_value.setAttribute("type", "text");
		el_first_value.setAttribute("value", w_title[index]);	
		el_first_value.style.cssText = "width:"+value_if_empty_width+"px;";
		el_first_value.setAttribute("onKeyUp", "change_input_value(this.value,'"+id+"_element_"+field+"form_id_temp')");
			
    el_first_value_first = document.getElementById('el_first_value_first');
	parent = el_first_value_first.parentNode;
	if(document.getElementById(id+'_enable_fieldsform_id_temp').getAttribute(field)=='yes') {
		if(field == 'title') {
			parent.insertBefore(gic1, el_first_value_first);
			parent.insertBefore(el_first_value, gic1);
		}
		else {
			parent.appendChild(gic2);
			parent.appendChild(el_first_value);
		}
	} else {
		if(document.getElementById('el_first_value_'+field)) {
			if(field == 'title') 
				parent.removeChild( document.getElementById('el_first_value_title').nextSibling);
			else
				parent.removeChild( document.getElementById('el_first_value_middle').previousSibling);
			parent.removeChild( document.getElementById('el_first_value_'+field));
		}	
	}
	
	refresh_attr(id, 'type_name');
	refresh_id_name(id, 'type_name');
	
	jQuery(document).ready(function() {	
		jQuery("label#"+id+"_mini_label_title").click(function() {		
			if (jQuery(this).children('input').length == 0) {				
				var title = "<input type='text' class='title' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
				jQuery(this).html(title);							
				jQuery("input.title").focus();			
				jQuery("input.title").blur(function() {	
					var value = jQuery(this).val();			
					jQuery("#"+id+"_mini_label_title").text(value);	
					document.getElementById('el_title_label').innerHTML = value;						
				});	
			}	
		});		

		jQuery("label#"+id+"_mini_label_middle").click(function() {		
			if (jQuery(this).children('input').length == 0) {				
				var middle = "<input type='text' class='middle' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
				jQuery(this).html(middle);							
				jQuery("input.middle").focus();			
				jQuery("input.middle").blur(function() {	
					var value = jQuery(this).val();			
					jQuery("#"+id+"_mini_label_middle").text(value);	
					document.getElementById('el_middle_label').innerHTML = value;						
				});	
			}	
		});	
	});	
}


function set_unique(id)
{	
	if(document.getElementById(id).value=="yes")
	{
		document.getElementById(id).setAttribute("value", "no");
	}	
	else
	{
		document.getElementById(id).setAttribute("value", "yes")
	}
}

function set_randomize(id)
{	
	if(document.getElementById(id).value=="yes")
	{
		document.getElementById(id).setAttribute("value", "no");
	}	
	else
	{
		document.getElementById(id).setAttribute("value", "yes")
	}
}
function show_other_input(num)
{
		jQuery('.change_pos').each(function() {
		var k = jQuery(this)[0].id;
		if(document.getElementById(num+"_elementform_id_temp"+k)) 
			if(	document.getElementById(num+"_elementform_id_temp"+k).getAttribute('other')) 
				if(	document.getElementById(num+"_elementform_id_temp"+k).getAttribute('other')==1)
				{
					element_other=document.getElementById(num+"_elementform_id_temp"+k);
					return false;
				}
	});


	var parent=element_other.parentNode;

	var br = document.createElement('br');
		br.setAttribute("id", num+"_other_brform_id_temp");
		
	var el_other = document.createElement('input');
		el_other.setAttribute("id", num+"_other_inputform_id_temp");
		el_other.setAttribute("name", num+"_other_inputform_id_temp");
		el_other.setAttribute("type", "text");
		el_other.setAttribute("class", "other_input");
	parent.appendChild(br);
	parent.appendChild(el_other);
}

function set_allow_other(num, type)
{	
	if(document.getElementById(num+'_allow_otherform_id_temp').value=="yes")
	{
	
		document.getElementById(num+'_allow_otherform_id_temp').setAttribute("value", "no");
		jQuery('.change_pos').each(function() {
			var k = jQuery(this)[0].id;
			if(document.getElementById("el_choices"+k)) 
				if(	document.getElementById("el_choices"+k).getAttribute('other')) 
					if(	document.getElementById("el_choices"+k).getAttribute('other')==1)
					{
						remove_choise(k,num,type);
						return false;
					}
		});
					
	}	
	else
	{
		document.getElementById(num+'_allow_otherform_id_temp').setAttribute("value", "yes");
		var max_value = 0;
		jQuery('.change_pos').each(function() {
			var value = parseInt(jQuery(this)[0].id);
			max_value = (value > max_value) ? value : max_value;
		});

		max_value = max_value + 1;

				
				var choices_td= document.getElementById('choices');
				var div = document.createElement('div');
			           div.setAttribute("id", max_value);
			           div.setAttribute("class", "change_pos");
				var el_choices = document.createElement('input');
					el_choices.setAttribute("id", "el_choices"+max_value);
					el_choices.setAttribute("type", "text");
					el_choices.setAttribute("value", "other");
					el_choices.setAttribute("other", "1");
					el_choices.setAttribute("class", "fm-field-choice");
			        el_choices.setAttribute("onKeyUp", "change_label('"+num+"_label_element"+max_value+"', this.value); change_in_value('"+num+"_elementform_id_temp"+max_value+"', this.value)");
					
			    var el_choices_value = document.createElement('input');
			        el_choices_value.setAttribute("id", "el_option_value"+max_value);
			        el_choices_value.setAttribute("type", "text");
			        el_choices_value.setAttribute("value", '');
					el_choices_value.setAttribute("class", "fm-field-choice");
			        el_choices_value.setAttribute("disabled", 'disabled');
			
				var el_choices_remove = document.createElement('img');
					el_choices_remove.setAttribute("id", "el_choices"+max_value+"_remove");
					el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
					el_choices_remove.style.cssText =  'cursor:pointer;vertical-align:middle; margin:2px; display:none';
					el_choices_remove.setAttribute("align", 'top');
					el_choices_remove.setAttribute("onClick", "remove_choise('"+max_value+"','"+num+"','"+type+"')");
			
				var el_choices_handle = document.createElement('img');
			        el_choices_handle.setAttribute("class", "el_choices_sortable");
			        el_choices_handle.setAttribute("src", plugin_url + '/images/move_cursor.png?ver=1.8.0');		
			        el_choices_handle.style.cssText = 'cursor:move; vertical-align:middle; margin:2px 0px 2px 34px;';
			        el_choices_handle.setAttribute("align", 'top');
		
		        var el_choices_params = document.createElement('input');
			        el_choices_params.setAttribute("id", "el_option_params"+max_value);
			        el_choices_params.setAttribute("class", "el_option_params");
			        el_choices_params.setAttribute("type", "hidden");
			        el_choices_params.setAttribute("value", "");
			
		        div.appendChild(el_choices);
		        div.appendChild(el_choices_value);
		        div.appendChild(el_choices_remove);
		        div.appendChild(el_choices_handle);
		        div.appendChild(el_choices_params);
		        choices_td.appendChild(div);
				
			if(type=='checkbox')
			refresh_attr(num, 'type_checkbox');
				

			if(type=='radio')
			refresh_attr(num, 'type_radio');

			
			refresh_rowcol(num, type);
	}

}

function option_right(id, type)
{
	jQuery('#'+id+'_table_little').find(jQuery('.ch-rad-label')).css("cssText", "float: none !important;");
	jQuery('#'+id+'_table_little').find(jQuery('#main_div input[type="'+type+'"]')).css("cssText", "float: left !important;");
	jQuery('#'+id+'_option_left_right').val('right');
}


function option_left(id, type)
{
	jQuery('#'+id+'_table_little').find(jQuery('.ch-rad-label')).css("cssText", "float: left !important;");
	jQuery('#'+id+'_table_little').find(jQuery('#main_div input[type="'+type+'"]')).css("cssText", "float: right !important;");
	jQuery('#'+id+'_option_left_right').val('left');
}

function flow_hor(id)
{
	tbody=document.getElementById(id+'_table_little');
	td_array= new Array();
	n=tbody.childNodes.length;
	for(k=0; k<n;k++)
		td_array[k]=tbody.childNodes[k].childNodes[0];
		
	for(k=0; k<n;k++)
		tbody.removeChild(tbody.childNodes[0]);
		
	var tr = document.createElement('div');
		tr.style.display="table-row";
           	tr.setAttribute("id", id+"_hor");
			
	tbody.appendChild(tr);
	for(k=0; k<n;k++)
		tr.appendChild(td_array[k]);
}

function flow_ver(id)
{	
	tbody=document.getElementById(id+'_table_little');
	tr=document.getElementById(id+'_hor');
	td_array= new Array();
	n=tr.childNodes.length;
	
	for(k=0; k<n;k++)
		td_array[k]=tr.childNodes[k];
			
	tbody.removeChild(tr);
	
	for(k=0; k<n;k++)
	{      	
		var tr_little = document.createElement('div');
			tr_little.setAttribute("id", id+"_element_tr"+td_array[k].getAttribute("idi"));
			tr_little.style.display="table-row";
		tr_little.appendChild(td_array[k]);
		tbody.appendChild(tr_little);
	}			
}

function check_isnum_3_10(e)
{
   	var chCode1 = e.which || e.keyCode;
    	if (chCode1 > 31 && (chCode1 < 51 || chCode1 > 57))
        return false
	else if((document.getElementById('captcha_digit').value+(chCode1-48))>9)
        return false;
	return true;
}

function check_isnum_less_then_5(e)
{
	var chCode1 = e.which || e.keyCode;
	if (chCode1 > 31 && (chCode1 < 49 || chCode1 > 57))
		return false;
	else if((document.getElementById('el_oper_count').value+(chCode1-48))>5)
        return false;
	return true;
}

function check_is_operation_valid(e)
{
	var chCode1 = e.which || e.keyCode;
	if (chCode1 == 46 || chCode1 < 42 || chCode1 > 47)
		return false;
	
	return true;
}

function set_sel_am_pm(select_)
{
	if(select_.options[0].selected) 
	{
		select_.options[0].setAttribute("selected", "selected");
		select_.options[1].removeAttribute("selected");
	}
	else
	{
		select_.options[1].setAttribute("selected", "selected");
		select_.options[0].removeAttribute("selected");
	}

}

function change_captcha_digit(digit) {
	captcha=document.getElementById('_wd_captchaform_id_temp');
	if (document.getElementById('captcha_digit').value) {	
		captcha.setAttribute("digit", digit);
		captcha.setAttribute("src", url_for_ajax + "?action=formmakerwdcaptcha&digit="+digit+"&i=form_id_temp");
		document.getElementById('_wd_captcha_inputform_id_temp').style.width=(document.getElementById('captcha_digit').value*10+15)+"px";
	}
	else {
		captcha.setAttribute("digit", "6");
		captcha.setAttribute("src", url_for_ajax+"?action=formmakerwdcaptcha&digit=6&i=form_id_temp");
		document.getElementById('_wd_captcha_inputform_id_temp').style.width=(6*10+15)+"px";
	}
}

function change_arithmetic_captcha(value, field) {
	arithmetic_captcha = document.getElementById('_wd_arithmetic_captchaform_id_temp');
	if (field == 'oper_count') {
		oper_count = value ? value : 1;
		operations = document.getElementById('el_operations') ? document.getElementById('el_operations').value : '+, -, *, /';
	} else {
		operations = value ? value : '+, -, *, /';
		oper_count = document.getElementById('el_oper_count') ? document.getElementById('el_oper_count').value : 1;
	}	

	arithmetic_captcha.setAttribute("operations_count", oper_count);
	arithmetic_captcha.setAttribute("operations", operations);
	arithmetic_captcha.setAttribute("src", url_for_ajax + "?action=formmakerwdmathcaptcha&operations_count="+oper_count+"&operations="+operations.replace('+','@')+"&i=form_id_temp");
}



function second_no(id)
{	
	time_box=document.getElementById(id+'_tr_time1');
	text_box=document.getElementById(id+'_tr_time2');
	second_box=document.getElementById(id+'_td_time_input3');
	second_text=document.getElementById(id+'_td_time_label3');
	document.getElementById(id+'_td_time_input2').parentNode.removeChild(document.getElementById(id+'_td_time_input2').nextSibling);
	time_box.removeChild(second_box);
	text_box.removeChild(second_text.previousSibling);
	text_box.removeChild(second_text);
	
}

function second_yes(id, w_ss)
{	
	time_box=document.getElementById(id+'_tr_time1');
	text_box=document.getElementById(id+'_tr_time2');
	
	var td_time_input2_ket = document.createElement('div');
           	td_time_input2_ket.setAttribute("align", "center");
			td_time_input2_ket.style.display="table-cell";
	var td_time_input3 = document.createElement('div');
           	td_time_input3.setAttribute("id", id+"_td_time_input3");
			td_time_input3.style.display="table-cell";
			
      	var td_time_label2_ket = document.createElement('div');
			td_time_label2_ket.style.display="table-cell";
	
      	var td_time_label3 = document.createElement('div');
           	td_time_label3.setAttribute("id", id+"_td_time_label3");
			td_time_label3.style.display="table-cell";

	var mm_ = document.createElement('span');
		mm_.setAttribute("class", 'wdform_colon');
		mm_.style.cssText = "font-style:bold; vertical-align:middle";
		mm_.innerHTML="&nbsp;:&nbsp;";
	td_time_input2_ket.appendChild(mm_);
		
	var ss = document.createElement('input');

           	ss.setAttribute("type", 'text');
           	ss.setAttribute("value", w_ss);
		
           	ss.setAttribute("class", "time_box");
		ss.setAttribute("id", id+"_ssform_id_temp");
		ss.setAttribute("name", id+"_ssform_id_temp");
		ss.setAttribute("onKeyPress", "return check_second(event, '"+id+"_ssform_id_temp')");
		ss.setAttribute("onKeyUp", "change_second(event,'"+id+"_ssform_id_temp')");
		ss.setAttribute("onBlur", "add_0('"+id+"_ssform_id_temp')");
	var ss_label = document.createElement('label');
           	ss_label.setAttribute("class", "mini_label");
		ss_label.innerHTML="SS";
		ss_label.setAttribute("id", id+"_mini_label_ss");

	td_time_input3.appendChild(ss);
	td_time_label3.appendChild(ss_label);
	
	if(document.getElementById(id+'_am_pm_select'))
	{
		select_=document.getElementById(id+"_am_pm_select");
		select_text=document.getElementById(id+"_am_pm_label");
		
		time_box.insertBefore(td_time_input3, select_);
		time_box.insertBefore(td_time_input2_ket, td_time_input3);
		
		text_box.insertBefore(td_time_label3, select_text);
		text_box.insertBefore(td_time_label2_ket, td_time_label3);
	}
	else
	{
	time_box.appendChild(td_time_input2_ket);
	time_box.appendChild(td_time_input3);
	text_box.appendChild(td_time_label2_ket);
	text_box.appendChild(td_time_label3);
	}
	
jQuery(document).ready(function() {	
	
		jQuery("label#"+id+"_mini_label_ss").click(function() {	
	if (jQuery(this).children('input').length == 0) {		
		var ss = "<input type='text' class='ss' style='outline:none; border:none; background:none; width:40px;' value=\""+jQuery(this).text()+"\">";	
			jQuery(this).html(ss);			
			jQuery("input.ss").focus();					
			jQuery("input.ss").blur(function() {			
			var value = jQuery(this).val();			
			
			jQuery("#"+id+"_mini_label_ss").text(value);	
		});	
	}	
	});
	});
	
	
refresh_attr(id, 'type_time');
}

function check_isnum_interval(e, id, from, to)
{
	
   	var chCode1 = e.which || e.keyCode;
    	if (chCode1 > 31 && (chCode1 < 48 || chCode1 > 57))
        return false;
	val=""+document.getElementById(id).value+String.fromCharCode(chCode1);

	if(val.length>2)
        	return false;
			
	if(val=='00')
        	return false;
			
	if((val<from) || (val>to))
        	return false;
	return true;

}


function check_isnum_point(e)
{
   	var chCode1 = e.which || e.keyCode;
	
	if (chCode1 ==46)
		return true;
	
	if (chCode1 > 31 && (chCode1 < 48 || chCode1 > 57))
        return false;
	return true;
}


function check_isnum(e)
{
	
   	var chCode1 = e.which || e.keyCode;
    	if (chCode1 > 31 && (chCode1 < 48 || chCode1 > 57))
        return false;
	return true;
}

function check_isnum_or_minus(e)
{
	
   	var chCode1 = e.which || e.keyCode;
	if (chCode1 != 45 )
	{
    	if (chCode1 > 31 && (chCode1 < 48 || chCode1 > 57))
        return false;
	}	
	return true;
}

function check_isspacebar(e)
{
	
   	var chCode1 = e.which || e.keyCode;
	if (chCode1 == 32 )
        return false;	

	return true;
}

function change_w_style(id, w)
{
	if(document.getElementById(id))
	document.getElementById(id).style.width=w+"px";
}

function change_w_label(id, w)
{
	if(document.getElementById(id))
	document.getElementById(id).innerHTML=w;
}

function change_h_style(id, h)
{
	document.getElementById(id).style.height=h+"px";
}

function change_w(id, w)
{
	document.getElementById(id).setAttribute("width", w)
}

function change_h(id, h)
{
	document.getElementById(id).setAttribute("height", h);
}

function change_key(value, attribute)
{
	document.getElementById('wd_recaptchaform_id_temp').setAttribute(attribute, value);
}

function captcha_refresh(id)
{	
	srcArr=document.getElementById(id+"form_id_temp").src.split("&r=");
	document.getElementById(id+"form_id_temp").src=srcArr[0]+'&r='+Math.floor(Math.random()*100);
	document.getElementById(id+"_inputform_id_temp").value='';
}

function up_row(id)
{
  event.stopPropagation();
	wdform_field=document.getElementById("wdform_field"+id);
	wdform_row=wdform_field.parentNode;
	wdform_column=wdform_row.parentNode;
	wdform_section=wdform_column.parentNode;
	wdform_page=wdform_section.parentNode;

	k=0;
	
	while(wdform_column.childNodes[k])
	{
		if(wdform_column.childNodes[k].getAttribute("wdid"))
			if(id==wdform_column.childNodes[k].getAttribute("wdid"))
				break;
		k++;
	}

	if(k!=0)
	{
		up=wdform_column.childNodes[k-1];
		down=wdform_column.childNodes[k];
		wdform_column.removeChild(down);
		wdform_column.insertBefore(down, up);
		return;
	}
	
	///////////en depqum yerb section breaka
	
	if(wdform_section.previousSibling)
	{
		if(wdform_section.previousSibling.getAttribute('type'))
		{
			wdform_section.previousSibling.previousSibling.firstChild.appendChild(wdform_row);
			return;
		}
	}

	///////////pagei mej

	page_up(id);
}

function down_row(id)
{
  event.stopPropagation();
	wdform_field=document.getElementById("wdform_field"+id);
	wdform_row=wdform_field.parentNode;
	wdform_column=wdform_row.parentNode;
	wdform_section=wdform_column.parentNode;
	wdform_page=wdform_section.parentNode;

	l=wdform_column.childNodes.length;
	
	/*
	form=wdform_column
	*/
	k=0;
	
	while(wdform_column.childNodes[k])
	{
		if(wdform_column.childNodes[k].getAttribute("wdid"))
			if(id==wdform_column.childNodes[k].getAttribute("wdid"))
				break;
		k++;
	}

	if(k!=l-1)
	{
	///////////ira mej
		up=wdform_column.childNodes[k];
		down=wdform_column.childNodes[k+2];
		wdform_column.removeChild(up);
		
		if(!down)
			down=null;

		wdform_column.insertBefore(up, down);
		return;
	}
	///////////en depqum yerb section breaka
	
	if(wdform_section.nextSibling.getAttribute('type'))
	{
		wdform_section.nextSibling.nextSibling.firstChild.appendChild(wdform_row);
		return;
	}

	///////////pagei mej
	page_down(id);
}

function right_row(id)
{
  event.stopPropagation();
	wdform_field=document.getElementById("wdform_field"+id);
	wdform_row=wdform_field.parentNode;
	wdform_column=wdform_row.parentNode;
	wdform_section=wdform_column.parentNode;
	if(wdform_column.nextSibling!=null)
	{
		wdform_column_next=wdform_column.nextSibling;
		wdform_column_next.appendChild(wdform_row);
	
	}
	else
	{
	    var wdform_column_new = document.createElement('div');
			wdform_column_new.setAttribute("class", "wdform_column");

	    wdform_section.appendChild(wdform_column_new);
	
	    wdform_column_new.appendChild(wdform_row);
	
	    
	}
//	if(wdform_column.firstChild==null)
//		wdform_section.removeChild(wdform_column);	
	
	
	sortable_columns();
	remove_empty_columns();

	if(document.getElementById("enable_sortable").value==0)
		jQuery('.wdform_column').sortable( "disable" );	
	
}

function left_row(id)
{
  event.stopPropagation();
	wdform_field=document.getElementById("wdform_field"+id);
	wdform_row=wdform_field.parentNode;
	wdform_column=wdform_row.parentNode;
	wdform_section=wdform_column.parentNode;
	if(wdform_column.previousSibling!=null)
	{
		wdform_column_next=wdform_column.previousSibling;
		wdform_column_next.appendChild(wdform_row);
	
	}

//	if(wdform_column.firstChild==null)
//		wdform_section.removeChild(wdform_column);
	
	sortable_columns();
	remove_empty_columns();
		
	if(document.getElementById("enable_sortable").value==0)
		jQuery('.wdform_column').sortable( "disable" );
}

function page_up(id)
{
  event.stopPropagation();
	wdform_field=document.getElementById("wdform_field"+id);
	wdform_row=wdform_field.parentNode;
	wdform_column=wdform_row.parentNode;
	wdform_section=wdform_column.parentNode;
	wdform_page=wdform_section.parentNode;
	wdform_page_and_images=wdform_page.parentNode;
			
			while(wdform_page_and_images)
			{
				wdform_page_and_images=wdform_page_and_images.previousSibling;	
				
				if(!wdform_page_and_images)
				{
					alert('Unable to move');
					return;
				}
					
				if(jQuery(wdform_page_and_images.firstChild).is(":visible"))
					break;
									
			}
		
		
			n=wdform_page_and_images.firstChild.childNodes.length;
			
			wdform_page_and_images.firstChild.childNodes[n-2].firstChild.appendChild(wdform_row);
		
			refresh_pages(id);
}

function page_down(id)
{
  event.stopPropagation();
	wdform_field=document.getElementById("wdform_field"+id);
	wdform_row=wdform_field.parentNode;
	wdform_column=wdform_row.parentNode;
	wdform_section=wdform_column.parentNode;
	wdform_page=wdform_section.parentNode;
	wdform_page_and_images=wdform_page.parentNode;
	
			
			while(wdform_page_and_images)
			{			
				wdform_page_and_images=wdform_page_and_images.nextSibling;	
				
							
				if(!wdform_page_and_images)
				{
					alert('Unable to move');
					return;
				}
					
				if(jQuery(wdform_page_and_images.firstChild).is(":visible"))
					break;									
			}
			
			wdform_page_and_images.firstChild.firstChild.firstChild.insertBefore(wdform_row, wdform_page_and_images.firstChild.firstChild.firstChild.firstChild);
			refresh_pages(id);

}

function remove_whitespace(node)
{
var ttt;
	for (ttt=0; ttt < node.childNodes.length; ttt++)
	{
        if( node.childNodes[ttt] && node.childNodes[ttt].nodeType == '3' && !/\S/.test(  node.childNodes[ttt].nodeValue ))
		{
			
			node.removeChild(node.childNodes[ttt]);
			 ttt--;
		}
		else
		{
			if(node.childNodes[ttt].childNodes.length)
				remove_whitespace(node.childNodes[ttt]);
		}
	}
	return
}

function Disable()
{	
	select_=document.getElementById('sel_el_pos');
	select_.setAttribute("disabled", "disabled");
	select_.innerHTML="";
}

function Enable()
{
	var pos=document.getElementsByName("el_pos");
			pos[0].setAttribute("checked", "checked");

	select_ = document.getElementById('sel_el_pos');
	select_.innerHTML="";
	
		for(k=1;k<=form_view_max;k++)
		if(document.getElementById('form_id_tempform_view'+k))
		{
			wdform_page=document.getElementById('form_id_tempform_view'+k);
			remove_whitespace(wdform_page);			
			n=wdform_page.childNodes.length-2;

			for(z=0;z<=n;z++)
			{
					if(!wdform_page.childNodes[z].getAttribute("wdid"))
					{
						wdform_section=wdform_page.childNodes[z];						
						for (x=0; x < wdform_section.childNodes.length; x++)
						{
							wdform_column=wdform_section.childNodes[x];																					
							
							if(wdform_column.firstChild)
							for (y=0; y < wdform_column.childNodes.length; y++)
							{	
								wdform_row=wdform_column.childNodes[y];
								wdid=wdform_row.getAttribute("wdid");
								
								if(wdid)
								{
								var option = document.createElement('option');
										option.setAttribute("id", wdid+"_sel_el_pos");
										option.setAttribute("value", wdid);
									option.innerHTML=document.getElementById( wdid+'_element_labelform_id_temp').innerHTML;	
								select_.appendChild(option);
								}
							}
						}
					}
			}
		}

	select_.removeAttribute("disabled");
}

function change_before()
{
	at_the_end=document.getElementById('pos_end');
	at_the_end.removeAttribute("checked");
	
	select_=document.getElementById('pos_before');
		select_.setAttribute("checked", "checked");
		select_.checked = true;
}


function all_labels()
{
	labels=new Array();
	for(k=1;k<=form_view_max;k++)
		if(document.getElementById('form_id_tempform_view'+k))
		{
			wdform_page=document.getElementById('form_id_tempform_view'+k);
			remove_whitespace(wdform_page);
			n=wdform_page.childNodes.length-2;	
			for(z=0;z<=n;z++)
			{
				if(!wdform_page.childNodes[z].getAttribute("wdid"))
				{
					wdform_section=wdform_page.childNodes[z];				
					for (x=0; x < wdform_section.childNodes.length; x++)
					{
						wdform_column=wdform_section.childNodes[x];
						if(wdform_column.firstChild)
						for (y=0; y < wdform_column.childNodes.length; y++)
						{
							wdform_row=wdform_column.childNodes[y];
							if(wdform_row.nodeType==3)
								continue;
							wdid=wdform_row.getAttribute("wdid");
							if(!wdid)
								continue;

							labels.push( document.getElementById( wdid+'_element_labelform_id_temp').innerHTML);
						}
					}
				}
			}
		}
	
	return labels;
}

function set_checked(id,j)
{
	checking=document.getElementById(id+"_elementform_id_temp"+j);
	if(checking.checked)
		checking.setAttribute("checked", "checked");
	if(!checking.checked)
	{
		checking.removeAttribute("checked");
		if(checking.getAttribute('other'))
			if(checking.getAttribute('other')==1)
			{
				if(document.getElementById(id+"_other_inputform_id_temp"))
				{
					document.getElementById(id+"_other_inputform_id_temp").parentNode.removeChild(document.getElementById(id+"_other_brform_id_temp"));
					document.getElementById(id+"_other_inputform_id_temp").parentNode.removeChild(document.getElementById(id+"_other_inputform_id_temp"));
				}
				return false;
			}
	}
	return true;
}

function set_default(id, j)
{
	for(k=0; k<100; k++)
		if(document.getElementById(id+"_elementform_id_temp"+k))
			if(!document.getElementById(id+"_elementform_id_temp"+k).checked)
				document.getElementById(id+"_elementform_id_temp"+k).removeAttribute("checked");
			else
				document.getElementById(id+"_elementform_id_temp"+j).setAttribute("checked", "checked");
	
	if(document.getElementById(id+"_other_inputform_id_temp"))
	{
		document.getElementById(id+"_other_inputform_id_temp").parentNode.removeChild(document.getElementById(id+"_other_brform_id_temp"));
		document.getElementById(id+"_other_inputform_id_temp").parentNode.removeChild(document.getElementById(id+"_other_inputform_id_temp"));
	}
}

function set_select(select_)
{
	for (p = select_.length - 1; p>=0; p--) 
	    if (select_.options[p].selected) 
		select_.options[p].setAttribute("selected", "selected");
	    else
  		select_.options[p].removeAttribute("selected");
}

function add_0(id)
{
	input=document.getElementById(id);
	if(input.value.length==1)
	{
		input.value='0'+input.value;
		input.setAttribute("value", input.value);
	}
}

function change_hour(ev, id, hour_interval)
{
	if(check_hour(ev, id, hour_interval))
	{
		input=document.getElementById(id);
		input.setAttribute("value", input.value);
	}
}

function change_minute(ev, id)
{
	if(check_minute(ev, id))
	{
		input=document.getElementById(id);
		input.setAttribute("value", input.value);
	}
}

function change_second(ev, id)
{
	if(check_second(ev, id))
	{
		input=document.getElementById(id);
		input.setAttribute("value", input.value);
	}
}

function check_hour(e, id, hour_interval)
{
   	var chCode1 = e.which || e.keyCode;
    	if (chCode1 > 31 && (chCode1 < 48 || chCode1 > 57))
        return false;
	hour=""+document.getElementById(id).value+String.fromCharCode(chCode1);

	hour=parseFloat(hour);
	if((hour<0) || (hour>hour_interval))
        	return false;
	return true;
} 

function check_minute(e, id)
{	
		
	
   	var chCode1 = e.which || e.keyCode;
    	if (chCode1 > 31 && (chCode1 < 48 || chCode1 > 57))
        return false;
	minute=""+document.getElementById(id).value+String.fromCharCode(chCode1);

	minute=parseFloat(minute);
	if((minute<0) || (minute>59))
        	return false;
	return true;
} 

function check_second(e, id)
{	
		
	
   	var chCode1 = e.which || e.keyCode;
    	if (chCode1 > 31 && (chCode1 < 48 || chCode1 > 57))
        return false;
	second=""+document.getElementById(id).value+String.fromCharCode(chCode1);

	second=parseFloat(second);
	if((second<0) || (second>59))
        	return false;
	return true;
} 

function change_day(ev, id)
{
	if(check_day(ev, id))
	{
		input=document.getElementById(id);
		input.setAttribute("value", input.value);
	}
}

function change_month(ev, id)
{
	if(check_month(ev, id))
	{
		input=document.getElementById(id);
		input.setAttribute("value", input.value);
	}
}

function change_year(id)
{
	year=document.getElementById(id).value;
	
	from=parseFloat(document.getElementById(id).getAttribute('from'));
	to=parseFloat(document.getElementById(id).getAttribute('to'));
	
	year=parseFloat(year);
	
	if((year>=from) && (year<=to))
		document.getElementById(id).setAttribute("value", year);
	else
		document.getElementById(id).setAttribute("value", '');
}

function check_day(e, id)
{	
   	var chCode1 = e.which || e.keyCode;
    	if (chCode1 > 31 && (chCode1 < 48 || chCode1 > 57))
        return false;
	day=""+document.getElementById(id).value+String.fromCharCode(chCode1);

	if(day.length>2)
        	return false;
			
	if(day=='00')
        	return false;
			
	day=parseFloat(day);
	if((day<0) || (day>31))
        	return false;
	return true;
} 

function check_month(e, id)
{	
		
	
   	var chCode1 = e.which || e.keyCode;
    	if (chCode1 > 31 && (chCode1 < 48 || chCode1 > 57))
        return false;
	month=""+document.getElementById(id).value+String.fromCharCode(chCode1);
	
	if(month.length>2)
        	return false;
			
	if(month=='00')
        	return false;
			
	month=parseFloat(month);
	if((month<0) || (month>12))
        	return false;
	return true;
} 

function check_year2(id)
{
	year=document.getElementById(id).value;
	
	from=parseFloat(document.getElementById(id).getAttribute('from'));
	
	year=parseFloat(year);
	
	if(year<from)
	{
		document.getElementById(id).value='';
		alert('The value of "year" is not valid.');
	}
}

function check_year1(e, id)
{	
   	var chCode1 = e.which || e.keyCode;
    	if (chCode1 > 31 && (chCode1 < 48 || chCode1 > 57))
        return false;

	year=""+document.getElementById(id).value+String.fromCharCode(chCode1);
	
	to=parseFloat(document.getElementById(id).getAttribute('to'));
	
	year=parseFloat(year);
	
	if(year>to)
        	return false;
	return true;
} 

function label_top(num)
{	
	document.getElementById(num+'_label_sectionform_id_temp').style.display="block";
	document.getElementById(num+'_element_sectionform_id_temp').style.display="block";
}

function label_left(num)
{
	document.getElementById(num+'_label_sectionform_id_temp').style.display="table-cell";
	document.getElementById(num+'_element_sectionform_id_temp').style.display="table-cell";
}

function delete_value(id)
{
	ofontStyle=document.getElementById(id).className;
	if(ofontStyle=="input_deactive")
	{
		document.getElementById(id).value="";
		destroyChildren(document.getElementById(id));
		document.getElementById(id).setAttribute("class", "input_active");
		document.getElementById(id).className='input_active';
	}
}


function return_value(id)
{
	input=document.getElementById(id);
	if(input.value=="")
	{
		input.value=input.title;
		input.className='input_deactive';
		input.setAttribute("class", 'input_deactive');
	}
}

function change_state_input(id,form_id)
{

	if((document.getElementById(id+"_country"+form_id) && document.getElementById(id+"_country"+form_id).value=="United States" && document.getElementById(id+"_disable_fieldsform_id_temp").getAttribute('us_states')=='yes') || (document.getElementById(id+"_disable_fieldsform_id_temp").getAttribute('country')=='yes' && document.getElementById(id+"_disable_fieldsform_id_temp").getAttribute('us_states')=='yes'))
	{	

		state_input=document.getElementById(id+"_state"+form_id);
		
		
		var state = document.createElement('select');
			state.setAttribute("type", 'text');
			state.style.cssText = "width:100%";
			state.setAttribute("id", id+"_state"+form_id);
			state.setAttribute("name", (parseInt(id)+3)+"_state"+form_id);
			state.setAttribute("onChange", "change_value('"+id+"_state"+form_id+"')");

	
		
		var option_ = document.createElement('option');
			option_.setAttribute("value", "");
			option_.innerHTML="";
		state.appendChild(option_);
		
		states=["Alabama","Alaska", "Arizona","Arkansas","California","Colorado","Connecticut","Delaware","District Of Columbia","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming"];	
		for(r=0;r<states.length;r++)
		{
		var option_ = document.createElement('option');
			option_.setAttribute("value", states[r]);
			option_.innerHTML=states[r];
		state.appendChild(option_);
		}
		
		var state_input_parent = state_input.parentNode;
		state_input_parent.removeChild(state_input);
		state_input_parent.insertBefore(state,state_input_parent.firstChild);

	}
	else
	{

		if(document.getElementById(id+"_state"+form_id).tagName=='SELECT')
		{
				
				var state_input = document.createElement('input');
					state_input.setAttribute("type", 'text');
					state_input.style.cssText = "width:100%";
					state_input.setAttribute("id", id+"_state"+form_id);
					state_input.setAttribute("name", (parseInt(id)+3)+"_state"+form_id);
					state_input.setAttribute("onChange", "change_value('"+id+"_state"+form_id+"')");
									
					
					state = document.getElementById(id+"_state"+form_id);
					
					var state_parent = state.parentNode;
						state_parent.removeChild(state);
						state_parent.insertBefore(state_input,state_parent.firstChild);
					
		}
	
	}


}

function change_value(id)
{
	input=document.getElementById(id);
	 
	tag=input.tagName;
	if(tag=="TEXTAREA")
	{
// destroyChildren(input)
	input.innerHTML=input.value;
	}
	else
	input.setAttribute("value", input.value);

}

function change_input_value(first_value, id)
{	
	input=document.getElementById(id);
	input.title=first_value;
	
if( window.getComputedStyle ) 
{
  ofontStyle = window.getComputedStyle(input,null).fontStyle;
} else if( input.currentStyle ) {
  ofontStyle = input.currentStyle.fontStyle;
}
	if(ofontStyle=="italic")
	{	
		input.value=first_value;
		input.setAttribute("value", first_value);
	}
}

function change_file_value(destination, id, prefix , postfix )
{	
	if(typeof(prefix)=='undefined') {prefix=''; postfix=''};
	input=document.getElementById(id);
	input.value=prefix+destination+postfix;
	input.setAttribute("value", prefix+destination+postfix);
	
}

function close_window() {
  if (need_enable) {
    enable();
  }
	need_enable = true;
  document.getElementById('edit_table').innerHTML = "";
  document.getElementById('show_table').innerHTML = "";
  document.getElementById('main_editor').style.display = "none";
  if (document.getElementById("form_maker_editor_ifr")) {
    ifr_id = "form_maker_editor_ifr";
    ifr = getIFrameDocument(ifr_id);
    ifr.body.innerHTML = "";
  }
  document.getElementById('form_maker_editor').value="";
  document.getElementById('editing_id').value="";
  document.getElementById('element_type').value="";
	alltypes=Array('customHTML','text','checkbox','radio','time_and_date','select','file_upload','captcha','map','button','page_break','section_break','paypal','survey');
	for (x = 0; x < 14; x++) {
		document.getElementById('img_'+alltypes[x]).parentNode.style.backgroundColor = "";
	}
}

function change_label(id, label) {
  label = label.replace(/(<([^>]+)>)/ig, "");
	document.getElementById(id).innerHTML = label;
	document.getElementById(id).value = label;
}

function change_label_name(num, id, label, type)
{
	jQuery('#'+id).html(label);
	if(!jQuery('#el_disable_value').prop('checked'))
	{
		if(!jQuery('#el_choices'+num).attr('other'))
			jQuery('#el_option_value'+num).val(label);		
		if(type=='select')
			jQuery('#'+id).val(label);	
	}
}

function change_label_name_on_paste(num, id, label, type)
{
	setTimeout(function(){
		label = elem.value;
		jQuery('#'+id).html(label);
		if(!jQuery('#el_disable_value').prop('checked'))
		{
			if(!jQuery('#el_choices'+num).attr('other'))
				jQuery('#el_option_value'+num).val(label);		
			if(type=='select')
				jQuery('#'+id).val(label);	
		}  
    }, 100);
}

function change_label_value(id, label)
{
	document.getElementById(id).value=label;	
}

function change_label_value_on_paste(id, elem)
{
	setTimeout(function(){
		label = elem.value;
		document.getElementById(id).value=label;	
    }, 100);
}


function change_label_1(id, label) {
	document.getElementById(id).value = label;
}

function change_label_price(id, label) {
	document.getElementById(id).innerHTML = label;
}

function change_value_price(id, label) {
	document.getElementById(id).value = label;
}

function change_func(id, label) {
	document.getElementById(id).setAttribute("onclick", label);
}

function change_in_value(id, label) {
  label = label.replace(/(<([^>]+)>)/ig, "");
  label = label.replace(/"/g, "&quot;");
	document.getElementById(id).setAttribute("value", label);
}

function change_size(size, num) {
	document.getElementById(num+'_elementform_id_temp').style.width=size+'px';
	if (document.getElementById(num+'_element_input')) {
		document.getElementById(num+'_element_input').style.width=size+'px';
  }
	switch(size) {
		case '111':
		{
			document.getElementById(num+'_elementform_id_temp').setAttribute("rows", "2"); break;
		}
		case '222':
		{
			document.getElementById(num+'_elementform_id_temp').setAttribute("rows", "4");break;
		}
		case '444':
		{
			document.getElementById(num+'_elementform_id_temp').setAttribute("rows", "8");break;
		}
	}
}

function add_choise_price(type, num)
{
var q=0;
	if(document.getElementById(num+'_hor'))
	{
		q=1;
		flow_ver(num);
	}
	var max_value = 0;
	jQuery('.change_pos').each(function() {
			var value = parseInt(jQuery(this)[0].id);
			max_value = (value > max_value) ? value : max_value;
		});

	max_value = max_value + 1;	
	if(type=='radio' || type=='checkbox')
	{
		element='input';
	
		var table = document.getElementById(num+'_table_little');
		var tr = document.createElement('div');
			tr.setAttribute("id", num+"_element_tr"+max_value);
			tr.style.display="table-row";
		var td = document.createElement('div');
			td.setAttribute("valign", "top");
			td.setAttribute("id", num+"_td_little"+max_value);
			td.setAttribute("idi", max_value);
			td.style.display="table-cell";
		
		var adding = document.createElement(element);
			adding.setAttribute("type", type);
			adding.setAttribute("value", "");
			adding.setAttribute("id", num+"_elementform_id_temp"+max_value);
			if(document.getElementById(num+"_option_left_right").value=="right")
				adding.style.cssText = "float: left !important";
		if(type=='checkbox')
		{	
			adding.setAttribute("onClick", "set_checked('"+num+"','"+max_value+"','form_id_temp')");
			adding.setAttribute("name", num+"_elementform_id_temp"+max_value);
		}
			
		if(type=='radio')
		{
			adding.setAttribute("onClick", "set_default('"+num+"','"+max_value+"','form_id_temp')");
			adding.setAttribute("name", num+"_elementform_id_temp");
		}
		
		
		var label_adding = document.createElement('label');
			label_adding.setAttribute("id", num+"_label_element"+max_value);
			label_adding.setAttribute("class", "ch-rad-label");
			label_adding.setAttribute("for",num+"_elementform_id_temp"+max_value);
			if(document.getElementById(num+"_option_left_right").value=="right")
				label_adding.style.cssText = "float: none !important";
			
		var adding_ch_label = document.createElement('input');
				adding_ch_label.setAttribute("type", "hidden");
				adding_ch_label.setAttribute("id", num+"_elementlabel_form_id_temp"+max_value);
				adding_ch_label.setAttribute("name", num+"_elementform_id_temp"+max_value+"_label");
				adding_ch_label.setAttribute("value", "");
			
		    td.appendChild(adding);
		    td.appendChild(label_adding);
		    td.appendChild(adding_ch_label);
		    tr.appendChild(td);
		    table.appendChild(tr);
		
		var choices_td= document.getElementById('choices');
		var div = document.createElement('div');
			div.setAttribute("id", max_value);
			div.setAttribute("class", "change_pos");
		var el_choices = document.createElement('input');
			el_choices.setAttribute("id", "el_choices"+max_value);
			el_choices.setAttribute("type", "text");
			el_choices.setAttribute("class", "fm-field-choice");
			el_choices.setAttribute("value", "");
			el_choices.setAttribute("onKeyUp", "change_label('"+num+"_label_element"+max_value+"', this.value); change_label_1('"+num+"_elementlabel_form_id_temp"+max_value+"', this.value); ");
	
		var el_choices_remove = document.createElement('img');
			el_choices_remove.setAttribute("id", "el_choices"+max_value+"_remove");
			el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_choices_remove.style.cssText =  'cursor:pointer;vertical-align:middle; margin:2px;';
			el_choices_remove.setAttribute("align", 'top');
			el_choices_remove.setAttribute("onClick", "remove_choise_price('"+max_value+"','"+num+"')");
			
		var el_choices_price = document.createElement('input');
			el_choices_price.setAttribute("id", "el_option_price"+max_value);
			el_choices_price.setAttribute("type", "text");
			el_choices_price.setAttribute("value", '');
			el_choices_price.setAttribute("class", "fm-field-paypal-choice");
			el_choices_price.setAttribute("onKeyUp", "change_value_price('"+num+"_elementform_id_temp"+max_value+"', this.value)");
			el_choices_price.setAttribute("onKeyPress", "return check_isnum_point(event)");
	
	
	    var el_choices_params = document.createElement('input');
			el_choices_params.setAttribute("id", "el_option_params"+max_value);
			el_choices_params.setAttribute("class", "el_option_params");
			el_choices_params.setAttribute("type", "hidden");
			el_choices_params.setAttribute("value", "");
			
		var el_choices_handle = document.createElement('img');
			el_choices_handle.setAttribute("class", "el_choices_sortable");
			el_choices_handle.setAttribute("src", plugin_url + '/images/move_cursor.png?ver=1.8.0');		
			el_choices_handle.style.cssText = 'cursor:move; vertical-align:middle; margin: 2px;';
			el_choices_handle.setAttribute("align", 'top');
		
			div.appendChild(el_choices);
			div.appendChild(el_choices_price);
			div.appendChild(el_choices_remove);
			div.appendChild(el_choices_handle);
			div.appendChild(el_choices_params);
			choices_td.appendChild(div);
		
		if(type=='checkbox')
		{	
			refresh_id_name(num, 'type_checkbox');
		}
			
		if(type=='radio')
		{
			refresh_id_name(num, 'type_radio');
		}
		
    
	refresh_attr(num, 'type_checkbox');
	
	}
	
	if(type=='select')
	{
		var select_ = document.getElementById(num+'_elementform_id_temp');
		var option = document.createElement('option');
			option.setAttribute("id", num+"_option"+max_value);
			
		    select_.appendChild(option);
		
		var choices_td= document.getElementById('choices');
		var div = document.createElement('div');
			div.setAttribute("id", max_value);
			div.setAttribute("class", "change_pos");
		var el_choices = document.createElement('input');
			el_choices.setAttribute("id", "el_option"+max_value);
			el_choices.setAttribute("type", "text");
			el_choices.setAttribute("class", "fm-field-choice");
			el_choices.setAttribute("value", "");
			el_choices.setAttribute("onKeyUp", "change_label_price('"+num+"_option"+max_value+"', this.value)");
			
		var el_choices_price = document.createElement('input');
			el_choices_price.setAttribute("id", "el_option_price"+max_value);
			el_choices_price.setAttribute("type", "text");
			el_choices_price.setAttribute("value", '');
			el_choices_price.setAttribute("class", "fm-field-paypal-choice");
			el_choices_price.setAttribute("onKeyUp", "change_value_price('"+num+"_option"+max_value+"', this.value)");
			el_choices_price.setAttribute("onKeyPress", "return check_isnum_point(event)");
			
	    var el_choices_params = document.createElement('input');
			el_choices_params.setAttribute("id", "el_option_params"+max_value);
			el_choices_params.setAttribute("class", "el_option_params");
			el_choices_params.setAttribute("type", "hidden");
			el_choices_params.setAttribute("value", "");
			
		var el_choices_remove = document.createElement('img');
			el_choices_remove.setAttribute("id", "el_option"+max_value+"_remove");
			el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_choices_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px;';
			el_choices_remove.setAttribute("align", 'top');
			el_choices_remove.setAttribute("onClick", "remove_option_price('"+max_value+"','"+num+"')");
			
		var el_choices_dis = document.createElement('input');
			el_choices_dis.setAttribute("type", 'checkbox');
			el_choices_dis.setAttribute("id", "el_option"+max_value+"_dis");
			el_choices_dis.setAttribute("onClick", "dis_option_price('"+num+"','"+max_value+"', this.checked)");
			el_choices_dis.style.cssText ="vertical-align: middle; margin-right:24px; margin-left:24px;";


	    var el_choices_handle = document.createElement('img');
			el_choices_handle.setAttribute("class", "el_choices_sortable");
			el_choices_handle.setAttribute("src", plugin_url + '/images/move_cursor.png?ver=1.8.0');		
			el_choices_handle.style.cssText = 'cursor:move; vertical-align:middle; margin:2px;';
			el_choices_handle.setAttribute("align", 'top');
		
		div.appendChild(el_choices);
		div.appendChild(el_choices_price);
		div.appendChild(el_choices_dis);
		div.appendChild(el_choices_remove);
		div.appendChild(el_choices_handle);
		div.appendChild(el_choices_params);
		choices_td.appendChild(div);	
    }
	if(q==1)
	{
		flow_hor(num);
	}

}

function add_choise(type, num)
{
	var max_value = 0;
	jQuery('.change_pos').each(function() {
			var value = parseInt(jQuery(this)[0].id);
			max_value = (value > max_value) ? value : max_value;
		});

	max_value = max_value + 1;
	if(type=='radio' || type=='checkbox')
	{
		var choices_td= document.getElementById('choices');
	
		var div = document.createElement('div');
			div.setAttribute("id", max_value);
			div.setAttribute("class", "change_pos");
			
		var el_choices = document.createElement('input');
			el_choices.setAttribute("id", "el_choices"+max_value);
			el_choices.setAttribute("type", "text");
			el_choices.setAttribute("class", "fm-field-choice");
			el_choices.setAttribute("value", "");
			el_choices.setAttribute("onKeyUp", "change_label_name('"+max_value+"', '"+num+"_label_element"+max_value+"', this.value, '"+type+"'); change_label_value('"+num+"_elementform_id_temp"+max_value+"', jQuery('#el_option_value"+max_value+"').val())");
			el_choices.setAttribute("onpaste", "elem = this; change_label_name_on_paste('"+max_value+"', '"+num+"_label_element"+max_value+"', '"+type+"'); change_label_value_on_paste('"+num+"_elementform_id_temp"+max_value+"', this)");	
	
		var el_choices_value = document.createElement('input');
			el_choices_value.setAttribute("id", "el_option_value"+max_value);
			el_choices_value.setAttribute("class", "el_option_value fm-field-choice");
			el_choices_value.setAttribute("type", "text");
			el_choices_value.setAttribute("value", "");	
			if(!jQuery('#el_disable_value').prop('checked'))
				el_choices_value.setAttribute("disabled", "disabled");
			el_choices_value.setAttribute("onKeyUp", "change_label_value('"+num+"_elementform_id_temp"+max_value+"', this.value)");
			el_choices_value.setAttribute("onpaste", "change_label_value_on_paste('"+num+"_elementform_id_temp"+max_value+"', this)");
	
		var el_choices_remove = document.createElement('img');
			el_choices_remove.setAttribute("id", "el_choices"+max_value+"_remove");
			el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_choices_remove.style.cssText =  'cursor:pointer;vertical-align:middle; margin:2px;';
			el_choices_remove.setAttribute("align", 'top');
			el_choices_remove.setAttribute("onClick", "remove_choise('"+max_value+"','"+num+"','"+type+"')");
		
		var el_choices_handle = document.createElement('img');
			el_choices_handle.setAttribute("class", "el_choices_sortable");
			el_choices_handle.setAttribute("src", plugin_url + '/images/move_cursor.png?ver=1.8.0');		
			el_choices_handle.style.cssText = 'cursor:move; vertical-align:middle; margin:2px;';
			el_choices_handle.setAttribute("align", 'top');
		
			div.appendChild(el_choices);
			div.appendChild(el_choices_value);
			div.appendChild(el_choices_remove);
			div.appendChild(el_choices_handle);
			choices_td.appendChild(div);
		
		refresh_rowcol(num, type);
		
		
		if(type=='checkbox')
		{	
			refresh_id_name(num, 'type_checkbox');
			refresh_attr(num, 'type_checkbox');
		}
			
		if(type=='radio')
		{
			refresh_id_name(num, 'type_radio');
			refresh_attr(num, 'type_radio');
		}

	}
	
	if(type=='select')
	{
		var select_ = document.getElementById(num+'_elementform_id_temp');
		var option = document.createElement('option');
			option.setAttribute("id", num+"_option"+max_value);
			
		    select_.appendChild(option);
		
		var choices_td= document.getElementById('choices');
		
		var div = document.createElement('div');
			div.setAttribute("id", max_value);
			div.setAttribute("class", "change_pos");
			
		var el_choices = document.createElement('input');
			el_choices.setAttribute("id", "el_option"+max_value);
			el_choices.setAttribute("type", "text");
			el_choices.setAttribute("class", "fm-field-choice");
			el_choices.setAttribute("value", "");
			el_choices.setAttribute("onKeyUp", "change_label_name('"+max_value+"', '"+num+"_option"+max_value+"', this.value, 'select')");
			el_choices.setAttribute("onpaste", "elem = this; change_label_name_on_paste('"+max_value+"', '"+num+"_option"+max_value+"', 'select')");
			
		var el_choices_remove = document.createElement('img');
			el_choices_remove.setAttribute("id", "el_option"+max_value+"_remove");
			el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_choices_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px;';
			el_choices_remove.setAttribute("align", 'top');
			el_choices_remove.setAttribute("onClick", "remove_option('"+max_value+"','"+num+"')");
			
		var el_choices_value = document.createElement('input');
			el_choices_value.setAttribute("id", "el_option_value"+max_value);
			el_choices_value.setAttribute("class", "el_option_value fm-field-choice");
			el_choices_value.setAttribute("type", "text");
			el_choices_value.setAttribute("value", "");	
			if(!jQuery('#el_disable_value').prop('checked'))
				el_choices_value.setAttribute("disabled", "disabled");
			el_choices_value.setAttribute("onKeyUp", "change_label_value('"+num+"_option"+max_value+"', this.value)");
			el_choices_value.setAttribute("onpaste", "change_label_value_on_paste('"+num+"_option"+max_value+"', this)");
			
		var el_choices_dis = document.createElement('input');
			el_choices_dis.setAttribute("type", 'checkbox');
			el_choices_dis.setAttribute("id", "el_option"+max_value+"_dis");
			el_choices_dis.setAttribute("class", "el_option_dis");
			el_choices_dis.setAttribute("onClick", "dis_option('"+num+"_option"+max_value+"', this.checked, '"+j+"')");
			el_choices_dis.style.cssText ="vertical-align: middle; margin-left:21px; margin-right:21px;";			
			if(jQuery('#el_disable_value').prop('checked'))
				el_choices_dis.setAttribute("disabled", "disabled");
				
		var el_choices_params = document.createElement('input');
			el_choices_params.setAttribute("id", "el_option_params"+max_value);
			el_choices_params.setAttribute("class", "el_option_params");
			el_choices_params.setAttribute("type", "hidden");
			el_choices_params.setAttribute("value", "");

		var el_choices_handle = document.createElement('img');
			el_choices_handle.setAttribute("class", "el_choices_sortable");
			el_choices_handle.setAttribute("src", plugin_url + '/images/move_cursor.png?ver=1.8.0');		
			el_choices_handle.style.cssText = 'cursor:move; vertical-align:middle; margin:2px';
			el_choices_handle.setAttribute("align", 'top');
		
		div.appendChild(el_choices);
		div.appendChild(el_choices_value);
		div.appendChild(el_choices_dis);
		div.appendChild(el_choices_remove);
		div.appendChild(el_choices_handle);
		div.appendChild(el_choices_params);
		choices_td.appendChild(div);

    }


}

function refresh_rowcol(num, type)
{
	if(!document.getElementById('edit_for_rowcol').value)
		document.getElementById('edit_for_rowcol').value =1;
		
		document.getElementById(num+'_rowcol_numform_id_temp').value = document.getElementById('edit_for_rowcol').value;

		var table = document.getElementById(num+'_table_little');
			table.removeAttribute("for_hor");
			table.innerHTML="";

		choeices = jQuery('.change_pos').length;	
		if(document.getElementById('edit_for_flow_vertical').checked==true)
		{
			var columns = document.getElementById('edit_for_rowcol').value;		
			var rows = parseInt((choeices+1)/columns);
			
			var gago=0;
			var vaxo=1;
				
			tr_row = document.createElement('div');
			tr_row.setAttribute("id", num+"_element_tr0");
			tr_row.style.display = 'table-row';
					
			jQuery('.change_pos').each(function() {
				var index = jQuery(this)[0].id;
				
				if(gago >= columns)
				{  
					gago=0;
					tr_row = document.createElement('div');
					tr_row.setAttribute("id", num+"_element_tr"+vaxo);
					tr_row.style.display = 'table-row';								
					
					vaxo++;
				}
				
				var td = document.createElement('div');
					td.setAttribute("valign", "top");
					td.setAttribute("id", num+"_td_little"+index);
					td.setAttribute("idi", index);
					td.style.display = 'table-cell';	

				var adding = document.createElement('input');
					adding.setAttribute("type", type);
					adding.setAttribute("id", num+"_elementform_id_temp"+index);					
					if(jQuery(this).find('#el_choices'+index)[0].getAttribute("checked")=="true")
						adding.setAttribute("checked", "checked");	
					if(document.getElementById(num+"_option_left_right").value=="right")
						adding.style.cssText = "float: left !important";		
						
				if(type=='checkbox')
				{
					adding.setAttribute("name", num+"_elementform_id_temp"+index);
					if(document.getElementById(num+"_allow_otherform_id_temp").value=="yes" && jQuery(this).find('#el_choices'+index).attr("other")=='1')
					{
						adding.setAttribute("value", "");	
						adding.setAttribute("other", "1");
						adding.setAttribute("onclick", "if(set_checked('"+num+"','"+index+"','form_id_temp')) show_other_input('"+num+"','form_id_temp');");
					}
					else
					{
						if(document.getElementById(num+"_value_disabledform_id_temp").value=="no")
							adding.setAttribute("value", jQuery(this).find('#el_choices'+index).val());	
						else
							adding.setAttribute("value", jQuery(this).find('#el_option_value'+index).val());	
						adding.setAttribute("onclick", "set_checked('"+num+"','"+index+"','form_id_temp')");
					}	
						
				}
					
				if(type=='radio')
				{
					adding.setAttribute("name", num+"_elementform_id_temp");
					if(document.getElementById(num+"_allow_otherform_id_temp").value=="yes" && jQuery(this).find('#el_choices'+index).attr("other")=='1')
					{
						adding.setAttribute("value", "");
						adding.setAttribute("other", "1");
						adding.setAttribute("onClick", "set_default('"+num+"','"+index+"','form_id_temp'); show_other_input('"+num+"','form_id_temp');");
					}
					else
					{
						if(document.getElementById(num+"_value_disabledform_id_temp").value=="no")
							adding.setAttribute("value", jQuery(this).find('#el_choices'+index).val());	
						else
							adding.setAttribute("value", jQuery(this).find('#el_option_value'+index).val());	
						adding.setAttribute("onClick", "set_default('"+num+"','"+index+"','form_id_temp')");
					}	
				}
			
				var label_adding = document.createElement('label');
					label_adding.setAttribute("id", num+"_label_element"+index);
					label_adding.setAttribute("class", "ch-rad-label");
					label_adding.setAttribute("for",num+"_elementform_id_temp"+index);
					label_adding.innerHTML= jQuery(this).find('#el_choices'+index).val();
					if(document.getElementById(num+"_option_left_right").value=="right")
						label_adding.style.cssText = "float: none !important";	
					if(jQuery(this).find('#el_option_params'+index).val())
					{
						w_params = jQuery(this).find('#el_option_params'+index).val().split("[where_order_by]");
						label_adding.setAttribute("where", w_params[0]);
						w_params = w_params[1].split("[db_info]");		
						label_adding.setAttribute("order_by", w_params[0]);
						label_adding.setAttribute("db_info", w_params[1]);
					}	
					
					td.appendChild(label_adding);						
					td.appendChild(adding);

				tr_row.appendChild(td);	
				table.appendChild(tr_row);	

				gago++;		
			});
			
		}

		else
		{

			var rows = document.getElementById('edit_for_rowcol').value;
			var columns = parseInt((choeices+1)/rows);
	
			var gago=0;
			var vaxo=0;
			
			jQuery('.change_pos').each(function(key) {
				var index = jQuery(this)[0].id;
			
				if(gago < rows)
				{
					tr_row = document.createElement('div');
					tr_row.setAttribute("id", num+"_element_tr"+key);
					tr_row.style.display = 'table-row';
						
				}
				
				var td = document.createElement('div');
					td.setAttribute("valign", "top");
					td.setAttribute("id", num+"_td_little"+index);
					td.setAttribute("idi", index);
					td.style.display = 'table-cell';
					
				var adding = document.createElement('input');
					adding.setAttribute("type", type);
					adding.setAttribute("id", num+"_elementform_id_temp"+index);	
					if(jQuery(this).find('#el_choices'+index)[0].getAttribute("checked")=="true")
						adding.setAttribute("checked", "checked");		
					if(document.getElementById(num+"_option_left_right").value=="right")
						adding.style.cssText = "float: left !important";			
					
				if(type=='checkbox')
				{
					adding.setAttribute("name", num+"_elementform_id_temp"+index);	
					if(document.getElementById(num+"_allow_otherform_id_temp").value=="yes" && jQuery(this).find('#el_choices'+index).attr('other')=='1')
					{
						adding.setAttribute("value", "");	
						adding.setAttribute("other", "1");
						adding.setAttribute("onclick", "if(set_checked('"+num+"','"+index+"','form_id_temp')) show_other_input('"+num+"','form_id_temp');");
					}
					else
					{
						if(document.getElementById(num+"_value_disabledform_id_temp").value=="no")
							adding.setAttribute("value", jQuery(this).find('#el_choices'+index).val());	
						else
							adding.setAttribute("value", jQuery(this).find('#el_option_value'+index).val());	
						adding.setAttribute("onclick", "set_checked('"+num+"','"+index+"','form_id_temp')");
						
					}	
						
				}
				
				if(type=='radio')
				{
					adding.setAttribute("name", num+"_elementform_id_temp");
					if(document.getElementById(num+"_allow_otherform_id_temp").value=="yes" && jQuery(this).find('#el_choices'+index).attr('other')=='1')
					{
						adding.setAttribute("other", "1");
						adding.setAttribute("onClick", "set_default('"+num+"','"+index+"','form_id_temp'); show_other_input('"+num+"','form_id_temp')");
						
					}
					else
					{
						if(document.getElementById(num+"_value_disabledform_id_temp").value=="no")
							adding.setAttribute("value", jQuery(this).find('#el_choices'+index).val());	
						else
							adding.setAttribute("value", jQuery(this).find('#el_option_value'+index).val());	
						adding.setAttribute("onClick", "set_default('"+num+"','"+index+"','form_id_temp')");
					}	
				}
				
				var label_adding = document.createElement('label');
					label_adding.setAttribute("id", num+"_label_element"+index);
					label_adding.setAttribute("class", "ch-rad-label");
					label_adding.setAttribute("for",num+"_elementform_id_temp"+index);
					label_adding.innerHTML=jQuery(this).find('#el_choices'+index).val();
					if(document.getElementById(num+"_option_left_right").value=="right")
						label_adding.style.cssText = "float: none !important";	
					if(jQuery(this).find('#el_option_params'+index).val())
					{
						w_params = jQuery(this).find('#el_option_params'+index).val().split("[where_order_by]");
						label_adding.setAttribute("where", w_params[0]);
						w_params = w_params[1].split("[db_info]");		
						label_adding.setAttribute("order_by", w_params[0]);
						label_adding.setAttribute("db_info", w_params[1]);
					}	
					
				td.appendChild(label_adding);	
				td.appendChild(adding);
				
				if(gago < rows)
				{
					tr_row.appendChild(td);	
					table.appendChild(tr_row);
				}
				else
				{
					if(vaxo==rows)
					vaxo=0;
					
					tr_row = document.getElementById(num+'_table_little').childNodes[vaxo];
					tr_row.appendChild(td);	
					vaxo++;
				}					
							
				gago++;	
			});
			
			table.setAttribute("for_hor", num+"_hor");
		}
}


function remove_choise(id, num, type)
{
	var choices_td= document.getElementById('choices');
	var div = document.getElementById(id);
		
		choices_td.removeChild(div);


refresh_rowcol(num,type);


refresh_id_name(num, document.getElementById(num+'_typeform_id_temp').value);

}


function remove_choise_price(id, num)
{
var q=0;
	if(document.getElementById(num+'_hor'))
	{
		q=1;
		flow_ver(num);
	}
		
		var table = document.getElementById(num+'_table_little');
		var tr = document.getElementById(num+'_element_tr'+id);
		table.removeChild(tr);
		
		var choices_td= document.getElementById('choices');
		var div = document.getElementById(id);
		
		
		choices_td.removeChild(div);
			
		if(q==1)
		{
			flow_hor(num);
		}
refresh_id_name(num, document.getElementById(num+'_typeform_id_temp').value );

}

function remove_option_price(id, num)
{
		var select_ = document.getElementById(num+'_elementform_id_temp');
		var option = document.getElementById(num+'_option'+id);
			
		select_.removeChild(option);
		
		var choices_td= document.getElementById('choices');
		var div = document.getElementById(id);
		
		choices_td.removeChild(div);
}

function add_grading_items(num){
	for(i=100;i>0;i--)
	{
		if(document.getElementById("el_items"+i))
			break;
	}	

	 m=i+1;
  
	var choices_td= document.getElementById("items");
	var br = document.createElement('br');
		br.setAttribute("id", "britems"+m);
	var el_choices = document.createElement('input');
		el_choices.setAttribute("id", "el_items"+m);
		el_choices.setAttribute("type", "text");
		el_choices.setAttribute("value", "");
		el_choices.setAttribute("class", "fm-field-choice");
		el_choices.setAttribute("onKeyUp", "change_label('"+num+"_label_elementform_id_temp"+m+"', this.value); change_in_value('"+num+"_label_elementform_id_temp"+m+"', this.value)");
	
	var el_choices_remove = document.createElement('img');
		el_choices_remove.setAttribute("id", "el_items"+m+"_remove");
		el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
		el_choices_remove.style.cssText =  'cursor:pointer;vertical-align:middle; margin:2px';
		el_choices_remove.setAttribute("align", 'top');
		el_choices_remove.setAttribute("onClick", "remove_grading_items('"+m+"','"+num+"')");
	
	choices_td.appendChild(br);
	choices_td.appendChild(el_choices);
	choices_td.appendChild(el_choices_remove);

	refresh_grading_items(num);
	refresh_id_name(num, 'type_grading');
}

function refresh_grading_items(num){

	for(i=100;i>0;i--)
	{
		if(document.getElementById("el_items"+i))
			break;
	}	
	m=i;

	var div = document.getElementById(num+'_elementform_id_temp');
		div.innerHTML='';
   
	for(i=0;i<=m;i++)
	{
		if(document.getElementById("el_items"+i)) {
			var div_grading = document.createElement('div');
				div_grading.setAttribute("id", num+"_element_div"+i);
				div_grading.setAttribute("class", "grading");
		
			var input_item = document.createElement('input');
				input_item.setAttribute("id", num+"_elementform_id_temp_"+i);
				input_item.setAttribute("name", num+"_elementform_id_temp_"+i);
				input_item.setAttribute("onKeyPress", "return check_isnum_or_minus(event)");
				input_item.setAttribute("value", "");					
				input_item.setAttribute("size", "5");					
				input_item.setAttribute("onKeyUp", "sum_grading_values("+num+",'form_id_temp')");
				input_item.setAttribute("onChange", "sum_grading_values("+num+",'form_id_temp')");
					
			var label_item = document.createElement('label');
				label_item.setAttribute("id", num+"_label_elementform_id_temp"+i);
				label_item.setAttribute("class", "ch-rad-label");
				label_item.innerHTML = document.getElementById("el_items"+i).value;	
		  
			div_grading.appendChild(input_item);	
			div_grading.appendChild(label_item);
			div.appendChild(div_grading);
			
		}   
		
	}
	var div_total = document.createElement('div');
		div_total.setAttribute("id", num+"_element_total_divform_id_temp");
		div_total.setAttribute("class", "grading_div");
	var Total = document.createTextNode("Total:");	
	var Seperator = document.createTextNode("/");	
	
	var span_total = document.createElement('span');
		span_total.setAttribute("id", num+"_total_elementform_id_temp");
		span_total.setAttribute("name", num+"_total_elementform_id_temp");
		span_total.innerHTML = document.getElementById(num+'_grading_totalform_id_temp').value;
	
	var span_gum = document.createElement('span');
		span_gum.setAttribute("id", num+"_sum_elementform_id_temp");	
		span_gum.setAttribute("name", num+"_sum_elementform_id_temp");	
		span_gum.innerHTML = 0;
	 
	var span_of_text = document.createElement('span');
		span_of_text.setAttribute("id", num+"_text_elementform_id_temp");	
		span_of_text.setAttribute("name", num+"_text_elementform_id_temp");	
		span_of_text.innerHTML = "";
		 
	div_total.appendChild(Total);
	div_total.appendChild(span_gum);
	div_total.appendChild(Seperator);
	div_total.appendChild(span_total);
	div_total.appendChild(span_of_text);
	div.appendChild(div_total);
}

function remove_grading_items(id, num)
{
	var choices_td= document.getElementById("items");
	
	var el_choices = document.getElementById('el_items'+id);
	var el_choices_remove = document.getElementById('el_items'+id+'_remove');
	var br = document.getElementById('britems'+id);
	
	choices_td.removeChild(el_choices);
	choices_td.removeChild(el_choices_remove);
	choices_td.removeChild(br);

	refresh_grading_items(num);
	refresh_id_name(num, 'type_grading');
}

function sum_grading_values(num,form_id){

	var sum = 0;
	for(var k=0; k<100;k++)
	{
		if(document.getElementById(num+'_element'+form_id+'_'+k))
			if(document.getElementById(num+'_element'+form_id+'_'+k).value)
			{
				sum = sum+parseInt(document.getElementById(num+'_element'+form_id+'_'+k).value);
			}
		
        if(document.getElementById(num+'_total_element'+form_id)){
		if(sum > document.getElementById(num+'_total_element'+form_id).innerHTML){
		
		document.getElementById(num+'_text_element'+form_id).innerHTML =" Total should be less than " + document.getElementById(num+'_total_element'+form_id).innerHTML;
		}
		else{
		document.getElementById(num+'_text_element'+form_id).innerHTML="";
		}
		}
	}
	
	 if(document.getElementById(num+'_sum_element'+form_id))
	document.getElementById(num+'_sum_element'+form_id).innerHTML = sum;

}




function add_to_matrix(type, num){
	for(i=100;i>0;i--)
	{
		if(document.getElementById("el_rows"+i))
			break;
	}
	
	if(type=="rows")
		m=i+1;
	else
		m=i;

	for(i=100;i>0;i--)
	{
		if(document.getElementById("el_columns"+i))
			break;
	}	
	if(type=="columns")
		n=i+1;
	else
		n=i;
	
	var choices_td= document.getElementById(type);
	if(type=="rows") {
		var br = document.createElement('br');
			br.setAttribute("id", "br"+type+m);
		var el_choices = document.createElement('input');
			el_choices.setAttribute("id", "el_"+type+m);
			el_choices.setAttribute("type", "text");
			el_choices.setAttribute("value", "");
			el_choices.setAttribute("class", "fm-field-choice");
			el_choices.setAttribute("onKeyUp", "change_label('"+num+"_label_elementform_id_temp"+m+"_0', this.value); change_in_value('"+num+"_label_elementform_id_temp"+m+"_0', this.value)");
	
		var el_choices_remove = document.createElement('img');
			el_choices_remove.setAttribute("id", "el_"+type+m+"_remove");
			el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_choices_remove.style.cssText =  'cursor:pointer;vertical-align:middle; margin:2px';
			el_choices_remove.setAttribute("align", 'top');
			el_choices_remove.setAttribute("onClick", "remove_rowcols('"+m+"','"+num+"','"+type+"')");
	
	    choices_td.appendChild(br);
	    choices_td.appendChild(el_choices);
	    choices_td.appendChild(el_choices_remove);
	}
	else
	{
		var br = document.createElement('br');
			br.setAttribute("id", "br"+type+n);
		var el_choices = document.createElement('input');
			el_choices.setAttribute("id", "el_"+type+n);
			el_choices.setAttribute("type", "text");
			el_choices.setAttribute("value", "");
			el_choices.setAttribute("class", "fm-field-choice");
			el_choices.setAttribute("onKeyUp", "change_label('"+num+"_label_elementform_id_temp"+"0_"+n+"', this.value); change_in_value('"+num+"_label_elementform_id_temp"+"0_"+n+"', this.value)");
	
		var el_choices_remove = document.createElement('img');
			el_choices_remove.setAttribute("id", "el_"+type+n+"_remove");
			el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_choices_remove.style.cssText =  'cursor:pointer;vertical-align:middle; margin:2px';
			el_choices_remove.setAttribute("align", 'top');
			el_choices_remove.setAttribute("onClick", "remove_rowcols('"+n+"','"+num+"','"+type+"')");
	
		choices_td.appendChild(br);
		choices_td.appendChild(el_choices);
		choices_td.appendChild(el_choices_remove);
	}	
	refresh_matrix(num);
}


function refresh_matrix(num){

	for(i=100;i>0;i--)
	{
		if(document.getElementById("el_rows"+i))
			break;
	}	
	m=i;

	for(i=100;i>0;i--)
	{
		if(document.getElementById("el_columns"+i))
			break;
	}	
	n=i;

	var table = document.getElementById(num+'_table_little');
		table.innerHTML='';
	
	var tr0 = document.createElement('div');
		tr0.setAttribute("id", num+"_element_tr0");
		tr0.style.display="table-row";
	
	table.appendChild(tr0);
		
	var td0 = document.createElement('div');
		td0.setAttribute("id", num+"_element_td0_0");		
		td0.style.display="table-cell";
		td0.innerHTML="";		
	tr0.appendChild(td0);

	for(k=1;k<=n;k++)
	{
		if(document.getElementById("el_columns"+k)) {
			var td = document.createElement('div');
				td.setAttribute("id", num+"_element_td0_"+k);	
				td.setAttribute("class", "matrix_");
				td.style.display="table-cell";

			var label_column = document.createElement('label');
				label_column.setAttribute("id", num+"_label_elementform_id_temp"+"0_"+k);
				label_column.setAttribute("name", num+"_label_elementform_id_temp"+"0_"+k);
				label_column.setAttribute("class", "ch-rad-label");
				label_column.setAttribute("for",num+"_elementform_id_temp"+k);	
				label_column.innerHTML=document.getElementById("el_columns"+k).value;	
			
				td.appendChild(label_column);
				tr0.appendChild(td);
		}
	}			

	for(i=1;i<=m;i++)
	{
		if(document.getElementById("el_rows"+i)) {
			var tr = document.createElement('div');
				tr.setAttribute("id", num+"_element_tr"+i);
				tr.style.display="table-row";
			var td0 = document.createElement('div');
				td0.setAttribute("id", num+"_element_td"+i+"_0");		
				td0.setAttribute("class", "matrix_");	
				td0.style.display="table-cell";
				
			var label_row = document.createElement('label');
				label_row.setAttribute("id", num+"_label_elementform_id_temp"+i+"_0");
				label_row.setAttribute("class", "ch-rad-label");
				label_row.setAttribute("for",num+"_elementform_id_temp"+i);	
				label_row.innerHTML=document.getElementById("el_rows"+i).value;	
			
			td0.appendChild(label_row);	
			tr.appendChild(td0);
			table.appendChild(tr);
			
			if(document.getElementById("edit_for_select_input_type").value=="text")
				document.getElementById("el_textbox").removeAttribute("style");
			else
				document.getElementById("el_textbox").style.display="none";
			
			for(k=1;k<=n;k++)
			{
				if(document.getElementById("el_columns"+k)) {
					var td = document.createElement('div');
						td.setAttribute("id", num+"_element_td"+i+"_"+k);	
						td.style.cssText="display:table-cell; text-align:center; padding:5px 0 0 5px;";

					if(document.getElementById("edit_for_select_input_type").value=="select"){
						var select_yes_no = document.createElement('select');
							select_yes_no.setAttribute("id", num+"_select_yes_noform_id_temp"+i+"_"+k);
							select_yes_no.setAttribute("name", num+"_select_yes_noform_id_temp"+i+"_"+k);
						var option_yes_no1 = document.createElement('option');
							option_yes_no1.setAttribute("value", "");
						Nothing = document.createTextNode(" ");
						
						var option_yes_no2 = document.createElement('option');
							option_yes_no2.setAttribute("value", "yes");
						Yes = document.createTextNode("Yes");
					
						var option_yes_no3 = document.createElement('option');
							option_yes_no3.setAttribute("value", "no");
						No = document.createTextNode("No");
					
							option_yes_no1.appendChild(Nothing);
							option_yes_no2.appendChild(Yes);
							option_yes_no3.appendChild(No);
							select_yes_no.appendChild(option_yes_no1);
							select_yes_no.appendChild(option_yes_no2);
							select_yes_no.appendChild(option_yes_no3);
							td.appendChild(select_yes_no);
					}			
					else{		
						var input_of_matrix = document.createElement('input');
							input_of_matrix.setAttribute("id", num+"_input_elementform_id_temp"+i+"_"+k);
							input_of_matrix.setAttribute("align", "center"); 
							input_of_matrix.setAttribute("size", "14"); 							
							input_of_matrix.setAttribute("type", document.getElementById("edit_for_select_input_type").value);	
									
						
						if(document.getElementById("edit_for_select_input_type").value=="radio"){
							input_of_matrix.setAttribute("name", num+"_input_elementform_id_temp"+i);
							input_of_matrix.setAttribute("value", i+"_"+k);
						}else {
							if(document.getElementById("edit_for_select_input_type").value=="checkbox"){
								input_of_matrix.setAttribute("name", num+"_input_elementform_id_temp"+i+"_"+k);
								input_of_matrix.setAttribute("value", 1);
							}
							else{
								document.getElementById( num+"_textbox_sizeform_id_temp").value = document.getElementById("edit_for_label_textbox_size").value;
								
								input_of_matrix.setAttribute("name", num+"_input_elementform_id_temp"+i+"_"+k);
								input_of_matrix.setAttribute("value", '');
								input_of_matrix.style.cssText = "width:"+document.getElementById("edit_for_label_textbox_size").value+"px;";
							}
						}
						td.appendChild(input_of_matrix);
					}
					tr.appendChild(td);
				}
			}
		}   
	}              
}

function remove_rowcols(id, num, type)
{
	var choices_td = document.getElementById(type);
	var el_choices = document.getElementById('el_'+type+id);
	var el_choices_remove = document.getElementById('el_'+type+id+'_remove');
	var br = document.getElementById('br'+type+id);
	
	choices_td.removeChild(el_choices);
	choices_td.removeChild(el_choices_remove);
	choices_td.removeChild(br);

	refresh_matrix(num);
}

function remove_option(id, num)
{
	var select_ = document.getElementById(num+'_elementform_id_temp');
	var option = document.getElementById(num+'_option'+id);
		
	select_.removeChild(option);
	
	var choices_td= document.getElementById('choices');
	var div = document.getElementById(id);
	
	choices_td.removeChild(div);
}

function getIFrameDocument(aID){ 
var rv = null; 
// if contentDocument exists, W3C compliant (Mozilla) 
if (document.getElementById(aID) && document.getElementById(aID).contentDocument){
rv = document.getElementById(aID).contentDocument; 
} else if (document.getElementById(aID)) {
// IE 
rv = document.frames[aID].document; 
} 
return rv; 
}

function delete_last_child() {
  if (document.getElementById("form_maker_editor_ifr")) {
    ifr_id = "form_maker_editor_ifr";
    ifr = getIFrameDocument(ifr_id);
    ifr.body.innerHTML = "";
  }
	document.getElementById('main_editor').style.display="none";
	document.getElementById('form_maker_editor').value="";
	if (document.getElementById('show_table').lastChild) {
		var del1 = document.getElementById('show_table').lastChild;
		var del2 = document.getElementById('edit_table').lastChild;
		var main1 = document.getElementById('show_table');
		var main2 = document.getElementById('edit_table');
		main1.removeChild(del1);
		main2.removeChild(del2);
	}
}

function format_12(num, am_or_pm, w_hh, w_mm, w_ss)
{
    	tr_time1 = document.getElementById(num+'_tr_time1')
    	tr_time2 = document.getElementById(num+'_tr_time2')
   	var td1 = document.createElement('div');
        	td1.setAttribute("id", num+"_am_pm_select");
        	td1.setAttribute("class", "td_am_pm_select");
			td1.style.display="table-cell";
   	var td2 = document.createElement('div');
        	td2.setAttribute("id", num+"_am_pm_label");
        	td2.setAttribute("class", "td_am_pm_select");
			td2.style.display="table-cell";
		
	var am_pm_select = document.createElement('select');
        	am_pm_select.setAttribute("class", "am_pm_select");
        	am_pm_select.setAttribute("name",  num+"_am_pmform_id_temp");
        	am_pm_select.setAttribute("id",  num+"_am_pmform_id_temp");
        	am_pm_select.setAttribute("onchange", "set_sel_am_pm(this)");
		
	var am_option = document.createElement('option');
        	am_option.setAttribute("value", "am");
        	am_option.innerHTML="AM";
		
	var pm_option = document.createElement('option');
        	pm_option.setAttribute("value", "pm");
        	pm_option.innerHTML="PM";
	
	if(am_or_pm=="pm")
	        pm_option.setAttribute("selected", "selected");
	else
	        am_option.setAttribute("selected", "selected");

		
	var am_pm_label = document.createElement('label');
		am_pm_label.setAttribute("class", "mini_label");
		am_pm_label.setAttribute("id", num+"_mini_label_am_pm");
		am_pm_label.innerHTML=w_mini_labels[3];
		
   	am_pm_select.appendChild(am_option);
   	am_pm_select.appendChild(pm_option);
   	td1.appendChild(am_pm_select);
   	td2.appendChild(am_pm_label);
   	tr_time1.appendChild(td1);
   	tr_time2.appendChild(td2);
	document.getElementById(num+'_hhform_id_temp').setAttribute("onKeyPress", "return check_hour(event, '"+num+"_hhform_id_temp',"+"'12'"+")");

    	document.getElementById(num+'_hhform_id_temp').value=w_hh;
    	document.getElementById(num+'_mmform_id_temp').value=w_mm;
	if(document.getElementById(num+'_ssform_id_temp'))
    	document.getElementById(num+'_ssform_id_temp').value=w_ss;
	
refresh_attr(num, 'type_time');

jQuery(document).ready(function() {	
	jQuery("label#"+num+"_mini_label_am_pm").click(function() {		
		if (jQuery(this).children('input').length == 0) {				
			var am_pm = "<input type='text' class='am_pm' size='4' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
				jQuery(this).html(am_pm);							
				jQuery("input.am_pm").focus();			
				jQuery("input.am_pm").blur(function() {	
			var value = jQuery(this).val();			


		jQuery("#"+num+"_mini_label_am_pm").text(value);		
		});	
	}	
	});		
	});	
}

function format_24(num)
{
    	tr_time1 = document.getElementById(num+'_tr_time1')
    	td1 = document.getElementById(num+'_am_pm_select')
    	tr_time2 = document.getElementById(num+'_tr_time2')
    	td2 = document.getElementById(num+'_am_pm_label')
	tr_time1.removeChild(td1);
	tr_time2.removeChild(td2);
	document.getElementById(num+'_hhform_id_temp').setAttribute("onKeyPress", "return check_hour(event, '"+num+"_hhform_id_temp', '23')");
    	document.getElementById(num+'_hhform_id_temp').value="";
    	document.getElementById(num+'_mmform_id_temp').value="";
	if(document.getElementById(num+'_ssform_id_temp'))
    	document.getElementById(num+'_ssform_id_temp').value="";
}

function format_extended(num,w_title_value,w_middle_value,w_title_title,w_middle_title)
{
	w_size=document.getElementById(num+'_element_firstform_id_temp').style.width;
    	tr_name1 = document.getElementById(num+'_tr_name1');
    	tr_name2 = document.getElementById(num+'_tr_name2');
	
   	var td_name_input1 = document.createElement('div');
        	td_name_input1.setAttribute("id", num+"_td_name_input_title");
			td_name_input1.style.display='table-cell';
		
   	var td_name_input4 = document.createElement('div');
        	td_name_input4.setAttribute("id", num+"_td_name_input_middle");
			td_name_input4.style.display='table-cell';
		
   	var td_name_label1 = document.createElement('div');
        	td_name_label1.setAttribute("id", num+"_td_name_label_title");
        	td_name_label1.setAttribute("align", "left");
			td_name_label1.style.display='table-cell';
		
   	var td_name_label4 = document.createElement('div');
        	td_name_label4.setAttribute("id", num+"_td_name_label_middle");
        	td_name_label4.setAttribute("align", "left");
			td_name_label4.style.display='table-cell';
		
	var title = document.createElement('input');
        title.setAttribute("type", 'text');
		
		
		
	    title.style.cssText = "margin: 0px 10px 0px 0px; padding: 0px; width:40px";
	    title.setAttribute("id", num+"_element_titleform_id_temp");
	    title.setAttribute("name", num+"_element_titleform_id_temp");
		if(w_title_value==w_title_title)
		{
		title.setAttribute("value", w_title_title);
		title.setAttribute("class", "input_deactive");
		}
		else
		{
		title.setAttribute("value", w_title_value);
		title.setAttribute("class", "input_active");
		}
		title.setAttribute("title", w_title_title);
		title.setAttribute("onFocus", 'delete_value("'+num+'_element_titleform_id_temp")');
		title.setAttribute("onBlur", 'return_value("'+num+'_element_titleform_id_temp")');
	    title.setAttribute("onChange", "change_value('"+num+"_element_titleform_id_temp')");
		
	var title_label = document.createElement('label');
	    title_label.setAttribute("class", "mini_label");
	    title_label.setAttribute("id", num+"_mini_label_title");
	    title_label.innerHTML= w_mini_labels[0];
		
	var middle = document.createElement('input');
		middle.setAttribute("type", 'text');
		middle.style.cssText = "padding: 0px; width:"+w_size;
		middle.setAttribute("id", num+"_element_middleform_id_temp");
		middle.setAttribute("name", num+"_element_middleform_id_temp");
		if(w_middle_value==w_middle_title)
		{
		middle.setAttribute("value", w_middle_title);
		middle.setAttribute("class", "input_deactive");
		}
		else
		{
		middle.setAttribute("value", w_middle_value);
		middle.setAttribute("class", "input_active");
		}
		middle.setAttribute("title", w_middle_title);
		middle.setAttribute("onFocus", 'delete_value("'+num+'_element_middleform_id_temp")');
		middle.setAttribute("onBlur", 'return_value("'+num+'_element_middleform_id_temp")');
	    middle.setAttribute("onChange", "change_value('"+num+"_element_middleform_id_temp')");
			
	var middle_label = document.createElement('label');
		middle_label.setAttribute("class", "mini_label");
		middle_label.setAttribute("id", num+"_mini_label_middle");
		middle_label.innerHTML=w_mini_labels[3];
		
    	first_input = document.getElementById(num+'_td_name_input_first');
    	last_input = document.getElementById(num+'_td_name_input_last');
    	first_label = document.getElementById(num+'_td_name_label_first');
    	last_label = document.getElementById(num+'_td_name_label_last');
	
      	td_name_input1.appendChild(title);
      	td_name_input4.appendChild(middle);
		
		tr_name1.insertBefore(td_name_input1, first_input);
		tr_name1.insertBefore(td_name_input4, null);
		
      	td_name_label1.appendChild(title_label);
      	td_name_label4.appendChild(middle_label);
		tr_name2.insertBefore(td_name_label1, first_label);
		tr_name2.insertBefore(td_name_label4, null);
		
	var gic1 = document.createTextNode("-");
	var gic2 = document.createTextNode("-");

	var el_first_value_title = document.createElement('input');
                el_first_value_title.setAttribute("id", "el_first_value_title");
                el_first_value_title.setAttribute("type", "text");
                el_first_value_title.setAttribute("value", w_title_title);
                el_first_value_title.style.cssText = "width:50px; margin-left:4px; margin-right:4px";
                el_first_value_title.setAttribute("onKeyUp", "change_input_value(this.value,'"+num+"_element_titleform_id_temp')");

	var el_first_value_middle = document.createElement('input');
                el_first_value_middle.setAttribute("id", "el_first_value_middle");
                el_first_value_middle.setAttribute("type", "text");
                el_first_value_middle.setAttribute("value", w_middle_title);
                el_first_value_middle.style.cssText = "width:100px; margin-left:4px";
                el_first_value_middle.setAttribute("onKeyUp", "change_input_value(this.value,'"+num+"_element_middleform_id_temp')");
				
    el_first_value_first = document.getElementById('el_first_value_first');
	parent=el_first_value_first.parentNode;
	parent.insertBefore(gic1, el_first_value_first);
	parent.insertBefore(el_first_value_title, gic1);
    parent.appendChild(gic2);
    parent.appendChild(el_first_value_middle);
		
refresh_attr(num, 'type_name');
refresh_id_name(num, 'type_name');

jQuery(document).ready(function() {	
	jQuery("label#"+num+"_mini_label_title").click(function() {		
		if (jQuery(this).children('input').length == 0) {				
			var title = "<input type='text' class='title' size='10' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
				jQuery(this).html(title);							
				jQuery("input.title").focus();			
				jQuery("input.title").blur(function() {	
			var value = jQuery(this).val();			


		jQuery("#"+num+"_mini_label_title").text(value);		
		});	
	}	
	});		


	jQuery("label#"+num+"_mini_label_middle").click(function() {	
	if (jQuery(this).children('input').length == 0) {		
		var middle = "<input type='text' class='middle'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
			jQuery(this).html(middle);			
			jQuery("input.middle").focus();					
			jQuery("input.middle").blur(function() {			
			var value = jQuery(this).val();			
			
			jQuery("#"+num+"_mini_label_middle").text(value);	
		});	
	}	
	});
	});	


}

function format_normal(num)
{
    	tr_name1 = document.getElementById(num+'_tr_name1');
    	tr_name2 = document.getElementById(num+'_tr_name2');
   	 	td_name_input1 = document.getElementById(num+'_td_name_input_title');
		
   		td_name_input4 = document.getElementById(num+'_td_name_input_middle');
		
   		td_name_label1 = document.getElementById(num+'_td_name_label_title');
		
   	 	td_name_label4 =document.getElementById(num+'_td_name_label_middle');
		
		tr_name1.removeChild(td_name_input1);
		tr_name1.removeChild(td_name_input4);
		tr_name2.removeChild(td_name_label1);
		tr_name2.removeChild(td_name_label4);
		
		el_first_value_first = document.getElementById('el_first_value_first');
		parent=el_first_value_first.parentNode;
		
		parent.removeChild( document.getElementById('el_first_value_title').nextSibling);
		parent.removeChild( document.getElementById('el_first_value_title'));
		parent.removeChild( document.getElementById('el_first_value_middle').previousSibling);
		parent.removeChild( document.getElementById('el_first_value_middle'));
refresh_attr(num, 'type_name');
refresh_id_name(num, 'type_name');

}

function type_section_break(i, w_editor) {
	var pos=document.getElementsByName("el_pos");
		pos[0].setAttribute("disabled", "disabled");
		pos[1].setAttribute("disabled", "disabled");
		pos[2].setAttribute("disabled", "disabled");
		
	var sel_el_pos=document.getElementById("sel_el_pos");
		sel_el_pos.setAttribute("disabled", "disabled");

    document.getElementById("element_type").value="type_section_break";
	delete_last_child();
	
	oElement = jQuery('#table_radio');
	oElementoffset = oElement.offset();
	oElementtable = jQuery('.formMakerDiv1_table');
	oElementtableoffset = jQuery('.formMakerDiv1_table').offset();

	iReturnLeft = oElementoffset.left + oElementtableoffset.left;
	//iReturnTop = oElementoffset.top;
	
	document.getElementById('main_editor').style.display="block";
	document.getElementById('main_editor').style.left=iReturnLeft+230+"px";
	document.getElementById('main_editor').style.top="120px";
		
		if (document.getElementById("form_maker_editor_ifr") && document.getElementById('form_maker_editor').style.display == "none") {
      ifr_id = "form_maker_editor_ifr";
      ifr = getIFrameDocument(ifr_id);
      ifr.body.innerHTML = w_editor;
    }
		else {
			document.getElementById('form_maker_editor').value = w_editor;
		}
		element = 'div';
     	var div = document.createElement('div');
      	    div.setAttribute("id", "main_div");		
      	var main_td  = document.getElementById('show_table');
      	main_td.appendChild(div);
		
     	var div = document.createElement('div');
      	    div.style.width="500px";				
		document.getElementById('edit_table').appendChild(div);				
}

function type_editor(i, w_editor) {
  document.getElementById("element_type").value="type_editor";
	delete_last_child();

	oElement = jQuery('#table_radio');
	oElementoffset = oElement.offset();
	oElementtable = jQuery('.formMakerDiv1_table');
	oElementtableoffset = jQuery('.formMakerDiv1_table').offset();

	iReturnLeft = oElementoffset.left + oElementtableoffset.left;
	//iReturnTop = oElementoffset.top;
	
	document.getElementById('main_editor').style.display="block";
	document.getElementById('main_editor').style.left=iReturnLeft+230+"px";
	document.getElementById('main_editor').style.top="120px";
		
	if (document.getElementById("form_maker_editor_ifr") && document.getElementById('form_maker_editor').style.display == "none") {
		ifr_id = "form_maker_editor_ifr";
		ifr=getIFrameDocument(ifr_id);
		ifr.body.innerHTML=w_editor;
	}
	else {
		document.getElementById('form_maker_editor').value=w_editor;
	}
	
	var div = document.createElement('div');
		div.setAttribute("id", "main_div");		
	var main_td  = document.getElementById('show_table');
		main_td.appendChild(div);
	
	var div = document.createElement('div');
		div.style.width="500px";				
	document.getElementById('edit_table').appendChild(div);
}

function type_submit_reset(i, w_submit_title , w_reset_title , w_class, w_act, w_attr_name, w_attr_value){

    document.getElementById("element_type").value = "type_submit_reset";
	delete_last_child();

	var edit_div = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		edit_div.setAttribute("style", "border-top:1px dotted black;padding:10px;  padding-top:0px; padding-bottom:0px; margin-top:10px;");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
	
	var el_submit_title_label = document.createElement('label');
		el_submit_title_label.setAttribute("class", "fm-field-label");
		el_submit_title_label.setAttribute("for", "edit_for_title");
		el_submit_title_label.innerHTML = "Submit button label";
	
	var el_submit_title_textarea = document.createElement('input');
		el_submit_title_textarea.setAttribute("id", "edit_for_title");
		el_submit_title_textarea.setAttribute("type", "text");
		el_submit_title_textarea.style.cssText = "width:160px";
		el_submit_title_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_submitform_id_temp', this.value)");
		el_submit_title_textarea.value = w_submit_title;
	
	var el_submit_func_label = document.createElement('label');
		el_submit_func_label.setAttribute("class", "fm-field-label");
		el_submit_func_label.innerHTML = "Submit function";
	
	var el_submit_func_textarea = document.createElement('input');
		el_submit_func_textarea.setAttribute("type", "text");
		el_submit_func_textarea.setAttribute("disabled", "disabled");
		el_submit_func_textarea.value = "check_required('submit', 'form_id_temp')";

	var el_reset_title_label = document.createElement('label');
		el_reset_title_label.setAttribute("class", "fm-field-label");
		el_reset_title_label.setAttribute("for", "edit_for_title_textarea");
		el_reset_title_label.innerHTML = "Reset button label";
	
	var el_reset_title_textarea = document.createElement('input');
		el_reset_title_textarea.setAttribute("id", "edit_for_title_textarea");
		el_reset_title_textarea.setAttribute("type", "text");
		el_reset_title_textarea.style.cssText = "width:160px";
		el_reset_title_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_resetform_id_temp', this.value)");
		el_reset_title_textarea.value = w_reset_title;

	var el_reset_active = document.createElement('input');
		el_reset_active.setAttribute("id", "el_reset_active");
		el_reset_active.setAttribute("type", "checkbox");
		el_reset_active.setAttribute("onClick", "active_reset(this.checked, "+i+")");
		if(w_act)
			el_reset_active.setAttribute("checked", "checked");
	
	var el_reset_active_label = document.createElement('label');
		el_reset_active_label.setAttribute("class", "fm-field-label");
		el_reset_active_label.setAttribute("for", "el_reset_active");
		el_reset_active_label.innerHTML = "Display Reset button";
	
	var el_reset_func_label = document.createElement('label');
		el_reset_func_label.setAttribute("class", "fm-field-label");
		el_reset_func_label.setAttribute("for", "el_reset_func_textarea");
		el_reset_func_label.innerHTML = "Reset function";
		
	var el_reset_func_textarea = document.createElement('input');
		el_reset_func_textarea.setAttribute("type", "text");
		el_reset_func_textarea.setAttribute("id", "el_reset_func_textarea");
		el_reset_func_textarea.setAttribute("disabled", "disabled");
		el_reset_func_textarea.value = "check_required('reset')";

	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.style.cssText = "width:200px;";
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");
	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");      
		el_attr_label.innerHTML = "Additional Attributes";
			
	var el_attr_add = document.createElement('img');    
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_submit_reset')");
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
		el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n = w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.style.cssText = "width:100px";
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_submit_reset')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.style.cssText = "width:100px";
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_submit_reset')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_submit_reset')");
			
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
	}

	var t  = document.getElementById('edit_table');
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	
	edit_main_td1.appendChild(el_submit_title_label);
	edit_main_td8.appendChild(el_submit_func_label);
	edit_main_td1_1.appendChild(el_submit_title_textarea);
	edit_main_td8_1.appendChild(el_submit_func_textarea);
	
	edit_main_td2.appendChild(el_reset_active_label);
	edit_main_td5.appendChild(el_reset_title_label);
	edit_main_td6.appendChild(el_reset_func_label);
	edit_main_td2_1.appendChild(el_reset_active);
	edit_main_td5_1.appendChild(el_reset_title_textarea);
	edit_main_td6_1.appendChild(el_reset_func_textarea);

	edit_main_td3.appendChild(el_style_label);
	edit_main_td3_1.appendChild(el_style_textarea);
	
	
	edit_main_td4.appendChild(el_attr_label);
	edit_main_td4.appendChild(el_attr_add);
	edit_main_td4.appendChild(br);
	edit_main_td4.appendChild(el_attr_table);
	edit_main_td4.setAttribute("colspan", "2");

	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);

	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr8);
	
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);

	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	
	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_submit_reset");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
	    
	var adding_submit = document.createElement('button');
		adding_submit.setAttribute("type", 'button');
		adding_submit.setAttribute("class", "button-submit");
		adding_submit.setAttribute("id", i+"_element_submitform_id_temp");
		adding_submit.setAttribute("value", w_submit_title);
		adding_submit.innerHTML = w_submit_title;
		adding_submit.setAttribute("onClick", "check_required('submit', 'form_id_temp');");

	var adding_reset = document.createElement('button');
		adding_reset.setAttribute("type", 'button');
		adding_reset.setAttribute("class", "button-reset");
		if(!w_act)
			adding_reset.style.display = "none";
		adding_reset.setAttribute("id", i+"_element_resetform_id_temp");
		adding_reset.setAttribute("value", w_reset_title );
		adding_reset.setAttribute("onClick", "check_required('reset');");
		adding_reset.innerHTML = w_reset_title;

	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
				
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");
    
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.style.cssText = 'display:none';
		label.innerHTML = "type_submit_reset_"+i;
	var main_td  = document.getElementById('show_table');
      
	div_label.appendChild(label);
	div_element.appendChild(adding_type);
	div_element.appendChild(adding_submit);
	div_element.appendChild(adding_reset);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
	div.appendChild(div_field);
	div.appendChild(br1);
	main_td.appendChild(div);
	
	change_class(w_class, i);
	refresh_attr(i, 'type_submit_reset');
}
function type_hidden(i, w_name, w_value, w_attr_name, w_attr_value){

    document.getElementById("element_type").value="type_hidden";
	delete_last_child();

	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	
	var el_field_id_label = document.createElement('label');
		el_field_id_label.setAttribute("class", "fm-field-label");
		el_field_id_label.style.cssText = "margin-right: 44px;";
		el_field_id_label.innerHTML = "Field Id";
	
	var el_field_id_input= document.createElement('input');
		el_field_id_input.setAttribute("type", "text");
		el_field_id_input.setAttribute("disabled", "disabled");
		el_field_id_input.setAttribute("value", "wdform_"+i+"_elementform_id_temp");

	var el_field_name_label = document.createElement('label');
	    el_field_name_label.setAttribute("class", "fm-field-label");
	    el_field_name_label.setAttribute("for", "el_hidden_name");
		el_field_name_label.innerHTML = "Field Name";
	
	var el_field_name_input= document.createElement('input');
		el_field_name_input.setAttribute("type", "text");
		el_field_name_input.setAttribute("value", w_name);
		el_field_name_input.setAttribute("id", "el_hidden_name");
		el_field_name_input.setAttribute("onKeyPress", "return check_isspacebar(event)");
		el_field_name_input.setAttribute("onChange", "change_field_name('"+i+"', this)");

	var el_field_value_label = document.createElement('label');
		el_field_value_label.setAttribute("class", "fm-field-label");
		el_field_value_label.setAttribute("for", "el_hidden_value");
		el_field_value_label.style.cssText = "margin-right: 22px;";
		el_field_value_label.innerHTML = "Field Value";
	
	var el_field_value_input= document.createElement('input');
		el_field_value_input.setAttribute("type", "text");
		el_field_value_input.setAttribute("id", "el_hidden_value");
		el_field_value_input.setAttribute("value", w_value);
		el_field_value_input.setAttribute("onKeyUp", "change_field_value('"+i+"', this.value)");

	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
                
           	el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_text')");
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_text')");
			
		var el_attr_value = document.createElement('input');
	
			el_attr_value.setAttribute("type", "text");
	
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_text')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_text')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}

	var t  = document.getElementById('edit_table');
	
	var hr = document.createElement('hr');
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	edit_main_td1.appendChild(el_field_id_label);
	edit_main_td1.appendChild(el_field_id_input);
	edit_main_td2.appendChild(el_field_name_label);
	edit_main_td2.appendChild(el_field_name_input);
	edit_main_td3.appendChild(el_field_value_label);
	edit_main_td3.appendChild(el_field_value_input);
	
	
	
	edit_main_td4.appendChild(el_attr_label);
	edit_main_td4.appendChild(el_attr_add);
	edit_main_td4.appendChild(br3);
	edit_main_td4.appendChild(el_attr_table);
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);

	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	
	element='input';	type='hidden';  
	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_hidden");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
	    
	var adding = document.createElement(element);
		adding.setAttribute("type", type);
		adding.setAttribute("value", w_value);
		adding.setAttribute("id", i+"_elementform_id_temp");
		adding.setAttribute("name", w_name);

	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
				
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.cssText = 'display:table-cell; padding-left: 7px;';
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");
		
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
    
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.style.cssText = 'display:none';
		label.innerHTML = w_name;
  
	var label_hidden = document.createElement('span');
		label_hidden.style.cssText = 'color:red; font-size:13px;';
		label_hidden.innerHTML = 'Hidden field';
		
		
	var div_hidden_name = document.createElement('div');
		
	var span_hidden_name_label = document.createElement('span');
		span_hidden_name_label.setAttribute("align", 'left');
		span_hidden_name_label.innerHTML = 'Name: ';	
		
	var span_hidden_name = document.createElement('span');
		span_hidden_name.setAttribute("align", 'left');
		span_hidden_name.innerHTML = w_name;	
		span_hidden_name.setAttribute("id", i+"_hidden_nameform_id_temp");	
	
	var div_hidden_value = document.createElement('div');

	var span_hidden_value_label = document.createElement('span');
		span_hidden_value_label.setAttribute("align", 'left');
		span_hidden_value_label.innerHTML = 'Value: ';	
		
	var span_hidden_value = document.createElement('span');
		span_hidden_value.setAttribute("align", 'left');
		span_hidden_value.innerHTML = w_value;	
		span_hidden_value.setAttribute("id", i+"_hidden_valueform_id_temp");	
		
	div_hidden_name.appendChild(span_hidden_name_label);
	div_hidden_name.appendChild(span_hidden_name);
	div_hidden_value.appendChild(span_hidden_value_label);
	div_hidden_value.appendChild(span_hidden_value);
      
	var main_td  = document.getElementById('show_table');
      
	div_label.appendChild(label);
	div_label.appendChild(label_hidden);
	div_element.appendChild(adding);
	div_element.appendChild(adding_type);
	div_element.appendChild(div_hidden_name);
	div_element.appendChild(div_hidden_value);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
	div.appendChild(div_field);
	div.appendChild(br3);
	main_td.appendChild(div);
	refresh_attr(i, 'type_text');
}

function type_button(i, w_title , w_func , w_class, w_attr_name, w_attr_value){
	
	document.getElementById("element_type").value="type_button";
	delete_last_child();

	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
		edit_main_td4.setAttribute("id", "buttons");
		edit_main_td4.setAttribute("colspan", "2");
	
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');

	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");
				
	var el_choices_add_label = document.createElement('label');
		el_choices_add_label.setAttribute("class", "fm-field-label");
		el_choices_add_label.innerHTML = "Add a new button&nbsp;";
		
	var el_choices_add = document.createElement('img');
                el_choices_add.setAttribute("id", "el_choices_add");
           	el_choices_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_choices_add.style.cssText = 'cursor:pointer;';
            	el_choices_add.setAttribute("title", 'add');
                el_choices_add.setAttribute("onClick", "add_button("+i+")");
	
				
	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
				el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
                
				el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_checkbox')");
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_checkbox')");
			
		var el_attr_value = document.createElement('input');
	
			el_attr_value.setAttribute("type", "text");
	
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_checkbox')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_checkbox')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}

	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	
	
	edit_main_td1.appendChild(el_style_label);
	edit_main_td1_1.appendChild(el_style_textarea);
	
	edit_main_td2.appendChild(el_attr_label);
	edit_main_td2.appendChild(el_attr_add);
	edit_main_td2.appendChild(br3);
	edit_main_td2.appendChild(el_attr_table);
	edit_main_td2.setAttribute("colspan", "2");
	
	edit_main_td3.appendChild(el_choices_add_label);
	edit_main_td3_1.appendChild(el_choices_add);
	
	n=w_title.length;
	for(j=0; j<n; j++)
	{	
		var table_button = document.createElement('table');
			table_button.setAttribute("width", "100%");
			table_button.setAttribute("border", "0");
			table_button.setAttribute("id", "button_opt"+j);
			table_button.setAttribute("idi", j+1);
		var tr_button = document.createElement('tr');
		var tr_hr = document.createElement('tr');
		
		var td_button = document.createElement('td');
		var td_X = document.createElement('td');
		var td_hr = document.createElement('td');
		    td_hr.setAttribute("colspan", "3");
		tr_hr.appendChild(td_hr);
		tr_button.appendChild(td_button);
		tr_button.appendChild(td_X);
		table_button.appendChild(tr_hr);
		table_button.appendChild(tr_button);
		
		var br1 = document.createElement('br');
		
		var hr = document.createElement('hr');
		hr.setAttribute("id", "br"+j);


		var el_title_label = document.createElement('label');
			el_title_label.setAttribute("class", "fm-field-label");
			el_title_label.setAttribute("for", "el_title"+j);
			el_title_label.innerHTML = "Button name";
		
		var el_title = document.createElement('input');
			el_title.setAttribute("id", "el_title"+j);
			el_title.setAttribute("type", "text");
			el_title.setAttribute("value", w_title[j]);
			el_title.style.cssText = "width:140px; margin-left:33px;";
			el_title.setAttribute("onKeyUp", "change_label('"+i+"_elementform_id_temp"+j+"', this.value);");
	
		var el_func_label = document.createElement('label');
			el_func_label.setAttribute("class", "fm-field-label");
			el_func_label.setAttribute("for", "el_func"+j);
			el_func_label.innerHTML = "OnClick function";
		
		var el_func = document.createElement('input');
			el_func.setAttribute("id", "el_func"+j);
			el_func.setAttribute("type", "text");
			el_func.setAttribute("value", w_func[j]);
			el_func.style.cssText =   "width:140px;  margin-left:11px;";
			el_func.setAttribute("onKeyUp", "change_func('"+i+"_elementform_id_temp"+j+"', this.value);");
		var el_choices_remove = document.createElement('img');
			el_choices_remove.setAttribute("id", "el_button"+j+"_remove");
			el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_choices_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_choices_remove.setAttribute("align", 'top');
			el_choices_remove.setAttribute("onClick", "remove_button("+j+","+i+")");
			
		td_hr.appendChild(hr);
		td_button.appendChild(el_title_label);
		td_button.appendChild(el_title);
		td_button.appendChild(br1);
		td_button.appendChild(el_func_label);
		td_button.appendChild(el_func);
		td_X.appendChild(el_choices_remove);
		edit_main_td4.appendChild(table_button);
	
	}

	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);

	edit_main_table.appendChild(edit_main_tr1);

	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr2);
//	edit_main_table.appendChild(edit_main_tr5);
//	edit_main_table.appendChild(edit_main_tr6);

	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	
//show table

	element='button';	type='button'; 
	var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_button");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
    var div = document.createElement('div');
       	div.setAttribute("id", "main_div");
//tbody sarqac
		
		
	var div_field = document.createElement('div');
           	div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
      	var div_label = document.createElement('div');
         	div_label.setAttribute("align", 'left');
         	div_label.style.display="table-cell";
			div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
      	var div_element = document.createElement('div');
         	div_element.setAttribute("align", 'left');
          	div_element.style.display="table-cell";
          	div_element.setAttribute("id", i+"_element_sectionform_id_temp");

      	var br1 = document.createElement('br');
      	var br2 = document.createElement('br');
     	var br3 = document.createElement('br');
      	var br4 = document.createElement('br');
	//	table_little -@ sarqaca tbody table_little darela table_little_t
      	var label = document.createElement('span');
			label.setAttribute("id", i+"_element_labelform_id_temp");
			label.innerHTML = "button_"+i;
			label.style.cssText = 'display:none';
	    
	n=w_title.length;
	for(j=0; j<n; j++)
	{      	
	
		var adding = document.createElement(element);
				adding.setAttribute("type", type);
				adding.setAttribute("id", i+"_elementform_id_temp"+j);
				adding.setAttribute("name", i+"_elementform_id_temp"+j);
				adding.setAttribute("value", w_title[j]);
				adding.innerHTML = w_title[j];
				adding.setAttribute("onclick", w_func[j]);
				
				
		div_element.appendChild(adding);
	}			
      	var main_td  = document.getElementById('show_table');
	
      	div_label.appendChild(label);
      
        div_element.appendChild(adding_type);
      	div_field.appendChild(div_label);
      	div_field.appendChild(div_element);
      
      

      	div.appendChild(div_field);
      	div.appendChild(br1);
      	main_td.appendChild(div);
change_class(w_class, i);
refresh_attr(i, 'type_checkbox');
}

function type_send_copy(i, w_field_label, w_field_label_size, w_field_label_pos, w_first_val, w_required, w_attr_name, w_attr_value) {

    document.getElementById("element_type").value="type_send_copy";
	delete_last_child();
	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");

	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10  = document.createElement('tr');

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');

	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
		
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
		
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
		  
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');

	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');
		  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
	    el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
        el_label_textarea.setAttribute("id", "edit_for_label");
        el_label_textarea.setAttribute("rows", "4");
        el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
		
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
		
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
	    el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";

	var el_required = document.createElement('input');
        el_required.setAttribute("id", "el_required");
        el_required.setAttribute("type", "checkbox");
        el_required.setAttribute("onclick", "set_required('"+i+"_required')");
	if(w_required=="yes")
        el_required.setAttribute("checked", "checked");
			
	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
			
	var el_attr_add = document.createElement('img');
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_send_copy')");
		
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	    el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_send_copy')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_send_copy')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_send_copy')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
	}

		
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td10.appendChild(el_label_size_label);
	edit_main_td10_1.appendChild(el_label_size);

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td6.appendChild(el_required_label);
	edit_main_td6_1.appendChild(el_required);
	

	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br2);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");

	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr7);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_text');
	
//show table

	element='input';	type='checkbox'; 
	var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_send_copy");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
	    
	var adding_required= document.createElement("input");
            adding_required.setAttribute("type", "hidden");
            adding_required.setAttribute("value", w_required);
            adding_required.setAttribute("name", i+"_requiredform_id_temp");
            adding_required.setAttribute("id", i+"_requiredform_id_temp");
			
	var adding = document.createElement(element);
        adding.setAttribute("type", type);
		if(w_first_val)
			adding.setAttribute("checked", "checked");
		adding.setAttribute("id", i+"_elementform_id_temp");
		adding.setAttribute("name", i+"_elementform_id_temp");
		adding.setAttribute("onclick", "set_checked('"+i+"','','form_id_temp')");

	 
     	var div = document.createElement('div');
      	    div.setAttribute("id", "main_div");
			
		var div_for_editable_labels = document.createElement('div');
			div_for_editable_labels.setAttribute("class", "fm-editable-label");
			
      	edit_labels = document.createTextNode("Use the field to allow the user to choose whether to receive a copy of the submitted form or not. Do not forget to fill in User Email section in Email Options in advance.");

		div_for_editable_labels.appendChild(edit_labels);  


			
      	var div_field = document.createElement('div');
           	div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
      	var div_label = document.createElement('div');
         	div_label.setAttribute("align", 'left');
         	div_label.style.display="table-cell";
			div_label.style.width= w_field_label_size+'px';
           	div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
      	var div_element = document.createElement('div');
         	div_element.setAttribute("align", 'left');
          	div_element.style.display="table-cell";
          	div_element.setAttribute("id", i+"_element_sectionform_id_temp");
			
      	var br1 = document.createElement('br');
      	var br2 = document.createElement('br');
     	var br3 = document.createElement('br');
      	var br4 = document.createElement('br');
      

	    
      	var label = document.createElement('span');
			label.setAttribute("id", i+"_element_labelform_id_temp");
			label.innerHTML = w_field_label;
			label.setAttribute("class", "label");
			label.style.verticalAlign="top";

	    
      	var required = document.createElement('span');
			required.setAttribute("id", i+"_required_elementform_id_temp");
			required.innerHTML = "";
			required.setAttribute("class", "required");
			required.style.verticalAlign="top";
	if(w_required=="yes")
			required.innerHTML = " *";
      	var main_td  = document.getElementById('show_table');
      
      	div_label.appendChild(label);
      	div_label.appendChild(required);
      	div_element.appendChild(adding_type);
      	div_element.appendChild(adding_required);
      	div_element.appendChild(adding);
      	div_field.appendChild(div_label);
      	div_field.appendChild(div_element);
      
      	div.appendChild(div_field);
      	div.appendChild(br3);
      	div.appendChild(div_for_editable_labels);
		
      	main_td.appendChild(div);
	if(w_field_label_pos=="top")
				label_top(i);
	refresh_attr(i, 'type_text');
}

function type_text(i, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_first_val, w_title, w_required, w_regExp_status, w_regExp_value, w_regExp_common, w_regExp_arg, w_regExp_alert, w_unique, w_attr_name, w_attr_value) {

    document.getElementById("element_type").value="type_text";
	delete_last_child();	
	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");

	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");

	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10  = document.createElement('tr');
	var edit_main_tr11 = document.createElement('tr');
	var edit_main_tr12 = document.createElement('tr');
		edit_main_tr12.setAttribute("id", "edit_main_tr12");
	var edit_main_tr13 = document.createElement('tr');
		edit_main_tr13.setAttribute("id", "edit_main_tr13");
	var edit_main_tr14 = document.createElement('tr');
		edit_main_tr14.setAttribute("id", "edit_main_tr14");
	var edit_main_tr15 = document.createElement('tr');
		edit_main_tr15.setAttribute("id", "edit_main_tr15");
	if(w_regExp_status == 'no' || w_regExp_status == "")
	{
		edit_main_tr12.style.cssText = 'display:none;';
		edit_main_tr13.style.cssText = 'display:none;';
		edit_main_tr14.style.cssText = 'display:none;';
		edit_main_tr15.style.cssText = 'display:none;';
	}	
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');

	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
		
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
		
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
		  
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');

	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');
	var edit_main_td11 = document.createElement('td');
	var edit_main_td11_1 = document.createElement('td');
	var edit_main_td12 = document.createElement('td');	  
	var	edit_main_td12_1 = document.createElement('td');	  
	var edit_main_td13 = document.createElement('td');
	var edit_main_td13_1 = document.createElement('td');
	var edit_main_td14 = document.createElement('td');
	var edit_main_td14_1 = document.createElement('td');
	var edit_main_td15 = document.createElement('td');
	var edit_main_td15_1 = document.createElement('td');
	
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
	    el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
        el_label_textarea.setAttribute("id", "edit_for_label");
        el_label_textarea.setAttribute("rows", "4");
        
        el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
		
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
		
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";
	
	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
        el_label_left.innerHTML = "Left";	
		
	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");
	
	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
        el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos == "top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_size_label = document.createElement('label');
		el_size_label.setAttribute("class", "fm-field-label");
	    el_size_label.setAttribute("for", "edit_for_input_size");
		el_size_label.innerHTML = "Field size(px) ";

	var el_size = document.createElement('input');
		el_size.setAttribute("id", "edit_for_input_size");
		el_size.setAttribute("type", "text");
		el_size.setAttribute("value", w_size);
		el_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_size.setAttribute("onKeyUp", "change_w_style('"+i+"_elementform_id_temp', this.value)");

	var el_first_value_label = document.createElement('label');
		el_first_value_label.setAttribute("class", "fm-field-label");
	    el_first_value_label.setAttribute("for", "el_first_value_input");
		el_first_value_label.innerHTML = "Value if empty ";
	
	var el_first_value_input = document.createElement('input');
        el_first_value_input.setAttribute("id", "el_first_value_input");
        el_first_value_input.setAttribute("type", "text");
        el_first_value_input.setAttribute("value", w_title);
        el_first_value_input.setAttribute("onKeyUp", "change_input_value(this.value,'"+i+"_elementform_id_temp')");
	
	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
	    el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";

	var el_required = document.createElement('input');
        el_required.setAttribute("id", "el_required");
        el_required.setAttribute("type", "checkbox");
        el_required.setAttribute("onclick", "set_required('"+i+"_required')");
	if(w_required=="yes")
        el_required.setAttribute("checked", "checked");
			
	/********************** REGULAR EXPRESSION ************************/
	var el_add_regExp_label = document.createElement('label');
		el_add_regExp_label.setAttribute("class", "fm-field-label");
		el_add_regExp_label.setAttribute("for", "el_regExp_"+i);
		el_add_regExp_label.innerHTML = "Validation (Regular Exp.)";

	var el_add_regExp = document.createElement('input');
        el_add_regExp.setAttribute("id", "el_regExp_"+i);
        el_add_regExp.setAttribute("type", "checkbox");
        el_add_regExp.setAttribute("onclick", "set_regExpStatus('"+i+"_regExpStatus')");
	if(w_regExp_status == "yes")
        el_add_regExp.setAttribute("checked", "checked");

	var el_reg_value_label = document.createElement('label');
		el_reg_value_label.setAttribute("class", "regExp_cell fm-field-label");
		el_reg_value_label.innerHTML = "Regular Expression";
	
	var el_reg_value = document.createElement('textarea');
		el_reg_value.setAttribute("id", "regExp_value"+i);
		el_reg_value.setAttribute("class","regExp_cell");
		el_reg_value.setAttribute("onKeyUp", "change_regExpValue('"+i+"', this.value ,'"+i+"_regExp_valueform_id_temp','')");
		el_reg_value.innerHTML = w_regExp_value;
	
	var count = 0;
	var common_val_arr = [];
		common_val_arr["Select"] = "";
		common_val_arr["Name(Latin letters and some symbols)"] = "^[a-zA-Z'-'\\s]+$";
		common_val_arr["Phone Number(Digits and dashes)"] = "^(\\+)?[0-9]+(-[0-9]+)?(-[0-9]+)?(-[0-9]+)?$";
		common_val_arr["Integer Number"] = "^(-)?[0-9]+$";
		common_val_arr["Decimal Number"] = "^(-)?[0-9]+(\\.[0-9]+)?$";
		common_val_arr["Latin letters and Numbers"] = "^[a-z&A-Z0-9]*$";
		common_val_arr["Credit Card (16 Digits)"] = "^([0-9](\\.)?){15}[0-9]$";
		common_val_arr["Zip Code"] = "^(\\d{5}-\\d{4}|\\d{5}|\\d{9})$|^([a-zA-Z]\\d[a-zA-Z] \\d[a-zA-Z]\\d)$";
		common_val_arr["IP Address"] = "^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$";
		common_val_arr["Date m/d/y (e.g. 12/21/2013)"] = "^([0-9]|1[0,1,2])/([0-9]|[0,1,2][0-9]|3[0,1])/[0-9]{4}$";
		common_val_arr["Date d.m.y (e.g. 21.12.2013)"] = "^([0-9]|[0,1,2][0-9]|3[0,1])\\.([0-9]|1[0,1,2])\\.[0-9]{4}$";
		common_val_arr["MySQL Date Format (2013-12-21)"] = "^\\d{4}-(0[0-9]|1[0,1,2])-([0,1,2][0-9]|3[0,1])$";
				
	var el_reg_com_val_label = document.createElement('label');
		el_reg_com_val_label.setAttribute("class", "regExp_cell fm-field-label");
		el_reg_com_val_label.innerHTML = "Common Regular Expressions ";
				
	var el_reg_com_val = document.createElement('select');
		el_reg_com_val.setAttribute("id", "common_RegExp"+i);
		el_reg_com_val.setAttribute("name", "common_RegExp"+i);
		el_reg_com_val.setAttribute("onChange", "change_regExpValue('"+i+"','"+w_regExp_value+"','"+i+"_regExp_valueform_id_temp', this.value)");
		el_reg_com_val.style.cssText ="width:200px; margin-bottom:9px;";
				
	for (var keys  in common_val_arr)
	{
		if (!common_val_arr.hasOwnProperty(keys)) 
			continue;
			
		var el_option_common = "el_com_val"+count;
			el_option_common = document.createElement('option');
			el_option_common.setAttribute("id", "edit_for_label_common"+count);
			el_option_common.setAttribute("value",common_val_arr[keys]);
			if(w_regExp_common == count)
				el_option_common.setAttribute("selected", "selected");
			el_option_common.innerHTML = keys;
			
		el_reg_com_val.appendChild(el_option_common);
		count++;
	}

	var el_reg_arg_label = document.createElement('label');
		el_reg_arg_label.setAttribute("class", "regExp_cell fm-field-label");
		el_reg_arg_label.innerHTML = "Case Insensitive";
			
	var el_reg_arg = document.createElement('input');
		el_reg_arg.setAttribute("id", "el_regArg_"+i+" ");
		el_reg_arg.setAttribute("type", "checkbox");
		el_reg_arg.setAttribute("onclick", "set_regExpArgument('"+i+"_regArgument')");
	if(w_regExp_arg == 'i')
		el_reg_arg.setAttribute("checked", "checked");
					
	var el_reg_alert_label = document.createElement('label');
		el_reg_alert_label.setAttribute("class", "regExp_cell fm-field-label");
		el_reg_alert_label.innerHTML = "Alert Message";
			
	var el_reg_alert = document.createElement('textarea');
		el_reg_alert.setAttribute("type", "text");
		el_reg_alert.setAttribute("id", "regExp_alert"+i);
		el_reg_alert.setAttribute("class","regExp_cell");
		el_reg_alert.setAttribute("onKeyUp", "change_regExpAlert(this.value,'"+i+"_regExp_alertform_id_temp')");
		el_reg_alert.innerHTML = w_regExp_alert;
	
	/**************************************************************************/	

	var el_unique_label = document.createElement('label');
		el_unique_label.setAttribute("class", "fm-field-label");
	    el_unique_label.setAttribute("for", "el_unique");
		el_unique_label.innerHTML = "Allow only unique values";

	var el_unique = document.createElement('input');
        el_unique.setAttribute("id", "el_unique");
        el_unique.setAttribute("type", "checkbox");
        el_unique.setAttribute("onclick", "set_unique('"+i+"_uniqueform_id_temp')");
	if(w_unique=="yes")
                el_unique.setAttribute("checked", "checked");
				
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.innerHTML = "Deactive Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", "input_deactive");
		el_style_textarea.setAttribute("disabled", "disabled");
        el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_style_label2 = document.createElement('label');
	    el_style_label2.setAttribute("class", "fm-field-label");
		el_style_label2.innerHTML = "Active Class name";
	
	var el_style_textarea2 = document.createElement('input');
		el_style_textarea2.setAttribute("type", "text");
		el_style_textarea2.setAttribute("value", "input_active");
		el_style_textarea2.setAttribute("disabled", "disabled");
        el_style_textarea2.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
			
	var el_attr_add = document.createElement('img');
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_text')");
		
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	    el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_text')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_text')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_text')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
	}

		
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td10.appendChild(el_label_size_label);
	edit_main_td10_1.appendChild(el_label_size);

	edit_main_td11.appendChild(el_add_regExp_label);
	edit_main_td11_1.appendChild(el_add_regExp);
	
	edit_main_td12.appendChild(el_reg_value_label);
	edit_main_td12_1.appendChild(el_reg_value);
	
	edit_main_td13.appendChild(el_reg_com_val_label);
	edit_main_td13_1.appendChild(el_reg_com_val);
	
	edit_main_td14.appendChild(el_reg_arg_label);
	edit_main_td14_1.appendChild(el_reg_arg);
	
	edit_main_td15.appendChild(el_reg_alert_label);
	edit_main_td15_1.appendChild(el_reg_alert);
	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_size_label);
	edit_main_td3_1.appendChild(el_size);
	
	edit_main_td4.appendChild(el_first_value_label);
	edit_main_td4_1.appendChild(el_first_value_input);
	
	edit_main_td5.appendChild(el_style_label);
	edit_main_td5_1.appendChild(el_style_textarea);
	
	edit_main_td9.appendChild(el_style_label2);
	edit_main_td9_1.appendChild(el_style_textarea2);
	
	edit_main_td6.appendChild(el_required_label);
	edit_main_td6_1.appendChild(el_required);
	
	edit_main_td8.appendChild(el_unique_label);
	edit_main_td8_1.appendChild(el_unique);
	
	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br2);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");

	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr11.appendChild(edit_main_td11);
	edit_main_tr11.appendChild(edit_main_td11_1);
	
	edit_main_tr12.appendChild(edit_main_td12);
	edit_main_tr12.appendChild(edit_main_td12_1);
	
	edit_main_tr13.appendChild(edit_main_td13);
	edit_main_tr13.appendChild(edit_main_td13_1);
	
	edit_main_tr14.appendChild(edit_main_td14);
	edit_main_tr14.appendChild(edit_main_td14_1);
	
	edit_main_tr15.appendChild(edit_main_td15);
	edit_main_tr15.appendChild(edit_main_td15_1);
	
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr11);
	edit_main_table.appendChild(edit_main_tr12);
	edit_main_table.appendChild(edit_main_tr13);
	edit_main_table.appendChild(edit_main_tr14);
	edit_main_table.appendChild(edit_main_tr15);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr7);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_text');
	
//show table

	element='input';	type='text'; 
	var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_text");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
	    
	var adding_required= document.createElement("input");
            adding_required.setAttribute("type", "hidden");
            adding_required.setAttribute("value", w_required);
            adding_required.setAttribute("name", i+"_requiredform_id_temp");
            adding_required.setAttribute("id", i+"_requiredform_id_temp");
			
	var adding_unique= document.createElement("input");
            adding_unique.setAttribute("type", "hidden");
            adding_unique.setAttribute("value", w_unique);
            adding_unique.setAttribute("name", i+"_uniqueform_id_temp");
            adding_unique.setAttribute("id", i+"_uniqueform_id_temp");
			
		var adding = document.createElement(element);
            adding.setAttribute("type", type);
		
		if(w_title==w_first_val)
		{
			adding.style.cssText = "width:"+w_size+"px;";
			adding.setAttribute("class", "input_deactive");
		}
		else
		{
			adding.style.cssText = "width:"+w_size+"px;";
			adding.setAttribute("class", "input_active");
		}
			adding.setAttribute("id", i+"_elementform_id_temp");
			adding.setAttribute("name", i+"_elementform_id_temp");
			adding.setAttribute("value", w_first_val);
			adding.setAttribute("title", w_title);
			adding.setAttribute("onFocus", 'delete_value("'+i+'_elementform_id_temp")');
			adding.setAttribute("onBlur", 'return_value("'+i+'_elementform_id_temp")');
			adding.setAttribute("onChange", 'change_value("'+i+'_elementform_id_temp")');
			
		var adding_regExp_status = document.createElement("input");
			adding_regExp_status.setAttribute("type", "hidden");
			adding_regExp_status.setAttribute("value", w_regExp_status);
			adding_regExp_status.setAttribute("name", i+"_regExpStatusform_id_temp");
			adding_regExp_status.setAttribute("id", i+"_regExpStatusform_id_temp");
	
		var adding_regArg = document.createElement("input");
			adding_regArg.setAttribute("type", "hidden");
			adding_regArg.setAttribute("value", w_regExp_arg);
			adding_regArg.setAttribute("name", i+"_regArgumentform_id_temp");
			adding_regArg.setAttribute("id", i+"_regArgumentform_id_temp");
		
		var adding_regExp_common = document.createElement("input");
			adding_regExp_common.setAttribute("type", "hidden");
			adding_regExp_common.setAttribute("value", w_regExp_common);
			adding_regExp_common.setAttribute("name", i+"_regExp_commonform_id_temp");
			adding_regExp_common.setAttribute("id", i+"_regExp_commonform_id_temp");
		
		var adding_regExp_value = document.createElement("input");
			adding_regExp_value.setAttribute("type", "hidden");
			adding_regExp_value.setAttribute("value", escape(w_regExp_value));
			adding_regExp_value.setAttribute("name", i+"_regExp_valueform_id_temp");
			adding_regExp_value.setAttribute("id", i+"_regExp_valueform_id_temp");
						
		var adding_regExp_alert = document.createElement("input");
			adding_regExp_alert.setAttribute("type", "hidden");
			adding_regExp_alert.setAttribute("value", w_regExp_alert);
			adding_regExp_alert.setAttribute("name", i+"_regExp_alertform_id_temp");
			adding_regExp_alert.setAttribute("id", i+"_regExp_alertform_id_temp");	

     	var div = document.createElement('div');
      	    div.setAttribute("id", "main_div");
					
      	var div_field = document.createElement('div');
           	div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
      	var div_label = document.createElement('div');
         	div_label.setAttribute("align", 'left');
         	div_label.style.display="table-cell";
			div_label.style.width= w_field_label_size+'px';
           	div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
      	var div_element = document.createElement('div');
         	div_element.setAttribute("align", 'left');
          	div_element.style.display="table-cell";
          	div_element.setAttribute("id", i+"_element_sectionform_id_temp");
			
      	var br = document.createElement('br');
    
      	var label = document.createElement('span');
			label.setAttribute("id", i+"_element_labelform_id_temp");
			label.innerHTML = w_field_label;
			label.setAttribute("class", "label");
			label.style.verticalAlign="top";

	    
      	var required = document.createElement('span');
			required.setAttribute("id", i+"_required_elementform_id_temp");
			required.innerHTML = "";
			required.setAttribute("class", "required");
			required.style.verticalAlign="top";
		if(w_required=="yes")
			required.innerHTML = " *";
      	
		var main_td  = document.getElementById('show_table');
      
		div_label.appendChild(label);
		div_label.appendChild(required);
		div_element.appendChild(adding_type);
		div_element.appendChild(adding_required);
		div_element.appendChild(adding_regExp_status);
		div_element.appendChild(adding_regExp_value); 
		div_element.appendChild(adding_regExp_common); 
		div_element.appendChild(adding_regExp_alert);
		div_element.appendChild(adding_regArg); 
		div_element.appendChild(adding_unique);
		div_element.appendChild(adding);
		div_field.appendChild(div_label);
		div_field.appendChild(div_element);
	  
		div.appendChild(div_field);
		div.appendChild(br);
		main_td.appendChild(div);
		
		if(w_field_label_pos == "top")
			label_top(i);
			
		refresh_attr(i, 'type_text');
}

function set_regExpStatus(id)
{	
	jQuery('#edit_main_tr12, #edit_main_tr13, #edit_main_tr14, #edit_main_tr15').toggle(200);
	if(document.getElementById(id+"form_id_temp").value == "yes")
		document.getElementById(id+"form_id_temp").setAttribute("value", "no");
	else
		document.getElementById(id+"form_id_temp").setAttribute("value", "yes");
}

function set_regExpArgument(id)
{	
	if(document.getElementById(id+"form_id_temp").value.length <= 0)
		document.getElementById(id+"form_id_temp").setAttribute("value", "i");
	else
		document.getElementById(id+"form_id_temp").setAttribute("value", "");
}

function change_regExpValue(i, regValue, regVal_id, com_option)
{
	if(com_option.length > 0)
	{
		document.getElementById("regExp_value"+i).value = com_option;
		document.getElementById(regVal_id).value = com_option;
		document.getElementById(i+"_regExp_commonform_id_temp").value = document.getElementById("common_RegExp"+i).selectedIndex; 
	}
	else
	{
		document.getElementById(regVal_id).value = regValue;
		document.getElementById(i+"_regExp_commonform_id_temp").value = regValue;
	}	
}

function change_regExpAlert(regAlert,id)
{
	document.getElementById(id).value = regAlert;
}


function type_number(i, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_first_val, w_title, w_required, w_unique, w_class, w_attr_name, w_attr_value) {

    document.getElementById("element_type").value="type_number";
	delete_last_child();
	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
			
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
		
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
	
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
	    el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
                el_label_textarea.setAttribute("id", "edit_for_label");
                el_label_textarea.setAttribute("rows", "4");
                
                el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	

	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_size_label = document.createElement('label');
		el_size_label.setAttribute("class", "fm-field-label");
	    el_size_label.setAttribute("for", "edit_for_input_size");
		el_size_label.innerHTML = "Field size(px) ";
	var el_size = document.createElement('input');
		el_size.setAttribute("id", "edit_for_input_size");
		el_size.setAttribute("type", "text");
		el_size.setAttribute("value", w_size);
		el_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_size.setAttribute("onKeyUp", "change_w_style('"+i+"_elementform_id_temp', this.value)");

	var el_first_value_label = document.createElement('label');
		el_first_value_label.setAttribute("class", "fm-field-label");
		el_first_value_label.setAttribute("for", "el_first_value_input");
		el_first_value_label.innerHTML = "Value if empty ";
	
	var el_first_value_input = document.createElement('input');
        el_first_value_input.setAttribute("id", "el_first_value_input");
		el_first_value_input.setAttribute("type", "text");
		el_first_value_input.setAttribute("value", w_title);
		el_first_value_input.setAttribute("onKeyUp", "change_input_value(this.value,'"+i+"_elementform_id_temp');");
		
	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
	    el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_required");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
	if(w_required=="yes")
		el_required.setAttribute("checked", "checked");
	
	var el_unique_label = document.createElement('label');
		el_unique_label.setAttribute("class", "fm-field-label");
	    el_unique_label.setAttribute("for", "el_unique");
		el_unique_label.innerHTML = "Allow only unique values";
	
	var el_unique = document.createElement('input');
		el_unique.setAttribute("id", "el_unique");
		el_unique.setAttribute("type", "checkbox");
		el_unique.setAttribute("onclick", "set_unique('"+i+"_uniqueform_id_temp')");
	if(w_unique=="yes")
        el_unique.setAttribute("checked", "checked");
							
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
	    el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";

	var el_style_textarea = document.createElement('input');
        el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
        
        el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
			
	var el_attr_add = document.createElement('img');
      	el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
        el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
        el_attr_add.setAttribute("title", 'add');
        el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_text')");
		
	var el_attr_table = document.createElement('table');
        el_attr_table.setAttribute("id", 'attributes');
        el_attr_table.setAttribute("border", '0');
        el_attr_table.style.cssText = 'margin-left:0px';
		
	var el_attr_tr_label = document.createElement('tr');
        el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
        el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
        el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
        el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	    el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
	var el_attr_value_label = document.createElement('label');
	    el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_text')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_text')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_text')");
	
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}

	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br6 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);

	edit_main_td9.appendChild(el_label_size_label);
	edit_main_td9_1.appendChild(el_label_size);
	
	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_size_label);
	edit_main_td3_1.appendChild(el_size);
	
	edit_main_td4.appendChild(el_first_value_label);
	edit_main_td4_1.appendChild(el_first_value_input);
	
	edit_main_td5.appendChild(el_style_label);
	edit_main_td5_1.appendChild(el_style_textarea);
	edit_main_td6.appendChild(el_required_label);
	edit_main_td6_1.appendChild(el_required);
				
	edit_main_td8.appendChild(el_unique_label);
	edit_main_td8_1.appendChild(el_unique);
	
	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br6);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");

	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr7);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_text');
	
//show table

	element='input';	type='text'; 
	var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_number");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
	    
	var adding_required= document.createElement("input");
            adding_required.setAttribute("type", "hidden");
            adding_required.setAttribute("value", w_required);
            adding_required.setAttribute("name", i+"_requiredform_id_temp");
            adding_required.setAttribute("id", i+"_requiredform_id_temp");
			
	var adding_unique= document.createElement("input");
            adding_unique.setAttribute("type", "hidden");
            adding_unique.setAttribute("value", w_unique);
            adding_unique.setAttribute("name", i+"_uniqueform_id_temp");
            adding_unique.setAttribute("id", i+"_uniqueform_id_temp");
			
			
	var adding = document.createElement(element);
			adding.setAttribute("type", type);
		
		if(w_title==w_first_val)
		{
			adding.style.cssText = "width:"+w_size+"px;";
			adding.setAttribute("class", "input_deactive");
		}
		else
		{
			adding.style.cssText = "width:"+w_size+"px;";
			adding.setAttribute("class", "input_active");
		}
			adding.setAttribute("id", i+"_elementform_id_temp");
			adding.setAttribute("name", i+"_elementform_id_temp");
			adding.setAttribute("value", w_first_val);
			adding.setAttribute("title", w_title);
			adding.setAttribute("onKeyPress", "return check_isnum(event)");
			adding.setAttribute("onFocus", 'delete_value("'+i+'_elementform_id_temp")');
			adding.setAttribute("onBlur", 'return_value("'+i+'_elementform_id_temp")');
			adding.setAttribute("onChange", 'change_value("'+i+'_elementform_id_temp")');
			
	 
     	var div = document.createElement('div');
      	    div.setAttribute("id", "main_div");
					
      	var div_field = document.createElement('div');
           	div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
      	var div_label = document.createElement('div');
         	div_label.setAttribute("align", 'left');
         	div_label.style.display="table-cell";
			div_label.style.width=w_field_label_size+"px";
           	div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
      	var div_element = document.createElement('div');
         	div_element.setAttribute("align", 'left');
          	div_element.style.display="table-cell";
          	div_element.setAttribute("id", i+"_element_sectionform_id_temp");
			
      	var label = document.createElement('span');
			label.setAttribute("id", i+"_element_labelform_id_temp");
			label.innerHTML = w_field_label;
			label.setAttribute("class", "label");
			label.style.verticalAlign="top";
	    
      	var required = document.createElement('span');
			required.setAttribute("id", i+"_required_elementform_id_temp");
			required.innerHTML = "";
			required.setAttribute("class", "required");
			required.style.verticalAlign="top";
	if(w_required=="yes")
			required.innerHTML = " *";
      	var main_td  = document.getElementById('show_table');
      
      	div_label.appendChild(label);
      	div_label.appendChild(required);
      	div_element.appendChild(adding_type);
      	div_element.appendChild(adding_required);
      	div_element.appendChild(adding_unique);
      	div_element.appendChild(adding);
      	div_field.appendChild(div_label);
      	div_field.appendChild(div_element);
      	
      
      	div.appendChild(div_field);
      	main_td.appendChild(div);
		
		if(w_field_label_pos=="top")
			label_top(i);
			
		change_class(w_class, i);
		refresh_attr(i, 'type_text');
}

function type_password(i, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_required, w_unique, w_class, w_attr_name, w_attr_value) {

    document.getElementById("element_type").value="type_password";
	delete_last_child();

	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');

	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
        el_label_textarea.setAttribute("id", "edit_for_label");
        el_label_textarea.setAttribute("rows", "4");
        
        el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
		
		
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";
	
	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
        el_label_left.innerHTML = "Left";	
		
	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");
	
	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
        el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos == "top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_size_label = document.createElement('label');
		el_size_label.setAttribute("class", "fm-field-label");
	    el_size_label.setAttribute("for", "edit_for_input_size");
		el_size_label.innerHTML = "Field size(px) ";
	
	var el_size = document.createElement('input');
		el_size.setAttribute("id", "edit_for_input_size");
		el_size.setAttribute("type", "text");
		el_size.setAttribute("value", w_size);
		el_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_size.setAttribute("onKeyUp", "change_w_style('"+i+"_elementform_id_temp', this.value)");

	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
	    el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
        el_required.setAttribute("id", "el_required");
        el_required.setAttribute("type", "checkbox");
        el_required.setAttribute("onclick", "set_required('"+i+"_required')");
	if(w_required=="yes")
		el_required.setAttribute("checked", "checked");
			
	var el_unique_label = document.createElement('label');
		el_unique_label.setAttribute("class", "fm-field-label");
	    el_unique_label.setAttribute("for", "el_unique");
		el_unique_label.innerHTML = "Allow only unique values";
	
	var el_unique = document.createElement('input');
        el_unique.setAttribute("id", "el_unique");
        el_unique.setAttribute("type", "checkbox");
        el_unique.setAttribute("onclick", "set_unique('"+i+"_uniqueform_id_temp')");
	if(w_unique=="yes")
        el_unique.setAttribute("checked", "checked");
				
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
	    el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
        el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
        
        el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");
		
	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
		
	var el_attr_add = document.createElement('img');
        el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
        el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
        el_attr_add.setAttribute("title", 'add');
        el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_text')");
	var el_attr_table = document.createElement('table');
        el_attr_table.setAttribute("id", 'attributes');
        el_attr_table.setAttribute("border", '0');
        el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
        el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
      	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
       	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
      	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	    el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
	var el_attr_value_label = document.createElement('label');
	    el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_text')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_text')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_text')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}

	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br3 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);

	edit_main_td8.appendChild(el_label_size_label);
	edit_main_td8_1.appendChild(el_label_size);
	
	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_size_label);
	edit_main_td3_1.appendChild(el_size);
	
	edit_main_td4.appendChild(el_style_label);
	edit_main_td4_1.appendChild(el_style_textarea);
	
	edit_main_td5.appendChild(el_required_label);
	edit_main_td5_1.appendChild(el_required);
	
	edit_main_td7.appendChild(el_unique_label);
	edit_main_td7_1.appendChild(el_unique);


	edit_main_td6.appendChild(el_attr_label);
	edit_main_td6.appendChild(el_attr_add);
	edit_main_td6.appendChild(br3);
	edit_main_td6.appendChild(el_attr_table);
	edit_main_td6.setAttribute("colspan", "2");

	
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr6);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_text');

//show table

	element='input';	type='password'; 
	var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_password");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required= document.createElement("input");
            adding_required.setAttribute("type", "hidden");
            adding_required.setAttribute("value", w_required);
            adding_required.setAttribute("name", i+"_requiredform_id_temp");
            adding_required.setAttribute("id", i+"_requiredform_id_temp");
			
	var adding_unique= document.createElement("input");
            adding_unique.setAttribute("type", "hidden");
            adding_unique.setAttribute("value", w_unique);
            adding_unique.setAttribute("name", i+"_uniqueform_id_temp");
            adding_unique.setAttribute("id", i+"_uniqueform_id_temp");

	var adding = document.createElement(element);
			adding.setAttribute("type", type);
			adding.setAttribute("id", i+"_elementform_id_temp");
			adding.setAttribute("name", i+"_elementform_id_temp");
			adding.style.cssText = "width:"+w_size+"px;";
		
			
     	var div = document.createElement('div');
      	    div.setAttribute("id", "main_div");
		
      	var div_field = document.createElement('div');
           	div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
      	var div_label = document.createElement('div');
         	div_label.setAttribute("align", 'left');
         	div_label.style.display="table-cell";
			div_label.style.width= w_field_label_size+"px";
           	div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
      	var div_element = document.createElement('div');
         	div_element.setAttribute("align", 'left');
          	div_element.style.display="table-cell";
          	div_element.setAttribute("id", i+"_element_sectionform_id_temp");

      	var label = document.createElement('span');
			label.setAttribute("id", i+"_element_labelform_id_temp");
			label.innerHTML = w_field_label;
			label.setAttribute("class", "label");
			label.style.verticalAlign="top";
	    
      	var required = document.createElement('span');
			required.setAttribute("id", i+"_required_elementform_id_temp");
			required.innerHTML = "";
			required.setAttribute("class", "required");
			required.style.verticalAlign="top";
	if(w_required=="yes")
			required.innerHTML = " *";
      	var main_td  = document.getElementById('show_table');
	
      
      	div_label.appendChild(label);
      	div_label.appendChild(required);
      	div_element.appendChild(adding_type);
      	div_element.appendChild(adding_required);
       	div_element.appendChild(adding_unique);
     	div_element.appendChild(adding);
      	div_field.appendChild(div_label);
      	div_field.appendChild(div_element);
		
      	div.appendChild(div_field);
      	main_td.appendChild(div);
	if(w_field_label_pos=="top")
				label_top(i);
change_class(w_class, i);
refresh_attr(i, 'type_text');
}

function type_textarea(i, w_field_label, w_field_label_size, w_field_label_pos, w_size_w, w_size_h, w_first_val, w_title, w_required, w_unique, w_class, w_attr_name, w_attr_value){
    
	document.getElementById("element_type").value="type_textarea";
	delete_last_child();

	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
		  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
        el_label_textarea.setAttribute("id", "edit_for_label");
        el_label_textarea.setAttribute("rows", "4");
        
        el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";

	if(w_field_label_pos == "top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_size_label = document.createElement('label');
		el_size_label.setAttribute("class", "fm-field-label");
	    el_size_label.setAttribute("for", "edit_for_input_size");
		el_size_label.innerHTML = "Field size(px) ";
		
	var el_size_w = document.createElement('input');
		el_size_w.setAttribute("id", "edit_for_input_size");
		el_size_w.setAttribute("type", "text");
		el_size_w.setAttribute("value", w_size_w);
		el_size_w.style.cssText = "margin-right:2px; width: 60px";
		el_size_w.setAttribute("onKeyPress", "return check_isnum(event)");
        el_size_w.setAttribute("onKeyUp", "change_w_style('"+i+"_elementform_id_temp', this.value)");
		   
		X = document.createTextNode("x");
		
	var el_size_h = document.createElement('input');
		el_size_h.setAttribute("id", "edit_for_input_size");
		el_size_h.setAttribute("type", "text");
		el_size_h.setAttribute("value", w_size_h);
		el_size_h.style.cssText = "margin-left:2px;  width:60px";
		el_size_h.setAttribute("onKeyPress", "return check_isnum(event)");
        el_size_h.setAttribute("onKeyUp", "change_h_style('"+i+"_elementform_id_temp', this.value)");
		
	var el_first_value_label = document.createElement('label');
		el_first_value_label.setAttribute("class", "fm-field-label");
	    el_first_value_label.setAttribute("for", "el_first_value_input");
		el_first_value_label.innerHTML = "Value if empty";
	
	var el_first_value_input = document.createElement('input');
                el_first_value_input.setAttribute("id", "el_first_value_input");
                el_first_value_input.setAttribute("type", "text");
                el_first_value_input.setAttribute("value", w_title);
                
                el_first_value_input.setAttribute("onKeyUp", "change_input_value(this.value,'"+i+"_elementform_id_temp')");
				
	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
	    el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
                el_required.setAttribute("id", "el_required");
                el_required.setAttribute("type", "checkbox");
                el_required.setAttribute("onclick", "set_required('"+i+"_required')");
	if(w_required=="yes")
			    el_required.setAttribute("checked", "checked");
		
	var el_unique_label = document.createElement('label');
		el_unique_label.setAttribute("class", "fm-field-label");
	    el_unique_label.setAttribute("for", "el_unique");
		el_unique_label.innerHTML = "Allow only unique values";
	
	var el_unique = document.createElement('input');
                el_unique.setAttribute("id", "el_unique");
                el_unique.setAttribute("type", "checkbox");
                el_unique.setAttribute("onclick", "set_unique('"+i+"_uniqueform_id_temp')");
	if(w_unique=="yes")
                el_unique.setAttribute("checked", "checked");
		
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
	        el_style_label.setAttribute("for", "el_style_textarea");
			el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
                el_style_textarea.setAttribute("id", "el_style_textarea");
				el_style_textarea.setAttribute("type", "text");
				el_style_textarea.setAttribute("value", w_class);
                
                el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
			
	var el_attr_add = document.createElement('img');
           	el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_text')");
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_text')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_text')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_text')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}

	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br6 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td9.appendChild(el_label_size_label);
	edit_main_td9_1.appendChild(el_label_size);

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_size_label);
	edit_main_td3_1.appendChild(el_size_w);
	edit_main_td3_1.appendChild(X);
	edit_main_td3_1.appendChild(el_size_h);
	
	edit_main_td4.appendChild(el_first_value_label);
	edit_main_td4_1.appendChild(el_first_value_input);
	
	edit_main_td5.appendChild(el_style_label);
	edit_main_td5_1.appendChild(el_style_textarea);
	
	edit_main_td6.appendChild(el_required_label);
	edit_main_td6_1.appendChild(el_required);
	
	edit_main_td8.appendChild(el_unique_label);
	edit_main_td8_1.appendChild(el_unique);

	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br6);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");

	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr7);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_text');

//show table

	element='textarea';
	var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_textarea");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required= document.createElement("input");
            adding_required.setAttribute("type", "hidden");
            adding_required.setAttribute("value", w_required);
            adding_required.setAttribute("name", i+"_requiredform_id_temp");			
            adding_required.setAttribute("id", i+"_requiredform_id_temp");
			
	var adding_unique= document.createElement("input");
            adding_unique.setAttribute("type", "hidden");
            adding_unique.setAttribute("value", w_unique);
            adding_unique.setAttribute("name", i+"_uniqueform_id_temp");
            adding_unique.setAttribute("id", i+"_uniqueform_id_temp");
			
		var div = document.createElement('div');
			div.setAttribute("id", "main_div");
			
      	var div_field = document.createElement('div');
           	div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
      	var div_label = document.createElement('div');
         	div_label.setAttribute("align", 'left');
         	div_label.style.display="table-cell";
          div_label.style.width=w_field_label_size+"px";
          div_label.style.verticalAlign = "top";
           	div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
      	var div_element = document.createElement('div');
         	div_element.setAttribute("align", 'left');
         	div_element.style.display="table-cell";
          	div_element.setAttribute("id", i+"_element_sectionform_id_temp");
			
      	var label = document.createElement('span');
			label.setAttribute("id", i+"_element_labelform_id_temp");
			label.innerHTML = w_field_label;
			label.setAttribute("class", "label");
			label.style.verticalAlign="top";
	    
      	var required = document.createElement('span');
			required.setAttribute("id", i+"_required_elementform_id_temp");
			required.innerHTML = "";
			required.setAttribute("class", "required");
			required.style.verticalAlign="top";
	if(w_required=="yes")
			required.innerHTML = " *";
	var adding = document.createElement(element);
		if(w_title==w_first_val)
		{
			adding.style.cssText = "width:"+w_size_w+"px; height:"+w_size_h+"px;";
			adding.setAttribute("class", "input_deactive");
		}
		else
		{
			adding.style.cssText = "width:"+w_size_w+"px; height:"+w_size_h+"px;";
			adding.setAttribute("class", "input_active");
		}
		adding.setAttribute("id", i+"_elementform_id_temp");
		adding.setAttribute("name", i+"_elementform_id_temp");
		adding.setAttribute("title", w_title);
		adding.setAttribute("value",w_first_val);
		adding.setAttribute("onFocus", "delete_value('"+i+"_elementform_id_temp')");
		adding.setAttribute("onBlur", "return_value('"+i+"_elementform_id_temp')");
		adding.setAttribute("onChange", "change_value('"+i+"_elementform_id_temp')");
		adding.innerHTML=w_first_val;
		
		var main_td  = document.getElementById('show_table');
      
      	div_label.appendChild(label);
      	div_label.appendChild(required);
      	div_element.appendChild(adding_type);
      	div_element.appendChild(adding_required);
      	div_element.appendChild(adding_unique);
      	div_element.appendChild(adding);
      	div_field.appendChild(div_label);
      	div_field.appendChild(div_element);
      
      	div.appendChild(div_field);
      	main_td.appendChild(div);
	if(w_field_label_pos=="top")
				label_top(i);
change_class(w_class, i);
refresh_attr(i, 'type_text');
}

function type_wdeditor(i, w_field_label,  w_field_label_size, w_field_label_pos, w_size_w, w_size_h, w_title, w_required, w_class, w_attr_name, w_attr_value){
    
	document.getElementById("element_type").value="type_wdeditor";

	delete_last_child();
// edit table	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
      	var edit_main_tr2  = document.createElement('tr');

	var edit_main_tr3  = document.createElement('tr');
  	var edit_main_tr4  = document.createElement('tr');
	
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');

	var edit_main_tr7  = document.createElement('tr');


	var edit_main_tr8  = document.createElement('tr');


	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');	
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
		edit_main_td3_1.style.cssText = "padding-top:10px";
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
		edit_main_td4_1.style.cssText = "padding-top:10px";
		
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
		edit_main_td5_1.style.cssText = "padding-top:10px";
				
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
		edit_main_td6_1.style.cssText = "padding-top:10px";

	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
		  
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
		  
	var el_label_label = document.createElement('label');
			        el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
			el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
                el_label_textarea.setAttribute("id", "edit_for_label");
                el_label_textarea.setAttribute("rows", "4");
                
                el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
				el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
			        el_label_position_label.setAttribute("class", "fm-field-label");
	    el_label_position_label.setAttribute("for", "edit_for_label_position_top");
		el_label_position_label.innerHTML = "Field label position";
	
	var el_label_position1 = document.createElement('input');
                el_label_position1.setAttribute("id", "edit_for_label_position_top");
                el_label_position1.setAttribute("type", "radio");
                el_label_position1.setAttribute("value", "left");
                

                el_label_position1.setAttribute("name", "edit_for_label_position");
                el_label_position1.setAttribute("onchange", "label_left("+i+")");
		Left = document.createTextNode("Left");
		
	var el_label_position2 = document.createElement('input');
                el_label_position2.setAttribute("id", "edit_for_label_position_left");
                el_label_position2.setAttribute("type", "radio");
                el_label_position2.setAttribute("value", "top");
	

                el_label_position2.setAttribute("name", "edit_for_label_position");
                el_label_position2.setAttribute("onchange", "label_top("+i+")");
		Top = document.createTextNode("Top");
		
	if(w_field_label_pos=="top")
				el_label_position2.setAttribute("checked", "checked");
	else
				el_label_position1.setAttribute("checked", "checked");

	var el_size_label = document.createElement('label');
	        el_size_label.style.cssText ="color:#000; font-weight:bold; font-size: 13px";
		el_size_label.innerHTML = "Field size(px) ";
		
	var el_size_w = document.createElement('input');
		   el_size_w.setAttribute("id", "edit_for_input_size");
		   el_size_w.setAttribute("type", "text");
		   el_size_w.setAttribute("value", w_size_w);
		   el_size_w.style.cssText = "margin-right:2px; width: 60px";
		   el_size_w.setAttribute("name", "edit_for_size");
		   el_size_w.setAttribute("onKeyPress", "return check_isnum(event)");
           el_size_w.setAttribute("onKeyUp", "change_w_style('"+i+"_elementform_id_temp', this.value)");
		   
		X = document.createTextNode("x");
		
	var el_size_h = document.createElement('input');
		   el_size_h.setAttribute("id", "edit_for_input_size");
		   el_size_h.setAttribute("type", "text");
		   el_size_h.setAttribute("value", w_size_h);
		   el_size_h.style.cssText = "margin-left:2px;  width:60px";
			el_size_h.setAttribute("name", "edit_for_size");
			el_size_h.setAttribute("onKeyPress", "return check_isnum(event)");
            el_size_h.setAttribute("onKeyUp", "change_h_style('"+i+"_elementform_id_temp', this.value)");
			
	var el_first_value_label = document.createElement('label');
	        el_first_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 13px";
		el_first_value_label.innerHTML = "Value if empty";
	
	var el_first_value_input = document.createElement('input');
                el_first_value_input.setAttribute("id", "el_first_value_input");
                el_first_value_input.setAttribute("type", "text");
                el_first_value_input.setAttribute("value", w_title);
                
                el_first_value_input.setAttribute("onKeyUp", "change_input_value(this.value,'"+i+"_elementform_id_temp')");
	var el_required_label = document.createElement('label');
	        el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_send");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
                el_required.setAttribute("id", "el_send");
                el_required.setAttribute("type", "checkbox");
                el_required.setAttribute("value", "yes");
                el_required.setAttribute("onclick", "set_required('"+i+"_required')");
	if(w_required=="yes")
			    el_required.setAttribute("checked", "checked");
		

		
	var el_style_label = document.createElement('label');
	        el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "element_style");
			el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
                el_style_textarea.setAttribute("id", "element_style");
				el_style_textarea.setAttribute("type", "text");
				el_style_textarea.setAttribute("value", w_class);
                
                el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_attr_label = document.createElement('label');
	                el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.setAttribute("for", "el_choices_add");
			el_attr_label.innerHTML = "Additional Attributes";
			
	var el_attr_add = document.createElement('img');
                el_attr_add.setAttribute("id", "el_choices_add");
           	el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_text')");
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_text')");
			
		var el_attr_value = document.createElement('input');
	
			el_attr_value.setAttribute("type", "text");
	
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_text')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("align", 'top');
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_text')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}

	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);

	edit_main_td8.appendChild(el_label_size_label);
	edit_main_td8_1.appendChild(el_label_size);
	
	
	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_size_label);
	
	edit_main_td3_1.appendChild(el_size_w);
	edit_main_td3_1.appendChild(X);
	edit_main_td3_1.appendChild(el_size_h);
	
	edit_main_td4.appendChild(el_first_value_label);
	edit_main_td4_1.appendChild(el_first_value_input);
	
	edit_main_td5.appendChild(el_style_label);
	edit_main_td5_1.appendChild(el_style_textarea);
	
	edit_main_td6.appendChild(el_required_label);
	edit_main_td6_1.appendChild(el_required);
	
	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br6);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");

	
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);

	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);

	edit_main_table.appendChild(edit_main_tr7);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_text');

//show table

	element='editor';
	var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_wdeditor");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required= document.createElement("input");
            adding_required.setAttribute("type", "hidden");
            adding_required.setAttribute("value", w_required);
            adding_required.setAttribute("name", i+"_requiredform_id_temp");			
            adding_required.setAttribute("id", i+"_requiredform_id_temp");
			
	
			
	var div = document.createElement('div');
      	div.setAttribute("id", "main_div");
		

		var div_field = document.createElement('div');
           	div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
      	var div_label = document.createElement('div');
         	div_label.setAttribute("align", 'left');
         	div_label.style.display="table-cell";
			div_label.style.width=w_field_label_size+"px";
           	div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
      	var div_element = document.createElement('div');
         	div_element.setAttribute("align", 'left');
          	div_element.style.display="table-cell";
          	div_element.setAttribute("id", i+"_element_sectionform_id_temp");
		
		
			
      	var br1 = document.createElement('br');
      	var br2 = document.createElement('br');
     	var br3 = document.createElement('br');
      	var br4 = document.createElement('br');
      
      	var label = document.createElement('span');
			label.setAttribute("id", i+"_element_labelform_id_temp");
			label.innerHTML = w_field_label;
			label.setAttribute("class", "label");
	    
      	var required = document.createElement('span');
			required.setAttribute("id", i+"_required_elementform_id_temp");
			required.innerHTML = "";
			required.setAttribute("class", "required");
	if(w_required=="yes")
			required.innerHTML = " *";
			
			
			
	var adding = document.createElement('input');
		adding.setAttribute("id", i+"_elementform_id_temp");
		adding.setAttribute("name", i+"_elementform_id_temp");
		adding.setAttribute("type", "hidden");
		adding.style.width = w_size_w+"px";
		adding.style.height = w_size_h+"px";
		adding.setAttribute("title", w_title);

	var adding_text = document.createElement('span');
		adding_text.style.color="red";
		adding_text.style.fontStyle="italic";
		adding_text.innerHTML="Editor doesn't display in back end";		
	
	Left = document.createTextNode(i+"_editorform_id_temp");
	var div_for_editor = document.createElement('div');
		div_for_editor.style.display="none";
	
		var main_td  = document.getElementById('show_table');
	
      
      	div_label.appendChild(label);
      	div_label.appendChild(required);
      	div_element.appendChild(adding_type);
	
      	div_element.appendChild(adding_required);

      	div_element.appendChild(adding);
		div_element.appendChild(adding_text);
		div_for_editor.appendChild(Left);
		div_element.appendChild(div_for_editor);
      	div_field.appendChild(div_label);
      	div_field.appendChild(div_element);
      
      
      	div.appendChild(div_field);
      	div.appendChild(br3);
      	main_td.appendChild(div);
	if(w_field_label_pos=="top")
				label_top(i);
change_class(w_class, i);
refresh_attr(i, 'type_text');
}




function type_phone(i, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_first_val, w_title, w_mini_labels, w_required, w_unique, w_class, w_attr_name, w_attr_value) {
	
	document.getElementById("element_type").value="type_phone";
	delete_last_child();
	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
		  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
                el_label_textarea.setAttribute("id", "edit_for_label");
                el_label_textarea.setAttribute("rows", "4");
                
                el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
				el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");

	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_size_label = document.createElement('label');
		el_size_label.setAttribute("class", "fm-field-label");
	        el_size_label.setAttribute("for", "edit_for_input_size");
			el_size_label.innerHTML = "Field size(px) ";
	var el_size = document.createElement('input');
			el_size.setAttribute("id", "edit_for_input_size");
			el_size.setAttribute("type", "text");
			el_size.setAttribute("value", w_size);			
			el_size.setAttribute("onKeyPress", "return check_isnum(event)");
            el_size.setAttribute("onKeyUp", "change_w_style('"+i+"_element_lastform_id_temp', this.value);");

	var gic = document.createTextNode("-");

	var el_first_value_label = document.createElement('label');
		el_first_value_label.setAttribute("class", "fm-field-label");
		el_first_value_label.setAttribute("for", "el_first_value_area");
		el_first_value_label.innerHTML = "Value if empty ";
	
	var el_first_value_area = document.createElement('input');
                el_first_value_area.setAttribute("id", "el_first_value_area");
                el_first_value_area.setAttribute("type", "text");
                el_first_value_area.setAttribute("value", w_title[0]);
				el_first_value_area.style.cssText = "width:66px;";
                el_first_value_area.setAttribute("onKeyUp", "change_input_value(this.value,'"+i+"_element_firstform_id_temp')");

	var el_first_value_phone = document.createElement('input');
                el_first_value_phone.setAttribute("id", "el_first_value_phone");
                el_first_value_phone.setAttribute("type", "text");
                el_first_value_phone.setAttribute("value", w_title[1]);
                el_first_value_phone.style.cssText = "width:127px;";

                el_first_value_phone.setAttribute("onKeyUp", "change_input_value(this.value,'"+i+"_element_lastform_id_temp')");


	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
	        el_required_label.setAttribute("for", "el_required");
			el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
                el_required.setAttribute("id", "el_required");
                el_required.setAttribute("type", "checkbox");
                el_required.setAttribute("onclick", "set_required('"+i+"_required')");
	if(w_required=="yes")
                el_required.setAttribute("checked", "checked");	

	var el_unique_label = document.createElement('label');
		el_unique_label.setAttribute("class", "fm-field-label");
				el_unique_label.setAttribute("for", "el_unique");
				el_unique_label.innerHTML = "Allow only unique values";
	
	var el_unique = document.createElement('input');
                el_unique.setAttribute("id", "el_unique");
                el_unique.setAttribute("type", "checkbox");
                el_unique.setAttribute("onclick", "set_unique('"+i+"_uniqueform_id_temp')");
	if(w_unique=="yes")
                el_unique.setAttribute("checked", "checked");
				
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
	        el_style_label.setAttribute("for", "el_style_textarea");
			el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
                el_style_textarea.setAttribute("id", "el_style_textarea");
				el_style_textarea.setAttribute("type", "text");
				el_style_textarea.setAttribute("value", w_class);
                
                el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
				el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
				el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_name')");
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
				el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_name')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_name')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_name')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}

		
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);

	edit_main_td9.appendChild(el_label_size_label);
	edit_main_td9_1.appendChild(el_label_size);
	
	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_first_value_label);
	edit_main_td3_1.appendChild(el_first_value_area);
	edit_main_td3_1.appendChild(gic);
	edit_main_td3_1.appendChild(el_first_value_phone);
	
	
	edit_main_td7.appendChild(el_size_label);
	edit_main_td7_1.appendChild(el_size);
	
	edit_main_td4.appendChild(el_style_label);
	edit_main_td4_1.appendChild(el_style_textarea);
	
	edit_main_td5.appendChild(el_required_label);
	edit_main_td5_1.appendChild(el_required);
	
	edit_main_td8.appendChild(el_unique_label);
	edit_main_td8_1.appendChild(el_unique);
	
	
	
	
	edit_main_td6.appendChild(el_attr_label);
	edit_main_td6.appendChild(el_attr_add);
	edit_main_td6.appendChild(br3);
	edit_main_td6.appendChild(el_attr_table);
	edit_main_td6.setAttribute("colspan", "2");
	
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr6);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_name');

//show table

	var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_phone");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
			
	var adding_required= document.createElement("input");
            adding_required.setAttribute("type", "hidden");
            adding_required.setAttribute("value", w_required);
            adding_required.setAttribute("name", i+"_requiredform_id_temp");
            adding_required.setAttribute("id", i+"_requiredform_id_temp");
			
	var adding_unique= document.createElement("input");
            adding_unique.setAttribute("type", "hidden");
            adding_unique.setAttribute("value", w_unique);
            adding_unique.setAttribute("name", i+"_uniqueform_id_temp");
            adding_unique.setAttribute("id", i+"_uniqueform_id_temp");
	    
     	var div = document.createElement('div');
      	    div.setAttribute("id", "main_div");
			
		var div_for_editable_labels = document.createElement('div');
			div_for_editable_labels.setAttribute("class", "fm-editable-label");
			
      	edit_labels = document.createTextNode("The labels of the fields are editable. Please, click the label to edit.");

		div_for_editable_labels.appendChild(edit_labels);  
		
      	var div_field = document.createElement('div');
           	div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
      	var div_label = document.createElement('div');
         	div_label.setAttribute("align", 'left');
         	div_label.style.display="table-cell";
			div_label.style.width=w_field_label_size+"px";
           	div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
      	var div_element = document.createElement('div');
         	div_element.setAttribute("align", 'left');
          	div_element.style.display="table-cell";
          	div_element.setAttribute("id", i+"_element_sectionform_id_temp");
			
      	var table_name = document.createElement('div');
		    table_name.style.display="table";
           	table_name.setAttribute("id", i+"_table_name");
			
      	var tr_name1 = document.createElement('div');
 		    tr_name1.style.display="table-row";
          	tr_name1.setAttribute("id", i+"_tr_name1");
			
      	var tr_name2 = document.createElement('div');
 		    tr_name2.style.display="table-row";
           	tr_name2.setAttribute("id", i+"_tr_name2");
			
      	var td_name_input1 = document.createElement('div');
  		    td_name_input1.style.display="table-cell";
          	td_name_input1.setAttribute("id", i+"_td_name_input_first");
			
      	var td_name_input2 = document.createElement('div');
  		    td_name_input2.style.display="table-cell";
          	td_name_input2.setAttribute("id", i+"_td_name_input_last");
		
      	var td_name_label1 = document.createElement('div');
 		    td_name_label1.style.display="table-cell";
           	td_name_label1.setAttribute("id", i+"_td_name_label_first");
           	td_name_label1.setAttribute("align", "left");
			
      	var td_name_label2 = document.createElement('div');
  		    td_name_label2.style.display="table-cell";
          	td_name_label2.setAttribute("id", i+"_td_name_label_last");
           	td_name_label2.setAttribute("align", "left");
			
      	var label = document.createElement('span');
			label.setAttribute("id", i+"_element_labelform_id_temp");
			label.innerHTML = w_field_label;
			label.setAttribute("class", "label");
			label.style.verticalAlign="top";
	    
      	var required = document.createElement('span');
			required.setAttribute("id", i+"_required_elementform_id_temp");
			required.innerHTML = "";
			required.setAttribute("class", "required");
	if(w_required=="yes")
			required.innerHTML = " *";	
			
	var first = document.createElement('input');
        first.setAttribute("type", 'text');
		if(w_title[0]==w_first_val[0])
			first.setAttribute("class", "input_deactive");
		else
			first.setAttribute("class", "input_active");
	    first.style.cssText = "width:50px";
	    first.setAttribute("id", i+"_element_firstform_id_temp");
	    first.setAttribute("name", i+"_element_firstform_id_temp");
		first.setAttribute("value", w_first_val[0]);
		first.setAttribute("title", w_title[0]);
		first.setAttribute("onFocus", 'delete_value("'+i+'_element_firstform_id_temp")');
		first.setAttribute("onBlur", 'return_value("'+i+'_element_firstform_id_temp")');
	    first.setAttribute("onChange", "change_value('"+i+"_element_firstform_id_temp')");
		first.setAttribute("onKeyPress", "return check_isnum(event)");
		
	var gic = document.createElement('span');
	    gic.setAttribute("class", "wdform_line");
		gic.style.cssText = "margin: 0px 4px 0px 4px; padding: 0px;";
		gic.innerHTML = "-";	

	var first_label = document.createElement('label');
	    first_label.setAttribute("class", "mini_label");
	    first_label.setAttribute("id", i+"_mini_label_area_code");
	    first_label.innerHTML= w_mini_labels[0];
			
	var last = document.createElement('input');
        last.setAttribute("type", 'text');
 		if(w_title[1]==w_first_val[1])
			last.setAttribute("class", "input_deactive");
		else
			last.setAttribute("class", "input_active");
	    last.style.cssText = "width:"+w_size+"px";
		last.setAttribute("id", i+"_element_lastform_id_temp");
	   	last.setAttribute("name", i+"_element_lastform_id_temp");
		last.setAttribute("value", w_first_val[1]);
		last.setAttribute("title", w_title[1]);
		last.setAttribute("onFocus", 'delete_value("'+i+'_element_lastform_id_temp")');
		last.setAttribute("onBlur", 'return_value("'+i+'_element_lastform_id_temp")');
		last.setAttribute("onChange", "change_value('"+i+"_element_lastform_id_temp')");
		last.setAttribute("onKeyPress", "return check_isnum(event)");

	var last_label = document.createElement('label');
		last_label.setAttribute("class", "mini_label");
		last_label.setAttribute("id", i+"_mini_label_phone_number");
		last_label.innerHTML=w_mini_labels[1];
			
    var main_td  = document.getElementById('show_table');
      
      	div_label.appendChild(label);
      	div_label.appendChild(required );
		
      	td_name_input1.appendChild(first);
      	td_name_input1.appendChild(gic);
      	td_name_input2.appendChild(last);
      	tr_name1.appendChild(td_name_input1);
      	tr_name1.appendChild(td_name_input2);
      	td_name_label1.appendChild(first_label);
      	td_name_label2.appendChild(last_label);
      	tr_name2.appendChild(td_name_label1);
      	tr_name2.appendChild(td_name_label2);
      	table_name.appendChild(tr_name1);
      	table_name.appendChild(tr_name2);
       	div_element.appendChild(adding_type);
       	div_element.appendChild(adding_required);
       	div_element.appendChild(adding_unique);
    	div_element.appendChild(table_name);
      	div_field.appendChild(div_label);
      	div_field.appendChild(div_element);
      	div.appendChild(div_field);
		div.appendChild(br1);
		div.appendChild(div_for_editable_labels);
      	main_td.appendChild(div);
		
	if(w_field_label_pos=="top")
				label_top(i);

change_class(w_class, i);
refresh_attr(i, 'type_name');

jQuery(document).ready(function() {	
	jQuery("label#"+i+"_mini_label_area_code").click(function() {		
	if (jQuery(this).children('input').length == 0) {		

		var area_code = "<input type='text' class='area_code' size='10' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";		

		jQuery(this).html(area_code);		
		jQuery("input.area_code").focus();		
		jQuery("input.area_code").blur(function() {	

		var value = jQuery(this).val();			
		jQuery("#"+i+"_mini_label_area_code").text(value);		
		});		
	}	
	});	

	
	jQuery("label#"+i+"_mini_label_phone_number").click(function() {		

	if (jQuery(this).children('input').length == 0) {			
		var phone_number = "<input type='text' class='phone_number'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";						

		jQuery(this).html(phone_number);					

		jQuery("input.phone_number").focus();			
		jQuery("input.phone_number").blur(function() {		
		
		var value = jQuery(this).val();			
		jQuery("#"+i+"_mini_label_phone_number").text(value);		
		});	
	}	
	});
	
	});


}

function change_input_range(type, id)
{
	var s='';
	if(document.getElementById('el_range_'+type+'1').value!='')
		s=document.getElementById('el_range_'+type+'1').value;

	if(document.getElementById('el_range_'+type+'2').value!='')
	{
		if(document.getElementById('el_range_'+type+'1').value=='')
			s='0';			

		s=s+'.'+document.getElementById('el_range_'+type+'2').value;
	}
	
	document.getElementById(id+'_range_'+type+'form_id_temp').value=s;
}
function explode( delimiter, string ) {	
	var emptyArray = { 0: '' };

	if ( arguments.length != 2	|| typeof arguments[0] == 'undefined'	|| typeof arguments[1] == 'undefined' )
	{
		return null;
	}

	if ( delimiter === '' || delimiter === false	|| delimiter === null )
	{
		return false;
	}

	if ( typeof delimiter == 'function'	|| typeof delimiter == 'object'	|| typeof string == 'function'	|| typeof string == 'object' )
	{
		return emptyArray;
	}

	if ( delimiter === true ) {
		delimiter = '1';
	}

	return string.toString().split ( delimiter.toString() );
}



function type_paypal_price(i, w_field_label, w_field_label_size, w_field_label_pos, w_first_val, w_title, w_mini_labels, w_size, w_required, w_hide_cents, w_class, w_attr_name, w_attr_value, w_range_min, w_range_max) {
	
	document.getElementById("element_type").value="type_paypal_price";
	delete_last_child();
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10  = document.createElement('tr');
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
		edit_main_td3_1.style.cssText = "line-height:20px";
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');
		  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	w_range_minarray = explode('.', w_range_min);
	w_range_maxarray = explode('.', w_range_max);
				
	var el_range_label = document.createElement('label');
		el_range_label.setAttribute("class", "fm-field-label");
		el_range_label.innerHTML = "Range ";
	
	var min = document.createTextNode("Min");
	
	var el_range_min1 = document.createElement('input');
        el_range_min1.setAttribute("type", "text");
        el_range_min1.setAttribute("id", "el_range_min1");
	if(w_range_minarray[0])
        el_range_min1.setAttribute("value", w_range_minarray[0]);
        el_range_min1.style.cssText = "width:60px; margin-right:4px;margin-left:8px";
		el_range_min1.setAttribute("onKeyPress", "return check_isnum(event)");
        el_range_min1.setAttribute("onChange", "change_input_range('min', '"+i+"')");

	var ket_min = document.createTextNode(".");

	var el_range_min2 = document.createElement('input');
        el_range_min2.setAttribute("type", "text");
        el_range_min2.setAttribute("id", "el_range_min2");
	if(w_range_minarray[1])
        el_range_min2.setAttribute("value", w_range_minarray[1]);
        el_range_min2.style.cssText = "width:30px; margin-left:4px";
		el_range_min2.setAttribute("onKeyPress", "return check_isnum(event)");
        el_range_min2.setAttribute("onChange", "change_input_range('min', '"+i+"')");

	var max = document.createTextNode("Max");
	
	var el_range_max1 = document.createElement('input');
        el_range_max1.setAttribute("type", "text");
        el_range_max1.setAttribute("id", "el_range_max1");
	if(w_range_maxarray[0])
        el_range_max1.setAttribute("value", w_range_maxarray[0]);
        el_range_max1.style.cssText = "width:60px; margin-right:4px; margin-left:7px";
		el_range_max1.setAttribute("onKeyPress", "return check_isnum(event)");
        el_range_max1.setAttribute("onChange", "change_input_range('max', '"+i+"')");

	var ket_max = document.createTextNode(".");

	var el_range_max2 = document.createElement('input');
        el_range_max2.setAttribute("type", "text");
        el_range_max2.setAttribute("id", "el_range_max2");
	if(w_range_maxarray[1])
        el_range_max2.setAttribute("value", w_range_maxarray[1]);
        el_range_max2.style.cssText = "width:30px; margin-left:4px";
		el_range_max2.setAttribute("onKeyPress", "return check_isnum(event)");
        el_range_max2.setAttribute("onChange", "change_input_range('max', '"+i+"')");

	var gic = document.createTextNode("-");

	var el_first_value_label = document.createElement('label');
		el_first_value_label.setAttribute("class", "fm-field-label");
		el_first_value_label.setAttribute("for", "el_first_value_first");
		el_first_value_label.innerHTML = "Value if empty ";
	
	var el_first_value_first = document.createElement('input');
		el_first_value_first.setAttribute("id", "el_first_value_first");
		el_first_value_first.setAttribute("type", "text");
		el_first_value_first.setAttribute("value", w_title[0]);
		el_first_value_first.style.cssText = "width:120px; margin-right:4px";
		el_first_value_first.setAttribute("onKeyPress", "return check_isnum(event)");
		el_first_value_first.setAttribute("onKeyUp", "change_input_value(this.value,'"+i+"_element_dollarsform_id_temp')");

	var el_first_value_last = document.createElement('input');
		el_first_value_last.setAttribute("id", "el_first_value_last");
		el_first_value_last.setAttribute("type", "text");
		el_first_value_last.setAttribute("value", w_title[1]);
		el_first_value_last.style.cssText = "width:67px; margin-left:4px; margin-right:4px";
		el_first_value_last.setAttribute("onKeyPress", "return check_isnum_interval(event,'"+i+"_element_centsform_id_temp',0,99)");
		el_first_value_last.setAttribute("onKeyUp", "change_input_value(this.value,'"+i+"_element_centsform_id_temp')");

	var el_size_label = document.createElement('label');
		el_size_label.setAttribute("class", "fm-field-label");
		el_size_label.setAttribute("for", "edit_for_input_size");
		el_size_label.innerHTML = "Field size(px) ";
	var el_size = document.createElement('input');
		el_size.setAttribute("id", "edit_for_input_size");
		el_size.setAttribute("type", "text");
		el_size.setAttribute("value", w_size);
		el_size.setAttribute("onKeyPress", "return check_isnum(event)");
		el_size.setAttribute("onKeyUp", "change_w_style('"+i+"_element_dollarsform_id_temp', this.value);");

	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_required");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required=="yes")
			el_required.setAttribute("checked", "checked");	
				
	var el_hide_cents_label = document.createElement('label');
		el_hide_cents_label.setAttribute("class", "fm-field-label");
	    el_hide_cents_label.setAttribute("for", "el_hide_cents");
		el_hide_cents_label.innerHTML = "Hide Cents";

	var el_hide_cents = document.createElement('input');
		el_hide_cents.setAttribute("id", "el_hide_cents");
		el_hide_cents.setAttribute("type", "checkbox");
		el_hide_cents.setAttribute("onclick", "hide_show_cents(this.checked, "+i+")");
		if(w_hide_cents=="yes")
			el_hide_cents.setAttribute("checked", "checked");	
				
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_paypal_price')");
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
	var el_attr_value_label = document.createElement('label');
		el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_paypal_price')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_paypal_price')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_paypal_price')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}

	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);

	edit_main_td10.appendChild(el_label_size_label);
	edit_main_td10_1.appendChild(el_label_size);
	
	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_range_label);
	edit_main_td3_1.appendChild(min);
	edit_main_td3_1.appendChild(el_range_min1);
	edit_main_td3_1.appendChild(ket_min);
	edit_main_td3_1.appendChild(el_range_min2);
	edit_main_td3_1.appendChild(br1);
	edit_main_td3_1.appendChild(max);
	edit_main_td3_1.appendChild(el_range_max1);
	edit_main_td3_1.appendChild(ket_max);
	edit_main_td3_1.appendChild(el_range_max2);

	edit_main_td9.appendChild(el_first_value_label);
	edit_main_td9_1.appendChild(el_first_value_first);
	edit_main_td9_1.appendChild(gic);
	edit_main_td9_1.appendChild(el_first_value_last);
	
	edit_main_td7.appendChild(el_size_label);
	edit_main_td7_1.appendChild(el_size);
	
	edit_main_td4.appendChild(el_style_label);
	edit_main_td4_1.appendChild(el_style_textarea);
	
	edit_main_td5.appendChild(el_required_label);
	edit_main_td5_1.appendChild(el_required);
	
	edit_main_td8.appendChild(el_hide_cents_label);
	edit_main_td8_1.appendChild(el_hide_cents);
	
	
	
	
	edit_main_td6.appendChild(el_attr_label);
	edit_main_td6.appendChild(el_attr_add);
	edit_main_td6.appendChild(br3);
	edit_main_td6.appendChild(el_attr_table);
	edit_main_td6.setAttribute("colspan", "2");
	
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr6);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_name');
	
//show table

	var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_paypal_price");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
			
	var adding_required= document.createElement("input");
            adding_required.setAttribute("type", "hidden");
            adding_required.setAttribute("value", w_required);
            adding_required.setAttribute("name", i+"_requiredform_id_temp");
            adding_required.setAttribute("id", i+"_requiredform_id_temp");
			
	var adding_range_min= document.createElement("input");
            adding_range_min.setAttribute("type", "hidden");
            adding_range_min.setAttribute("value", w_range_min);
            adding_range_min.setAttribute("name", i+"_range_minform_id_temp");
            adding_range_min.setAttribute("id", i+"_range_minform_id_temp");
			
	var adding_range_max= document.createElement("input");
            adding_range_max.setAttribute("type", "hidden");
            adding_range_max.setAttribute("value", w_range_max);
            adding_range_max.setAttribute("name", i+"_range_maxform_id_temp");
            adding_range_max.setAttribute("id", i+"_range_maxform_id_temp");
			
     	var div = document.createElement('div');
      	    div.setAttribute("id", "main_div");
		var div_for_editable_labels = document.createElement('div');
			div_for_editable_labels.setAttribute("class", "fm-editable-label");
			
      	edit_labels = document.createTextNode("The labels of the fields are editable. Please, click the label to edit.");

		div_for_editable_labels.appendChild(edit_labels);  

		
					
      	var div_field = document.createElement('div');
           	div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
      	var div_label = document.createElement('div');
         	div_label.setAttribute("align", 'left');
         	div_label.style.display="table-cell";
			div_label.style.width=w_field_label_size+"px";
           	div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
      	var div_element = document.createElement('div');
         	div_element.setAttribute("align", 'left');
          	div_element.style.display="table-cell";
          	div_element.setAttribute("id", i+"_element_sectionform_id_temp");
			
      	var table_price = document.createElement('div');
           	table_price.setAttribute("id", i+"_table_price");
			table_price.style.display="table";
			
      	var tr_price1 = document.createElement('div');
           	tr_price1.setAttribute("id", i+"_tr_price1");
			tr_price1.style.display="table-row";
			
      	var tr_price2 = document.createElement('div');
           	tr_price2.setAttribute("id", i+"_tr_price2");
			tr_price2.style.display="table-row";
			
      	var td_name_currency = document.createElement('div');
           	td_name_currency.setAttribute("id", i+"_td_name_currency");
			td_name_currency.style.display="table-cell";
			
      	var td_name_dollars = document.createElement('div');
           	td_name_dollars.setAttribute("id", i+"_td_name_dollars");
			td_name_dollars.style.display="table-cell";
			
       	var td_name_ket = document.createElement('div');
           	td_name_ket.setAttribute("id", i+"_td_name_divider");
			td_name_ket.style.display="table-cell";
		
     	var td_name_cents = document.createElement('div');
           	td_name_cents.setAttribute("id", i+"_td_name_cents");
			td_name_cents.style.display="table-cell";
			
      	var td_name_label_currency = document.createElement('div');
			td_name_label_currency.style.display="table-cell";
			
      	var td_name_label_dollars = document.createElement('div');
           	td_name_label_dollars.setAttribute("align", "left");
			td_name_label_dollars.style.display="table-cell";
			
      	var td_name_label_ket = document.createElement('div');
           	td_name_label_ket.setAttribute("id", i+"_td_name_label_divider");
			td_name_label_ket.style.display="table-cell";
			
      	var td_name_label_cents = document.createElement('div');
	        td_name_label_cents.setAttribute("align", "left");
           	td_name_label_cents.setAttribute("id", i+"_td_name_label_cents");
			td_name_label_cents.style.display="table-cell";
		
    var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
		label.style.verticalAlign="top";
	    
    var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
		required.style.verticalAlign="top";
		
	if(w_required=="yes")
		required.innerHTML = " *";	
		
	var currency = document.createElement('span');
		currency.setAttribute("class", 'wdform_colon');
		currency.style.cssText = "font-style:bold; vertical-align:middle";
		currency.innerHTML="<!--repstart-->&nbsp;$&nbsp;<!--repend-->";

	var currency_label = document.createElement('label');
	    currency_label.setAttribute("class", "mini_label");

	var dollars = document.createElement('input');
        dollars.setAttribute("type", 'text');
		if(w_title[0]==w_first_val[0])
			dollars.setAttribute("class", "input_deactive");
		else
			dollars.setAttribute("class", "input_active");
	    dollars.style.cssText = "width:"+w_size+"px";
	    dollars.setAttribute("id", i+"_element_dollarsform_id_temp");
	    dollars.setAttribute("name", i+"_element_dollarsform_id_temp");
		dollars.setAttribute("value", w_first_val[0]);
		dollars.setAttribute("title", w_title[0]);
		dollars.setAttribute("onFocus", 'delete_value("'+i+'_element_dollarsform_id_temp")');
		dollars.setAttribute("onBlur", 'return_value("'+i+'_element_dollarsform_id_temp")');
	    dollars.setAttribute("onChange", "change_value('"+i+"_element_dollarsform_id_temp')");
		dollars.setAttribute("onKeyPress", "return check_isnum(event)");
			
	var dollars_label = document.createElement('label');
	    dollars_label.setAttribute("class", "mini_label");
	    dollars_label.setAttribute("id", i+"_mini_label_dollars");
		dollars_label.innerHTML= w_mini_labels[0];
		
	var ket = document.createElement('span');
        ket.setAttribute("class", 'wdform_colon');
		ket.style.cssText = "font-style:bold; vertical-align:middle";
		ket.innerHTML="&nbsp;.&nbsp;";

	var ket_label = document.createElement('label');
	    ket_label.setAttribute("class", "mini_label");

	var cents = document.createElement('input');
        cents.setAttribute("type", 'text');
		if(w_title[1]==w_first_val[1])
			cents.setAttribute("class", "input_deactive");
		else
			cents.setAttribute("class", "input_active");
		cents.style.cssText = "width:30px";
		cents.setAttribute("id", i+"_element_centsform_id_temp");
	   	cents.setAttribute("name", i+"_element_centsform_id_temp");
		cents.setAttribute("value", w_first_val[1]);
		cents.setAttribute("title", w_title[1]);
		cents.setAttribute("onFocus", 'delete_value("'+i+'_element_centsform_id_temp")');
		cents.setAttribute("onBlur", 'return_value("'+i+'_element_centsform_id_temp"); add_0("'+i+'_element_centsform_id_temp")');
		cents.setAttribute("onChange", "change_value('"+i+"_element_centsform_id_temp')");
		cents.setAttribute("onKeyPress", "return check_isnum_interval(event,'"+i+"_element_centsform_id_temp',0,99)");

	var cents_label = document.createElement('label');
		cents_label.setAttribute("class", "mini_label");
		cents_label.setAttribute("id", i+"_mini_label_cents");
		cents_label.innerHTML= w_mini_labels[1];
			
    var main_td  = document.getElementById('show_table');
      	div_label.appendChild(label);
      	div_label.appendChild(required );
      	td_name_currency.appendChild(currency);
      	td_name_dollars.appendChild(dollars);
      	td_name_ket.appendChild(ket);
      	td_name_cents.appendChild(cents);
      	tr_price1.appendChild(td_name_currency);
      	tr_price1.appendChild(td_name_dollars);
      	tr_price1.appendChild(td_name_ket);
      	tr_price1.appendChild(td_name_cents);
      	td_name_label_currency.appendChild(currency_label);
      	td_name_label_dollars.appendChild(dollars_label);
      	td_name_label_ket.appendChild(ket_label);
      	td_name_label_cents.appendChild(cents_label);
      	tr_price2.appendChild(td_name_label_currency);
      	tr_price2.appendChild(td_name_label_dollars);
      	tr_price2.appendChild(td_name_label_ket);
      	tr_price2.appendChild(td_name_label_cents);
      	table_price.appendChild(tr_price1);
      	table_price.appendChild(tr_price2);
       	div_element.appendChild(adding_type);
       	div_element.appendChild(adding_required);
       	div_element.appendChild(adding_range_min);
       	div_element.appendChild(adding_range_max);
    	div_element.appendChild(table_price);
      	div_field.appendChild(div_label);
      	div_field.appendChild(div_element);
      	div.appendChild(div_field);
		div.appendChild(br3);
		div.appendChild(div_for_editable_labels);
      	main_td.appendChild(div);
		
	if(w_field_label_pos=="top")
				label_top(i);
				
	if(w_hide_cents=="yes")				
		hide_show_cents(true, i)
		
change_class(w_class, i);
refresh_attr(i, 'type_paypal_price');

jQuery(document).ready(function() {	
	jQuery("label#"+i+"_mini_label_dollars").click(function() {		
		if (jQuery(this).children('input').length == 0) {				
			var dollars = "<input type='text' class='dollars' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
				jQuery(this).html(dollars);							
				jQuery(dollars).focus();			
				jQuery("input.dollars").blur(function() {	
			var value = jQuery(this).val();			


		jQuery("#"+i+"_mini_label_dollars").text(value);		
		});	
	}	
	});		


	jQuery("label#"+i+"_mini_label_cents").click(function() {	
	if (jQuery(this).children('input').length == 0) {		
		var cents = "<input type='text' class='cents'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
			jQuery(this).html(cents);			
			jQuery("input.cents").focus();					
			jQuery("input.cents").blur(function() {			
			var value = jQuery(this).val();			
			
			jQuery("#"+i+"_mini_label_cents").text(value);	
		});	
	}	
	});
	});			
		


}

function hide_show_cents(hide, id)
{
	td_divider			=document.getElementById(id+"_td_name_divider");
	td_cents			=document.getElementById(id+"_td_name_cents");
	td_divider_label	=document.getElementById(id+"_td_name_label_divider");
	td_cents_label		=document.getElementById(id+"_td_name_label_cents");
	change_input_value('',id+'_element_centsform_id_temp');
	document.getElementById("el_first_value_last").value="";
	document.getElementById(id+'_element_centsform_id_temp').value="";

	if(hide)
	{
		td_divider.style.display="none";
		td_cents.style.display="none";
		td_divider_label.style.display="none";
		td_cents_label.style.display="none";

	}
	else
	{
		td_divider.style.display="table-cell";
		td_cents.style.display="table-cell";
		td_divider_label.style.display="table-cell";
		td_cents_label.style.display="table-cell";
	}
}

function type_name(i, w_field_label, w_field_label_size, w_field_label_pos, w_first_val, w_title, w_mini_labels, w_size, w_name_format, w_required, w_unique, w_class, w_attr_name, w_attr_value, w_name_fields) {
	
	document.getElementById("element_type").value="type_name";
	delete_last_child();
	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
		edit_main_tr3.style.cssText = "display:none";
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10  = document.createElement('tr');
	var edit_main_tr11  = document.createElement('tr');
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');
	var edit_main_td11 = document.createElement('td');
	var edit_main_td11_1 = document.createElement('td');
			
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";

if(w_field_label_pos == "top")
	el_label_position2.setAttribute("checked", "checked");
else
	el_label_position1.setAttribute("checked", "checked");

	var gic = document.createTextNode("-");

	var el_first_value_label = document.createElement('label');
		el_first_value_label.setAttribute("class", "fm-field-label");
	    el_first_value_label.setAttribute("for", "el_first_value_input");
		el_first_value_label.innerHTML = "Value if empty ";
	
	var el_first_value_first = document.createElement('input');
		el_first_value_first.setAttribute("id", "el_first_value_first");
		el_first_value_first.setAttribute("type", "text");
		el_first_value_first.setAttribute("value", w_title[0]);
		el_first_value_first.style.cssText = "width:96px;";
		el_first_value_first.setAttribute("onKeyUp", "change_input_value(this.value,'"+i+"_element_firstform_id_temp')");

	var el_first_value_last = document.createElement('input');
		el_first_value_last.setAttribute("id", "el_first_value_last");
		el_first_value_last.setAttribute("type", "text");
		el_first_value_last.setAttribute("value", w_title[1]);
		el_first_value_last.style.cssText = "width:96px;";
		el_first_value_last.setAttribute("onKeyUp", "change_input_value(this.value,'"+i+"_element_lastform_id_temp')");

	var el_size_label = document.createElement('label');
		el_size_label.setAttribute("class", "fm-field-label");
		el_size_label.setAttribute("for", "edit_for_input_size");
		el_size_label.innerHTML = "Field size(px) ";
	var el_size = document.createElement('input');
		el_size.setAttribute("id", "edit_for_input_size");
		el_size.setAttribute("type", "text");
		el_size.setAttribute("value", w_size);
		el_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_size.setAttribute("onKeyUp", "change_w_style('"+i+"_element_firstform_id_temp', this.value); change_w_style('"+i+"_element_lastform_id_temp', this.value); change_w_style('"+i+"_element_middleform_id_temp', this.value)");

	var el_format_label = document.createElement('label');
		el_format_label.setAttribute("class", "fm-field-label");
		el_format_label.setAttribute("for", "el_format_normal");
		el_format_label.innerHTML = "Name Format";
	
	var el_format_normal = document.createElement('input');
		el_format_normal.setAttribute("id", "el_format_normal");
		el_format_normal.setAttribute("type", "radio");
		el_format_normal.setAttribute("value", "normal");
		el_format_normal.setAttribute("name", "edit_for_name_format");
		el_format_normal.setAttribute("onchange", "format_normal("+i+")");
		el_format_normal.setAttribute("checked", "checked");
		Normal = document.createTextNode("Normal");
		
	var el_format_extended = document.createElement('input');
		el_format_extended.setAttribute("id", "el_format_extended");
		el_format_extended.setAttribute("type", "radio");
		el_format_extended.setAttribute("value", "extended");
		el_format_extended.setAttribute("name", "edit_for_name_format");
		el_format_extended.setAttribute("onchange", "format_extended("+i+",'','','','')");
		Extended = document.createTextNode("Extended");
		
	if(w_name_format=="normal")
		el_format_normal.setAttribute("checked", "checked");
	else
		el_format_extended.setAttribute("checked", "checked");

	////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////	

	var el_enable_field_label = document.createElement('label');
		el_enable_field_label.setAttribute("class", "fm-field-label");
		el_enable_field_label.setAttribute("for", "el_title");
		el_enable_field_label.innerHTML = "Enable Field(s)";
	
	var el_enable_title = document.createElement('input');
		el_enable_title.setAttribute("id", "el_title");
		el_enable_title.setAttribute("type", "checkbox");
		el_enable_title.setAttribute("value", "no");
		el_enable_title.setAttribute("onclick", "enable_name_fields('"+i+"','title')");
		if(w_name_fields[0]=="yes")
			el_enable_title.setAttribute("checked", "checked");	

	var el_enable_middle = document.createElement('input');
		el_enable_middle.setAttribute("id", "el_middle");
		el_enable_middle.setAttribute("type", "checkbox");
		el_enable_middle.setAttribute("value", "no");
		el_enable_middle.setAttribute("onclick", "enable_name_fields('"+i+"','middle')");
		if(w_name_fields[1]=="yes")
			el_enable_middle.setAttribute("checked", "checked");	

	var el_title = document.createTextNode(w_mini_labels[0]);
	var el_first = document.createTextNode(w_mini_labels[1]);
	var el_last = document.createTextNode(w_mini_labels[2]);
	var el_middle = document.createTextNode(w_mini_labels[3]);

	var el_title_label = document.createElement('label');
		el_title_label.setAttribute("id", "el_title_label");
		el_title_label.setAttribute("for", "el_title");
	
	var el_first_label = document.createElement('label');
		el_first_label.setAttribute("id", "el_first_label");
		el_first_label.setAttribute("for", "el_first");
	
	var el_last_label = document.createElement('label');
		el_last_label.setAttribute("id", "el_last_label");
		el_last_label.setAttribute("for", "el_last");
		
	var el_middle_label = document.createElement('label');
		el_middle_label.setAttribute("id", "el_middle_label");		
		el_middle_label.setAttribute("for", "el_middle");	
	////////////////////////////////////////////////////////////////////////	
	//////////////////////////////////////////////////////////////////	
	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_required");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required=="yes")
			el_required.setAttribute("checked", "checked");	

	var el_unique_label = document.createElement('label');
		el_unique_label.setAttribute("class", "fm-field-label");
	    el_unique_label.setAttribute("for", "el_unique");
		el_unique_label.innerHTML = "Allow only unique values";
	
	var el_unique = document.createElement('input');
		el_unique.setAttribute("id", "el_unique");
		el_unique.setAttribute("type", "checkbox");
		el_unique.setAttribute("onclick", "set_unique('"+i+"_uniqueform_id_temp')");
		if(w_unique=="yes")
			el_unique.setAttribute("checked", "checked");
				
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
		
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_name')");
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
		el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_name')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_name')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
		el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_name')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
	}

	var t  = document.getElementById('edit_table');
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	var br7 = document.createElement('br');
	var br8 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);

	edit_main_td10.appendChild(el_label_size_label);
	edit_main_td10_1.appendChild(el_label_size);
	
	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td9.appendChild(el_first_value_label);
	edit_main_td9_1.appendChild(el_first_value_first);
	edit_main_td9_1.appendChild(gic);
	edit_main_td9_1.appendChild(el_first_value_last);
	
	edit_main_td7.appendChild(el_size_label);
	edit_main_td7_1.appendChild(el_size);
	
	edit_main_td3.appendChild(el_format_label);
	edit_main_td3_1.appendChild(el_format_normal);
	edit_main_td3_1.appendChild(Normal);
	edit_main_td3_1.appendChild(br1);
	edit_main_td3_1.appendChild(el_format_extended);
	edit_main_td3_1.appendChild(Extended);
	
///////////////////////////////////////
/////////////////////////////////////////	
	el_title_label.appendChild(el_title);
	el_first_label.appendChild(el_first);
	el_last_label.appendChild(el_last);
	el_middle_label.appendChild(el_middle);
	
	edit_main_td11.appendChild(el_enable_field_label);
	edit_main_td11_1.appendChild(el_enable_title);
	edit_main_td11_1.appendChild(el_title_label);
	edit_main_td11_1.appendChild(br3);
	edit_main_td11_1.appendChild(el_enable_middle);
	edit_main_td11_1.appendChild(el_middle_label);
	edit_main_td11_1.appendChild(br6);

///////////////////////////////////////////////	
////////////////////////////////////////////////	
	edit_main_td4.appendChild(el_style_label);
	edit_main_td4_1.appendChild(el_style_textarea);
	
	edit_main_td5.appendChild(el_required_label);
	edit_main_td5_1.appendChild(el_required);
	
	edit_main_td8.appendChild(el_unique_label);
	edit_main_td8_1.appendChild(el_unique);
	
	
	
	
	edit_main_td6.appendChild(el_attr_label);
	edit_main_td6.appendChild(el_attr_add);
	edit_main_td6.appendChild(br2);
	edit_main_td6.appendChild(el_attr_table);
	edit_main_td6.setAttribute("colspan", "2");
	
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr11.appendChild(edit_main_td11);
	edit_main_tr11.appendChild(edit_main_td11_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr11);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr6);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_name');
//show table

	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_name");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required= document.createElement("input");
		adding_required.setAttribute("type", "hidden");
		adding_required.setAttribute("value", w_required);
		adding_required.setAttribute("name", i+"_requiredform_id_temp");
		adding_required.setAttribute("id", i+"_requiredform_id_temp");
	
	var adding_fields = document.createElement("input");
		adding_fields.setAttribute("type", "hidden");
		adding_fields.setAttribute("name", i+"_enable_fieldsform_id_temp");
		adding_fields.setAttribute("id", i+"_enable_fieldsform_id_temp");	
		adding_fields.setAttribute("title", w_name_fields[0]);
		adding_fields.setAttribute("first", 'yes');
		adding_fields.setAttribute("last", 'yes');
		adding_fields.setAttribute("middle", w_name_fields[1]);

	var adding_unique= document.createElement("input");
		adding_unique.setAttribute("type", "hidden");
		adding_unique.setAttribute("value", w_unique);
		adding_unique.setAttribute("name", i+"_uniqueform_id_temp");
		adding_unique.setAttribute("id", i+"_uniqueform_id_temp");
	
    edit_labels = document.createTextNode("The labels of the fields are editable. Please, click the label to edit.");

	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
	var div_for_editable_labels = document.createElement('div');
		div_for_editable_labels.setAttribute("class", "fm-editable-label");
		div_for_editable_labels.appendChild(edit_labels);  

	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width=w_field_label_size +"px";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");
		
	var table_name = document.createElement('div');
		table_name.style.display="table";
		table_name.setAttribute("id", i+"_table_name");
		table_name.setAttribute("cellpadding", '0');
		table_name.setAttribute("cellspacing", '0');
		
	var tr_name1 = document.createElement('div');
		tr_name1.style.display="table-row";
		tr_name1.setAttribute("id", i+"_tr_name1");
		
	var tr_name2 = document.createElement('div');
		tr_name2.style.display="table-row";
		tr_name2.setAttribute("id", i+"_tr_name2");
		
	var td_name_input1 = document.createElement('div');
		td_name_input1.style.display="table-cell";
		td_name_input1.setAttribute("id", i+"_td_name_input_first");
		
	var td_name_input2 = document.createElement('div');
		td_name_input2.style.display="table-cell";
		td_name_input2.setAttribute("id", i+"_td_name_input_last");
	
	var td_name_label1 = document.createElement('div');
		td_name_label1.style.display="table-cell";
		td_name_label1.setAttribute("id", i+"_td_name_label_first");
		td_name_label1.setAttribute("align", "left");
		
	var td_name_label2 = document.createElement('div');
		td_name_label2.style.display="table-cell";
		td_name_label2.setAttribute("id", i+"_td_name_label_last");
		td_name_label2.setAttribute("align", "left");
	
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
		label.style.verticalAlign="top";
		
	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
		required.style.verticalAlign="top";
		if(w_required=="yes")
			required.innerHTML = " *";		
			
	var first = document.createElement('input');
		first.setAttribute("type", 'text');
		if(w_title[0]==w_first_val[0])
			first.setAttribute("class", "input_deactive");
		else
			first.setAttribute("class", "input_active");
	    first.style.cssText = "margin-right: 10px; width:"+w_size+"px";
	    first.setAttribute("id", i+"_element_firstform_id_temp");
	    first.setAttribute("name", i+"_element_firstform_id_temp");
		first.setAttribute("value", w_first_val[0]);
		first.setAttribute("title", w_title[0]);
		first.setAttribute("onFocus", 'delete_value("'+i+'_element_firstform_id_temp")');
		first.setAttribute("onBlur", 'return_value("'+i+'_element_firstform_id_temp")');
	    first.setAttribute("onChange", "change_value('"+i+"_element_firstform_id_temp')");
			
	var first_label = document.createElement('label');
	    first_label.setAttribute("class", "mini_label");
	    first_label.setAttribute("id", i+"_mini_label_first");
	    first_label.innerHTML= w_mini_labels[1];
			
	var last = document.createElement('input');
        last.setAttribute("type", 'text');
		if(w_title[1]==w_first_val[1])
			last.setAttribute("class", "input_deactive");
		else
			last.setAttribute("class", "input_active");
		last.style.cssText = "margin-right: 10px; width:"+w_size+"px";
		last.setAttribute("id", i+"_element_lastform_id_temp");
		last.setAttribute("name", i+"_element_lastform_id_temp");
		last.setAttribute("value", w_first_val[1]);
		last.setAttribute("title", w_title[1]);
		last.setAttribute("onFocus", 'delete_value("'+i+'_element_lastform_id_temp")');
		last.setAttribute("onBlur", 'return_value("'+i+'_element_lastform_id_temp")');
		last.setAttribute("onChange", "change_value('"+i+"_element_lastform_id_temp')");

	var last_label = document.createElement('label');
		last_label.setAttribute("class", "mini_label");
		last_label.setAttribute("id", i+"_mini_label_last");
		last_label.innerHTML= w_mini_labels[2];
			
    var main_td  = document.getElementById('show_table');
      
	div_label.appendChild(label);
	div_label.appendChild(required );
	
	td_name_input1.appendChild(first);
	td_name_input2.appendChild(last);
	tr_name1.appendChild(td_name_input1);
	tr_name1.appendChild(td_name_input2);
	
	td_name_label1.appendChild(first_label);
	td_name_label2.appendChild(last_label);
	tr_name2.appendChild(td_name_label1);
	tr_name2.appendChild(td_name_label2);
	table_name.appendChild(tr_name1);
	table_name.appendChild(tr_name2);

	
	div_element.appendChild(adding_type);
	div_element.appendChild(adding_required);
	div_element.appendChild(adding_unique);
	div_element.appendChild(adding_fields);
	div_element.appendChild(table_name);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
  
	div.appendChild(div_field);
	div.appendChild(br8);
	div.appendChild(div_for_editable_labels);
	main_td.appendChild(div);
		
	if(w_field_label_pos=="top")
		label_top(i);
	
//	if(w_name_format=="extended")
//		format_extended(i,w_first_val[2],w_first_val[3],w_title[2],w_title[3]);

	change_class(w_class, i);
	if(w_name_fields[0] == 'yes')
		enable_name_fields(i, 'title');
		
	if(w_name_fields[1] == 'yes')
		enable_name_fields(i, 'middle');	
		
	jQuery(document).ready(function() {	
		jQuery("label#"+i+"_mini_label_first").click(function() {		
			if (jQuery(this).children('input').length == 0) {				
				var first = "<input type='text' class='first' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
				jQuery(this).html(first);							
				jQuery("input.first").focus();			
				jQuery("input.first").blur(function() {	
					var value = jQuery(this).val();			
					jQuery("#"+i+"_mini_label_first").text(value);	
					document.getElementById('el_first_label').innerHTML = value;						
				});	
			}	
		});		

		jQuery("label#"+i+"_mini_label_last").click(function() {	
			if (jQuery(this).children('input').length == 0) {		
				var last = "<input type='text' class='last'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
				jQuery(this).html(last);			
				jQuery("input.last").focus();					
				jQuery("input.last").blur(function() {			
					var value = jQuery(this).val();			
					jQuery("#"+i+"_mini_label_last").text(value);	
					document.getElementById('el_last_label').innerHTML = value;	
				});	
			}	
		});
	});	

	refresh_attr(i, 'type_name');
	refresh_id_name(i, 'type_name');
}

function go_to_type_address(new_id)
{
 	w_attr_name = [];
 	w_attr_value = [];
	w_mini_labels = ['Street Address', 'Street Address Line 2', 'City', 'State / Province / Region', 'Postal / Zip Code', 'Country',];
	w_disabled_fields = ['no', 'no', 'no', 'no', 'no', 'no', 'no'];
	type_address(new_id, 'Address:', '100', 'left', '300', w_mini_labels, w_disabled_fields, 'no', 'wdform_address', w_attr_name, w_attr_value)
}

function change_state_input(id,form_id)
{
	if((document.getElementById(id+"_country"+form_id) && document.getElementById(id+"_country"+form_id).value=="United States" && document.getElementById(id+"_disable_fieldsform_id_temp").getAttribute('us_states')=='yes') || (document.getElementById(id+"_disable_fieldsform_id_temp").getAttribute('country')=='yes' && document.getElementById(id+"_disable_fieldsform_id_temp").getAttribute('us_states')=='yes'))
	{	

		state_input=document.getElementById(id+"_state"+form_id);
		
		
		var state = document.createElement('select');
			state.setAttribute("type", 'text');
			state.style.cssText = "width:100%";
			state.setAttribute("id", id+"_state"+form_id);
			state.setAttribute("name", (parseInt(id)+3)+"_state"+form_id);
			state.setAttribute("onChange", "change_value('"+id+"_state"+form_id+"')");

	
		
		var option_ = document.createElement('option');
			option_.setAttribute("value", "");
			option_.innerHTML="";
		state.appendChild(option_);
		
		states=["Alabama","Alaska", "Arizona","Arkansas","California","Colorado","Connecticut","Delaware","District Of Columbia","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming"];	
		for(r=0;r<states.length;r++)
		{
		var option_ = document.createElement('option');
			option_.setAttribute("value", states[r]);
			option_.innerHTML=states[r];
		state.appendChild(option_);
		}
		
		var state_input_parent = state_input.parentNode;
		state_input_parent.removeChild(state_input);
		state_input_parent.insertBefore(state,state_input_parent.firstChild);

	}
	else
	{

		if(document.getElementById(id+"_state"+form_id).tagName=='SELECT')
		{
				
				var state_input = document.createElement('input');
					state_input.setAttribute("type", 'text');
					state_input.style.cssText = "width:100%";
					state_input.setAttribute("id", id+"_state"+form_id);
					state_input.setAttribute("name", (parseInt(id)+3)+"_state"+form_id);
					state_input.setAttribute("onChange", "change_value('"+id+"_state"+form_id+"')");
									
					
					state = document.getElementById(id+"_state"+form_id);
					
					var state_parent = state.parentNode;
						state_parent.removeChild(state);
						state_parent.insertBefore(state_input,state_parent.firstChild);
					
		}
	
	}


}

function disable_fields(id,field)
{	
	var div = document.getElementById(id+"_div_address");	
	if(field)
	{
		if(document.getElementById("el_"+field).checked == true)
			document.getElementById(id+"_disable_fieldsform_id_temp").setAttribute(field, "yes");
		else
			document.getElementById(id+"_disable_fieldsform_id_temp").setAttribute(field, "no");
	}

	if(document.getElementById(id+"_disable_fieldsform_id_temp").getAttribute("state") == 'yes')
		document.getElementById("el_us_states").disabled = true;
	else
	{
		document.getElementById("el_us_states").disabled = false;
		if(field == 'us_states')
		{		
			change_state_input(id,'form_id_temp');
			return;
		}
	}
	
	div.innerHTML = '';
	var hidden_labels = new Array();
	var address_fields = ['street1','street2','city','state','postal','country'];
	var left_right = 0;
		
	for(l=0; l<6; l++)
	{
		if(document.getElementById(id+'_disable_fieldsform_id_temp').getAttribute(address_fields[l]) == 'no')	
		{
			if(address_fields[l]=='street1' || address_fields[l]=='street2')    
			{  
				var street = document.createElement('input');
					street.setAttribute("type", 'text');
					street.style.cssText = "width:100%";
					street.setAttribute("id", id+"_"+address_fields[l]+"form_id_temp");
					street.setAttribute("name", (parseInt(id)+l)+"_"+address_fields[l]+"form_id_temp");
					street.setAttribute("onChange", "change_value('"+id+"_"+address_fields[l]+"form_id_temp')");
						
				var street_label = document.createElement('label');
					street_label.setAttribute("class", "mini_label");	
					street_label.setAttribute("id", id+"_mini_label_"+address_fields[l]);
					street_label.style.cssText = "display:block;";
					street_label.innerHTML=document.getElementById('el_'+address_fields[l]+"_label").innerHTML;
					w_mini_labels[l] = document.getElementById('el_'+address_fields[l]+"_label").innerHTML;
					
				var span_addres = document.createElement('span');
					span_addres.style.cssText = "float:left; width:100%; padding-bottom: 8px; display:block";	
				
				span_addres.appendChild(street);
				span_addres.appendChild(street_label);
				div.appendChild(span_addres);					
			}	
			else
			{
				left_right++;
				if(address_fields[l]!='country')
				{
					var field = document.createElement('input');
						field.setAttribute("type", 'text');
						field.style.cssText = "width:100%";
						field.setAttribute("id", id+"_"+address_fields[l]+"form_id_temp");
						field.setAttribute("name", (parseInt(id)+l)+"_"+address_fields[l]+"form_id_temp");
						field.setAttribute("onChange", "change_value('"+id+"_"+address_fields[l]+"form_id_temp')");

					var field_label = document.createElement('label');
						field_label.setAttribute("class", "mini_label");		
						field_label.setAttribute("id", id+"_mini_label_"+address_fields[l]);
						field_label.style.cssText = "display:block;";
						field_label.innerHTML=document.getElementById('el_'+address_fields[l]+"_label").innerHTML;
						w_mini_labels[l] = document.getElementById('el_'+address_fields[l]+"_label").innerHTML;
				}
				else
				{
					var field = document.createElement('select');
						field.setAttribute("type", 'text');
						field.style.cssText = "width:100%";
						field.setAttribute("id", id+"_countryform_id_temp");
						field.setAttribute("name", (parseInt(id)+l)+"_countryform_id_temp");
						field.setAttribute("onChange", "change_state_input('"+id+"', 'form_id_temp')");

					var field_label = document.createElement('label');
						field_label.setAttribute("class", "mini_label");	
						field_label.setAttribute("id", id+"_mini_label_country");
						field_label.style.cssText = "display:block;";
						field_label.innerHTML=document.getElementById('el_'+address_fields[l]+"_label").innerHTML;
						w_mini_labels[l] = document.getElementById('el_'+address_fields[l]+"_label").innerHTML;
						
					var option_ = document.createElement('option');
						option_.setAttribute("value", "");
						option_.innerHTML="";
					field.appendChild(option_);
						
					coutries = ["Afghanistan","Albania",	"Algeria","Andorra","Angola","Antigua and Barbuda","Argentina","Armenia","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bhutan","Bolivia","Bosnia and Herzegovina","Botswana","Brazil","Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde","Central African Republic","Chad","Chile","China","Colombi","Comoros","Congo (Brazzaville)","Congo","Costa Rica","Cote d'Ivoire","Croatia","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","East Timor (Timor Timur)","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Fiji","Finland","France","Gabon","Gambia, The","Georgia","Germany","Ghana","Greece","Grenada","Guatemala","Guinea","Guinea-Bissau","Guyana","Haiti","Honduras","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Israel","Italy","Jamaica","Japan","Jordan","Kazakhstan","Kenya","Kiribati","Korea, North","Korea, South","Kuwait","Kyrgyzstan","Laos","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Mauritania","Mauritius","Mexico","Micronesia","Moldova","Monaco","Mongolia","Morocco","Mozambique","Myanmar","Namibia","Nauru","Nepa","Netherlands","New Zealand","Nicaragua","Niger","Nigeria","Norway","Oman","Pakistan","Palau","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Poland","Portugal","Qatar","Romania","Russia","Rwanda","Saint Kitts and Nevis","Saint Lucia","Saint Vincent","Samoa","San Marino","Sao Tome and Principe","Saudi Arabia","Senegal","Serbia and Montenegro","Seychelles","Sierra Leone","Singapore","Slovakia","Slovenia","Solomon Islands","Somalia","South Africa","Spain","Sri Lanka","Sudan","Suriname","Swaziland","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Togo","Tonga","Trinidad and Tobago","Tunisia","Turkey","Turkmenistan","Tuvalu","Uganda","Ukraine","United Arab Emirates","United Kingdom","United States","Uruguay","Uzbekistan","Vanuatu","Vatican City","Venezuela","Vietnam","Yemen","Zambia","Zimbabwe"];	
					
					for(r=0;r<coutries.length;r++)
					{
						var option_ = document.createElement('option');
							option_.setAttribute("value", coutries[r]);
							option_.innerHTML=coutries[r];
						field.appendChild(option_);
					}
				}	

				if(left_right%2!=0)	
				{
					var span_addres = document.createElement('span');
						span_addres.style.cssText = "float:left; width:48%; padding-bottom: 8px;";
				}
				else
				{
					var span_addres = document.createElement('span');
						span_addres.style.cssText = "float:right; width:48%; padding-bottom: 8px;";
				}	
					
				span_addres.appendChild(field);
				span_addres.appendChild(field_label);
				div.appendChild(span_addres);	
			}
		}
		else
		{
			var hidden_field = document.createElement('input');
				hidden_field.setAttribute("type", 'hidden');
				hidden_field.setAttribute("id", id+"_"+address_fields[l]+"form_id_temp");
				hidden_field.setAttribute("value", document.getElementById("el_"+address_fields[l]+"_label").innerHTML);
				hidden_field.setAttribute("id_for_label", parseInt(id)+l); 

				hidden_labels.push(hidden_field);
		}
		
		for(k=0; k<hidden_labels.length; k++)
			div.appendChild(hidden_labels[k]);
	}
	
	if(document.getElementById(id+"_disable_fieldsform_id_temp").getAttribute("state")=='no' && document.getElementById(id+"_disable_fieldsform_id_temp").getAttribute("country")=='yes')
		change_state_input(id,'form_id_temp');
		
	jQuery(document).ready(function(jQuery) {		
		jQuery("label#"+id+"_mini_label_street1").click(function() {			
			if (jQuery(this).children('input').length == 0) 
			{				
				var street1 = "<input type='text' class='street1' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";
				jQuery(this).html(street1);					
				jQuery("input.street1").focus();		
				jQuery("input.street1").blur(function() {	
					var value = jQuery(this).val();			
					jQuery("#"+id+"_mini_label_street1").text(value);		
					document.getElementById('el_street1_label').innerHTML=	value;	
				});		
			}	
		});		
	
		jQuery("label#"+id+"_mini_label_street2").click(function() {		
			if (jQuery(this).children('input').length == 0)
			{		
				var street2 = "<input type='text' class='street2'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";
				jQuery(this).html(street2);					
				jQuery("input.street2").focus();		
				jQuery("input.street2").blur(function() {	
					var value = jQuery(this).val();			
					jQuery("#"+id+"_mini_label_street2").text(value);
					document.getElementById('el_street2_label').innerHTML=	value;		
				});		
			}	
		});	
	
		jQuery("label#"+id+"_mini_label_city").click(function() {	
			if (jQuery(this).children('input').length == 0)
			{	
				var city = "<input type='text' class='city'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";
				jQuery(this).html(city);			
				jQuery("input.city").focus();				
				jQuery("input.city").blur(function() {			
					var value = jQuery(this).val();		
					jQuery("#"+id+"_mini_label_city").text(value);	
					document.getElementById('el_city_label').innerHTML=	value;		
				});		
			}	
		});	
	
		jQuery("label#"+id+"_mini_label_state").click(function() {		
			if (jQuery(this).children('input').length == 0)
			{	
				var state = "<input type='text' class='state'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
				jQuery(this).html(state);		
				jQuery("input.state").focus();		
				jQuery("input.state").blur(function() {		
					var value = jQuery(this).val();			
					jQuery("#"+id+"_mini_label_state").text(value);
					document.getElementById('el_state_label').innerHTML=	value;		
				});	
			}
		});		

		jQuery("label#"+id+"_mini_label_postal").click(function() {		
			if (jQuery(this).children('input').length == 0)
			{			
				var postal = "<input type='text' class='postal'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";
				jQuery(this).html(postal);			
				jQuery("input.postal").focus();			
				jQuery("input.postal").blur(function() {			
					var value = jQuery(this).val();		
					jQuery("#"+id+"_mini_label_postal").text(value);	
					document.getElementById('el_postal_label').innerHTML=	value;		
				});	
			}
		});		
	
		jQuery("label#"+id+"_mini_label_country").click(function() {		
			if (jQuery(this).children('input').length == 0) 
			{		
				var country = "<input type='text' class='country'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";
				jQuery(this).html(country);		
				jQuery("input.country").focus();	
				jQuery("input.country").blur(function() {		
					var value = jQuery(this).val();			
					jQuery("#"+id+"_mini_label_country").text(value);
					document.getElementById('el_country_label').innerHTML=	value;				
				});	
			}	
		});
	});	
	
	refresh_attr(id,type);
}

function type_address(i, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_mini_labels, w_disabled_fields, w_required, w_class, w_attr_name, w_attr_value)
{
	document.getElementById("element_type").value = "type_address";
	delete_last_child();
	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		edit_div.setAttribute("style", "border-top:1px dotted black;padding:10px;  padding-top:0px; padding-bottom:0px; margin-top:10px;");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10  = document.createElement('tr');
	
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');
	
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.style.cssText = "width:200px;";
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";
	
	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
        el_label_left.innerHTML = "Left";	
		
	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");
	
	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
        el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos == "top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_size_label = document.createElement('label');
		el_size_label.setAttribute("for", "edit_for_input_size");
		el_size_label.setAttribute("class", "fm-field-label");
		el_size_label.innerHTML = "Overall size(px) ";
	var el_size = document.createElement('input');
		el_size.setAttribute("id", "edit_for_input_size");
		el_size.setAttribute("type", "text");
		el_size.setAttribute("value", w_size);
		el_size.setAttribute("onKeyPress", "return check_isnum(event)");
		el_size.setAttribute("onKeyUp", "change_w_style('"+i+"_div_address', this.value);");
		
	var el_disable_field_label = document.createElement('label');
		el_disable_field_label.setAttribute("class", "fm-field-label");
		el_disable_field_label.innerHTML = "Disable Field(s)";

	var el_disable_address1 = document.createElement('input');
		el_disable_address1.setAttribute("id", "el_street1");
		el_disable_address1.setAttribute("type", "checkbox");
		el_disable_address1.setAttribute("value", "no");
		el_disable_address1.setAttribute("onclick", "disable_fields('"+i+"','street1')");
		if(w_disabled_fields[0] == "yes")
			el_disable_address1.setAttribute("checked", "checked");	
	
	var el_disable_address2 = document.createElement('input');
		el_disable_address2.setAttribute("id", "el_street2");
		el_disable_address2.setAttribute("type", "checkbox");
		el_disable_address2.setAttribute("value", "no");
		el_disable_address2.setAttribute("onclick", "disable_fields('"+i+"','street2')");
		if(w_disabled_fields[1] == "yes")
			el_disable_address2.setAttribute("checked", "checked");	
	
	var el_disable_city = document.createElement('input');
		el_disable_city.setAttribute("id", "el_city");
		el_disable_city.setAttribute("type", "checkbox");
		el_disable_city.setAttribute("value", "no");
		el_disable_city.setAttribute("onclick", "disable_fields('"+i+"','city')");
		if(w_disabled_fields[2] == "yes")
			el_disable_city.setAttribute("checked", "checked");	
	
	var el_disable_state = document.createElement('input');
		el_disable_state.setAttribute("id", "el_state");
		el_disable_state.setAttribute("type", "checkbox");
		el_disable_state.setAttribute("value", "no");
		el_disable_state.setAttribute("onclick", "disable_fields('"+i+"','state')");
		if(w_disabled_fields[3] == "yes")
			el_disable_state.setAttribute("checked", "checked");	
	
	var el_disable_postal = document.createElement('input');
		el_disable_postal.setAttribute("id", "el_postal");
		el_disable_postal.setAttribute("type", "checkbox");
		el_disable_postal.setAttribute("value", "no");
		el_disable_postal.setAttribute("onclick", "disable_fields('"+i+"','postal')");
		if(w_disabled_fields[4] == "yes")
			el_disable_postal.setAttribute("checked", "checked");
	
	var el_disable_country = document.createElement('input');
		el_disable_country.setAttribute("id", "el_country");
		el_disable_country.setAttribute("type", "checkbox");
		el_disable_country.setAttribute("value", "no");
		el_disable_country.setAttribute("onclick", "disable_fields('"+i+"','country')");
		if(w_disabled_fields[5] == "yes")
			el_disable_country.setAttribute("checked", "checked");			
			
	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_required");
		el_required.setAttribute("type", "checkbox");     
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required == "yes")
			el_required.setAttribute("checked", "checked");	

	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.style.cssText = "width:200px;";
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");      
		el_attr_label.innerHTML = "Additional Attributes";
		
	var el_attr_add = document.createElement('img');
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_address')");
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
		el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n = w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.style.cssText = "width:100px";
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_address')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.style.cssText = "width:100px";
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_address')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_address')");
			
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);	
	}
	
	var el_us_states_label = document.createElement('label');
		el_us_states_label.setAttribute("class", "fm-field-label");  
		el_us_states_label.setAttribute("for", "el_us_states");  
		el_us_states_label.innerHTML = "Use list for US states";
	
	var el_disable_us_states = document.createElement('input');
		el_disable_us_states.setAttribute("id", "el_us_states");
		el_disable_us_states.setAttribute("type", "checkbox");
		el_disable_us_states.setAttribute("value", "yes");
		el_disable_us_states.setAttribute("onclick", "disable_fields('"+i+"','us_states')");
		if(w_disabled_fields[6] == "yes")
			el_disable_us_states.setAttribute("checked", "checked"); 
	
	var el_street1 = document.createTextNode(w_mini_labels[0]);
	var el_street2 = document.createTextNode(w_mini_labels[1]);
	var el_city = document.createTextNode(w_mini_labels[2]);
	var el_state = document.createTextNode(w_mini_labels[3]);
	var el_postal = document.createTextNode(w_mini_labels[4]);
	var el_country = document.createTextNode(w_mini_labels[5]);
	
	var el_street1_label = document.createElement('label');
		el_street1_label.setAttribute("for", "el_street1");
		el_street1_label.setAttribute("id", "el_street1_label");
	
	var el_street2_label = document.createElement('label');
		el_street2_label.setAttribute("for", "el_street2");
		el_street2_label.setAttribute("id", "el_street2_label");
	
	var el_city_label = document.createElement('label');
		el_city_label.setAttribute("for", "el_city");
		el_city_label.setAttribute("id", "el_city_label");
	
	var el_state_label = document.createElement('label');
		el_state_label.setAttribute("for", "el_state");
		el_state_label.setAttribute("id", "el_state_label");
	
	var el_postal_label = document.createElement('label');
		el_postal_label.setAttribute("for", "el_postal");
		el_postal_label.setAttribute("id", "el_postal_label");
	
	var el_country_label = document.createElement('label');
		el_country_label.setAttribute("for", "el_country");
		el_country_label.setAttribute("id", "el_country_label");
	
	el_street1_label.appendChild(el_street1);
	el_street2_label.appendChild(el_street2);
	el_city_label.appendChild(el_city);
	el_state_label.appendChild(el_state);
	el_postal_label.appendChild(el_postal);
	el_country_label.appendChild(el_country);
	
	var t  = document.getElementById('edit_table');	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	var br7 = document.createElement('br');

	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);

	edit_main_td9.appendChild(el_label_size_label);
	edit_main_td9_1.appendChild(el_label_size);
	
	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td7.appendChild(el_size_label);
	edit_main_td7_1.appendChild(el_size);
	
	edit_main_td4.appendChild(el_style_label);
	edit_main_td4_1.appendChild(el_style_textarea);
	
	edit_main_td5.appendChild(el_required_label);
	edit_main_td5_1.appendChild(el_required);
	
	edit_main_td8.appendChild(el_disable_field_label);
	edit_main_td8_1.appendChild(el_disable_address1);
	edit_main_td8_1.appendChild(el_street1_label);
	edit_main_td8_1.appendChild(br1);
	edit_main_td8_1.appendChild(el_disable_address2);
	edit_main_td8_1.appendChild(el_street2_label);
	edit_main_td8_1.appendChild(br2);
	edit_main_td8_1.appendChild(el_disable_city);
	edit_main_td8_1.appendChild(el_city_label);
	edit_main_td8_1.appendChild(br3);
	edit_main_td8_1.appendChild(el_disable_state);
	edit_main_td8_1.appendChild(el_state_label);
	edit_main_td8_1.appendChild(br4);
	edit_main_td8_1.appendChild(el_disable_postal);
	edit_main_td8_1.appendChild(el_postal_label);
	edit_main_td8_1.appendChild(br5);
	edit_main_td8_1.appendChild(el_disable_country);
	edit_main_td8_1.appendChild(el_country_label);
	edit_main_td8_1.appendChild(br6);

	edit_main_td10.appendChild(el_us_states_label);
	edit_main_td10_1.appendChild(el_disable_us_states);
	
	
	
	edit_main_td6.appendChild(el_attr_label);
	edit_main_td6.appendChild(el_attr_add);
	edit_main_td6.appendChild(br7);
	edit_main_td6.appendChild(el_attr_table);
	edit_main_td6.setAttribute("colspan", "2");
	
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_address');

	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_address");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
			
	var adding_country= document.createElement("input");
		adding_country.setAttribute("type", "hidden");
		adding_country.setAttribute("name", i+"_disable_fieldsform_id_temp");
		adding_country.setAttribute("id", i+"_disable_fieldsform_id_temp");	
		adding_country.setAttribute("street1", w_disabled_fields[0]);
		adding_country.setAttribute("street2", w_disabled_fields[1]);
		adding_country.setAttribute("city", w_disabled_fields[2]);
		adding_country.setAttribute("state", w_disabled_fields[3]);
		adding_country.setAttribute("us_states", w_disabled_fields[6]);
		adding_country.setAttribute("postal", w_disabled_fields[4]);
		adding_country.setAttribute("country", w_disabled_fields[5]);
            		
	var adding_required = document.createElement("input");
		adding_required.setAttribute("type", "hidden");
		adding_required.setAttribute("value", w_required);
		adding_required.setAttribute("name", i+"_requiredform_id_temp");
		adding_required.setAttribute("id", i+"_requiredform_id_temp");

	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
	
	var edit_labels = document.createTextNode("The labels of the fields are editable. Please, click the label to edit.");
	var div_for_editable_labels = document.createElement('div');
		div_for_editable_labels.setAttribute("style", "margin-left:4px; color:red; display:inline-block;");
		div_for_editable_labels.appendChild(edit_labels);  	
					
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width=w_field_label_size+"px";
		div_label.style.verticalAlign="top";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");
			
	var div_address = document.createElement('div');
		div_address.setAttribute("id", i+"_div_address");
		div_address.style.cssText = "width:"+w_size+"px";
		
	var span_addres1 = document.createElement('span');
		span_addres1.style.cssText = "float:left; width:100%;  padding-bottom: 8px; display:block";
		
	var span_addres2 = document.createElement('span');
		span_addres2.style.cssText = "float:left; width:100%;  padding-bottom: 8px; display:block";
		
	var span_addres3_1 = document.createElement('span');
		span_addres3_1.style.cssText = "float:left; width:48%; padding-bottom: 8px;";
	
	var span_addres3_2 = document.createElement('span');
		span_addres3_2.style.cssText = "float:right; width:48%; padding-bottom: 8px;";
	
	var span_addres4_1 = document.createElement('span');
		span_addres4_1.style.cssText = "float:left; width:48%; padding-bottom: 8px;";
	
	var span_addres4_2 = document.createElement('span');
		span_addres4_2.style.cssText = "float:right; width:48%; padding-bottom: 8px;";

	var br = document.createElement('br');    
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "wd_form_label");
		label.style.verticalAlign="top";
	    
	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
		required.style.verticalAlign="top";
		if(w_required == "yes")
			required.innerHTML = " *";	
			
	var street1 = document.createElement('input');
        street1.setAttribute("type", 'text');
	    street1.style.cssText = "width:100%";
	    street1.setAttribute("id", i+"_street1form_id_temp");
	    street1.setAttribute("name", i+"_street1form_id_temp");
	    street1.setAttribute("onChange", "change_value('"+i+"_street1form_id_temp')");
			
	var street1_label = document.createElement('label');
	    street1_label.setAttribute("class", "mini_label");
		street1_label.setAttribute("id", i+"_mini_label_street1");
	    street1_label.style.cssText = "display:block;";
	    street1_label.innerHTML = w_mini_labels[0];
			
	var street2 = document.createElement('input');
        street2.setAttribute("type", 'text');
		street2.style.cssText = "width:100%";
		street2.setAttribute("id", i+"_street2form_id_temp");
	   	street2.setAttribute("name", (parseInt(i)+1)+"_street2form_id_temp");
		street2.setAttribute("onChange", "change_value('"+i+"_street2form_id_temp')");

	var street2_label = document.createElement('label');
		street2_label.setAttribute("class", "mini_label");
	    street2_label.setAttribute("id", i+"_mini_label_street2");
	    street2_label.style.cssText = "display:block;";
		street2_label.innerHTML = w_mini_labels[1];
			
	var city = document.createElement('input');
        city.setAttribute("type", 'text');
		city.style.cssText = "width:100%";
		city.setAttribute("id", i+"_cityform_id_temp");
	   	city.setAttribute("name", (parseInt(i)+2)+"_cityform_id_temp");
		city.setAttribute("onChange", "change_value('"+i+"_cityform_id_temp')");

	var city_label = document.createElement('label');
		city_label.setAttribute("class", "mini_label");
	    city_label.setAttribute("id", i+"_mini_label_city");
	    city_label.style.cssText = "display:block;";
		city_label.innerHTML = w_mini_labels[2];
			
	var state = document.createElement('input');
        state.setAttribute("type", 'text');
		state.style.cssText = "width:100%";
		state.setAttribute("id", i+"_stateform_id_temp");
	   	state.setAttribute("name", (parseInt(i)+3)+"_stateform_id_temp");
		state.setAttribute("onChange", "change_value('"+i+"_stateform_id_temp')");

	var state_label = document.createElement('label');
		state_label.setAttribute("class", "mini_label");
	    state_label.setAttribute("id", i+"_mini_label_state");
	    state_label.style.cssText = "display:block;";
		state_label.innerHTML = w_mini_labels[3];

	var postal = document.createElement('input');
        postal.setAttribute("type", 'text');
		postal.style.cssText = "width:100%";
		postal.setAttribute("id", i+"_postalform_id_temp");
	   	postal.setAttribute("name", (parseInt(i)+4)+"_postalform_id_temp");
		postal.setAttribute("onChange", "change_value('"+i+"_postalform_id_temp')");

	var postal_label = document.createElement('label');
		postal_label.setAttribute("class", "mini_label");
	    postal_label.setAttribute("id", i+"_mini_label_postal");
	    postal_label.style.cssText = "display:block;";
		postal_label.innerHTML = w_mini_labels[4];
			
	var country = document.createElement('select');
        country.setAttribute("type", 'text');
		country.style.cssText = "width:100%";
		country.setAttribute("id", i+"_countryform_id_temp");
	   	country.setAttribute("name", (parseInt(i)+5)+"_countryform_id_temp");
		country.setAttribute("onChange", "change_state_input('"+i+"','form_id_temp')");

	var country_label = document.createElement('label');
		country_label.setAttribute("class", "mini_label");
	    country_label.setAttribute("id", i+"_mini_label_country");
	    country_label.style.cssText = "display:block;";
		country_label.innerHTML=w_mini_labels[5];

	var option_ = document.createElement('option');
		option_.setAttribute("value", "");
		option_.innerHTML = "";
		
	country.appendChild(option_);
	coutries = ["Afghanistan","Albania",	"Algeria","Andorra","Angola","Antigua and Barbuda","Argentina","Armenia","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bhutan","Bolivia","Bosnia and Herzegovina","Botswana","Brazil","Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde","Central African Republic","Chad","Chile","China","Colombi","Comoros","Congo (Brazzaville)","Congo","Costa Rica","Cote d'Ivoire","Croatia","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","East Timor (Timor Timur)","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Fiji","Finland","France","Gabon","Gambia, The","Georgia","Germany","Ghana","Greece","Grenada","Guatemala","Guinea","Guinea-Bissau","Guyana","Haiti","Honduras","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Israel","Italy","Jamaica","Japan","Jordan","Kazakhstan","Kenya","Kiribati","Korea, North","Korea, South","Kuwait","Kyrgyzstan","Laos","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Mauritania","Mauritius","Mexico","Micronesia","Moldova","Monaco","Mongolia","Morocco","Mozambique","Myanmar","Namibia","Nauru","Nepa","Netherlands","New Zealand","Nicaragua","Niger","Nigeria","Norway","Oman","Pakistan","Palau","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Poland","Portugal","Qatar","Romania","Russia","Rwanda","Saint Kitts and Nevis","Saint Lucia","Saint Vincent","Samoa","San Marino","Sao Tome and Principe","Saudi Arabia","Senegal","Serbia and Montenegro","Seychelles","Sierra Leone","Singapore","Slovakia","Slovenia","Solomon Islands","Somalia","South Africa","Spain","Sri Lanka","Sudan","Suriname","Swaziland","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Togo","Tonga","Trinidad and Tobago","Tunisia","Turkey","Turkmenistan","Tuvalu","Uganda","Ukraine","United Arab Emirates","United Kingdom","United States","Uruguay","Uzbekistan","Vanuatu","Vatican City","Venezuela","Vietnam","Yemen","Zambia","Zimbabwe"];
	
	for(r=0;r<coutries.length;r++)
	{
		var option_ = document.createElement('option');
			option_.setAttribute("value", coutries[r]);
			option_.innerHTML = coutries[r];
			
		country.appendChild(option_);
	}

	var main_td  = document.getElementById('show_table');
      
	div_label.appendChild(label);
	div_label.appendChild(required );
		
	span_addres1.appendChild(street1);
	span_addres1.appendChild(street1_label);
		
	span_addres2.appendChild(street2);
	span_addres2.appendChild(street2_label);
	
	span_addres3_1.appendChild(city);		
	span_addres3_1.appendChild(city_label);
	span_addres3_2.appendChild(state);		
	span_addres3_2.appendChild(state_label);
		
	span_addres4_1.appendChild(postal);		
	span_addres4_1.appendChild(postal_label);
	span_addres4_2.appendChild(country);		
	span_addres4_2.appendChild(country_label);	
				
	div_address.appendChild(span_addres1);
	div_address.appendChild(span_addres2);	
	div_address.appendChild(span_addres3_1);	
	div_address.appendChild(span_addres3_2);
	div_address.appendChild(span_addres4_1);
	div_address.appendChild(span_addres4_2);
						
	div_element.appendChild(adding_type);
	div_element.appendChild(adding_required);
	div_element.appendChild(adding_country);
	div_element.appendChild(div_address);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element); 
	div.appendChild(div_field);
	div.appendChild(br);
	div.appendChild(div_for_editable_labels);
	main_td.appendChild(div);
		
	if(w_field_label_pos == "top")
		label_top(i);
		
	change_class(w_class, i);
	refresh_attr(i, 'type_address');

	if(w_disabled_fields[0] == "yes")
		disable_fields(i,'street1');
	if(w_disabled_fields[1] == "yes")
		disable_fields(i,'street2');
	if(w_disabled_fields[2] == "yes")
		disable_fields(i,'city');
	if(w_disabled_fields[3] == "yes")
		disable_fields(i,'state');
	if(w_disabled_fields[4] == "yes")
		disable_fields(i,'postal');
	if(w_disabled_fields[5] == "yes")		
		disable_fields(i,'country');
	if(w_disabled_fields[6] == "yes")		
		disable_fields(i,'us_states');	
		
	jQuery(document).ready(function(jQuery)
	{		
		jQuery("label#"+i+"_mini_label_street1").click(function() {			
			if (jQuery(this).children('input').length == 0) 
			{				
				var street1 = "<input type='text' class='street1' style='outline:none; border:none; background:none; width:130px;' value=\""+jQuery(this).text()+"\">";
				jQuery(this).html(street1);					
				jQuery("input.street1").focus();		
				jQuery("input.street1").blur(function() {	
					var value = jQuery(this).val();			
					jQuery("#"+i+"_mini_label_street1").text(value);		
					document.getElementById('el_street1_label').innerHTML =	value;	
				});		
			}	
		});		
	
		jQuery("label#"+i+"_mini_label_street2").click(function() {		
			if (jQuery(this).children('input').length == 0)
			{		
				var street2 = "<input type='text' class='street2'  style='outline:none; border:none; background:none; width:130px;' value=\""+jQuery(this).text()+"\">";
				jQuery(this).html(street2);					
				jQuery("input.street2").focus();		
				jQuery("input.street2").blur(function() {	
					var value = jQuery(this).val();			
					jQuery("#"+i+"_mini_label_street2").text(value);
					document.getElementById('el_street2_label').innerHTML=	value;		
				});		
			}	
		});	

		jQuery("label#"+i+"_mini_label_city").click(function() {	
			if (jQuery(this).children('input').length == 0)
			{	
				var city = "<input type='text' class='city'  style='outline:none; border:none; background:none; width:130px;' value=\""+jQuery(this).text()+"\">";
				jQuery(this).html(city);			
				jQuery("input.city").focus();				
				jQuery("input.city").blur(function() {			
					var value = jQuery(this).val();		
					jQuery("#"+i+"_mini_label_city").text(value);	
					document.getElementById('el_city_label').innerHTML=	value;		
				});		
			}	
		});	
	
		jQuery("label#"+i+"_mini_label_state").click(function() {		
			if (jQuery(this).children('input').length == 0) 
			{	
				var state = "<input type='text' class='state'  style='outline:none; border:none; background:none; width:130px;' value=\""+jQuery(this).text()+"\">";	
				jQuery(this).html(state);		
				jQuery("input.state").focus();		
				jQuery("input.state").blur(function() {		
					var value = jQuery(this).val();			
					jQuery("#"+i+"_mini_label_state").text(value);
					document.getElementById('el_state_label').innerHTML=	value;		
				});	
			}
		});		

		jQuery("label#"+i+"_mini_label_postal").click(function() {		
			if (jQuery(this).children('input').length == 0)
			{			
				var postal = "<input type='text' class='postal'  style='outline:none; border:none; background:none; width:130px;' value=\""+jQuery(this).text()+"\">";
				jQuery(this).html(postal);			
				jQuery("input.postal").focus();			
				jQuery("input.postal").blur(function() {			
					var value = jQuery(this).val();		
					jQuery("#"+i+"_mini_label_postal").text(value);	
					document.getElementById('el_postal_label').innerHTML=	value;		
				});	
			}
		});	

		jQuery("label#"+i+"_mini_label_country").click(function() {		
			if (jQuery(this).children('input').length == 0) {		
				var country = "<input type='text' class='country'  style='outline:none; border:none; background:none; width:130px;' value=\""+jQuery(this).text()+"\">";
				jQuery(this).html(country);		
				jQuery("input.country").focus();	
				jQuery("input.country").blur(function() {		
					var value = jQuery(this).val();			
					jQuery("#"+i+"_mini_label_country").text(value);
					document.getElementById('el_country_label').innerHTML=	value;				
				});	
			}	
		});
	});	
}

function type_submitter_mail(i, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_first_val, w_title, w_required, w_unique, w_class, w_attr_name, w_attr_value){
    document.getElementById("element_type").value="type_submitter_mail";

	delete_last_child();
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10  = document.createElement('tr');
      			
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
		
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
		
	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');
		  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
                el_label_textarea.setAttribute("id", "edit_for_label");
                el_label_textarea.setAttribute("rows", "4");
                
                el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_size_label = document.createElement('label');
		el_size_label.setAttribute("class", "fm-field-label");
		el_size_label.setAttribute("for", "edit_for_input_size");
		el_size_label.innerHTML = "Field size(px) ";
	var el_size = document.createElement('input');
		   el_size.setAttribute("id", "edit_for_input_size");
		   el_size.setAttribute("type", "text");
		   el_size.setAttribute("value", w_size);
		   
			
			el_size.setAttribute("onKeyPress", "return check_isnum(event)");
            el_size.setAttribute("onKeyUp", "change_w_style('"+i+"_elementform_id_temp', this.value)");

	var el_first_value_label = document.createElement('label');
		el_first_value_label.setAttribute("class", "fm-field-label");
	        el_first_value_label.setAttribute("for", "el_first_value_input");
		el_first_value_label.innerHTML = "Value if empty";
	
	var el_first_value_input = document.createElement('input');
                el_first_value_input.setAttribute("id", "el_first_value_input");
                el_first_value_input.setAttribute("type", "text");
                el_first_value_input.setAttribute("value", w_title);
                el_first_value_input.setAttribute("onKeyUp", "change_input_value(this.value,'"+i+"_elementform_id_temp')");
				
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
	        el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
                el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
 		el_style_textarea.setAttribute("value", w_class);
                
                el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");
	
	
	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
                el_required.setAttribute("id", "el_required");
                el_required.setAttribute("type", "checkbox");
                
                el_required.setAttribute("onclick", "set_required('"+i+"_required')");
	if(w_required=="yes")
			
                el_required.setAttribute("checked", "checked");

	var el_unique_label = document.createElement('label');
		el_unique_label.setAttribute("class", "fm-field-label");
	    el_unique_label.setAttribute("for", "el_unique");
		el_unique_label.innerHTML = "Allow only unique values";
	
	var el_unique = document.createElement('input');
                el_unique.setAttribute("id", "el_unique");
                el_unique.setAttribute("type", "checkbox");
                
                el_unique.setAttribute("onclick", "set_unique('"+i+"_uniqueform_id_temp')");
	if(w_unique=="yes")
                el_unique.setAttribute("checked", "checked");
			
	var el_attr_label = document.createElement('label');
	    el_attr_label.setAttribute("class", "fm-field-label");           
		el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
                
           	el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_text')");
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_text')");
			
		var el_attr_value = document.createElement('input');
	
			el_attr_value.setAttribute("type", "text");
	
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_text')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_text')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}

	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);

	edit_main_td10.appendChild(el_label_size_label);
	edit_main_td10_1.appendChild(el_label_size);
	
	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_size_label);
	edit_main_td3_1.appendChild(el_size);
	
	edit_main_td4.appendChild(el_first_value_label);
	edit_main_td4_1.appendChild(el_first_value_input);

	edit_main_td5.appendChild(el_style_label);
	edit_main_td5_1.appendChild(el_style_textarea);
	edit_main_td7.appendChild(el_required_label);
	edit_main_td7_1.appendChild(el_required);
	
	edit_main_td9.appendChild(el_unique_label);
	edit_main_td9_1.appendChild(el_unique);
	
	
	edit_main_td8.appendChild(el_attr_label);
	edit_main_td8.appendChild(el_attr_add);
	edit_main_td8.appendChild(br4);
	edit_main_td8.appendChild(el_attr_table);
	edit_main_td8.setAttribute("colspan", "2");
	
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr8);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_text');
	
//show table

	element='input';	type='text'; 
	var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_submitter_mail");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
	    
	var adding_required = document.createElement("input");
            adding_required.setAttribute("type", "hidden");
            adding_required.setAttribute("value", w_required);
            adding_required.setAttribute("name", i+"_requiredform_id_temp");
            adding_required.setAttribute("id", i+"_requiredform_id_temp");
	    
	var adding_unique= document.createElement("input");
            adding_unique.setAttribute("type", "hidden");
            adding_unique.setAttribute("value", w_unique);
            adding_unique.setAttribute("name", i+"_uniqueform_id_temp");
            adding_unique.setAttribute("id", i+"_uniqueform_id_temp");
			
	var adding = document.createElement(element);
            adding.setAttribute("type", type);
		
		
		if(w_title==w_first_val)
		{
			adding.style.cssText = "width:"+w_size+"px;";
			adding.setAttribute("class", "input_deactive");
		}
		else
		{
			adding.style.cssText = "width:"+w_size+"px;";
			adding.setAttribute("class", "input_active");
		}
			adding.setAttribute("id", i+"_elementform_id_temp");
			adding.setAttribute("name", i+"_elementform_id_temp");
			adding.setAttribute("value", w_first_val);
			adding.setAttribute("title", w_title);
			
			adding.setAttribute("onFocus", "delete_value('"+i+"_elementform_id_temp')");
			adding.setAttribute("onBlur", "return_value('"+i+"_elementform_id_temp')");
			adding.setAttribute("onChange", "change_value('"+i+"_elementform_id_temp')");
			

     	var div = document.createElement('div');
      	    div.setAttribute("id", "main_div");
					
      
      	var div_field = document.createElement('div');
           	div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
      	var div_label = document.createElement('div');
         	div_label.setAttribute("align", 'left');
         	div_label.style.display="table-cell";
			div_label.style.width=w_field_label_size+"px";
           	div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
      	var div_element = document.createElement('div');
         	div_element.setAttribute("align", 'left');
          	div_element.style.display="table-cell";
          	div_element.setAttribute("id", i+"_element_sectionform_id_temp");

      	var br1 = document.createElement('br');
      	var br2 = document.createElement('br');
     	var br3 = document.createElement('br');
      	var br4 = document.createElement('br');
      

	    
      	var label = document.createElement('span');
			label.setAttribute("id", i+"_element_labelform_id_temp");
			label.innerHTML = w_field_label;
			label.setAttribute("class", "label");
			label.style.verticalAlign="top";
	    
      	var required = document.createElement('span');
			required.setAttribute("id", i+"_required_elementform_id_temp");
			required.innerHTML = "";
			required.setAttribute("class", "required");
			required.style.verticalAlign="top";
	if(w_required=="yes")
			required.innerHTML = " *";
      	var main_td  = document.getElementById('show_table');
      
      	div_label.appendChild(label);
      	div_label.appendChild(required);
      	div_element.appendChild(adding_type);
      	div_element.appendChild(adding_required);
      	div_element.appendChild(adding_unique);
      	div_element.appendChild(adding);
      	div_field.appendChild(div_label);
      	div_field.appendChild(div_element);
      	
      
      	div.appendChild(div_field);
      	div.appendChild(br3);
      	main_td.appendChild(div);
	if(w_field_label_pos=="top")
				label_top(i);
change_class(w_class, i);
refresh_attr(i, 'type_text');
}

function type_checkbox(i, w_field_label, w_field_label_size, w_field_label_pos, w_field_option_pos, w_flow, w_choices, w_choices_checked, w_rowcol,  w_required, w_randomize, w_allow_other,w_allow_other_num, w_class, w_attr_name, w_attr_value, w_value_disabled, w_choices_value, w_choices_params) {

	document.getElementById("element_type").value="type_checkbox";

	delete_last_child();	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');   		
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10 = document.createElement('tr');
	var edit_main_tr11 = document.createElement('tr');
    var edit_main_tr12 = document.createElement('tr');
    var edit_main_tr13 = document.createElement('tr');  				

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
		edit_main_td4.setAttribute("id", "choices");
	var edit_main_td4_1 = document.createElement('td');	
		edit_main_td4_1.style.cssText = "padding:20px 0 0 25px; vertical-align:top;";
		
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
		
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
		  
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
		
	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');
	
	var edit_main_td11 = document.createElement('td');
	var edit_main_td11_1 = document.createElement('td');
	
	var edit_main_td12 = document.createElement('td');
	var edit_main_td12_1 = document.createElement('td');
	
	var edit_main_td13 = document.createElement('td');
	var edit_main_td13_1 = document.createElement('td');
		  		
		  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
		
	    el_label_size.setAttribute("value", w_field_label_size);
		
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");
				
	var el_option_position_label = document.createElement('label');
		el_option_position_label.setAttribute("class", "fm-field-label");
		el_option_position_label.innerHTML = "Field option label position";
	
	var el_option_position1 = document.createElement('input');
		el_option_position1.setAttribute("id", "edit_for_option_position_right");
		el_option_position1.setAttribute("type", "radio");        
		el_option_position1.setAttribute("name", "edit_for_option_position");
		el_option_position1.setAttribute("onchange", "option_left("+i+",'checkbox')");
	
	var el_option_left = document.createElement('label');
		el_option_left.setAttribute("for", "edit_for_option_position_right");
        el_option_left.innerHTML = "Left";	
		
	var el_option_position2 = document.createElement('input');
		el_option_position2.setAttribute("id", "edit_for_option_position_left");
		el_option_position2.setAttribute("type", "radio");
    	el_option_position2.setAttribute("name", "edit_for_option_position");
		el_option_position2.setAttribute("onchange", "option_right("+i+",'checkbox')");
	
	var el_option_right = document.createElement('label');
		el_option_right.setAttribute("for", "edit_for_option_position_left");
        el_option_right.innerHTML = "Right";	
		
	if(w_field_option_pos == "right")
		el_option_position2.setAttribute("checked", "checked");
	else
		el_option_position1.setAttribute("checked", "checked");				
				
	var el_label_flow = document.createElement('label');
		el_label_flow.setAttribute("class", "fm-field-label");
		el_label_flow.innerHTML = "Relative Position";
	
	var el_flow_vertical = document.createElement('input');
		el_flow_vertical.setAttribute("id", "edit_for_flow_vertical");
		el_flow_vertical.setAttribute("type", "radio");
		el_flow_vertical.setAttribute("value", "ver");
		el_flow_vertical.setAttribute("name", "edit_for_flow");
		el_flow_vertical.setAttribute("onchange", "refresh_rowcol("+i+",'checkbox')");
		
	var el_label_vertical = document.createElement('label');
		el_label_vertical.setAttribute("for", "edit_for_flow_vertical");
        el_label_vertical.innerHTML = "Vertical";		
		
	var el_flow_horizontal = document.createElement('input');
		el_flow_horizontal.setAttribute("id", "edit_for_flow_horizontal");
		el_flow_horizontal.setAttribute("type", "radio");
		el_flow_horizontal.setAttribute("value", "hor");
		el_flow_horizontal.setAttribute("name", "edit_for_flow");
		el_flow_horizontal.setAttribute("onchange", "refresh_rowcol("+i+",'checkbox')");
		
	var el_label_horizontal = document.createElement('label');
		el_label_horizontal.setAttribute("for", "edit_for_flow_horizontal");
        el_label_horizontal.innerHTML = "Horizontal";		
	
	if(w_flow == "hor")
		el_flow_horizontal.setAttribute("checked", "checked");
	else
		el_flow_vertical.setAttribute("checked", "checked");
				
	var el_rowcol_label = document.createElement('label');
	    el_rowcol_label.setAttribute("class", "fm-field-label");
		el_rowcol_label.innerHTML = "Rows/Columns";
	
	var el_rowcol_textarea = document.createElement('input');
		el_rowcol_textarea.setAttribute("id", "edit_for_rowcol");
		el_rowcol_textarea.setAttribute("type", "text");
 		el_rowcol_textarea.setAttribute("value", w_rowcol);
		el_rowcol_textarea.setAttribute("onChange", "refresh_rowcol('"+i+"','checkbox')");	

	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
 		el_style_textarea.setAttribute("value", w_class);
		
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_required");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required=="yes")
			el_required.setAttribute("checked", "checked");
	var el_disable_value_label = document.createElement('label');
		el_disable_value_label.setAttribute("class", "fm-field-label");
		el_disable_value_label.setAttribute("for", "el_disable_value");
		el_disable_value_label.innerHTML = "Enable option's value";
	
	var el_disable_value = document.createElement('input');
		el_disable_value.setAttribute("id", "el_disable_value");
		el_disable_value.setAttribute("type", "checkbox");   
		el_disable_value.setAttribute("onclick", "refresh_sel_options('"+i+"', 'checkbox')");
		if(w_value_disabled =="yes")
			el_disable_value.setAttribute("checked", "checked");		
		
	var el_randomize_label = document.createElement('label');
		el_randomize_label.setAttribute("class", "fm-field-label");
		el_randomize_label.innerHTML = "Randomize in frontend";
	
	var el_randomize = document.createElement('input');
		el_randomize.setAttribute("id", "el_randomize");
		el_randomize.setAttribute("type", "checkbox");
		el_randomize.setAttribute("value", "yes");
		el_randomize.setAttribute("onclick", "set_randomize('"+i+"_randomizeform_id_temp')");
		if(w_randomize=="yes")
			el_randomize.setAttribute("checked", "checked");

	var el_allow_other_label = document.createElement('label');
		el_allow_other_label.setAttribute("class", "fm-field-label");
		el_allow_other_label.innerHTML = "Allow other";
	
	var el_allow_other = document.createElement('input');
		el_allow_other.setAttribute("id", "el_allow_other");
		el_allow_other.setAttribute("type", "checkbox");
		el_allow_other.setAttribute("value", "yes");
		el_allow_other.setAttribute("onclick", "set_allow_other('"+i+"','checkbox')");
		if(w_allow_other=="yes")
			el_allow_other.setAttribute("checked", "checked");
	
	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_checkbox')");
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
		el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
		var el_attr_td_value = document.createElement('td');
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_checkbox')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");	
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_checkbox')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_checkbox')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
	}

	var el_choices_label = document.createElement('label');
		el_choices_label.setAttribute("class", "fm-field-label");
		el_choices_label.innerHTML = "Options ";
	var el_choices_add = document.createElement('img');
		el_choices_add.setAttribute("id", "el_choices_add");
		el_choices_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_choices_add.style.cssText = 'cursor:pointer;';
		el_choices_add.setAttribute("title", 'add');
		el_choices_add.setAttribute("onClick", "add_choise('checkbox',"+i+")");
	var	el_choices_add_text = document.createElement("span");
		el_choices_add_text.style.cssText ="font-size: 12px; padding-left:7px; font-weight:bold; cursor:pointer;";
		el_choices_add_text.innerHTML ="Add option(s)";				
		el_choices_add_text.setAttribute("onClick", "add_choise('checkbox',"+i+")");
	
	var el_choices_select = document.createElement('a');
	    el_choices_select.style.cssText ="color:#000; font-weight:bold; font-size: 13px; cursor:pointer; padding-top:10px; display:block;";
		el_choices_select.innerHTML = "Select options from database";
		el_choices_select.setAttribute("rel", "{handler: 'iframe', size: {x: 530, y: 370}}"	);
		el_choices_select.setAttribute("onclick","tb_show('', 'admin-ajax.php?action=select_data_from_db&field_id="+i+"&field_type=checkbox&value_disabled="+w_value_disabled+"&width=530&height=370&TB_iframe=1')");
		el_choices_select.setAttribute("class","modal");
		
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	var br7 = document.createElement('br');
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td10.appendChild(el_label_size_label);
	edit_main_td10_1.appendChild(el_label_size);

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);

	edit_main_td3.appendChild(el_label_flow);
	edit_main_td3_1.appendChild(el_flow_vertical);
	edit_main_td3_1.appendChild(el_label_vertical);
	edit_main_td3_1.appendChild(br1);
	edit_main_td3_1.appendChild(el_flow_horizontal);
	edit_main_td3_1.appendChild(el_label_horizontal);
	
	
	edit_main_td13.appendChild(el_disable_value_label);
	edit_main_td13_1.appendChild(el_disable_value);
	
	edit_main_td5.appendChild(el_required_label);
	edit_main_td5_1.appendChild(el_required);
	
	edit_main_td8.appendChild(el_randomize_label);
	edit_main_td8_1.appendChild(el_randomize);
	
	edit_main_td12.appendChild(el_option_position_label);
	edit_main_td12_1.appendChild(el_option_position1);
	edit_main_td12_1.appendChild(el_option_left);
	edit_main_td12_1.appendChild(br2);
	edit_main_td12_1.appendChild(el_option_position2);
	edit_main_td12_1.appendChild(el_option_right);
	
	edit_main_td9.appendChild(el_allow_other_label);
	edit_main_td9_1.appendChild(el_allow_other);
	
	edit_main_td11.appendChild(el_rowcol_label);
	edit_main_td11_1.appendChild(el_rowcol_textarea);
	
	edit_main_td6.appendChild(el_style_label);
	edit_main_td6_1.appendChild(el_style_textarea);
	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br6);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");
	
	edit_main_td4.appendChild(el_choices_label);
	edit_main_td4_1.appendChild(br7);
	edit_main_td4_1.appendChild(el_choices_add);
	edit_main_td4_1.appendChild(el_choices_add_text);
	edit_main_td4_1.appendChild(el_choices_select);
	
	var div_ = document.createElement('div');
		div_.style.cssText = 'border-bottom:1px dotted black; width: 275px;';
	var br = document.createElement('br');
		
	var el_choices_mini_label = document.createElement('b');
		el_choices_mini_label.innerHTML="Name";
		el_choices_mini_label.style.cssText='padding-right: 40px; padding-left: 40px; font-size:9px; font-weight:bold;';

	var el_choices_value_mini_label = document.createElement('b');
		el_choices_value_mini_label.innerHTML="Value";
		el_choices_value_mini_label.style.cssText='padding-right: 38px; padding-left: 38px; font-size:9px; font-weight:bold;';
		
	var el_choices_dis_mini_label = document.createElement('b');
		el_choices_dis_mini_label.innerHTML="Delete";
		el_choices_dis_mini_label.style.cssText='padding-left: 3px; padding-right: 3px; font-size:9px; font-weight:bold;';
	
	var el_choices_move_mini_label = document.createElement('b');
		el_choices_move_mini_label.innerHTML="Move";
		el_choices_move_mini_label.style.cssText='padding-left: 3px; padding-right: 3px; font-size:9px; font-weight:bold;';		
	
	div_.appendChild(br);
	div_.appendChild(el_choices_mini_label);
	div_.appendChild(el_choices_value_mini_label);
	div_.appendChild(el_choices_dis_mini_label);
	div_.appendChild(el_choices_move_mini_label);
	edit_main_td4.appendChild(div_);

	
	aaa = false;
	n=w_choices.length;
	for(j=0; j<n; j++) {	
		var div = document.createElement('div');
			div.setAttribute("id", j);
			div.setAttribute("class", "change_pos");
			
		var el_choices = document.createElement('input');
			el_choices.setAttribute("id", "el_choices"+j);
			el_choices.setAttribute("type", "text");
			el_choices.setAttribute("class", "fm-field-choice");
			if(w_allow_other=="yes" && j==w_allow_other_num)
			el_choices.setAttribute("other", '1');
			el_choices.setAttribute("value", w_choices[j]);
			el_choices.setAttribute("checked", w_choices_checked[j]);
			el_choices.setAttribute("onKeyUp", "change_label_name("+j+", '"+i+"_label_element"+j+"', this.value, 'checkbox'); change_label_value('"+i+"_elementform_id_temp"+j+"', jQuery('#el_option_value"+j+"').val());");
			el_choices.setAttribute("onpaste", "elem = this; change_label_name_on_paste('"+j+"', '"+i+"_label_element"+j+"', 'checkbox'); change_label_value_on_paste('"+i+"_elementform_id_temp"+j+"', this)");	
			if(w_choices_params[j])
				el_choices.setAttribute("disabled", 'disabled');	
	
		var el_choices_value = document.createElement('input');
			el_choices_value.setAttribute("id", "el_option_value"+j);		
			if(!w_choices_params[j] && (w_allow_other!="yes" || j!=w_allow_other_num))
				el_choices_value.setAttribute("class", "el_option_value fm-field-choice");
			else
				el_choices_value.setAttribute("class", "fm-field-choice");
			el_choices_value.setAttribute("type", "text");
			el_choices_value.setAttribute("value", w_choices_value[j]);
			el_choices_value.setAttribute("onKeyUp", "change_label_value('"+i+"_elementform_id_temp"+j+"', this.value)");
			el_choices_value.setAttribute("onpaste", "change_label_value_on_paste('"+i+"_elementform_id_temp"+j+"', this)");
			if(w_value_disabled=='no' || w_choices_params[j] || (w_allow_other=="yes" && j==w_allow_other_num))
				el_choices_value.setAttribute("disabled", 'disabled');
	
		var el_choices_params = document.createElement('input');
			el_choices_params.setAttribute("id", "el_option_params"+j);
			el_choices_params.setAttribute("class", "el_option_params");
			el_choices_params.setAttribute("type", "hidden");
			el_choices_params.setAttribute("value", w_choices_params[j]);

		var el_choices_remove = document.createElement('img');
			el_choices_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
		if(w_allow_other=="yes" && j==w_allow_other_num)
			el_choices_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px; display:none';
		else			
			el_choices_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px;';
			el_choices_remove.setAttribute("align", 'top');
			el_choices_remove.setAttribute("onClick", "remove_choise("+j+","+i+",'checkbox')");
			
		var el_choices_handle = document.createElement('img');
			el_choices_handle.setAttribute("class", "el_choices_sortable");
			el_choices_handle.setAttribute("src", plugin_url + '/images/move_cursor.png?ver=1.8.0');	
			if(w_allow_other=="yes" && j==w_allow_other_num)			
				el_choices_handle.style.cssText = 'cursor:move; vertical-align:middle; margin:2px 0px 2px 34px;';
			else	
				el_choices_handle.style.cssText = 'cursor:move; vertical-align:middle;  margin:2px;';
			el_choices_handle.setAttribute("align", 'top');
	
		
		div.appendChild(el_choices);
		div.appendChild(el_choices_value);	
		div.appendChild(el_choices_remove);
		div.appendChild(el_choices_handle);
		div.appendChild(el_choices_params);
		edit_main_td4.appendChild(div);
		if(w_choices_checked[j]==true)
			if(w_allow_other=="yes" && j==w_allow_other_num)
				aaa = true;
	}

	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr13.appendChild(edit_main_td13);
	edit_main_tr13.appendChild(edit_main_td13_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr12.appendChild(edit_main_td12);
	edit_main_tr12.appendChild(edit_main_td12_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr11.appendChild(edit_main_td11);
	edit_main_tr11.appendChild(edit_main_td11_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr11);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr12);
	edit_main_table.appendChild(edit_main_tr13);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr7);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	
	element='input';
	type = 'checkbox'; 
	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_checkbox");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required = document.createElement("input");
		adding_required.setAttribute("type", "hidden");
		adding_required.setAttribute("value", w_required);
		adding_required.setAttribute("name", i+"_requiredform_id_temp");
		adding_required.setAttribute("id", i+"_requiredform_id_temp");
			
 	var adding_randomize = document.createElement("input");
		adding_randomize.setAttribute("type", "hidden");
		adding_randomize.setAttribute("value", w_randomize);
		adding_randomize.setAttribute("name", i+"_randomizeform_id_temp");			
		adding_randomize.setAttribute("id", i+"_randomizeform_id_temp");
	    
	var adding_allow_other = document.createElement("input");
		adding_allow_other.setAttribute("type", "hidden");
		adding_allow_other.setAttribute("value", w_allow_other);
		adding_allow_other.setAttribute("name", i+"_allow_otherform_id_temp");			
		adding_allow_other.setAttribute("id", i+"_allow_otherform_id_temp");
	    
	var adding_allow_other_id = document.createElement("input");
		adding_allow_other_id.setAttribute("type", "hidden");
		adding_allow_other_id.setAttribute("value", w_allow_other_num);
		adding_allow_other_id.setAttribute("name", i+"_allow_other_numform_id_temp");			
		adding_allow_other_id.setAttribute("id", i+"_allow_other_numform_id_temp");
			
	var adding_rowcol= document.createElement("input");
		adding_rowcol.setAttribute("type", "hidden");
		adding_rowcol.setAttribute("value", w_rowcol);
		adding_rowcol.setAttribute("name", i+"_rowcol_numform_id_temp");			
		adding_rowcol.setAttribute("id", i+"_rowcol_numform_id_temp");		
	var adding_option_left_right= document.createElement("input");
		adding_option_left_right.setAttribute("type", "hidden");
		adding_option_left_right.setAttribute("value", w_field_option_pos);	
		adding_option_left_right.setAttribute("id", i+"_option_left_right");		 

	var adding_value_disabled = document.createElement("input");
		adding_value_disabled.setAttribute("type", "hidden");
		adding_value_disabled.setAttribute("value", w_value_disabled);
		adding_value_disabled.setAttribute("name", i+"_value_disabledform_id_temp");	
		adding_value_disabled.setAttribute("id", i+"_value_disabledform_id_temp"); 	    
	var div = document.createElement('div');
       	div.setAttribute("id", "main_div");
		
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width=w_field_label_size+"px";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");

	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	
	var table_little_t = document.createElement('div');
		table_little_t.style.display="table";
			
	var table_little = document.createElement('div');
		table_little.setAttribute("id", i+"_table_little");
		table_little.style.display="table-row-group";
		table_little_t.appendChild(table_little);
   
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
		label.style.verticalAlign="top";

	
	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
		required.style.verticalAlign="top";
		if(w_required=="yes")
			required.innerHTML = " *";

	var main_td  = document.getElementById('show_table');
  
	div_label.appendChild(label);
	div_label.appendChild(required);
	div_element.appendChild(adding_type);

	div_element.appendChild(adding_required);
	div_element.appendChild(adding_randomize);
	div_element.appendChild(adding_allow_other);
	div_element.appendChild(adding_allow_other_id);
	div_element.appendChild(adding_rowcol);
	div_element.appendChild(adding_option_left_right);
	div_element.appendChild(adding_value_disabled);
	div_element.appendChild(table_little_t);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
  
	div.appendChild(div_field);
	div.appendChild(br3);
	main_td.appendChild(div);

	if(w_field_label_pos=="top")
		label_top(i);
				
	change_class(w_class, i);
	refresh_attr(i, 'type_checkbox');

	refresh_rowcol(i, 'checkbox');
	add_id_and_name(i, 'type_checkbox');
	if(aaa)
		show_other_input(i);
	
	jQuery(function() {
		jQuery( "#choices" ).sortable({ 
			items: ".change_pos" ,
			handle: ".el_choices_sortable",
			update: function(event, ui) {		
				refresh_rowcol(i, 'checkbox');
				refresh_id_name(i, 'type_checkbox');
			}
		});	
	});
}

function type_radio(i, w_field_label, w_field_label_size, w_field_label_pos, w_field_option_pos, w_flow, w_choices, w_choices_checked, w_rowcol, w_required, w_randomize, w_allow_other, w_allow_other_num, w_class, w_attr_name, w_attr_value,w_value_disabled, w_choices_value, w_choices_params ){

	document.getElementById("element_type").value="type_radio";
	delete_last_child();
	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");

	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10  = document.createElement('tr');
	var edit_main_tr11  = document.createElement('tr');
    var edit_main_tr12  = document.createElement('tr');
    var edit_main_tr13  = document.createElement('tr'); 				

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
		edit_main_td4.setAttribute("id", "choices");
	var edit_main_td4_1 = document.createElement('td');
		edit_main_td4_1.style.cssText = "padding:20px 0 0 25px; vertical-align:top;";
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');
	var edit_main_td11 = document.createElement('td');
	var edit_main_td11_1 = document.createElement('td');
	var edit_main_td12 = document.createElement('td');
	var edit_main_td12_1 = document.createElement('td');
	var edit_main_td13 = document.createElement('td');
	var edit_main_td13_1 = document.createElement('td');		
		  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.setAttribute("class", "fm-field-label");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
		
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";
	
	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");
		el_label_position1.setAttribute("checked", "checked");
		
	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
        el_label_left.innerHTML = "Left";
		
	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");
		
	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
        el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos == "top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");
				
	var el_option_position_label = document.createElement('label');
		el_option_position_label.setAttribute("class", "fm-field-label");
		el_option_position_label.innerHTML = "Field option label position";
	
	var el_option_position1 = document.createElement('input');
		el_option_position1.setAttribute("id", "edit_for_option_position_right");
		el_option_position1.setAttribute("type", "radio");        
		el_option_position1.setAttribute("name", "edit_for_option_position");
		el_option_position1.setAttribute("onchange", "option_left("+i+",'radio')");
		
	var el_option_left = document.createElement('label');
		el_option_left.setAttribute("for", "edit_for_option_position_right");
        el_option_left.innerHTML = "Left";	
		
	var el_option_position2 = document.createElement('input');
		el_option_position2.setAttribute("id", "edit_for_option_position_left");
		el_option_position2.setAttribute("type", "radio");
    	el_option_position2.setAttribute("name", "edit_for_option_position");
		el_option_position2.setAttribute("onchange", "option_right("+i+",'radio')");
		
	var el_option_right = document.createElement('label');
		el_option_right.setAttribute("for", "edit_for_option_position_left");
        el_option_right.innerHTML = "Right";
		
	if(w_field_option_pos == "right")
		el_option_position2.setAttribute("checked", "checked");
	else
		el_option_position1.setAttribute("checked", "checked");
	var el_label_flow = document.createElement('label');
		el_label_flow.setAttribute("class", "fm-field-label");
		el_label_flow.innerHTML = "Relative Position";

	var el_flow_vertical = document.createElement('input');
		el_flow_vertical.setAttribute("id", "edit_for_flow_vertical");
		el_flow_vertical.setAttribute("type", "radio");
		el_flow_vertical.setAttribute("value", "ver");
		el_flow_vertical.setAttribute("name", "edit_for_flow");
		el_flow_vertical.setAttribute("onchange", "refresh_rowcol("+i+",'radio')");
	
	var el_label_vertical = document.createElement('label');
		el_label_vertical.setAttribute("for", "edit_for_flow_vertical");
        el_label_vertical.innerHTML = "Vertical";	
		
	var el_flow_horizontal = document.createElement('input');
            el_flow_horizontal.setAttribute("id", "edit_for_flow_horizontal");
            el_flow_horizontal.setAttribute("type", "radio");
            el_flow_horizontal.setAttribute("value", "hor");
            el_flow_horizontal.setAttribute("name", "edit_for_flow");
            el_flow_horizontal.setAttribute("onchange", "refresh_rowcol("+i+",'radio')");
			
	var el_label_horizontal = document.createElement('label');
		el_label_horizontal.setAttribute("for", "edit_for_flow_horizontal");
        el_label_horizontal.innerHTML = "Horizontal";		
	
	if(w_flow == "hor")
		el_flow_horizontal.setAttribute("checked", "checked");
	else
		el_flow_vertical.setAttribute("checked", "checked");
	var el_rowcol_label = document.createElement('label');
		el_rowcol_label.setAttribute("class", "fm-field-label");
		el_rowcol_label.setAttribute("for", "edit_for_rowcol");
		el_rowcol_label.innerHTML = "Rows/Columns";
	
	var el_rowcol_textarea = document.createElement('input');
        el_rowcol_textarea.setAttribute("id", "edit_for_rowcol");
		el_rowcol_textarea.setAttribute("type", "text");
 		el_rowcol_textarea.setAttribute("value", w_rowcol);
		el_rowcol_textarea.setAttribute("onChange", "refresh_rowcol('"+i+"','radio')");	

	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
	    el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
        el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
        
        el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");
	
	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_required");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required=="yes")
			el_required.setAttribute("checked", "checked");

	var el_disable_value_label = document.createElement('label');
		el_disable_value_label.setAttribute("for", "el_disable_value");
		el_disable_value_label.setAttribute("class", "fm-field-label");
		el_disable_value_label.innerHTML = "Enable option's value";
	
	var el_disable_value = document.createElement('input');
		el_disable_value.setAttribute("id", "el_disable_value");
		el_disable_value.setAttribute("type", "checkbox");   
		el_disable_value.setAttribute("onclick", "refresh_sel_options('"+i+"', 'radio')");
		if(w_value_disabled =="yes")
			el_disable_value.setAttribute("checked", "checked");
		
	var el_randomize_label = document.createElement('label');
		el_randomize_label.setAttribute("class", "fm-field-label");
		el_randomize_label.setAttribute("for", "el_randomize");
		el_randomize_label.innerHTML = "Randomize in frontend";
	
	var el_randomize = document.createElement('input');
		el_randomize.setAttribute("id", "el_randomize");
		el_randomize.setAttribute("type", "checkbox");
		el_randomize.setAttribute("value", "yes");
		el_randomize.setAttribute("onclick", "set_randomize('"+i+"_randomizeform_id_temp')");
		if(w_randomize=="yes")
			el_randomize.setAttribute("checked", "checked");

	var el_allow_other_label = document.createElement('label');
		el_allow_other_label.setAttribute("class", "fm-field-label");
		el_allow_other_label.setAttribute("for", "el_allow_other");
		el_allow_other_label.innerHTML = "Allow other";
	
	var el_allow_other = document.createElement('input');
		el_allow_other.setAttribute("id", "el_allow_other");
		el_allow_other.setAttribute("type", "checkbox");
		el_allow_other.setAttribute("value", "yes");
		el_allow_other.setAttribute("onclick", "set_allow_other('"+i+"','radio')");
		if(w_allow_other=="yes")
			el_allow_other.setAttribute("checked", "checked");

	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_checkbox')");
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
		el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++) {	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_checkbox')");
			
		var el_attr_value = document.createElement('input');
	
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_checkbox')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
		el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_checkbox')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
	}

	var el_choices_label = document.createElement('label');
		el_choices_label.setAttribute("class", "fm-field-label");
		el_choices_label.innerHTML = "Options ";

	var el_choices_add = document.createElement('img');
		el_choices_add.setAttribute("id", "el_choices_add");
		el_choices_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_choices_add.style.cssText = 'cursor:pointer;';
		el_choices_add.setAttribute("title", 'add');
		el_choices_add.setAttribute("onClick", "add_choise('radio',"+i+")");
	var	el_choices_add_text = document.createElement("span");
		el_choices_add_text.style.cssText ="font-size: 12px; padding-left:7px; font-weight:bold; cursor:pointer;";
		el_choices_add_text.innerHTML ="Add option(s)";				
		el_choices_add_text.setAttribute("onClick", "add_choise('radio',"+i+")");
		
	var el_choices_select = document.createElement('a');
	    el_choices_select.style.cssText ="color:#000; font-weight:bold; font-size: 13px; cursor:pointer; padding-top:10px; display:block;";
		el_choices_select.innerHTML = "Select options from database";
		el_choices_select.setAttribute("rel", "{handler: 'iframe', size: {x: 530, y: 370}}"	);
		el_choices_select.setAttribute("onclick","tb_show('', 'admin-ajax.php?action=select_data_from_db&field_id="+i+"&field_type=radio&value_disabled="+w_value_disabled+"&width=530&height=370&TB_iframe=1')");
		el_choices_select.setAttribute("class","modal");			
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	var br7 = document.createElement('br');

	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td10.appendChild(el_label_size_label);
	edit_main_td10_1.appendChild(el_label_size);

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_label_flow);
	edit_main_td3_1.appendChild(el_flow_vertical);
	edit_main_td3_1.appendChild(el_label_vertical);
	edit_main_td3_1.appendChild(br1);
	edit_main_td3_1.appendChild(el_flow_horizontal);
	edit_main_td3_1.appendChild(el_label_horizontal);
	
	edit_main_td13.appendChild(el_disable_value_label);
	edit_main_td13_1.appendChild(el_disable_value);
	
	edit_main_td11.appendChild(el_rowcol_label);
	edit_main_td11_1.appendChild(el_rowcol_textarea);

	edit_main_td6.appendChild(el_style_label);
	edit_main_td6_1.appendChild(el_style_textarea);
	
	edit_main_td5.appendChild(el_required_label);
	edit_main_td5_1.appendChild(el_required);
	
	edit_main_td8.appendChild(el_randomize_label);
	edit_main_td8_1.appendChild(el_randomize);
	
	edit_main_td12.appendChild(el_option_position_label);
	edit_main_td12_1.appendChild(el_option_position1);
	edit_main_td12_1.appendChild(el_option_left);
	edit_main_td12_1.appendChild(br2);
	edit_main_td12_1.appendChild(el_option_position2);
	edit_main_td12_1.appendChild(el_option_right);
	
	edit_main_td9.appendChild(el_allow_other_label);
	edit_main_td9_1.appendChild(el_allow_other);
	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br6);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");
	
	edit_main_td4.appendChild(el_choices_label);
	edit_main_td4_1.appendChild(br7);
	edit_main_td4_1.appendChild(el_choices_add);
	edit_main_td4_1.appendChild(el_choices_add_text);
	edit_main_td4_1.appendChild(el_choices_select);

	var div_ = document.createElement('div');
		div_.style.cssText = 'border-bottom:1px dotted black; width: 275px;';
	var br = document.createElement('br');
		
	var el_choices_mini_label = document.createElement('b');
		el_choices_mini_label.innerHTML="Name";
		el_choices_mini_label.style.cssText='padding-right: 40px; padding-left: 40px; font-size:9px';

	var el_choices_value_mini_label = document.createElement('b');
		el_choices_value_mini_label.innerHTML="Value";
		el_choices_value_mini_label.style.cssText='padding-right: 38px; padding-left: 38px; font-size:9px; font-weight:bold;';
		
	var el_choices_dis_mini_label = document.createElement('b');
		el_choices_dis_mini_label.innerHTML="Delete";
		el_choices_dis_mini_label.style.cssText='padding-left: 3px; padding-right: 3px; font-size:9px; font-weight:bold;';
	
	var el_choices_move_mini_label = document.createElement('b');
		el_choices_move_mini_label.innerHTML="Move";
		el_choices_move_mini_label.style.cssText='padding-left: 3px; padding-right: 3px; font-size:9px; font-weight:bold;';		
	
	div_.appendChild(br);
	div_.appendChild(el_choices_mini_label);
	div_.appendChild(el_choices_value_mini_label);
	div_.appendChild(el_choices_dis_mini_label);
	div_.appendChild(el_choices_move_mini_label);
	edit_main_td4.appendChild(div_);
						
	aaa=false;
	n=w_choices.length;
	for(j=0; j<n; j++) {	
		var div = document.createElement('div');
			div.setAttribute("id", j);
			div.setAttribute("class", "change_pos");
			
		var el_choices = document.createElement('input');
			el_choices.setAttribute("id", "el_choices"+j);
			el_choices.setAttribute("class", "fm-field-choice");
			el_choices.setAttribute("type", "text");
			if(w_allow_other=="yes" && j==w_allow_other_num)
			el_choices.setAttribute("other", '1');
			el_choices.setAttribute("value", w_choices[j]);
			el_choices.setAttribute("checked", w_choices_checked[j]);
			el_choices.setAttribute("onKeyUp", "change_label('"+i+"_label_element"+j+"', this.value)");
			el_choices.setAttribute("onpaste", "elem = this; change_label_name_on_paste('"+j+"', '"+i+"_label_element"+j+"', 'radio'); change_label_value_on_paste('"+i+"_elementform_id_temp"+j+"', this)");	
			if(w_choices_params[j])
				el_choices.setAttribute("disabled", 'disabled');
	
		var el_choices_value = document.createElement('input');
			el_choices_value.setAttribute("id", "el_option_value"+j);
			if(!w_choices_params[j] && (w_allow_other!="yes" || j!=w_allow_other_num))
				el_choices_value.setAttribute("class", "el_option_value fm-field-choice");
			else
				el_choices_value.setAttribute("class", "fm-field-choice");
			el_choices_value.setAttribute("type", "text");
			el_choices_value.setAttribute("value", w_choices_value[j]);
			el_choices_value.setAttribute("onKeyUp", "change_label_value('"+i+"_elementform_id_temp"+j+"', this.value)");
			el_choices_value.setAttribute("onpaste", "change_label_value_on_paste('"+i+"_elementform_id_temp"+j+"', this)");
			if(w_value_disabled=='no' || w_choices_params[j] || (w_allow_other=="yes" && j==w_allow_other_num))
				el_choices_value.setAttribute("disabled", 'disabled');
	
		var el_choices_params = document.createElement('input');
			el_choices_params.setAttribute("id", "el_option_params"+j);
			el_choices_params.setAttribute("class", "el_option_params");
			el_choices_params.setAttribute("type", "hidden");
			el_choices_params.setAttribute("value", w_choices_params[j]);
	
		var el_choices_remove = document.createElement('img');
			el_choices_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
		if(w_allow_other=="yes" && j==w_allow_other_num)
			el_choices_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px; display:none';
		else			
			el_choices_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_choices_remove.setAttribute("align", 'top');
			el_choices_remove.setAttribute("onClick", "remove_choise("+j+","+i+",'radio')");
			
		var el_choices_handle = document.createElement('img');
			el_choices_handle.setAttribute("class", "el_choices_sortable");
			el_choices_handle.setAttribute("src", plugin_url + '/images/move_cursor.png?ver=1.8.0');		
			if(w_allow_other=="yes" && j==w_allow_other_num)			
				el_choices_handle.style.cssText = 'cursor:move; vertical-align:middle; margin:2px 0px 2px 34px;';
			else	
				el_choices_handle.style.cssText = 'cursor:move; vertical-align:middle; margin:2px;';
			el_choices_handle.setAttribute("align", 'top');
	
			
		div.appendChild(el_choices);
		div.appendChild(el_choices_value);	
		div.appendChild(el_choices_remove);
		div.appendChild(el_choices_handle);
		div.appendChild(el_choices_params);
		edit_main_td4.appendChild(div);
		if(w_choices_checked[j]==true)
			if(w_allow_other=="yes" && j==w_allow_other_num)
				aaa=true;
	}
	
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr13.appendChild(edit_main_td13);
	edit_main_tr13.appendChild(edit_main_td13_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr12.appendChild(edit_main_td12);
	edit_main_tr12.appendChild(edit_main_td12_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr11.appendChild(edit_main_td11);
	edit_main_tr11.appendChild(edit_main_td11_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr11);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr12);
	edit_main_table.appendChild(edit_main_tr13);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr7);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	
	element='input';	
	type='radio'; 
	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_radio");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required = document.createElement("input");
		adding_required.setAttribute("type", "hidden");
		adding_required.setAttribute("value", w_required);
		adding_required.setAttribute("name", i+"_requiredform_id_temp");			
		adding_required.setAttribute("id", i+"_requiredform_id_temp");
	    
	var adding_randomize = document.createElement("input");
		adding_randomize.setAttribute("type", "hidden");
		adding_randomize.setAttribute("value", w_randomize);
		adding_randomize.setAttribute("name", i+"_randomizeform_id_temp");			
		adding_randomize.setAttribute("id", i+"_randomizeform_id_temp");
	    
	var adding_allow_other= document.createElement("input");
		adding_allow_other.setAttribute("type", "hidden");
		adding_allow_other.setAttribute("value", w_allow_other);
		adding_allow_other.setAttribute("name", i+"_allow_otherform_id_temp");			
		adding_allow_other.setAttribute("id", i+"_allow_otherform_id_temp");
	 
	var adding_rowcol= document.createElement("input");
		adding_rowcol.setAttribute("type", "hidden");
		adding_rowcol.setAttribute("value", w_rowcol);
		adding_rowcol.setAttribute("name", i+"_rowcol_numform_id_temp");			
		adding_rowcol.setAttribute("id", i+"_rowcol_numform_id_temp");
		
	var adding_option_left_right= document.createElement("input");
		adding_option_left_right.setAttribute("type", "hidden");
		adding_option_left_right.setAttribute("value", w_field_option_pos);	
		adding_option_left_right.setAttribute("id", i+"_option_left_right");	
			
	var adding_value_disabled = document.createElement("input");
		adding_value_disabled.setAttribute("type", "hidden");
		adding_value_disabled.setAttribute("value", w_value_disabled);
		adding_value_disabled.setAttribute("name", i+"_value_disabledform_id_temp");	
		adding_value_disabled.setAttribute("id", i+"_value_disabledform_id_temp"); 				
	
	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
			
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width=w_field_label_size+"px";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");

	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');	
	
	var table_little_t = document.createElement('div');
		table_little_t.style.display="table";
		
	var table_little = document.createElement('div');
		table_little.setAttribute("id", i+"_table_little");
		table_little.style.display="table-row-group";
			
	table_little_t.appendChild(table_little);
	
	var tr_little1 = document.createElement('div');
		tr_little1.setAttribute("id", i+"_element_tr1");
		tr_little1.style.display="table-row";
	
	var tr_little2 = document.createElement('div');
		tr_little2.setAttribute("id", i+"_element_tr2");
		tr_little2.style.display="table-row";
		
	var td_little1 = document.createElement('div');
		td_little1.setAttribute("valign", 'top');
		td_little1.setAttribute("id", i+"_td_little1");
		td_little1.style.display="table-cell";
		
	var td_little2 = document.createElement('div');
		td_little2.setAttribute("valign", 'top');
		td_little2.setAttribute("id", i+"_td_little2");
		td_little2.style.display="table-cell";
			
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
		label.style.verticalAlign="top";
	
	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
		required.style.verticalAlign="top";
		if(w_required=="yes")
			required.innerHTML = " *";
	    
	var main_td  = document.getElementById('show_table');

  
	div_label.appendChild(label);
	div_label.appendChild(required);
	div_element.appendChild(adding_type);

	div_element.appendChild(adding_required);
	div_element.appendChild(adding_randomize);
	div_element.appendChild(adding_allow_other);
	div_element.appendChild(adding_rowcol);
	div_element.appendChild(adding_option_left_right);
	div_element.appendChild(adding_value_disabled);
	div_element.appendChild(table_little_t);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);

	div.appendChild(div_field);
	div.appendChild(br3);
	main_td.appendChild(div);
		
	if(w_field_label_pos=="top")
		label_top(i);
		
	change_class(w_class, i);
	refresh_attr(i, 'type_checkbox');

	refresh_rowcol(i, 'radio');
	add_id_and_name(i, 'type_radio');
	if(aaa)
		show_other_input(i);
	
	jQuery(function() {
		jQuery( "#choices" ).sortable({ 
			items: ".change_pos" ,
			handle: ".el_choices_sortable",
			update: function(event, ui) {		
				refresh_rowcol(i, 'radio');
				refresh_id_name(i, 'type_radio');
			}
		});	
	});
}

function type_time(i, w_field_label, w_field_label_size, w_field_label_pos, w_time_type, w_am_pm, w_sec, w_hh, w_mm, w_ss, w_mini_labels, w_required, w_class, w_attr_name, w_attr_value) {
	
	document.getElementById("element_type").value="type_time";
	delete_last_child();
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');	
		  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
			el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
                el_label_textarea.setAttribute("id", "edit_for_label");
                el_label_textarea.setAttribute("rows", "4");
                
                el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
				el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_label_time_type_label = document.createElement('label');
	    el_label_time_type_label.setAttribute("class", "fm-field-label");
		el_label_time_type_label.setAttribute("for", "el_label_time_type1");
		el_label_time_type_label.innerHTML = "Time Format";
	
	var el_label_time_type1 = document.createElement('input');
                el_label_time_type1.setAttribute("id", "el_label_time_type1");
                el_label_time_type1.setAttribute("type", "radio");
                el_label_time_type1.setAttribute("value", "format_24");
                el_label_time_type1.setAttribute("name", "edit_for_time_type");
                el_label_time_type1.setAttribute("onchange", "format_24("+i+")");
		el_label_time_type1.setAttribute("checked", "checked");
		hour_24 = document.createTextNode("24 hour");
		
	var el_label_time_type2 = document.createElement('input');
                el_label_time_type2.setAttribute("id", "el_label_time_type2");
                el_label_time_type2.setAttribute("type", "radio");
                el_label_time_type2.setAttribute("value", "format_12");
                el_label_time_type2.setAttribute("name", "edit_for_time_type");
                el_label_time_type2.setAttribute("onchange", "format_12("+i+", 'am','', '','')");
		am_pm = document.createTextNode("12 hour");
		
	if(w_time_type=="24")
	
				el_label_time_type1.setAttribute("checked", "checked");
	else
				el_label_time_type2.setAttribute("checked", "checked");

	var el_label_second_label = document.createElement('label');
	    el_label_second_label.setAttribute("class", "fm-field-label");
		el_label_second_label.setAttribute("for", "el_second_yes");
		el_label_second_label.innerHTML = "Display Seconds";
	
	var el_second_yes = document.createElement('input');
                el_second_yes.setAttribute("id", "el_second_yes");
                el_second_yes.setAttribute("type", "radio");
                el_second_yes.setAttribute("value", "yes");
                el_second_yes.setAttribute("name", "edit_for_time_second");
                el_second_yes.setAttribute("onchange", "second_yes("+i+",'"+w_ss+"')");
		el_second_yes.setAttribute("checked", "checked");
		display_seconds = document.createTextNode("Yes");
		
	var el_second_no = document.createElement('input');
                el_second_no.setAttribute("id", "el_second_no");
                el_second_no.setAttribute("type", "radio");
                el_second_no.setAttribute("value", "no");
                el_second_no.setAttribute("name", "edit_for_time_second");
                el_second_no.setAttribute("onchange", "second_no("+i+")");
		dont_display_seconds = document.createTextNode("No");
		
	if(w_sec=="1")
	
				el_second_yes.setAttribute("checked", "checked");
	else
				el_second_no.setAttribute("checked", "checked");
	var el_style_label = document.createElement('label');
	    el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
                el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
                
                el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
	        el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
                el_required.setAttribute("id", "el_required");
                el_required.setAttribute("type", "checkbox");
                
                el_required.setAttribute("onclick", "set_required('"+i+"_required')");
	if(w_required=="yes")
			
                el_required.setAttribute("checked", "checked");
	var el_attr_label = document.createElement('label');
	    el_attr_label.setAttribute("class", "fm-field-label");                   
			el_attr_label.innerHTML = "Additional Attributes";
			
	var el_attr_add = document.createElement('img');
                
           	el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_time')");
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_time')");
			
		var el_attr_value = document.createElement('input');
	
			el_attr_value.setAttribute("type", "text");
	
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_time')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_time')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}

	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td8.appendChild(el_label_size_label);
	edit_main_td8_1.appendChild(el_label_size);

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_label_time_type_label);
	edit_main_td3_1.appendChild(el_label_time_type1);
	edit_main_td3_1.appendChild(hour_24);
	edit_main_td3_1.appendChild(br6);
	edit_main_td3_1.appendChild(el_label_time_type2);
	edit_main_td3_1.appendChild(am_pm);
	
	edit_main_td4.appendChild(el_label_second_label);
	edit_main_td4_1.appendChild(el_second_yes);
	edit_main_td4_1.appendChild(display_seconds);
	edit_main_td4_1.appendChild(br4);
	edit_main_td4_1.appendChild(el_second_no);
	edit_main_td4_1.appendChild(dont_display_seconds);
	
	edit_main_td5.appendChild(el_style_label);
	edit_main_td5_1.appendChild(el_style_textarea);
	
	edit_main_td6.appendChild(el_required_label);
	edit_main_td6_1.appendChild(el_required);

	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br6);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr7);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_time');
	
//show table
	var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_time");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required = document.createElement("input");
            adding_required.setAttribute("type", "hidden");
            adding_required.setAttribute("value", w_required);
            adding_required.setAttribute("name", i+"_requiredform_id_temp");
			
            adding_required.setAttribute("id", i+"_requiredform_id_temp");
     	var div = document.createElement('div');
      	    div.setAttribute("id", "main_div");
		
		var div_for_editable_labels = document.createElement('div');
			div_for_editable_labels.setAttribute("class", "fm-editable-label");
			
      	edit_labels = document.createTextNode("The labels of the fields are editable. Please, click the label to edit.");

		div_for_editable_labels.appendChild(edit_labels);  	

		
      	var div_field = document.createElement('div');
           	div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
      	var div_label = document.createElement('div');
         	div_label.setAttribute("align", 'left');
         	div_label.style.display="table-cell";
			div_label.style.width=w_field_label_size+"px";
           	div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
      	var div_element = document.createElement('div');
         	div_element.setAttribute("align", 'left');
          	div_element.style.display="table-cell";
          	div_element.setAttribute("id", i+"_element_sectionform_id_temp");
			
      	var table_time = document.createElement('div');
           	table_time.setAttribute("id", i+"_table_time");
			table_time.style.display="table";
			
      	var tr_time1 = document.createElement('div');
           	tr_time1.setAttribute("id", i+"_tr_time1");
			tr_time1.style.display="table-row";
			
      	var tr_time2 = document.createElement('div');
           	tr_time2.setAttribute("id", i+"_tr_time2");
			tr_time2.style.display="table-row";
			
      	var td_time_input1 = document.createElement('div');
           	td_time_input1.setAttribute("id", i+"_td_time_input1");
	        td_time_input1.style.cssText ="width:32px";
			td_time_input1.style.display="table-cell";
		
      	var td_time_input1_ket = document.createElement('div');
           	td_time_input1_ket.setAttribute("align", "center");
			td_time_input1_ket.style.display="table-cell";
		

      	var td_time_input2 = document.createElement('div');
           	td_time_input2.setAttribute("id", i+"_td_time_input2");
 	        td_time_input2.style.cssText ="width:32px";
			td_time_input2.style.display="table-cell";
			
     	var td_time_input2_ket = document.createElement('div');
           	td_time_input2_ket.setAttribute("align", "center");
			td_time_input2_ket.style.display="table-cell";
		
      	var td_time_input3 = document.createElement('div');
           	td_time_input3.setAttribute("id", i+"_td_time_input3");
 	        td_time_input3.style.cssText ="width:32px";
			td_time_input3.style.display="table-cell";

      	var td_time_label1 = document.createElement('div');
           	td_time_label1.setAttribute("id", i+"_td_time_label1");
			td_time_label1.style.display="table-cell";
			
      	var td_time_label1_ket = document.createElement('div');
			td_time_label1_ket.style.display="table-cell";
      	var td_time_label2 = document.createElement('div');
           	td_time_label2.setAttribute("id", i+"_td_time_label2");
			td_time_label2.style.display="table-cell";
      	var td_time_label2_ket = document.createElement('div');
			td_time_label2_ket.style.display="table-cell";
      	var td_time_label3 = document.createElement('div');
           	td_time_label3.setAttribute("id", i+"_td_time_label3");
			td_time_label3.style.display="table-cell";
			
      	var br1 = document.createElement('br');
      	var br2 = document.createElement('br');
     	var br3 = document.createElement('br');
      	var br4 = document.createElement('br');
      

      	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
		label.style.verticalAlign="top";
	    
      	var required = document.createElement('span');
			required.setAttribute("id", i+"_required_elementform_id_temp");
			required.innerHTML = "";
			required.setAttribute("class", "required");
			required.style.verticalAlign="top";
	if(w_required=="yes")
			required.innerHTML = " *";
			
	var hh = document.createElement('input');
	hh.setAttribute("type", 'text');
	hh.setAttribute("value", w_hh);
	    hh.setAttribute("class", "time_box");
	    hh.setAttribute("id", i+"_hhform_id_temp");
	    hh.setAttribute("name", i+"_hhform_id_temp");
	    hh.setAttribute("onKeyPress", "return check_hour(event, '"+i+"_hhform_id_temp', '23')");
	    hh.setAttribute("onKeyUp", "change_hour(event, '"+i+"_hhform_id_temp','23')");
	    hh.setAttribute("onBlur", "add_0('"+i+"_hhform_id_temp')");
			
	var hh_label = document.createElement('label');
	    hh_label.setAttribute("class", "mini_label");
	    hh_label.setAttribute("id", i+"_mini_label_hh");
	    hh_label.innerHTML=w_mini_labels[0];
			
	var hh_ = document.createElement('span');
        hh_.setAttribute("class", 'wdform_colon');
	    hh_.style.cssText = "font-style:bold; vertical-align:middle";
	    hh_.innerHTML="&nbsp;:&nbsp;";
		
	var mm = document.createElement('input');
        mm.setAttribute("type", 'text');
		mm.setAttribute("value", w_mm);
		mm.setAttribute("class", "time_box");
		
		mm.setAttribute("id", i+"_mmform_id_temp");
	    	mm.setAttribute("name", i+"_mmform_id_temp");
		mm.setAttribute("onKeyPress", "return check_minute(event, '"+i+"_mmform_id_temp')");
	        mm.setAttribute("onKeyUp", "change_minute(event, '"+i+"_mmform_id_temp')");
		mm.setAttribute("onBlur", "add_0('"+i+"_mmform_id_temp')");
		
	var mm_label = document.createElement('label');
		mm_label.setAttribute("class", "mini_label");
		mm_label.setAttribute("id", i+"_mini_label_mm");
		mm_label.innerHTML=w_mini_labels[1];
			
	var mm_ = document.createElement('span');
		mm_.style.cssText = "font-style:bold; vertical-align:middle";
		mm_.innerHTML="&nbsp;:&nbsp;";
        mm_.setAttribute("class", 'wdform_colon');
		
	var ss = document.createElement('input');
           	ss.setAttribute("type", 'text');
		ss.setAttribute("value", w_ss);
		ss.setAttribute("class", "time_box");
		
		ss.setAttribute("id", i+"_ssform_id_temp");
		ss.setAttribute("name", i+"_ssform_id_temp");
		ss.setAttribute("onKeyPress", "return check_second(event, '"+i+"_ssform_id_temp')");
		ss.setAttribute("onKeyUp", "change_second(event, '"+i+"_ssform_id_temp')");
		ss.setAttribute("onBlur", "add_0('"+i+"_ssform_id_temp')");

	var ss_label = document.createElement('label');
		ss_label.setAttribute("class", "mini_label");
		ss_label.setAttribute("id", i+"_mini_label_ss");
		ss_label.innerHTML=w_mini_labels[2];
			
      	var main_td  = document.getElementById('show_table');
	
      
      	div_label.appendChild(label);
      	div_label.appendChild(required);
		
      	td_time_input1.appendChild(hh);
      	td_time_input1_ket.appendChild(hh_);
      	td_time_input2.appendChild(mm);
      	td_time_input2_ket.appendChild(mm_);
      	td_time_input3.appendChild(ss);
      	tr_time1.appendChild(td_time_input1);
      	tr_time1.appendChild(td_time_input1_ket);
      	tr_time1.appendChild(td_time_input2);
      	tr_time1.appendChild(td_time_input2_ket);
      	tr_time1.appendChild(td_time_input3);
		
      	td_time_label1.appendChild(hh_label);
      	td_time_label2.appendChild(mm_label);
      	td_time_label3.appendChild(ss_label);
      	tr_time2.appendChild(td_time_label1);
      	tr_time2.appendChild(td_time_label1_ket);
      	tr_time2.appendChild(td_time_label2);
      	tr_time2.appendChild(td_time_label2_ket);
      	tr_time2.appendChild(td_time_label3);
      	table_time.appendChild(tr_time1);
      	table_time.appendChild(tr_time2);
		
        div_element.appendChild(adding_type);
	
        div_element.appendChild(adding_required);
	div_element.appendChild(table_time);
      	div_field.appendChild(div_label);
      	div_field.appendChild(div_element);
      
      
      	div.appendChild(div_field);
      	div.appendChild(br3);
		div.appendChild(div_for_editable_labels);
      	main_td.appendChild(div);

	if(w_field_label_pos=="top")
				label_top(i);
	if(w_time_type=="12")
				format_12(i, w_am_pm,w_hh, w_mm,w_ss);

	if(w_sec=="0")
				second_no(i);
change_class(w_class, i);
refresh_attr(i, 'type_time');

jQuery(document).ready(function() {	
	jQuery("label#"+i+"_mini_label_hh").click(function() {		
		if (jQuery(this).children('input').length == 0) {				
			var hh = "<input type='text' class='hh' size='4' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
				jQuery(this).html(hh);							
				jQuery("input.hh").focus();			
				jQuery("input.hh").blur(function() {	
			var value = jQuery(this).val();			


		jQuery("#"+i+"_mini_label_hh").text(value);		
		});	
	}	
	});		


	jQuery("label#"+i+"_mini_label_mm").click(function() {	
	if (jQuery(this).children('input').length == 0) {		
		var mm = "<input type='text' class='mm' size='4' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
			jQuery(this).html(mm);			
			jQuery("input.mm").focus();					
			jQuery("input.mm").blur(function() {			
			var value = jQuery(this).val();			
			
			jQuery("#"+i+"_mini_label_mm").text(value);	
		});	
	}	
	});
	
		jQuery("label#"+i+"_mini_label_ss").click(function() {	
	if (jQuery(this).children('input').length == 0) {		
		var ss = "<input type='text' class='ss' size='4' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
			jQuery(this).html(ss);			
			jQuery("input.ss").focus();					
			jQuery("input.ss").blur(function() {			
			var value = jQuery(this).val();			
			
			jQuery("#"+i+"_mini_label_ss").text(value);	
		});	
	}	
	});
	
	});


}

function type_date(i, w_field_label, w_field_label_size, w_field_label_pos, w_date, w_required, w_class, w_format, w_but_val, w_attr_name, w_attr_value,w_disable_past_days) { 

	document.getElementById("element_type").value="type_date";
	delete_last_child();
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
			
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
		edit_main_tr4.style.cssText = "display:none;";
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
      				
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
	
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");

	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_format_label = document.createElement('label');
		el_format_label.setAttribute("class", "fm-field-label");
		el_format_label.setAttribute("for", "date_format");
		el_format_label.innerHTML = "Date format";
	
	var el_format_textarea = document.createElement('input');
		el_format_textarea.setAttribute("id", "date_format");
		el_format_textarea.setAttribute("type", "text");
		el_format_textarea.setAttribute("value", w_format);
		el_format_textarea.setAttribute("onChange", "change_date_format(this.value,'"+i+"', 'format')");

	var el_button_value_label = document.createElement('label');
		el_button_value_label.setAttribute("class", "fm-field-label");
		el_button_value_label.setAttribute("for", "button_value");
		el_button_value_label.innerHTML = "Date Picker label";
	
	var el_button_value_textarea = document.createElement('input');
		el_button_value_textarea.setAttribute("id", "button_value");
		el_button_value_textarea.setAttribute("type", "text");
		el_button_value_textarea.setAttribute("value", w_but_val);
		el_button_value_textarea.style.cssText = "width:150px;";
		el_button_value_textarea.setAttribute("onKeyUp", "change_file_value(this.value,'"+i+"_buttonform_id_temp')");

	var el_disable_past_days_label = document.createElement('label');
		el_disable_past_days_label.setAttribute("class", "fm-field-label");
		el_disable_past_days_label.setAttribute("for", "el_disable_past_days");
		el_disable_past_days_label.innerHTML = "Allow selecting dates starting from current day";
	
	var el_disable_past_days = document.createElement('input');
		el_disable_past_days.setAttribute("id", "el_disable_past_days");
		el_disable_past_days.setAttribute("type", "checkbox");
        el_disable_past_days.setAttribute("onclick", "change_date_format(this.checked, '"+i+"', 'dis_days')");
		if(w_disable_past_days == "yes")
            el_disable_past_days.setAttribute("checked", "checked");
		
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
		
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_required");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required == "yes")
			el_required.setAttribute("checked", "checked");
		
	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_date')");
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
		el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_date')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_date')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
		el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_date')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
	}

	var t  = document.getElementById('edit_table');
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	edit_main_td8.appendChild(el_label_size_label);
	edit_main_td8_1.appendChild(el_label_size);

edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);

	edit_main_td3.appendChild(el_format_label);
	edit_main_td3_1.appendChild(el_format_textarea);
	
	edit_main_td4.appendChild(el_button_value_label);
	edit_main_td4_1.appendChild(el_button_value_textarea);
	
	edit_main_td9.appendChild(el_disable_past_days_label);
	edit_main_td9_1.appendChild(el_disable_past_days);
	
	edit_main_td5.appendChild(el_style_label);
	edit_main_td5_1.appendChild(el_style_textarea);
	
	edit_main_td6.appendChild(el_required_label);
	edit_main_td6_1.appendChild(el_required);
	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br1);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");
	
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr7);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_text');
	
	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_date");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required = document.createElement("input");
		adding_required.setAttribute("type", "hidden");
		adding_required.setAttribute("value", w_required);
		adding_required.setAttribute("name", i+"_requiredform_id_temp");
		adding_required.setAttribute("id", i+"_requiredform_id_temp");
	var adding_dis_past_days = document.createElement('input');
		adding_dis_past_days.setAttribute("type", 'hidden');
		adding_dis_past_days.setAttribute("value", w_disable_past_days);
		adding_dis_past_days.setAttribute("id", i+"_dis_past_daysform_id_temp");
		adding_dis_past_days.setAttribute("name", i+"_dis_past_daysform_id_temp");
			
	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
				
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width=w_field_label_size+"px";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");
		
	var table_date = document.createElement('div');
		table_date.setAttribute("id", i+"_table_date");
		table_date.style.display="table";
		
	var tr_date1 = document.createElement('div');
		tr_date1.setAttribute("id", i+"_tr_date1");
		tr_date1.style.display="table-row";
		
	var tr_date2 = document.createElement('div');
		tr_date2.setAttribute("id", i+"_tr_date2");
		tr_date2.style.display="table-row";
		
	var td_date_input1 = document.createElement('div');
		td_date_input1.setAttribute("id", i+"_td_date_input1");
		td_date_input1.style.display="table-cell";
			
	var td_date_input2 = document.createElement('div');
		td_date_input2.setAttribute("id", i+"_td_date_input2");
		td_date_input2.style.display="table-cell";
		
	var td_date_input3 = document.createElement('div');
		td_date_input3.setAttribute("id", i+"_td_date_input3");
		td_date_input3.style.display="table-cell";

	var td_date_label1 = document.createElement('div');
		td_date_label1.setAttribute("id", i+"_td_date_label1");
		td_date_label1.style.display="table-cell";
			
	var td_date_label2 = document.createElement('div');
		td_date_label2.setAttribute("id", i+"_td_date_label2");
		td_date_label2.style.display="table-cell";
		
	var td_date_label3 = document.createElement('div');
		td_date_label3.setAttribute("id", i+"_td_date_label3");
		td_date_label3.style.display="table-cell";
		
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
      

    var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
		label.style.verticalAlign="top";
		
	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
		required.style.verticalAlign="top";
		if(w_required=="yes")
			required.innerHTML = " *";
			
	var adding = document.createElement('input');
		adding.setAttribute("type", 'text');
		adding.setAttribute("value", w_date);
		adding.setAttribute("class", 'wdform-date');
		adding.setAttribute("id", i+"_elementform_id_temp");
		adding.setAttribute("name", i+"_elementform_id_temp");
		adding.setAttribute("maxlength", "10");
		adding.setAttribute("size", "10");
		adding.setAttribute("onChange", "change_value('"+i+"_elementform_id_temp')");
	
	var dis_past_days = w_disable_past_days == 'yes' ? true : false;
	
	var adding_button = document.createElement('input');
		adding_button.setAttribute("id", i+"_buttonform_id_temp");
		adding_button.setAttribute("class", "button");
		adding_button.setAttribute("type", 'reset');
		adding_button.setAttribute("value", w_but_val);
		adding_button.setAttribute("format", w_format);
        adding_button.setAttribute("onclick", "return showCalendar('"+i+"_elementform_id_temp' ,'"+w_format+"', "+dis_past_days+")");
			
	var main_td  = document.getElementById('show_table');
      
	div_label.appendChild(label);
	div_label.appendChild(required);
	div_element.appendChild(adding_type);
	div_element.appendChild(adding_required);
	div_element.appendChild(adding_dis_past_days);
	div_element.appendChild(adding);
	div_element.appendChild(adding_button);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
	div.appendChild(div_field);
	div.appendChild(br3);
	main_td.appendChild(div);

	if(w_field_label_pos=="top")
		label_top(i);
	change_class(w_class, i);
	refresh_attr(i, 'type_date');
}

function field_to_select(id, type)
{

	switch(type)
	{
		case 'day': 
		{
			w_width=document.getElementById('edit_for_day_size').value!=''?document.getElementById('edit_for_day_size').value:30;
			w_day=document.getElementById(id+"_dayform_id_temp").value;
			document.getElementById(id+"_td_date_input1").innerHTML='';	
			
			var select_day  = document.createElement('select');
				select_day.setAttribute("id", id+'_dayform_id_temp');
				select_day.setAttribute("name", id+'_dayform_id_temp');
				select_day.setAttribute("onChange", 'set_select(this)');
				select_day.style.width=w_width+'px';
				
			var options  = document.createElement('option');
				options.setAttribute("value",'');
				options.innerHTML= '';
				select_day.appendChild(options);
				
			for(k=1; k<=31;k++)
			{
				if(k<10)
					k='0'+k;
				var options  = document.createElement('option');
					options.setAttribute("value", k);
					options.innerHTML= k;
				 if (k==w_day) 
					options.setAttribute("selected", "selected");

					select_day.appendChild(options);
					
			}

			document.getElementById(id+"_td_date_input1").appendChild(select_day);

			break;	
		}
		case 'month': 
		{ 
			w_width=document.getElementById('edit_for_month_size').value!=''?document.getElementById('edit_for_month_size').value:60;
			w_month=document.getElementById(id+"_monthform_id_temp").value;
			
			document.getElementById(id+"_td_date_input2").innerHTML='';
			
		var select_month = document.createElement('select');
				select_month.setAttribute("id", id+'_monthform_id_temp');
				select_month.setAttribute("name", id+'_monthform_id_temp');
				select_month.setAttribute("onChange", 'set_select(this)');
				select_month.style.width=w_width+'px';
				
		var options  = document.createElement('option');
				options.setAttribute("value",'');
				options.innerHTML= '';
				select_month.appendChild(options);
				
		var myMonths=new Array("<!--repstart-->January<!--repend-->","<!--repstart-->February<!--repend-->","<!--repstart-->March<!--repend-->","<!--repstart-->April<!--repend-->","<!--repstart-->May<!--repend-->","<!--repstart-->June<!--repend-->","<!--repstart-->July<!--repend-->","<!--repstart-->August<!--repend-->","<!--repstart-->September<!--repend-->","<!--repstart-->October<!--repend-->","<!--repstart-->November<!--repend-->","<!--repstart-->December<!--repend-->");
			for(k=1; k<=12;k++)
			{
				if(k<10)
					k='0'+k;
				var options  = document.createElement('option');
					options.setAttribute("value", k);
					options.innerHTML= myMonths[k-1];
				if (k==w_month) 
					options.setAttribute("selected", "selected");

					select_month.appendChild(options);
					
			}
			document.getElementById(id+"_td_date_input2").appendChild(select_month);
		break;	
		}	
		case 'year':
		{ 
			w_width=document.getElementById('edit_for_year_size').value!=''?document.getElementById('edit_for_year_size').value:60;
			w_year=document.getElementById(id+"_yearform_id_temp").value;
			
		document.getElementById(id+"_td_date_input3").innerHTML=''; 
		var select_year  = document.createElement('select');
			select_year.setAttribute("id", id+'_yearform_id_temp');
			select_year.setAttribute("name", id+'_yearform_id_temp');
			select_year.setAttribute("onChange", 'set_select(this)');
			select_year.style.width=w_width+'px';
			
		var options  = document.createElement('option');
			options.setAttribute("value",'');
			options.innerHTML= '';
			select_year.appendChild(options);
			
		from= parseInt(document.getElementById("edit_for_year_interval_from").value);
		to= parseInt(document.getElementById("edit_for_year_interval_to").value);
		for(k=to; k>=from;k--)
		{
		var options  = document.createElement('option');
			options.setAttribute("value", k);
			options.innerHTML= k;
		if (k==w_year) 
			options.setAttribute("selected", "selected");
			
			select_year.appendChild(options);
		}
		select_year.value=w_year;
		select_year.setAttribute('from',from);
		select_year.setAttribute('to',to);
		document.getElementById(id+"_td_date_input3").appendChild(select_year);
		
		break;
		}
	}
	
refresh_attr(id, 'type_date_fields');

}

function field_to_text(id, type)
{

	switch(type)
	{
		case 'day': 
		{	
			w_width=document.getElementById('edit_for_day_size').value!=''?document.getElementById('edit_for_day_size').value:30;
			w_day=document.getElementById(id+"_dayform_id_temp").value;
			document.getElementById(id+"_td_date_input1").innerHTML='';	

			var day = document.createElement('input');
			day.setAttribute("type", 'text');
			day.setAttribute("value", w_day);
			//day.setAttribute("class", "time_box");
			day.setAttribute("id", id+"_dayform_id_temp");
			day.setAttribute("name", id+"_dayform_id_temp");
			day.setAttribute("onChange", "change_value('"+ id+"_dayform_id_temp')");
			day.setAttribute("onKeyPress", "return check_day(event, '"+id+"_dayform_id_temp')");
		    day.setAttribute("onBlur", "if (this.value=='0') this.value=''; else add_0('"+id+"_dayform_id_temp')");
		
			day.style.width=w_width+'px';

			document.getElementById(id+"_td_date_input1").appendChild(day);
			break;	
		}
		case 'month': 
		{ 
			w_width=document.getElementById('edit_for_month_size').value!=''?document.getElementById('edit_for_month_size').value:60;
			w_month=document.getElementById(id+"_monthform_id_temp").value;
			
			document.getElementById(id+"_td_date_input2").innerHTML='';
			
		var month = document.createElement('input');
			month.setAttribute("type", 'text');
			month.setAttribute("value", w_month);
			//month.setAttribute("class", "time_box");
			month.setAttribute("id", id+"_monthform_id_temp");
			month.setAttribute("name", id+"_monthform_id_temp");
			month.style.width=w_width+'px';
			month.setAttribute("onKeyPress", "return check_month(event, '"+id+"_monthform_id_temp')");
			month.setAttribute("onChange", "change_value('"+id+"_monthform_id_temp')");
			month.setAttribute("onBlur", "if (this.value=='0') this.value=''; else add_0('"+id+"_monthform_id_temp')");
			/*month.setAttribute("onKeyPress", "return check_minute(event, '"+i+"_mmform_id_temp')");
			month.setAttribute("onKeyUp", "change_minute(event, '"+i+"_mmform_id_temp')");
			month.setAttribute("onBlur", "add_0('"+i+"_mmform_id_temp')");*/

			document.getElementById(id+"_td_date_input2").appendChild(month);
			break;	
		}	
		case 'year':
		{ 
			w_width=document.getElementById('edit_for_year_size').value!=''?document.getElementById('edit_for_year_size').value:60;
			w_year=document.getElementById(id+"_yearform_id_temp").value;
			
			document.getElementById(id+"_td_date_input3").innerHTML='';
			
			from= parseInt(document.getElementById("edit_for_year_interval_from").value);
			to= parseInt(document.getElementById("edit_for_year_interval_to").value);
			if((parseInt(w_year)<from) || (parseInt(w_year)>to))
				w_year='';
			var year = document.createElement('input');
			year.setAttribute("type", 'text');
			year.setAttribute("value", w_year);
			//year.setAttribute("class", "time_box");
			year.setAttribute("id", id+"_yearform_id_temp");
			year.setAttribute("name", id+"_yearform_id_temp");
			year.setAttribute("onChange", "change_year('"+id+"_yearform_id_temp')");
			year.setAttribute("onKeyPress", "return check_year1(event, '"+id+"_yearform_id_temp')");
			year.setAttribute("onBlur", "check_year2('"+id+"_yearform_id_temp')");
			year.style.width=w_width+'px';
			year.setAttribute('from',from);
			year.setAttribute('to',to);

			document.getElementById(id+"_td_date_input3").appendChild(year);

			break;
		}
	}
	refresh_attr(id, 'type_date_fields');


}

function set_divider(id, divider)
{
	document.getElementById(id+"_separator1").innerHTML=divider;
	document.getElementById(id+"_separator2").innerHTML=divider;
}

function year_interval(id)
{
	from= parseInt(document.getElementById("edit_for_year_interval_from").value);
	to= parseInt(document.getElementById("edit_for_year_interval_to").value);
	if(to-from<0)
	{	
		alert('Invalid interval of years.');
		document.getElementById("edit_for_year_interval_from").value=to;
	}
	else
	{
		if(document.getElementById(id+"_yearform_id_temp").tagName=='SELECT')
			field_to_select(id, 'year');
		else
			field_to_text(id, 'year');
	}
}

function type_date_fields(i, w_field_label, w_field_label_size, w_field_label_pos, w_day, w_month, w_year, w_day_type, w_month_type, w_year_type, w_day_label, w_month_label, w_year_label, w_day_size, w_month_size, w_year_size, w_required, w_class, w_from, w_to, w_divider, w_attr_name, w_attr_value)
{ 
	current_date = new Date();
	document.getElementById("element_type").value = "type_date_fields";
	delete_last_child();
	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');	
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr10  = document.createElement('tr');  				
	var edit_main_tr11  = document.createElement('tr');  		
	var edit_main_tr12  = document.createElement('tr');  		
	var edit_main_tr13  = document.createElement('tr');  		
	var edit_main_tr14  = document.createElement('tr');  		
			
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');
	var edit_main_td11 = document.createElement('td');
	var edit_main_td11_1 = document.createElement('td');
	var edit_main_td12 = document.createElement('td');
	var edit_main_td12_1 = document.createElement('td');
	var edit_main_td13 = document.createElement('td');
		edit_main_td13.style.cssText ="vertical-align:top;";
	var edit_main_td13_1 = document.createElement('td');
	var edit_main_td14 = document.createElement('td');
	var edit_main_td14_1 = document.createElement('td');
  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.style.cssText = "width:200px;";
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";
	
	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");
		el_label_position1.setAttribute("checked", "checked");
	
	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
        el_label_left.innerHTML = "Left";

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");
		
	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
        el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos == "top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_fields_divider_label = document.createElement('label');
		el_fields_divider_label.setAttribute("class", "fm-field-label");
		el_fields_divider_label.setAttribute("for", "edit_for_fields_divider");
		el_fields_divider_label.innerHTML = "Fields separator";
	
	var el_fields_divider = document.createElement('input');
        el_fields_divider.setAttribute("id", "edit_for_fields_divider");
        el_fields_divider.setAttribute("type", "text");
        el_fields_divider.setAttribute("value", w_divider);
        el_fields_divider.style.cssText = "width:80px";
        el_fields_divider.setAttribute("onKeyUp", "set_divider('"+i+"', this.value)");
			
/////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// D A Y //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
		
	var el_day_field_type_label = document.createElement('label');
		el_day_field_type_label.setAttribute("class", "fm-field-label");
		el_day_field_type_label.innerHTML = "Day field type";

	var el_day_field_type_input1 = document.createElement('input');
		el_day_field_type_input1.setAttribute("id", "el_day_field_type_text");
		el_day_field_type_input1.setAttribute("type", "radio");
		el_day_field_type_input1.setAttribute("value", "text");
		el_day_field_type_input1.setAttribute("name", "edit_for_day_field_type");
		el_day_field_type_input1.setAttribute("onchange", "field_to_text("+i+", 'day')");
	
	var el_day_label_text_1 = document.createElement('label');
		el_day_label_text_1.setAttribute("for", "el_day_field_type_text");
        el_day_label_text_1.innerHTML = "Input";	
		
	var el_day_field_type_input2 = document.createElement('input');
		el_day_field_type_input2.setAttribute("id", "el_day_field_type_select");
		el_day_field_type_input2.setAttribute("type", "radio");
		el_day_field_type_input2.setAttribute("value", "select");
		el_day_field_type_input2.setAttribute("name", "edit_for_day_field_type");
		el_day_field_type_input2.setAttribute("onchange", "field_to_select("+i+", 'day')");
		
	var el_day_label_select_1 = document.createElement('label');
		el_day_label_select_1.setAttribute("for", "el_day_field_type_select");
        el_day_label_select_1.innerHTML = "Select";		
	
	if(w_day_type == "SELECT")
		el_day_field_type_input2.setAttribute("checked", "checked");
	else
		el_day_field_type_input1.setAttribute("checked", "checked");
		
	var el_day_field_size_label = document.createElement('label');
	    el_day_field_size_label.setAttribute("class", "fm-field-label");
		el_day_field_size_label.setAttribute("for", "edit_for_day_size");
		el_day_field_size_label.innerHTML = "Day field size(px)";
	
	var el_day_field_size_input = document.createElement('input');
        el_day_field_size_input.setAttribute("id", "edit_for_day_size");
		el_day_field_size_input.setAttribute("type", "text");
		el_day_field_size_input.setAttribute("value", w_day_size);
		el_day_field_size_input.setAttribute("onKeyPress", "return check_isnum(event)");
		el_day_field_size_input.setAttribute("onKeyUp", "change_w_style('"+i+"_dayform_id_temp', this.value)");
		
	var el_day_field_text_label = document.createElement('label');
	    el_day_field_text_label.setAttribute("class", "fm-field-label");
		el_day_field_text_label.innerHTML = "Day label";
	
	var el_day_field_text_input = document.createElement('input');
        el_day_field_text_input.setAttribute("id", "edit_for_day_text");
		el_day_field_text_input.setAttribute("type", "text");
		el_day_field_text_input.setAttribute("value", w_day_label)
        el_day_field_text_input.setAttribute("onKeyUp", "change_w_label('"+i+"_day_label', this.value)");
							
/////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// M O N T H //////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
		
	var el_month_field_type_label = document.createElement('label');
		el_month_field_type_label.setAttribute("class", "fm-field-label");
		el_month_field_type_label.innerHTML = "Month field type";
	
	var el_month_field_type_input1 = document.createElement('input');
		el_month_field_type_input1.setAttribute("id", "el_month_field_type_text");
		el_month_field_type_input1.setAttribute("type", "radio");
		el_month_field_type_input1.setAttribute("value", "text");
		el_month_field_type_input1.setAttribute("name", "edit_for_month_field_type");
		el_month_field_type_input1.setAttribute("onchange", "field_to_text("+i+", 'month')");
		
	var el_day_label_text_2 = document.createElement('label');
		el_day_label_text_2.setAttribute("for", "el_month_field_type_text");
        el_day_label_text_2.innerHTML = "Input";
		
	var el_month_field_type_input2 = document.createElement('input');
		el_month_field_type_input2.setAttribute("id", "el_month_field_type_select");
		el_month_field_type_input2.setAttribute("type", "radio");
		el_month_field_type_input2.setAttribute("value", "select");
		el_month_field_type_input2.setAttribute("name", "edit_for_month_field_type");
		el_month_field_type_input2.setAttribute("onchange", "field_to_select("+i+", 'month')");
	
	var el_day_label_select_2 = document.createElement('label');
		el_day_label_select_2.setAttribute("for", "el_month_field_type_select");
        el_day_label_select_2.innerHTML = "Select";		
		
	if(w_month_type == "SELECT")
		el_month_field_type_input2.setAttribute("checked", "checked");
	else
		el_month_field_type_input1.setAttribute("checked", "checked");
		
	var el_month_field_size_label = document.createElement('label');
	    el_month_field_size_label.setAttribute("class", "fm-field-label");
		el_month_field_size_label.setAttribute("for", "edit_for_month_size");
		el_month_field_size_label.innerHTML = "Month field size(px) ";
	
	var el_month_field_size_input = document.createElement('input');
        el_month_field_size_input.setAttribute("id", "edit_for_month_size");
		el_month_field_size_input.setAttribute("type", "text");
		el_month_field_size_input.setAttribute("value", w_month_size);
		el_month_field_size_input.setAttribute("onKeyPress", "return check_isnum(event)");
		el_month_field_size_input.setAttribute("onKeyUp", "change_w_style('"+i+"_monthform_id_temp', this.value)");
				
	var el_month_field_text_label = document.createElement('label');
	    el_month_field_text_label.setAttribute("class", "fm-field-label");
		el_month_field_text_label.innerHTML = "Month label";
	
	var el_month_field_text_input = document.createElement('input');
        el_month_field_text_input.setAttribute("id", "edit_for_month_text");
		el_month_field_text_input.setAttribute("type", "text");
		el_month_field_text_input.setAttribute("value", w_month_label);
        el_month_field_text_input.setAttribute("onKeyUp", "change_w_label('"+i+"_month_label', this.value)");
		
/////////////////////////////////////////////////////////////////////////////////
////////////////////////////////  Y E A R  //////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
		
	var el_year_field_type_label = document.createElement('label');
		el_year_field_type_label.setAttribute("class", "fm-field-label");
		el_year_field_type_label.innerHTML = "Year field type";
	
	var el_year_field_type_input1 = document.createElement('input');
		el_year_field_type_input1.setAttribute("id", "el_year_field_type_text");
		el_year_field_type_input1.setAttribute("type", "radio");
		el_year_field_type_input1.setAttribute("value", "text");
		el_year_field_type_input1.setAttribute("name", "edit_for_year_field_type");
		el_year_field_type_input1.setAttribute("onchange", "field_to_text("+i+", 'year')");
		
	var el_day_label_text_3 = document.createElement('label');
		el_day_label_text_3.setAttribute("for", "el_year_field_type_text");
        el_day_label_text_3.innerHTML = "Text";		
		
	var el_year_field_type_input2 = document.createElement('input');
		el_year_field_type_input2.setAttribute("id", "el_year_field_type_select");
		el_year_field_type_input2.setAttribute("type", "radio");
		el_year_field_type_input2.setAttribute("value", "select");
		el_year_field_type_input2.setAttribute("name", "edit_for_year_field_type");
		el_year_field_type_input2.setAttribute("onchange", "field_to_select("+i+", 'year')");
		
	var el_day_label_select_3 = document.createElement('label');
		el_day_label_select_3.setAttribute("for", "el_year_field_type_select");
        el_day_label_select_3.innerHTML = "Select";		
		
	if(w_year_type == "SELECT")
		el_year_field_type_input2.setAttribute("checked", "checked");
	else
		el_year_field_type_input1.setAttribute("checked", "checked");
		
	var el_year_field_interval_label = document.createElement('label');
		el_year_field_interval_label.setAttribute("class", "fm-field-label");
		el_year_field_interval_label.innerHTML = "Year interval";
	
	var el_year_field_interval_from_input = document.createElement('input');
        el_year_field_interval_from_input.setAttribute("id", "edit_for_year_interval_from");
		el_year_field_interval_from_input.setAttribute("type", "text");
		el_year_field_interval_from_input.setAttribute("value", w_from);
		el_year_field_interval_from_input.style.cssText ="width:40px";
		el_year_field_interval_from_input.setAttribute("onKeyPress", "return check_isnum(event)");
        el_year_field_interval_from_input.setAttribute("onChange", "year_interval("+i+")");
		
	Line = document.createTextNode(" - ");
	if(w_to == current_date.getFullYear())
		w_to_left = '';
	else
		w_to_left = w_to;
	var el_year_field_interval_to_input = document.createElement('input');
        el_year_field_interval_to_input.setAttribute("id", "edit_for_year_interval_to");
		el_year_field_interval_to_input.setAttribute("type", "text");
		el_year_field_interval_to_input.setAttribute("value", w_to);
		el_year_field_interval_to_input.style.cssText = "width:40px";
		el_year_field_interval_to_input.setAttribute("onKeyPress", "return check_isnum(event)");
        el_year_field_interval_to_input.setAttribute("onChange", "year_interval("+i+")");
	
	var el_year_field_interval_to_span = document.createElement('div');
		el_year_field_interval_to_span.style.cssText ="color:red; width:275px;";
		el_year_field_interval_to_span.innerHTML ="Leave the second field empty and the current year will be used automatically. For a specific year (other than current) fill out both the start and finish points of the range.";
	
	var el_year_field_size_label = document.createElement('label');
	    el_year_field_size_label.setAttribute("class", "fm-field-label");
		el_year_field_size_label.setAttribute("for", "edit_for_year_size");
		el_year_field_size_label.innerHTML = "Year field size(px)";
	
	var el_year_field_size_input = document.createElement('input');
        el_year_field_size_input.setAttribute("id", "edit_for_year_size");
		el_year_field_size_input.setAttribute("type", "text");
		el_year_field_size_input.setAttribute("value", w_year_size);
		el_year_field_size_input.setAttribute("onKeyPress", "return check_isnum(event)");
        el_year_field_size_input.setAttribute("onKeyUp", "change_w_style('"+i+"_yearform_id_temp', this.value)");
				
	var el_year_field_text_label = document.createElement('label');
	    el_year_field_text_label.setAttribute("class", "fm-field-label");
		el_year_field_text_label.innerHTML = "Year label";
	
	var el_year_field_text_input = document.createElement('input');
        el_year_field_text_input.setAttribute("id", "edit_for_year_text");
		el_year_field_text_input.setAttribute("type", "text");
		el_year_field_text_input.setAttribute("value", w_year_label);
        el_year_field_text_input.setAttribute("onKeyUp", "change_w_label('"+i+"_year_label', this.value)");		
				
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.style.cssText = "width:200px;";
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_required");
		el_required.setAttribute("type", "checkbox");       
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required == "yes")
			el_required.setAttribute("checked", "checked");
		
	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');      
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_date_fields')");
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
		el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n = w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.style.cssText = "width:100px";
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_date_fields')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.style.cssText = "width:100px";
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_date_fields')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_add.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_date_fields')");
			
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);	
	}

	var t  = document.getElementById('edit_table');
	var br = document.createElement('br');
	var br6 = document.createElement('br');
	var br7 = document.createElement('br');
	var br8 = document.createElement('br');
	var br9 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);

	edit_main_td10.appendChild(el_label_size_label);
	edit_main_td10_1.appendChild(el_label_size);
	
	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);

	edit_main_td3.appendChild(el_fields_divider_label);
	edit_main_td3_1.appendChild(el_fields_divider);
	
	edit_main_td4.appendChild(el_day_field_type_label);
	edit_main_td4_1.appendChild(el_day_field_type_input1);
	edit_main_td4_1.appendChild(el_day_label_text_1);
	edit_main_td4_1.appendChild(el_day_field_type_input2);
	edit_main_td4_1.appendChild(el_day_label_select_1);

	edit_main_td11.appendChild(el_day_field_size_label);
	edit_main_td11_1.appendChild(el_day_field_size_input);
	
	edit_main_td8.appendChild(el_month_field_type_label);
	edit_main_td8_1.appendChild(el_month_field_type_input1);
	edit_main_td8_1.appendChild(el_day_label_text_2);
	edit_main_td8_1.appendChild(el_month_field_type_input2);
	edit_main_td8_1.appendChild(el_day_label_select_2);
	
	edit_main_td12.appendChild(el_month_field_size_label);
	edit_main_td12_1.appendChild(el_month_field_size_input);
	
	edit_main_td9.appendChild(el_year_field_type_label);
	edit_main_td9_1.appendChild(el_year_field_type_input1);
	edit_main_td9_1.appendChild(el_day_label_text_3);
	edit_main_td9_1.appendChild(el_year_field_type_input2);
	edit_main_td9_1.appendChild(el_day_label_select_3);
	
	edit_main_td13.appendChild(el_year_field_interval_label);
	edit_main_td13_1.appendChild(el_year_field_interval_from_input);
	edit_main_td13_1.appendChild(Line);
	edit_main_td13_1.appendChild(el_year_field_interval_to_input);
	edit_main_td13_1.appendChild(el_year_field_interval_to_span);

	edit_main_td14.appendChild(el_year_field_size_label);
	edit_main_td14_1.appendChild(el_year_field_size_input);
	
	edit_main_td5.appendChild(el_style_label);
	edit_main_td5_1.appendChild(el_style_textarea);
	
	edit_main_td6.appendChild(el_required_label);
	edit_main_td6_1.appendChild(el_required);
	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br8);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");

	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr11.appendChild(edit_main_td11);
	edit_main_tr11.appendChild(edit_main_td11_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr12.appendChild(edit_main_td12);
	edit_main_tr12.appendChild(edit_main_td12_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr13.appendChild(edit_main_td13);
	edit_main_tr13.appendChild(edit_main_td13_1);
	edit_main_tr14.appendChild(edit_main_td14);
	edit_main_tr14.appendChild(edit_main_td14_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr11);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr12);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr13);
	edit_main_table.appendChild(edit_main_tr14);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr7);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_date_fields');

	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_date_fields");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
		
	var adding_required = document.createElement("input");
		adding_required.setAttribute("type", "hidden");
		adding_required.setAttribute("value", w_required);
		adding_required.setAttribute("name", i+"_requiredform_id_temp");
		adding_required.setAttribute("id", i+"_requiredform_id_temp");
		
	var edit_labels = document.createTextNode("The labels of the fields are editable. Please, click the label to edit.");	
	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
	
	var div_for_editable_labels = document.createElement('div');
		div_for_editable_labels.setAttribute("style", "margin-left:4px; color:red;");
		div_for_editable_labels.appendChild(edit_labels);  

	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.cssText = 'display:table-cell; vertical-align:top; width:'+w_field_label_size+'px';
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");

	var table_date = document.createElement('div');
		table_date.setAttribute("id", i+"_table_date");
		table_date.style.display="table";

	var tr_date1 = document.createElement('div');
		tr_date1.setAttribute("id", i+"_tr_date1");
		tr_date1.style.display="table-row";
		
	var tr_date2 = document.createElement('div');
		tr_date2.setAttribute("id", i+"_tr_date2");
		tr_date2.style.display="table-row";
		
	var td_date_input1 = document.createElement('div');
		td_date_input1.setAttribute("id", i+"_td_date_input1");
		td_date_input1.style.display = "table-cell";
		
	var td_date_separator1 = document.createElement('div');
		td_date_separator1.setAttribute("id", i+"_td_date_separator1");
		td_date_separator1.style.display="table-cell";
		
	var td_date_input2 = document.createElement('div');
		td_date_input2.setAttribute("id", i+"_td_date_input2");
		td_date_input2.style.display = "table-cell";
		
	var td_date_separator2 = document.createElement('div');
		td_date_separator2.setAttribute("id", i+"_td_date_separator2");
		td_date_separator2.style.display = "table-cell";
		
	var td_date_input3 = document.createElement('div');
		td_date_input3.setAttribute("id", i+"_td_date_input3");
		td_date_input3.style.display = "table-cell";

	var td_date_label1 = document.createElement('div');
		td_date_label1.setAttribute("id", i+"_td_date_label1");
		td_date_label1.style.display="table-cell";
			
	var td_date_label_empty1 = document.createElement('div');
		td_date_label_empty1.style.display="table-cell";
		
	var td_date_label2 = document.createElement('div');
		td_date_label2.setAttribute("id", i+"_td_date_label2");
		td_date_label2.style.display="table-cell";
	var td_date_label_empty2 = document.createElement('div');
		td_date_label_empty2.style.display="table-cell";
		
	var td_date_label3 = document.createElement('div');
		td_date_label3.setAttribute("id", i+"_td_date_label3");
		td_date_label3.style.display="table-cell";

	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "wd_form_label");
		label.style.verticalAlign="top";
		
	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
		required.style.verticalAlign="top";
		if(w_required == "yes")
			required.innerHTML = " *";

	var day = document.createElement('input');
		day.setAttribute("type", 'text');
		day.setAttribute("value", w_day);
	    day.setAttribute("id", i+"_dayform_id_temp");
	    day.setAttribute("name", i+"_dayform_id_temp");
		day.setAttribute("onChange", "change_value('"+i+"_dayform_id_temp')");
		day.setAttribute("onKeyPress", "return check_day(event, '"+i+"_dayform_id_temp')");
	    day.setAttribute("onBlur", "if (this.value=='0') this.value=''; else add_0('"+i+"_dayform_id_temp')");
		day.style.width = w_day_size+'px';

	var day_label = document.createElement('label');
	    day_label.setAttribute("class", "mini_label");
	    day_label.setAttribute("id", i+"_day_label");
	    day_label.innerHTML = w_day_label;
			
	var day_ = document.createElement('span');
	    day_.setAttribute("id", i+"_separator1");
	    day_.setAttribute("class", "wdform_separator");
	    day_.innerHTML = w_divider;
		
	var month = document.createElement('input');
        month.setAttribute("type", 'text');
		month.setAttribute("value", w_month);
		month.setAttribute("id", i+"_monthform_id_temp");
	    month.setAttribute("name", i+"_monthform_id_temp");
		month.style.width=w_month_size+'px';
		month.setAttribute("onKeyPress", "return check_month(event, '"+i+"_monthform_id_temp')");
		month.setAttribute("onChange", "change_value('"+i+"_monthform_id_temp')");
	    month.setAttribute("onBlur", "if (this.value=='0') this.value=''; else add_0('"+i+"_monthform_id_temp')");
		
	var month_label = document.createElement('label');
		month_label.setAttribute("class", "mini_label");
		month_label.setAttribute("class", "mini_label");
	    month_label.setAttribute("id", i+"_month_label");
		month_label.innerHTML = w_month_label;
			
	var month_ = document.createElement('span');
	    month_.setAttribute("id", i+"_separator2");
	    month_.setAttribute("class", "wdform_separator");
		month_.innerHTML = w_divider;
		
	if(w_to == '')
		w_to = current_date.getFullYear();
	var year = document.createElement('input');
        year.setAttribute("type", 'text');
        year.setAttribute("from", w_from);
        year.setAttribute("to", w_to);
		year.setAttribute("value", w_year);
		year.setAttribute("id", i+"_yearform_id_temp");
		year.setAttribute("name", i+"_yearform_id_temp");
		year.style.width=w_year_size+'px';
		year.setAttribute("onChange", "change_year('"+i+"_yearform_id_temp')");
		year.setAttribute("onKeyPress", "return check_year1(event, '"+i+"_yearform_id_temp')");
		year.setAttribute("onBlur", "check_year2('"+i+"_yearform_id_temp')");

	var year_label = document.createElement('label');
		year_label.setAttribute("class", "mini_label");
	    year_label.setAttribute("id", i+"_year_label");
		year_label.innerHTML = w_year_label;
			
    var main_td  = document.getElementById('show_table');
      
	div_label.appendChild(label);
	div_label.appendChild(required);
	td_date_input1.appendChild(day);
	td_date_separator1.appendChild(day_);
	td_date_input2.appendChild(month);
	td_date_separator2.appendChild(month_);
	td_date_input3.appendChild(year);
	tr_date1.appendChild(td_date_input1);
	tr_date1.appendChild(td_date_separator1);
	tr_date1.appendChild(td_date_input2);
	tr_date1.appendChild(td_date_separator2);
	tr_date1.appendChild(td_date_input3);
	td_date_label1.appendChild(day_label);
	td_date_label2.appendChild(month_label);
	td_date_label3.appendChild(year_label);
	tr_date2.appendChild(td_date_label1);
	tr_date2.appendChild(td_date_label_empty1);
	tr_date2.appendChild(td_date_label2);
	tr_date2.appendChild(td_date_label_empty2);
	tr_date2.appendChild(td_date_label3);
	table_date.appendChild(tr_date1);
	table_date.appendChild(tr_date2);
	div_element.appendChild(adding_type);
	div_element.appendChild(adding_required);
	div_element.appendChild(table_date);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
	div.appendChild(div_field);
	div.appendChild(br9);
	div.appendChild(div_for_editable_labels);
	main_td.appendChild(div);

	if(w_field_label_pos == "top")
		label_top(i);
	
	if(w_day_type == "SELECT")
		field_to_select(i, 'day');
			
	if(w_month_type == "SELECT")
		field_to_select(i, 'month');
			
	if(w_year_type == "SELECT")
		field_to_select(i, 'year');
		
	change_class(w_class, i);
	refresh_attr(i, 'type_date_fields');

	jQuery(document).ready(function(jQuery) {	
		jQuery("label#"+i+"_day_label").click(function() {		
			if (jQuery(this).children('input').length == 0)
			{				
				var day = "<input type='text' class='day' style='outline:none; border:none; background:none; width:100px;' value=\""+jQuery(this).text()+"\">";	
				jQuery(this).html(day);							
				jQuery("input.day").focus();			
				jQuery("input.day").blur(function() {	
					var value = jQuery(this).val();			
					jQuery("#"+i+"_day_label").text(value);		
				});	
			}	
		});		

		jQuery("label#"+i+"_month_label").click(function() {	
			if (jQuery(this).children('input').length == 0)
			{		
				var month = "<input type='text' class='month'  style='outline:none; border:none; background:none; width:100px;' value=\""+jQuery(this).text()+"\">";	
				jQuery(this).html(month);			
				jQuery("input.month").focus();					
				jQuery("input.month").blur(function() {			
					var value = jQuery(this).val();			
					jQuery("#"+i+"_month_label").text(value);	
				});	
			}	
		});
	
		jQuery("label#"+i+"_year_label").click(function() {	
			if (jQuery(this).children('input').length == 0)
			{		
				var year = "<input type='text' class='year' size='8' style='outline:none; border:none; background:none; width:100px;' value=\""+jQuery(this).text()+"\">";	
				jQuery(this).html(year);			
				jQuery("input.year").focus();					
				jQuery("input.year").blur(function() {			
					var value = jQuery(this).val();			
					jQuery("#"+i+"_year_label").text(value);	
				});	
			}	
		});
	});	
}

function type_own_select(i, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_choices, w_choices_checked, w_required, w_value_disabled, w_class, w_attr_name, w_attr_value, w_choices_disabled, w_choices_value, w_choices_params){
	document.getElementById("element_type").value="type_own_select";

	delete_last_child();
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
		edit_main_td3_1.style.cssText = "padding:60px 0 0 20px; vertical-align:top;";
		edit_main_td3.setAttribute("id", "choices");
		
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');	
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');		
		  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
                el_label_textarea.setAttribute("id", "edit_for_label");
                el_label_textarea.setAttribute("rows", "4");
                
                el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
				el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");
	
	var el_size_label = document.createElement('label');
		el_size_label.setAttribute("class", "fm-field-label");
	        el_size_label.setAttribute("for", "edit_for_input_size");
		el_size_label.innerHTML = "Field size(px) ";
	var el_size = document.createElement('input');
		   el_size.setAttribute("id", "edit_for_input_size");
		   el_size.setAttribute("type", "text");
		   el_size.setAttribute("value", w_size);
		   
			
			el_size.setAttribute("onKeyPress", "return check_isnum(event)");
            el_size.setAttribute("onKeyUp", "change_w_style('"+i+"_elementform_id_temp', this.value)");
	
	
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
	        el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
                el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
                
                el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");
	
	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
	        el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
                el_required.setAttribute("id", "el_required");
                el_required.setAttribute("type", "checkbox");
                
                el_required.setAttribute("onclick", "set_required('"+i+"_required')");
	if(w_required=="yes")
			
                el_required.setAttribute("checked", "checked");
				
	var el_disable_value_label = document.createElement('label');
		el_disable_value_label.setAttribute("class", "fm-field-label");
		el_disable_value_label.setAttribute("for", "el_disable_value");
		el_disable_value_label.innerHTML = "Enable option's value";
	
	var el_disable_value = document.createElement('input');
		el_disable_value.setAttribute("id", "el_disable_value");
		el_disable_value.setAttribute("type", "checkbox");   
		el_disable_value.setAttribute("onclick", "refresh_sel_options('"+i+"','select')");
	if(w_value_disabled =="yes")
		el_disable_value.setAttribute("checked", "checked");
		
	var el_attr_label = document.createElement('label');
	    el_attr_label.setAttribute("class", "fm-field-label");            
			el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
                
           	el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_text')");
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_text')");
			
		var el_attr_value = document.createElement('input');
	
			el_attr_value.setAttribute("type", "text");
	
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_text')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_text')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}
		
	var el_choices_label = document.createElement('label');
		el_choices_label.setAttribute("class", "fm-field-label");    
		el_choices_label.innerHTML = "Options";
	var el_choices_add = document.createElement('img');
                el_choices_add.setAttribute("id", "el_choices_add");
           	el_choices_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_choices_add.style.cssText = 'cursor:pointer;';
            	el_choices_add.setAttribute("title", 'add');
                el_choices_add.setAttribute("onClick", "add_choise('select',"+i+")");
				
    var	el_choices_add_text = document.createElement("span");
		el_choices_add_text.style.cssText ="font-size: 12px; padding-left:7px; font-weight:bold; cursor:pointer;";
		el_choices_add_text.innerHTML ="Add option(s)";				
		el_choices_add_text.setAttribute("onClick", "add_choise('select',"+i+")");
		
	var el_choices_important = document.createElement('div');			
	    el_choices_important.style.cssText = 'color:red; padding:10px 0; width:330px;';
		el_choices_important.innerHTML = 'IMPORTANT! Check the "Empty value" checkbox only if you want the option to be considered as empty.';

    var el_choices_select = document.createElement('a');
	    el_choices_select.style.cssText ="color:#000; font-weight:bold; font-size: 13px; cursor:pointer; padding-top:10px; display:block;";
		el_choices_select.innerHTML = "Select options from database";
		el_choices_select.setAttribute("rel", "{handler: 'iframe', size: {x: 530, y: 370}}"	);
		el_choices_select.setAttribute("onclick","tb_show('', 'admin-ajax.php?action=select_data_from_db&field_id="+i+"&field_type=select&value_disabled="+w_value_disabled+"&width=530&height=370&TB_iframe=1')");
		el_choices_select.setAttribute("class","modal");
	


	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
        br3.setAttribute("id", "br1");
	var br4 = document.createElement('br');
        br4.setAttribute("id", "br2");
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	var br7 = document.createElement('br');
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td8.appendChild(el_label_size_label);
	edit_main_td8_1.appendChild(el_label_size);

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td6.appendChild(el_style_label);
	edit_main_td6_1.appendChild(el_style_textarea);
	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br3);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");
	edit_main_td4.appendChild(el_required_label);
	edit_main_td4_1.appendChild(el_required);
	
	edit_main_td9.appendChild(el_disable_value_label);
	edit_main_td9_1.appendChild(el_disable_value);
	
	edit_main_td5.appendChild(el_size_label);
	edit_main_td5_1.appendChild(el_size);
	
	edit_main_td3.appendChild(el_choices_label);
	edit_main_td3.appendChild(el_choices_important);
	edit_main_td3_1.appendChild(br7);
	edit_main_td3_1.appendChild(el_choices_add);
	edit_main_td3_1.appendChild(el_choices_add_text);
	edit_main_td3_1.appendChild(el_choices_select);
	
	
	var div_ = document.createElement('div');
		div_.style.cssText = 'border-bottom:1px dotted black; width: 330px;';
		
	var el_choices_mini_label = document.createElement('b');
		el_choices_mini_label.innerHTML="Name";
		el_choices_mini_label.style.cssText='padding-right: 40px; padding-left: 40px; font-size:9px';

	var el_choices_value_mini_label = document.createElement('b');
		el_choices_value_mini_label.innerHTML="Value";
		el_choices_value_mini_label.style.cssText='padding-right: 38px; padding-left: 38px; font-size:9px; font-weight:bold;';

	var el_choices_remove_mini_label = document.createElement('b');
		el_choices_remove_mini_label.innerHTML="Empty value";
		el_choices_remove_mini_label.style.cssText='padding-right: 3px; padding-left: 3px; font-size:9px;font-weight:bold;';
		
	var el_choices_dis_mini_label = document.createElement('b');
		el_choices_dis_mini_label.innerHTML="Delete";
		el_choices_dis_mini_label.style.cssText='padding-left: 3px; padding-right: 3px; font-size:9px; font-weight:bold;';
	
	var el_choices_move_mini_label = document.createElement('b');
		el_choices_move_mini_label.innerHTML="Move";
		el_choices_move_mini_label.style.cssText='padding-left: 3px; padding-right: 3px; font-size:9px; font-weight:bold;';	
		
	div_.appendChild(el_choices_mini_label);
	div_.appendChild(el_choices_value_mini_label);
	div_.appendChild(el_choices_remove_mini_label);
	div_.appendChild(el_choices_dis_mini_label);
	div_.appendChild(el_choices_move_mini_label);
	edit_main_td3.appendChild(div_);
	
	n=w_choices.length;
	for(j=0; j<n; j++)
	{	
		var div = document.createElement('div');
			div.setAttribute("id", j);
			div.setAttribute("class", "change_pos");
		var el_choices = document.createElement('input');
			el_choices.setAttribute("id", "el_option"+j);
			el_choices.setAttribute("type", "text");
			el_choices.setAttribute("class", "fm-field-choice");
			el_choices.setAttribute("value", w_choices[j]);
			el_choices.setAttribute("onKeyUp", "change_label_name('"+j+"', '"+i+"_option"+j+"',  this.value, 'select')");
			el_choices.setAttribute("onpaste", "elem = this; change_label_name_on_paste('"+j+"', '"+i+"_option"+j+"', 'select')");
			if(w_choices_params[j])
				el_choices.setAttribute("disabled", 'disabled');
	
		var el_choices_remove = document.createElement('img');
			el_choices_remove.setAttribute("id", "el_option"+j+"_remove");
			el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_choices_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_choices_remove.setAttribute("align", 'top');
			el_choices_remove.setAttribute("onClick", "remove_option("+j+","+i+")");
			
		var el_choices_dis = document.createElement('input');
			el_choices_dis.setAttribute("type", 'checkbox');
			el_choices_dis.setAttribute("title", 'Empty value');
			el_choices_dis.setAttribute("id", "el_option"+j+"_dis");
			el_choices_dis.setAttribute("class", "el_option_dis");
			el_choices_dis.setAttribute("onClick", "dis_option('"+i+"_option"+j+"', this.checked)");
			el_choices_dis.style.cssText ="vertical-align: middle; margin-left:21px; margin-right:21px;";
			if(w_choices_disabled[j])
				el_choices_dis.setAttribute("checked", "checked");
			
		if(w_value_disabled =='yes')
				el_choices_dis.setAttribute("disabled", 'disabled');
		
		var el_choices_value = document.createElement('input');
			el_choices_value.setAttribute("id", "el_option_value"+j);
			if(!w_choices_params[j])
			el_choices_value.setAttribute("class", "el_option_value fm-field-choice");
			el_choices_value.setAttribute("type", "text");
			el_choices_value.setAttribute("value", w_choices_value[j]);
			el_choices_value.setAttribute("onKeyUp", "change_label_value('"+i+"_option"+j+"', this.value)");
			el_choices_value.setAttribute("onpaste", "change_label_value_on_paste('"+i+"_option"+j+"', this)");
			if(w_value_disabled=='no' || w_choices_params[j])
				el_choices_value.setAttribute("disabled", 'disabled');
		
		var el_choices_params = document.createElement('input');
			el_choices_params.setAttribute("id", "el_option_params"+j);
			el_choices_params.setAttribute("class", "el_option_params");
			el_choices_params.setAttribute("type", "hidden");
			el_choices_params.setAttribute("value", w_choices_params[j]);

		var el_choices_handle = document.createElement('img');
			el_choices_handle.setAttribute("class", "el_choices_sortable");
			el_choices_handle.setAttribute("src", plugin_url + '/images/move_cursor.png?ver=1.8.0');		
			el_choices_handle.style.cssText = 'cursor:move; vertical-align:middle; margin:2px;';
			el_choices_handle.setAttribute("align", 'top');
		
		div.appendChild(el_choices);
		div.appendChild(el_choices_value);
		div.appendChild(el_choices_dis);
		div.appendChild(el_choices_remove);
		div.appendChild(el_choices_handle);
		div.appendChild(el_choices_params);

		edit_main_td3.appendChild(div);
	
	}


	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr7);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_text');
	
//show table
	var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_own_select");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
	    
	var adding_required = document.createElement("input");
            adding_required.setAttribute("type", "hidden");
            adding_required.setAttribute("value", w_required);
            adding_required.setAttribute("name", i+"_requiredform_id_temp");
			
            adding_required.setAttribute("id", i+"_requiredform_id_temp");
	 var adding_value_disabled = document.createElement("input");
            adding_value_disabled.setAttribute("type", "hidden");
            adding_value_disabled.setAttribute("value", w_value_disabled);
            adding_value_disabled.setAttribute("name", i+"_value_disabledform_id_temp");	
            adding_value_disabled.setAttribute("id", i+"_value_disabledform_id_temp");
			
     	var div = document.createElement('div');
      	    div.setAttribute("id", "main_div");
			
		var div_field = document.createElement('div');
           	div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
      	var div_label = document.createElement('div');
         	div_label.setAttribute("align", 'left');
         	div_label.style.display="table-cell";
			div_label.style.width=w_field_label_size+"px";
           	div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			

      	var div_element = document.createElement('div');
         	div_element.setAttribute("align", 'left');
          	div_element.style.display="table-cell";
          	div_element.setAttribute("id", i+"_element_sectionform_id_temp");

      	var br1 = document.createElement('br');
      	var br2 = document.createElement('br');
     	var br3 = document.createElement('br');
      	var br4 = document.createElement('br');
		
	var table_little = document.createElement('div');
           	table_little.setAttribute("id", i+"_table_little");
			table_little.style.display="table";
			
      	var tr_little1 = document.createElement('div');
	        tr_little1.setAttribute("id", i+"_element_tr1");
			tr_little1.style.display="table-row";
		
      	var tr_little2 = document.createElement('div');
 	        tr_little2.setAttribute("id", i+"_element_tr2");
			tr_little2.style.display="table-row";
			
      	var td_little1 = document.createElement('div');
         	td_little1.setAttribute("valign", 'top');
           	td_little1.setAttribute("id", i+"_td_little1");
			td_little1.style.display="table-cell";
			
      	var td_little2 = document.createElement('div');
        	td_little2.setAttribute("valign", 'top');
           	td_little2.setAttribute("id", i+"_td_little2");
			td_little2.style.display="table-cell";
			
   
      	var label = document.createElement('span');
			label.setAttribute("id", i+"_element_labelform_id_temp");
			label.innerHTML = w_field_label;
			label.setAttribute("class", "label");
			label.style.verticalAlign="top";
	    
      	var required = document.createElement('span');
			required.setAttribute("id", i+"_required_elementform_id_temp");
			required.innerHTML = "";
			required.setAttribute("class", "required");
			required.style.verticalAlign="top";
	if(w_required=="yes")
			required.innerHTML = " *";
	var select_ = document.createElement('select');
		select_.setAttribute("id", i+"_elementform_id_temp");
		select_.setAttribute("name", i+"_elementform_id_temp");
		select_.style.cssText = "width:"+w_size+"px";
		select_.setAttribute("onchange", "set_select(this)");
		
	for(j=0; j<n; j++)
	{      	
		var option = document.createElement('option');
		option.setAttribute("id", i+"_option"+j);
	if(w_value_disabled =='yes')
				option.setAttribute("value", w_choices_value[j]);
			else
			{
				if(w_choices_disabled[j])
					option.value="";
				else
					option.setAttribute("value", w_choices[j]);
			}
			
			if(w_choices_params[j])
			{
				w_params = w_choices_params[j].split("[where_order_by]");
				option.setAttribute("where", w_params[0]);
				w_params = w_params[1].split("[db_info]");		
				option.setAttribute("order_by", w_params[0]);
				option.setAttribute("db_info", w_params[1]);
			}
		option.setAttribute("onselect", "set_select('"+i+"_option"+j+"')");
           	option.innerHTML = w_choices[j];
	if(w_choices_checked[j]==1)
		option.setAttribute("selected", "selected");
		select_.appendChild(option);
	}			
	
    
      	var main_td  = document.getElementById('show_table');
	
      
      	div_label.appendChild(label);
      	div_label.appendChild(required);
	div_element.appendChild(adding_type);
	
	    div_element.appendChild(adding_required);
	    div_element.appendChild(adding_value_disabled);
      	div_element.appendChild(select_);
      	div_field.appendChild(div_label);
      	div_field.appendChild(div_element);
      	
      
      	div.appendChild(div_field);
      	div.appendChild(br3);
      	main_td.appendChild(div);
	
	if(w_field_label_pos=="top")
				label_top(i);
change_class(w_class, i);
refresh_attr(i, 'type_text');
//enable_modals();
jQuery(function() {
	jQuery( "#choices" ).sortable({ 
		items: ".change_pos" ,
		handle: ".el_choices_sortable",
		update: function(event, ui) {		
			refresh_sel_options(i,'select');
		}
	
	});	
  });
}

function form_maker_getElementsByAttribute(node,tag,attr,value){
  var elems = (tag=="*" && node.all) ? node.all : node.getElementsByTagName(tag),
    returnElems = new Array(),
    nValue = (typeof value!="undefined") ? new RegExp("(^|\\s)" + value + "(\\s|$)") : null,
    nAttr,
    cur;
  for (var i = 0; i < elems.length; i++) {
    cur = elems[i];
    nAttr = cur.getAttribute && cur.getAttribute(attr);
    if (typeof nAttr == "string" && nAttr.length > 0) {
      if (typeof value == "undefined" || (nValue && nValue.test(nAttr))) {
        returnElems.push(cur);
      }
    }
  }
  return returnElems;
}


function refresh_sel_options(id, type)
{
	if(type=='checkbox' || type=='radio')
	{
		if(jQuery('#el_disable_value').prop( 'checked' ))
		{
			jQuery('#'+id+'_value_disabledform_id_temp').val('yes');
			jQuery('.el_option_value').removeAttr('disabled');			
		}
		else
		{
			jQuery('#'+id+'_value_disabledform_id_temp').val('no');
			jQuery('.el_option_value').attr('disabled', 'disabled');	
		}

		refresh_rowcol(id, type);
	}	
	
	
	if(type=='select')
	{
		if(jQuery('#el_disable_value').prop( 'checked' ))
		{
			jQuery('#'+id+'_value_disabledform_id_temp').val('yes');
			jQuery('.el_option_value').removeAttr('disabled');
			jQuery('.el_option_dis').attr('disabled', 'disabled');	
			
		}
		else
		{
			jQuery('#'+id+'_value_disabledform_id_temp').val('no');
			jQuery('.el_option_value').attr('disabled', 'disabled');
			jQuery('.el_option_dis').removeAttr('disabled');		
		}

		var select = document.getElementById(id+'_elementform_id_temp');
			select.innerHTML='';

		jQuery('.change_pos').each(function() {
			var idi = jQuery(this)[0].id;

			var option = document.createElement('option');
				option.setAttribute("id", id+"_option"+idi);

			if(jQuery('#el_disable_value').prop( 'checked' ))
			{
				option.setAttribute("value", jQuery(this).find(jQuery("input[type='text']"))[1].value);
			}
			else
			{
				if(jQuery(this).find(jQuery("input[type='checkbox']")).prop( 'checked' ))
					option.value="";
				else
					option.setAttribute("value", jQuery(this).find(jQuery("input[type='text']"))[0].value);
			}	
			
			
			if(jQuery(this).find(jQuery(".el_option_params")).val())
			{
				w_params = jQuery(this).find(jQuery(".el_option_params")).val().split("[where_order_by]");
				option.setAttribute("where", w_params[0]);
				w_params = w_params[1].split("[db_info]");		
				option.setAttribute("order_by", w_params[0]);
				option.setAttribute("db_info", w_params[1]);
			}
		
			option.setAttribute("onselect", "set_select('"+id+"_option"+idi+"')");
			option.innerHTML =	jQuery(this).find(jQuery("input[type='text']"))[0].value;
			
			select.appendChild(option);
		});
	}	

	jQuery('#el_choices_add').parent().find(jQuery('a')).attr("onclick","tb_show('', 'admin-ajax.php?action=select_data_from_db&field_id="+id+"&field_type="+type+"&value_disabled="+jQuery("#"+id+"_value_disabledform_id_temp").val()+"&width=530&height=370&TB_iframe=1')");
	
}


function add_quantity(i, w_quantity_value) {
	div_=document.getElementById(i+"_divform_id_temp");
	// if (div_.getElementById( i+"_element_quantityform_id_temp")) {
  if (form_maker_getElementsByAttribute(div_, "*", "id", i + "_element_quantityform_id_temp") != '') {
		div_.removeChild(document.getElementById( i+"_element_quantity_spanform_id_temp"));
		return;
	}
	select_ = document.createElement('input');
	select_.setAttribute("type", 'text');				
	select_.setAttribute("value", w_quantity_value);				
	select_.setAttribute("id", i+"_element_quantityform_id_temp");
	select_.setAttribute("name", i+"_element_quantityform_id_temp");
	select_.setAttribute("onKeyPress", "return check_isnum(event)");
	select_.setAttribute("onChange", "change_value('"+i+"_element_quantityform_id_temp', this.value)");
	select_.style.cssText = "width:30px; margin:2px 0px";
		
	var select_label = document.createElement('label');
			select_label.innerHTML =  "<!--repstart-->Quantity<!--repend-->";
			select_label.style.cssText = "margin-right:5px";		
			select_label.setAttribute("class", 'mini_label');
			select_label.setAttribute("id", i+'_element_quantity_label_form_id_temp');

		var span_ = document.createElement('span');
			span_.style.cssText = "margin-right:15px";
			span_.setAttribute("id", i+'_element_quantity_spanform_id_temp');
			
		span_.appendChild(select_label);
		span_.appendChild(select_);
		if(div_.firstChild)
			div_.insertBefore(span_, div_.firstChild);
		else
			div_.appendChild(span_);

}

function type_paypal_select(i, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_choices, w_choices_price, w_choices_checked, w_required, w_quantity, w_quantity_value, w_class, w_attr_name, w_attr_value, w_choices_disabled, w_property, w_property_values, w_choices_params){
	
	document.getElementById("element_type").value="type_paypal_select";
	delete_last_child();
	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10  = document.createElement('tr');
      				
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
		edit_main_td3.setAttribute("id", "choices");
	var edit_main_td3_1 = document.createElement('td');
		edit_main_td3_1.style.cssText = "padding:70px 0 0 20px; vertical-align:top;";
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
		  
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
		
	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');
			
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");
	
	var el_size_label = document.createElement('label');
		el_size_label.setAttribute("class", "fm-field-label");
		el_size_label.setAttribute("for", "edit_for_input_size");
		el_size_label.innerHTML = "Field size(px) ";
		
	var el_size = document.createElement('input');
		el_size.setAttribute("id", "edit_for_input_size");
		el_size.setAttribute("type", "text");
		el_size.setAttribute("value", w_size);
		el_size.setAttribute("onKeyPress", "return check_isnum(event)");
		el_size.setAttribute("onKeyUp", "change_w_style('"+i+"_elementform_id_temp', this.value)");
	
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");
	
	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_required");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required=="yes")
			el_required.setAttribute("checked", "checked");
	
	var el_quantity_label = document.createElement('label');
		el_quantity_label.setAttribute("class", "fm-field-label");
		el_quantity_label.setAttribute("for", "el_quantity");
		el_quantity_label.innerHTML = "Quantity property";
		
	var el_quantity = document.createElement('input');
        el_quantity.setAttribute("id", "el_quantity");
        el_quantity.setAttribute("type", "checkbox");
        el_quantity.setAttribute("value", "yes");
        el_quantity.setAttribute("onclick", "add_quantity('"+i+"',"+w_quantity_value+")");
		if(w_quantity=="yes")
			el_quantity.setAttribute("checked", "checked");
	
	var el_product_option_label = document.createElement('label');
	    el_product_option_label.setAttribute("class", "fm-field-label");
		el_product_option_label.innerHTML = "Product properties";
	
	var el_product_option_add_a = document.createElement('a');
		el_product_option_add_a.setAttribute("onclick", "tb_show('', 'admin-ajax.php?action=product_option&field_id="+i+"&width=530&height=370&TB_iframe=1')");
	//	el_product_option_add_a.setAttribute("href", url_for_ajax + "?action=product_option&field_id=" + i + "&url_for_ajax=" + url_for_ajax + "&width=600&height=400&TB_iframe=1");
		el_product_option_add_a.setAttribute("class","thickbox-preview");

	var el_product_option_add_img = document.createElement('img');
		el_product_option_add_img.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		
	var el_product_option_add_ul = document.createElement('ul');
		el_product_option_add_ul.setAttribute("id", 'option_ul');
		el_product_option_add_ul.style.cssText="list-style-type: none; padding:0px"
				
	el_product_option_add_a.appendChild(el_product_option_add_img);
	
	var el_attr_label = document.createElement('label');
	    el_attr_label.setAttribute("class", "fm-field-label");            
		el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_text')");
				
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_text')");
			
		var el_attr_value = document.createElement('input');
	
			el_attr_value.setAttribute("type", "text");
	
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_text')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_text')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}
		
	var el_choices_label = document.createElement('label');
	    el_choices_label.setAttribute("class", "fm-field-label");
		el_choices_label.innerHTML = "Options";
	var el_choices_add = document.createElement('img');
                el_choices_add.setAttribute("id", "el_choices_add");
           	el_choices_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_choices_add.style.cssText = 'cursor:pointer;';
            	el_choices_add.setAttribute("title", 'add');
                el_choices_add.setAttribute("onClick", "add_choise_price('select',"+i+")");
				
	var	el_choices_add_text = document.createElement("span");
		el_choices_add_text.style.cssText ="font-size: 12px; padding-left:7px; font-weight:bold; cursor:pointer;";
		el_choices_add_text.innerHTML ="Add option(s)";				
		el_choices_add_text.setAttribute("onClick", "add_choise_price('select',"+i+")");			
				
	var el_choices_important = document.createElement('div');			
	    el_choices_important.style.cssText = 'color:red; width:330px;';
		el_choices_important.innerHTML = 'IMPORTANT! Check the "Empty value" checkbox only if you want the option to be considered as empty.';
				
	var el_choices_select = document.createElement('a');
	    el_choices_select.style.cssText ="color:#000; font-weight:bold; font-size: 13px; cursor:pointer;  padding-top:10px;  display:block;";
		el_choices_select.innerHTML = "Select options from database";
		el_choices_select.setAttribute("onclick","tb_show('', 'admin-ajax.php?action=select_data_from_db&field_id="+i+"&field_type=paypal_select&width=530&height=370&TB_iframe=1')");
		el_choices_select.setAttribute("class","modal");			
								
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
        br3.setAttribute("id", "br1");
	var br4 = document.createElement('br');
        br4.setAttribute("id", "br2");
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	var br7 = document.createElement('br');
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td10.appendChild(el_label_size_label);
	edit_main_td10_1.appendChild(el_label_size);

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td6.appendChild(el_style_label);
	edit_main_td6_1.appendChild(el_style_textarea);
	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br3);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");
	edit_main_td4.appendChild(el_required_label);
	edit_main_td4_1.appendChild(el_required);
	
	edit_main_td9.appendChild(el_quantity_label);
	edit_main_td9_1.appendChild(el_quantity);
	
	edit_main_td5.appendChild(el_size_label);
	edit_main_td5_1.appendChild(el_size);
	
	edit_main_td3.appendChild(el_choices_label);
	edit_main_td3.appendChild(el_choices_important);
	edit_main_td3_1.appendChild(br7);
	edit_main_td3_1.appendChild(el_choices_add);
	edit_main_td3_1.appendChild(el_choices_add_text);
	edit_main_td3_1.appendChild(el_choices_select);
	
	edit_main_td8.appendChild(el_product_option_label);
	edit_main_td8.appendChild(el_product_option_add_ul);
	edit_main_td8_1.appendChild(el_product_option_add_a);
	
	var div_ = document.createElement('div');
		div_.style.cssText = 'border-bottom:1px dotted black; width: 290px;';
	var br = document.createElement('br');
	
	var el_choices_mini_label = document.createElement('b');
		el_choices_mini_label.innerHTML="Product name";
		el_choices_mini_label.style.cssText='padding-right: 20px; padding-left: 20px; font-size:9px';
		
	var el_choices_price_mini_label = document.createElement('b');
		el_choices_price_mini_label.innerHTML="Price";
		el_choices_price_mini_label.style.cssText='padding-right: 20px; padding-left: 20px;  font-size:9px';

	var el_choices_remove_mini_label = document.createElement('b');
		el_choices_remove_mini_label.innerHTML="Empty value";
		el_choices_remove_mini_label.style.cssText='padding-right: 3px; padding-left: 3px; font-size:9px; font-weight:bold;';
		
	var el_choices_dis_mini_label = document.createElement('b');
		el_choices_dis_mini_label.innerHTML="Delete";
		el_choices_dis_mini_label.style.cssText='padding-left: 3px; padding-right: 3px; font-size:9px; font-weight:bold;';
		
	var el_choices_move_mini_label = document.createElement('b');
		el_choices_move_mini_label.innerHTML="Move";
		el_choices_move_mini_label.style.cssText='padding-left: 3px; padding-right: 3px; font-size:9px; font-weight:bold;';	
		
	div_.appendChild(br);
	div_.appendChild(el_choices_mini_label);
	div_.appendChild(el_choices_price_mini_label);
	div_.appendChild(el_choices_remove_mini_label);
	div_.appendChild(el_choices_dis_mini_label);
	div_.appendChild(el_choices_move_mini_label);
	edit_main_td3.appendChild(div_);

	n=w_choices.length;
	for(j=0; j<n; j++)
	{	
		var div = document.createElement('div');
			div.setAttribute("id", j);
			div.setAttribute("class", "change_pos");
		var el_choices = document.createElement('input');
			el_choices.setAttribute("id", "el_option"+j);
			el_choices.setAttribute("type", "text");
			el_choices.setAttribute("value", w_choices[j]);
			el_choices.setAttribute("class", "fm-field-choice");
			el_choices.setAttribute("onKeyUp", "change_label_price('"+i+"_option"+j+"', this.value)");
			if(w_choices_params[j])
				el_choices.setAttribute("disabled", 'disabled');
		var el_choices_price = document.createElement('input');
			el_choices_price.setAttribute("id", "el_option_price"+j);
			el_choices_price.setAttribute("type", "text");
			el_choices_price.setAttribute("value", w_choices_price[j]);
			el_choices_price.setAttribute("class", "fm-field-paypal-choice");
			el_choices_price.setAttribute("onKeyUp", "change_value_price('"+i+"_option"+j+"', this.value)");
			el_choices_price.setAttribute("onKeyPress", "return check_isnum_point(event)");
	            if(w_choices_params[j])
				   el_choices_price.setAttribute("disabled", 'disabled');	
	
		var el_choices_params = document.createElement('input');
			el_choices_params.setAttribute("id", "el_option_params"+j);
			el_choices_params.setAttribute("class", "el_option_params");
			el_choices_params.setAttribute("type", "hidden");
			el_choices_params.setAttribute("value", w_choices_params[j]);
			
		var el_choices_remove = document.createElement('img');
			el_choices_remove.setAttribute("id", "el_option"+j+"_remove");
			el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_choices_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin: 3px;';
			el_choices_remove.setAttribute("align", 'top');
			el_choices_remove.setAttribute("onClick", "remove_option_price("+j+","+i+")");
			
		var el_choices_dis = document.createElement('input');
			el_choices_dis.setAttribute("type", 'checkbox');
			el_choices_dis.setAttribute("title", 'Empty value');
			el_choices_dis.setAttribute("id", "el_option"+j+"_dis");
			el_choices_dis.setAttribute("onClick", "dis_option_price('"+i+"','"+j+"', this.checked)");
			el_choices_dis.style.cssText ="vertical-align: middle; margin-right:24px; margin-left:24px;";
			if(w_choices_disabled[j])
				el_choices_dis.setAttribute("checked", "checked");
			
		var el_choices_handle = document.createElement('img');
			el_choices_handle.setAttribute("class", "el_choices_sortable");
			el_choices_handle.setAttribute("src", plugin_url + '/images/move_cursor.png?ver=1.8.0');		
			el_choices_handle.style.cssText = 'cursor:move; vertical-align:middle; margin: 2px;';
			el_choices_handle.setAttribute("align", 'top');
			
		div.appendChild(el_choices);
		div.appendChild(el_choices_price);
		div.appendChild(el_choices_dis);
		div.appendChild(el_choices_remove);
		div.appendChild(el_choices_handle);
		div.appendChild(el_choices_params);
		edit_main_td3.appendChild(div);
	}


	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr4);
	
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr7);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_text');
	
//show table
	var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_paypal_select");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
	    
	var adding_required = document.createElement("input");
            adding_required.setAttribute("type", "hidden");
            adding_required.setAttribute("value", w_required);
            adding_required.setAttribute("name", i+"_requiredform_id_temp");
			
            adding_required.setAttribute("id", i+"_requiredform_id_temp");
	    
     	var div = document.createElement('div');
      	    div.setAttribute("id", "main_div");
			
		var div_field = document.createElement('div');
           	div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
      	var div_label = document.createElement('div');
         	div_label.setAttribute("align", 'left');
         	div_label.style.display="table-cell";
			div_label.style.width=w_field_label_size+"px";
           	div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
      	var div_element = document.createElement('div');
         	div_element.setAttribute("align", 'left');
          	div_element.style.display="table-cell";
          	div_element.setAttribute("id", i+"_element_sectionform_id_temp");

      	var br1 = document.createElement('br');
      	var br2 = document.createElement('br');
     	var br3 = document.createElement('br');
      	var br4 = document.createElement('br');
		
	var table_little = document.createElement('div');
           	table_little.setAttribute("id", i+"_table_little");
			table_little.style.display="table";
			
      	var tr_little1 = document.createElement('div');
	        tr_little1.setAttribute("id", i+"_element_tr1");
			tr_little1.style.display="table-row";
		
      	var tr_little2 = document.createElement('div');
 	        tr_little2.setAttribute("id", i+"_element_tr2");
			tr_little2.style.display="table-row";
			
      	var td_little1 = document.createElement('div');
         	td_little1.setAttribute("valign", 'top');
           	td_little1.setAttribute("id", i+"_td_little1");
			td_little1.style.display="table-cell";
			
      	var td_little2 = document.createElement('div');
        	td_little2.setAttribute("valign", 'top');
           	td_little2.setAttribute("id", i+"_td_little2");
			td_little2.style.display="table-cell";
			
   
      	var label = document.createElement('span');
			label.setAttribute("id", i+"_element_labelform_id_temp");
			label.innerHTML = w_field_label;
			label.setAttribute("class", "label");
			label.style.verticalAlign="top";
	    
      	var required = document.createElement('span');
			required.setAttribute("id", i+"_required_elementform_id_temp");
			required.innerHTML = "";
			required.setAttribute("class", "required");
			required.style.verticalAlign="top";
	if(w_required=="yes")
			required.innerHTML = " *";
	var select_ = document.createElement('select');
		select_.setAttribute("id", i+"_elementform_id_temp");
		select_.setAttribute("name", i+"_elementform_id_temp");
		select_.style.cssText = "width:"+w_size+"px";
		select_.setAttribute("onchange", "set_select(this)");
		
	for(j=0; j<n; j++)
	{      	
		var option = document.createElement('option');
		option.setAttribute("id", i+"_option"+j);
	if(w_choices_disabled[j])
		option.value="";
	else
		option.setAttribute("value", w_choices_price[j]);
	
    if(w_choices_params[j])
		{
			w_params = w_choices_params[j].split("[where_order_by]");
			option.setAttribute("where", w_params[0]);
			w_params = w_params[1].split("[db_info]");		
			option.setAttribute("order_by", w_params[0]);
			option.setAttribute("db_info", w_params[1]);
		}
		
		option.setAttribute("onselect", "set_select('"+i+"_option"+j+"')");
           	option.innerHTML = w_choices[j];
	if(w_choices_checked[j]==1)
		option.setAttribute("selected", "selected");
		select_.appendChild(option);
	}	
	
		var div_ = document.createElement('div');
			div_.setAttribute("id", i+"_divform_id_temp");

    
      	var main_td  = document.getElementById('show_table');
	
      
      	div_label.appendChild(label);
      	div_label.appendChild(required);
	div_element.appendChild(adding_type);
	
	div_element.appendChild(adding_required);
      	div_element.appendChild(select_);
       	div_element.appendChild(div_);
     	div_field.appendChild(div_label);
      	div_field.appendChild(div_element);

      
      	div.appendChild(div_field);
      	div.appendChild(br3);
      	main_td.appendChild(div);
	
	if(w_field_label_pos=="top")
				label_top(i);
		

	if(w_quantity=="yes")
				add_quantity(i, w_quantity_value);
							
change_class(w_class, i);
refresh_attr(i, 'type_text');
add_properties(i, w_property, w_property_values);
// form_maker_open_in_popup(11);
//fm_popup();
jQuery(function() {
	jQuery( "#choices" ).sortable({ 
		items: ".change_pos" ,
		handle: ".el_choices_sortable",
		update: function(event, ui) {		
			refresh_paypal_fields(i,'select');
		}
	
	});	
  });
}

function remove_property(id,i)
{
	property_=document.getElementById(id+'_property_'+i);
	property_.parentNode.removeChild(property_);
	property_li_=document.getElementById('property_li_'+i);
	property_li_.parentNode.removeChild(property_li_);
}


function add_properties(id, w_property, w_property_values)
{
	n=w_property.length;
	for(i=0; i<n; i++ )
	{
		select_ = document.createElement('select');
		select_.setAttribute("id", id+"_propertyform_id_temp"+i);
		select_.setAttribute("name", id+"_propertyform_id_temp"+i);

		select_.style.cssText = "width:auto; margin:2px 0px";

		for(k=0; k<w_property_values[i].length; k++ )
		{
			var option = document.createElement('option');
				option.setAttribute("id",id+"_"+i+"_option"+k);
				option.setAttribute("value", w_property_values[i][k]);
				option.innerHTML =  w_property_values[i][k];
				select_.appendChild(option);	
		}
		
	
		var select_label = document.createElement('label');
				select_label.innerHTML =  w_property[i];
				select_label.style.cssText = "margin-right:5px";
				select_label.setAttribute("class", 'mini_label');
				select_label.setAttribute("id", id+'_property_label_form_id_temp'+i);

		var span_ = document.createElement('span');
			span_.style.cssText = "margin-right:15px";
			span_.setAttribute("id", id+'_property_'+i);
			

		
		div_=document.getElementById(id+"_divform_id_temp");
		span_.appendChild(select_label);
		span_.appendChild(select_);
		div_.appendChild(span_);
		
		var li_ = document.createElement('li');
			li_.setAttribute("id", 'property_li_'+i);

		var li_label = document.createElement('label');
			li_label.innerHTML=w_property[i];
			li_label.setAttribute("id", 'label_property_'+i);
			li_label.style.cssText ="font-weight:bold; font-size: 13px";
			
		var li_edit = document.createElement('a');
			li_edit.setAttribute("onclick", "tb_show('', 'admin-ajax.php?action=product_option&field_id="+id+"&property_id="+i+"&width=530&height=370&TB_iframe=1')");
		//	li_edit.setAttribute("href", url_for_ajax + "?action=product_option&field_id="+id+"&property_id="+i+"&url_for_ajax=" + url_for_ajax + "&width=600&height=400&TB_iframe=1");
			li_edit.setAttribute("class","thickbox-preview");
		
		var li_edit_img = document.createElement('img');
			li_edit_img.setAttribute("src", plugin_url + '/images/edit.png');
			li_edit_img.style.cssText = "margin-left:13px; width:17px;";

		li_edit.appendChild(li_edit_img);
			
		var li_x = document.createElement('img');
			li_x.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			li_x.setAttribute("onClick", 'remove_property('+id+','+i+')');
			li_x.style.cssText = "margin-left:3px; cursor:pointer; width:22px;";
			
			
		ul_=document.getElementById("option_ul");
		
		li_.appendChild(li_label);
		li_.appendChild(li_edit);
		li_.appendChild(li_x);
		ul_.appendChild(li_);
	}
}


function dis_option(id, value, num)
{
	if(value)
	{
		jQuery(id).val('');
		
		jQuery('#el_option_value'+num).val('');
	}	
	else
	{
		jQuery(id).val(jQuery(id).html());
		jQuery('#el_option_value'+num).val(jQuery('#el_option'+num).val());
	}	

}

function dis_option_price(id, i, value)
{
	//document.getElementById(id).disabled=value;
	if(value)
		document.getElementById(id+'_option'+i).value='';
	else
		document.getElementById(id+'_option'+i).value=document.getElementById('el_option_price'+i).value;
}


function type_paypal_checkbox(i, w_field_label, w_field_label_size, w_field_label_pos, w_field_option_pos, w_flow, w_choices, w_choices_price, w_choices_checked, w_required, w_randomize, w_allow_other,w_allow_other_num, w_class, w_attr_name, w_attr_value,  w_property,  w_property_values, w_quantity, w_quantity_value, w_choices_params) {

	document.getElementById("element_type").value="type_paypal_checkbox";
	delete_last_child();

	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");

	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10  = document.createElement('tr');
	var edit_main_tr11  = document.createElement('tr');
	var edit_main_tr12  = document.createElement('tr');
    var edit_main_tr13  = document.createElement('tr');   				

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');

	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
		edit_main_td4_1.style.cssText = "padding: 20px 0px 0px 25px; vertical-align:top;";
      	edit_main_td4.setAttribute("id", "choices");
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
	var edit_main_td11 = document.createElement('td');
	var edit_main_td11_1 = document.createElement('td');
	var edit_main_td12 = document.createElement('td');
	var edit_main_td12_1 = document.createElement('td');
	var edit_main_td13 = document.createElement('td');
	var edit_main_td13_1 = document.createElement('td');	
	
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;

	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");
				
	var el_option_position_label = document.createElement('label');
		el_option_position_label.setAttribute("class", "fm-field-label");
		el_option_position_label.innerHTML = "Field option label position";
	
	var el_option_position1 = document.createElement('input');
		el_option_position1.setAttribute("id", "edit_for_option_position_right");
		el_option_position1.setAttribute("type", "radio");        
		el_option_position1.setAttribute("name", "edit_for_option_position");
		el_option_position1.setAttribute("onchange", "option_left("+i+",'checkbox')");
		
	var el_option_left = document.createElement('label');
		el_option_left.setAttribute("for", "edit_for_option_position_right");
        el_option_left.innerHTML = "Left";	
		
	var el_option_position2 = document.createElement('input');
		el_option_position2.setAttribute("id", "edit_for_option_position_left");
		el_option_position2.setAttribute("type", "radio");
    	el_option_position2.setAttribute("name", "edit_for_option_position");
		el_option_position2.setAttribute("onchange", "option_right("+i+",'checkbox')");
		
	var el_option_right = document.createElement('label');
		el_option_right.setAttribute("for", "edit_for_option_position_left");
        el_option_right.innerHTML = "Right";	
		
	if(w_field_option_pos == "right")
		el_option_position2.setAttribute("checked", "checked");
	else
		el_option_position1.setAttribute("checked", "checked");	
	
	var el_label_flow = document.createElement('label');
		el_label_flow.setAttribute("class", "fm-field-label");
		el_label_flow.innerHTML = "Relative Position";
	
	var el_flow_vertical = document.createElement('input');
		el_flow_vertical.setAttribute("id", "edit_for_flow_vertical");
		el_flow_vertical.setAttribute("type", "radio");
		el_flow_vertical.setAttribute("value", "ver");
		el_flow_vertical.setAttribute("name", "edit_for_flow");
		el_flow_vertical.setAttribute("onchange", "flow_ver("+i+")");
		
	var el_label_vertical = document.createElement('label');
		el_label_vertical.setAttribute("for", "edit_for_flow_vertical");
        el_label_vertical.innerHTML = "Vertical";	
		
	var el_flow_horizontal = document.createElement('input');
		el_flow_horizontal.setAttribute("id", "edit_for_flow_horizontal");
		el_flow_horizontal.setAttribute("type", "radio");
		el_flow_horizontal.setAttribute("value", "hor");
		el_flow_horizontal.setAttribute("name", "edit_for_flow");
		el_flow_horizontal.setAttribute("onchange", "flow_hor("+i+")");
		
	var el_label_horizontal = document.createElement('label');
		el_label_horizontal.setAttribute("for", "edit_for_flow_horizontal");
        el_label_horizontal.innerHTML = "Horizontal";
		
	if(w_flow == "hor")
		el_flow_horizontal.setAttribute("checked", "checked");
	else
		el_flow_vertical.setAttribute("checked", "checked");
				
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
 		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_required");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required=="yes")
			el_required.setAttribute("checked", "checked");
		
	var el_quantity_label = document.createElement('label');
		el_quantity_label.setAttribute("class", "fm-field-label");
		el_quantity_label.setAttribute("for", "el_quantity");
		el_quantity_label.innerHTML = "Quantity property";
		
	var el_quantity = document.createElement('input');
        el_quantity.setAttribute("id", "el_quantity");
        el_quantity.setAttribute("type", "checkbox");
        el_quantity.setAttribute("value", "yes");
        el_quantity.setAttribute("onclick", "add_quantity('"+i+"',"+w_quantity_value+")");
		if(w_quantity=="yes")
			el_quantity.setAttribute("checked", "checked");
				
	var el_randomize_label = document.createElement('label');
		el_randomize_label.setAttribute("class", "fm-field-label");
		el_randomize_label.innerHTML = "Randomize in frontend";
	
	var el_randomize = document.createElement('input');
		el_randomize.setAttribute("id", "el_randomize");
		el_randomize.setAttribute("type", "checkbox");
		el_randomize.setAttribute("value", "yes");
		el_randomize.setAttribute("onclick", "set_randomize('"+i+"_randomizeform_id_temp')");
		if(w_randomize=="yes")
			    el_randomize.setAttribute("checked", "checked");

	var el_allow_other_label = document.createElement('label');
		el_allow_other_label.setAttribute("class", "fm-field-label");
		el_allow_other_label.innerHTML = "Allow other";
	
	var el_allow_other = document.createElement('input');
		el_allow_other.setAttribute("id", "el_allow_other");
		el_allow_other.setAttribute("type", "checkbox");
		el_allow_other.setAttribute("value", "yes");
		el_allow_other.setAttribute("onclick", "set_allow_other('"+i+"','checkbox')");
		if(w_allow_other=="yes")
			el_allow_other.setAttribute("checked", "checked");
	
	var el_product_option_label = document.createElement('label');
	    el_product_option_label.setAttribute("class", "fm-field-label");
		el_product_option_label.innerHTML = "Product properties";
	
	var el_product_option_add_a = document.createElement('a');
		el_product_option_add_a.setAttribute("onclick","tb_show('', 'admin-ajax.php?action=product_option&field_id="+i+"&width=530&height=370&TB_iframe=1')");
	//	el_product_option_add_a.setAttribute("href", url_for_ajax + "?action=product_option&field_id=" + i + "&url_for_ajax=" + url_for_ajax + "&width=600&height=400&TB_iframe=1");
		el_product_option_add_a.setAttribute("class","thickbox-preview");

	var el_product_option_add_img = document.createElement('img');
		el_product_option_add_img.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		
	var el_product_option_add_ul = document.createElement('ul');
		el_product_option_add_ul.setAttribute("id", 'option_ul');
		el_product_option_add_ul.style.cssText="list-style-type: none; padding:0px"
				
	el_product_option_add_a.appendChild(el_product_option_add_img);

	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
			el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
                
           	el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_checkbox')");
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_checkbox')");
			
		var el_attr_value = document.createElement('input');
	
			el_attr_value.setAttribute("type", "text");	
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_checkbox')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_checkbox')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}

	var el_choices_label = document.createElement('label');
		el_choices_label.setAttribute("class", "fm-field-label");
		el_choices_label.innerHTML = "Options ";
			
	var el_choices_add = document.createElement('img');
		el_choices_add.setAttribute("id", "el_choices_add");
		el_choices_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_choices_add.style.cssText = 'cursor:pointer;';
		el_choices_add.setAttribute("title", 'add');
		el_choices_add.setAttribute("onClick", "add_choise_price('checkbox',"+i+")");
				
	var	el_choices_add_text = document.createElement("span");
		el_choices_add_text.style.cssText ="font-size: 12px; padding-left:7px; font-weight:bold; cursor:pointer;";
		el_choices_add_text.innerHTML ="Add option(s)";				
		el_choices_add_text.setAttribute("onClick", "add_choise_price('checkbox',"+i+")");
	
	var el_choices_select = document.createElement('a');
	    el_choices_select.style.cssText ="color:#000; font-weight:bold; font-size: 13px; cursor:pointer;  padding-top:10px; display:block;";
		el_choices_select.innerHTML = "Select options from database";
		el_choices_select.setAttribute("onclick","tb_show('', 'admin-ajax.php?action=select_data_from_db&field_id="+i+"&field_type=paypal_checkbox&width=530&height=370&TB_iframe=1')");
		el_choices_select.setAttribute("class","modal");
	
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	var br7 = document.createElement('br');
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td12.appendChild(el_label_size_label);
	edit_main_td12_1.appendChild(el_label_size);

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);

	edit_main_td3.appendChild(el_label_flow);
	edit_main_td3_1.appendChild(el_flow_vertical);
	edit_main_td3_1.appendChild(el_label_vertical);
	edit_main_td3_1.appendChild(br1);
	edit_main_td3_1.appendChild(el_flow_horizontal);
	edit_main_td3_1.appendChild(el_label_horizontal);
	
	edit_main_td5.appendChild(el_required_label);
	edit_main_td5_1.appendChild(el_required);
	
	edit_main_td13.appendChild(el_option_position_label);
	edit_main_td13_1.appendChild(el_option_position1);
	edit_main_td13_1.appendChild(el_option_left);
	edit_main_td13_1.appendChild(br2);
	edit_main_td13_1.appendChild(el_option_position2);
	edit_main_td13_1.appendChild(el_option_right);
	
	edit_main_td8.appendChild(el_randomize_label);
	edit_main_td8_1.appendChild(el_randomize);
	
	edit_main_td9.appendChild(el_allow_other_label);
	edit_main_td9_1.appendChild(el_allow_other);
	
	edit_main_td6.appendChild(el_style_label);
	edit_main_td6_1.appendChild(el_style_textarea);
	
	edit_main_td10.appendChild(el_product_option_label);
	edit_main_td10.appendChild(el_product_option_add_ul);
	edit_main_td10_1.appendChild(el_product_option_add_a);
		
	edit_main_td11.appendChild(el_quantity_label);
	edit_main_td11_1.appendChild(el_quantity);
	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br6);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");
	
	edit_main_td4.appendChild(el_choices_label);
	edit_main_td4_1.appendChild(br7);
	edit_main_td4_1.appendChild(el_choices_add);
	edit_main_td4_1.appendChild(el_choices_add_text);
	edit_main_td4_1.appendChild(el_choices_select);
	
	
	var div_ = document.createElement('div');
		div_.style.cssText = 'border-bottom:1px dotted black; width: 220px;';
	var br = document.createElement('br');
		
	var el_choices_mini_label = document.createElement('b');
		el_choices_mini_label.innerHTML="Product name";
		el_choices_mini_label.style.cssText='padding-right: 20px; padding-left: 20px; font-size:9px';
		
	var el_choices_price_mini_label = document.createElement('b');
		el_choices_price_mini_label.innerHTML="Price";
		el_choices_price_mini_label.style.cssText='padding-right: 20px; padding-left: 20px;  font-size:9px';

	var el_choices_remove_mini_label = document.createElement('b');
		el_choices_remove_mini_label.innerHTML="Empty value";
		el_choices_remove_mini_label.style.cssText='padding-right: 3px; padding-left: 3px; font-size:9px; font-weight:bold;';
		
	var el_choices_dis_mini_label = document.createElement('b');
		el_choices_dis_mini_label.innerHTML="Delete";
		el_choices_dis_mini_label.style.cssText='padding-left: 3px; padding-right: 3px; font-size:9px; font-weight:bold;';
		
	var el_choices_move_mini_label = document.createElement('b');
		el_choices_move_mini_label.innerHTML="Move";
		el_choices_move_mini_label.style.cssText='padding-left: 3px; padding-right: 3px; font-size:9px; font-weight:bold;';	
	div_.appendChild(br);
	div_.appendChild(el_choices_mini_label);
	div_.appendChild(el_choices_price_mini_label);
	div_.appendChild(el_choices_dis_mini_label);
	div_.appendChild(el_choices_move_mini_label);
	edit_main_td4.appendChild(div_);
	
	n=w_choices.length;
	for(j=0; j<n; j++)
	{	
		var div = document.createElement('div');
			div.setAttribute("id", j);
			div.setAttribute("class", "change_pos");
			
		var el_choices = document.createElement('input');
			el_choices.setAttribute("id", "el_choices"+j);
			el_choices.setAttribute("type", "text");
			el_choices.setAttribute("value", w_choices[j]);
			el_choices.setAttribute("checked", w_choices_checked[j]);
			el_choices.setAttribute("class", "fm-field-choice");
			el_choices.setAttribute("onKeyUp", "change_label('"+i+"_label_element"+j+"', this.value); change_label_1('"+i+"_elementlabel_form_id_temp"+j+"', this.value); ");
	           if(w_choices_params[j])
				   el_choices.setAttribute("disabled", 'disabled');
		var el_choices_price = document.createElement('input');
			el_choices_price.setAttribute("id", "el_option_price"+j);
			el_choices_price.setAttribute("type", "text");
			el_choices_price.setAttribute("value", w_choices_price[j]);
			el_choices_price.setAttribute("class", "fm-field-paypal-choice");
			el_choices_price.setAttribute("onKeyUp", "change_value_price('"+i+"_elementform_id_temp"+j+"', this.value)");
			el_choices_price.setAttribute("onKeyPress", "return check_isnum_point(event)");
	        if(w_choices_params[j])
				el_choices_price.setAttribute("disabled", 'disabled');
	
		var el_choices_params = document.createElement('input');
			el_choices_params.setAttribute("id", "el_option_params"+j);
			el_choices_params.setAttribute("class", "el_option_params");
			el_choices_params.setAttribute("type", "hidden");
			el_choices_params.setAttribute("value", w_choices_params[j]);
			
		var el_choices_remove = document.createElement('img');
			el_choices_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');		
			el_choices_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_choices_remove.setAttribute("align", 'top');
			el_choices_remove.setAttribute("onClick", "remove_choise_price("+j+","+i+")");
			
		var el_choices_handle = document.createElement('img');
			el_choices_handle.setAttribute("class", "el_choices_sortable");
			el_choices_handle.setAttribute("src", plugin_url + '/images/move_cursor.png?ver=1.8.0');		
			el_choices_handle.style.cssText = 'cursor:move; vertical-align:middle; margin: 2px;';
			el_choices_handle.setAttribute("align", 'top');
	
		div.appendChild(el_choices);
		div.appendChild(el_choices_price);
		div.appendChild(el_choices_remove);
		div.appendChild(el_choices_handle);
		div.appendChild(el_choices_params);
		edit_main_td4.appendChild(div);
	}

	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr12.appendChild(edit_main_td12);
	edit_main_tr12.appendChild(edit_main_td12_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr11.appendChild(edit_main_td11);
	edit_main_tr11.appendChild(edit_main_td11_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr8.style.display="none";
	edit_main_tr13.appendChild(edit_main_td13);
	edit_main_tr13.appendChild(edit_main_td13_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr9.style.display="none";
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr12);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr13);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr11);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr7);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	
//show table

	element='input';	type='checkbox'; 
	var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_paypal_checkbox");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required = document.createElement("input");
            adding_required.setAttribute("type", "hidden");
            adding_required.setAttribute("value", w_required);
            adding_required.setAttribute("name", i+"_requiredform_id_temp");
            adding_required.setAttribute("id", i+"_requiredform_id_temp");
			
 	var adding_randomize = document.createElement("input");
            adding_randomize.setAttribute("type", "hidden");
            adding_randomize.setAttribute("value", w_randomize);
            adding_randomize.setAttribute("name", i+"_randomizeform_id_temp");			
            adding_randomize.setAttribute("id", i+"_randomizeform_id_temp");
	    
	var adding_allow_other= document.createElement("input");
            adding_allow_other.setAttribute("type", "hidden");
            adding_allow_other.setAttribute("value", w_allow_other);
            adding_allow_other.setAttribute("name", i+"_allow_otherform_id_temp");			
            adding_allow_other.setAttribute("id", i+"_allow_otherform_id_temp");
	    
	var adding_allow_other_id= document.createElement("input");
            adding_allow_other_id.setAttribute("type", "hidden");
            adding_allow_other_id.setAttribute("value", w_allow_other_num);
            adding_allow_other_id.setAttribute("name", i+"_allow_other_numform_id_temp");			
            adding_allow_other_id.setAttribute("id", i+"_allow_other_numform_id_temp");
	var adding_option_left_right= document.createElement("input");
            adding_option_left_right.setAttribute("type", "hidden");
            adding_option_left_right.setAttribute("value", w_field_option_pos);	
            adding_option_left_right.setAttribute("id", i+"_option_left_right");	    
   var div = document.createElement('div');
       	div.setAttribute("id", "main_div");
		
	var div_field = document.createElement('div');
           	div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width=w_field_label_size+"px";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");

	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');

	var table_little_t = document.createElement('div');
		table_little_t.style.display="table";
			
	var table_little = document.createElement('div');
		table_little.setAttribute("id", i+"_table_little");
		table_little.style.display="table-row-group";
		table_little_t.appendChild(table_little);
  
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
		label.style.verticalAlign="top";

	
	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
		required.style.verticalAlign="top";
		if(w_required=="yes")
			required.innerHTML = " *";
	n=w_choices.length;
	for(j=0; j<n; j++)
	{      	
		var tr_little = document.createElement('div');
			tr_little.setAttribute("id", i+"_element_tr"+j);
			tr_little.style.display="table-row";
				
		var td_little = document.createElement('div');
			td_little.setAttribute("valign", 'top');
			td_little.setAttribute("id", i+"_td_little"+j);
			td_little.setAttribute("idi", j);
			td_little.style.display="table-cell";
	
		var adding = document.createElement(element);
				adding.setAttribute("type", type);
				adding.setAttribute("id", i+"_elementform_id_temp"+j);
				adding.setAttribute("name", i+"_elementform_id_temp"+j);
				adding.setAttribute("value", w_choices_price[j]);
				if(w_field_option_pos=="right")
					adding.style.cssText = "float: left !important";
			if(w_allow_other=="yes" && j==w_allow_other_num)
			{
				adding.setAttribute("other", "1");
				adding.setAttribute("onclick", "if(set_checked('"+i+"','"+j+"','form_id_temp')) show_other_input('"+i+"','form_id_temp');");
			}
			else
				adding.setAttribute("onclick", "set_checked('"+i+"','"+j+"','form_id_temp')");
			
		if(w_choices_checked[j]=='1')
				adding.setAttribute("checked", "checked");
				
				
				
		var label_adding = document.createElement('label');
			label_adding.setAttribute("id", i+"_label_element"+j);
			label_adding.setAttribute("class","ch-rad-label");
			label_adding.setAttribute("for",i+"_elementform_id_temp"+j);
			label_adding.innerHTML = w_choices[j];
			if(w_field_option_pos=="right")
				label_adding.style.cssText = "float: none !important";
			if(w_choices_params[j])
			{
				w_params = w_choices_params[j].split("[where_order_by]");
				label_adding.setAttribute("where", w_params[0]);
				w_params = w_params[1].split("[db_info]");		
				label_adding.setAttribute("order_by", w_params[0]);
				label_adding.setAttribute("db_info", w_params[1]);
			}
			
		var adding_ch_label = document.createElement('input');
				adding_ch_label.setAttribute("type", "hidden");
				adding_ch_label.setAttribute("id", i+"_elementlabel_form_id_temp"+j);
				adding_ch_label.setAttribute("name", i+"_elementform_id_temp"+j+"_label");
				adding_ch_label.setAttribute("value", w_choices[j]);
				
		td_little.appendChild(adding);
		td_little.appendChild(label_adding);
		td_little.appendChild(adding_ch_label);
		tr_little.appendChild(td_little);
		table_little.appendChild(tr_little);
	}			
	
	var div_ = document.createElement('div');
		div_.setAttribute("id", i+"_divform_id_temp");

	var main_td  = document.getElementById('show_table');

	div_label.appendChild(label);
	div_label.appendChild(required);
	div_element.appendChild(adding_type);

	div_element.appendChild(adding_required);
	div_element.appendChild(adding_randomize);
	div_element.appendChild(adding_allow_other);
	div_element.appendChild(adding_allow_other_id);
	div_element.appendChild(adding_option_left_right);
	div_element.appendChild(table_little_t);
	div_element.appendChild(div_);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
	
	div.appendChild(div_field);
	div.appendChild(br3);
	main_td.appendChild(div);
	add_id_and_name(i, 'type_checkbox');
		
	if(w_field_label_pos=="top")
		label_top(i);
				
	if(w_flow=="hor")
		flow_hor(i);
	change_class(w_class, i);
	refresh_attr(i, 'type_checkbox');
	
	if(w_quantity=="yes")
		add_quantity(i, w_quantity_value);

	add_properties(i, w_property, w_property_values);

//	fm_popup();
	jQuery(function() {
		jQuery( "#choices" ).sortable({ 
			items: ".change_pos" ,
			handle: ".el_choices_sortable",
			update: function(event, ui) {		
				refresh_paypal_fields(i,'checkbox');
				refresh_id_name(i, 'type_checkbox');
			}
		});	
	});
}

function refresh_paypal_fields(id, type)
{
	
	if(type=='radio' || type=='checkbox')
	{
		var table_little = document.getElementById(id+'_table_little');
		table_little.innerHTML = '';
		
		jQuery('.change_pos').each(function() {
			var idi = jQuery(this)[0].id;

			var tr_little = document.createElement('div');
				tr_little.setAttribute("id", id+"_element_tr"+idi);
				tr_little.style.display="table-row";
			
			var td_little = document.createElement('div');
				td_little.setAttribute("valign", 'top');
				td_little.setAttribute("id", id+"_td_little"+idi);
				td_little.setAttribute("idi", idi);
				td_little.style.display="table-cell";
			
			var adding = document.createElement(element);
				adding.setAttribute("type", type);
				adding.setAttribute("id", id+"_elementform_id_temp"+idi);
				adding.setAttribute("value", jQuery(this).find(jQuery("#el_option_price"+idi))[0].value);
			if(type=='checkbox')
			{	
				adding.setAttribute("onClick", "set_checked('"+id+"','"+idi+"','form_id_temp')");
				adding.setAttribute("name", id+"_elementform_id_temp"+idi);
			}
				
			if(type=='radio')
			{
				adding.setAttribute("onClick", "set_default('"+id+"','"+idi+"','form_id_temp')");
				adding.setAttribute("name", id+"_elementform_id_temp");
			}
			
			
			var label_adding = document.createElement('label');
				label_adding.setAttribute("id", id+"_label_element"+idi);
				label_adding.setAttribute("class","ch-rad-label");
				label_adding.setAttribute("for",id+"_elementform_id_temp"+idi);
				label_adding.innerHTML = jQuery(this).find(jQuery("#el_choices"+idi))[0].value;
			
			if(jQuery(this).find(jQuery(".el_option_params")).val())
			{
				w_params = jQuery(this).find(jQuery(".el_option_params")).val().split("[where_order_by]");
				label_adding.setAttribute("where", w_params[0]);
				w_params = w_params[1].split("[db_info]");		
				label_adding.setAttribute("order_by", w_params[0]);
				label_adding.setAttribute("db_info", w_params[1]);		
			}
			
			var adding_ch_label = document.createElement('input');
				adding_ch_label.setAttribute("type", "hidden");
				adding_ch_label.setAttribute("id", id+"_elementlabel_form_id_temp"+idi);
				adding_ch_label.setAttribute("name", id+"_elementform_id_temp"+idi+"_label");
				adding_ch_label.setAttribute("value", jQuery(this).find(jQuery("#el_choices"+idi))[0].value);
			
	
			td_little.appendChild(adding);
			td_little.appendChild(label_adding);
			td_little.appendChild(adding_ch_label);
			tr_little.appendChild(td_little);
			table_little.appendChild(tr_little);

		});
		
		if(document.getElementById('edit_for_flow_horizontal').checked)	
			flow_hor(id);
	}

	if(type=='select')
	{

		var select = document.getElementById(id+'_elementform_id_temp');
		select.innerHTML='';

		jQuery('.change_pos').each(function() {
			var idi = jQuery(this)[0].id;

			var option = document.createElement('option');
				option.setAttribute("id", id+"_option"+idi);

			if(jQuery(this).find(jQuery("input[type='checkbox']")).prop( 'checked' ))
				option.value="";
			else
				option.setAttribute("value", jQuery(this).find(jQuery("#el_option_price"+idi))[0].value);
			

			if(jQuery(this).find(jQuery(".el_option_params")).val())
			{
				w_params = jQuery(this).find(jQuery(".el_option_params")).val().split("[where_order_by]");
				option.setAttribute("where", w_params[0]);
				w_params = w_params[1].split("[db_info]");		
				option.setAttribute("order_by", w_params[0]);
				option.setAttribute("db_info", w_params[1]);	

			}
			
			option.setAttribute("onselect", "set_select('"+id+"_option"+idi+"')");
			option.innerHTML =	jQuery(this).find(jQuery("#el_option"+idi))[0].value;
			
			select.appendChild(option);
		});
	
	
	}
}

function type_paypal_radio(i, w_field_label, w_field_label_size, w_field_label_pos, w_field_option_pos, w_flow, w_choices, w_choices_price, w_choices_checked, w_required, w_randomize, w_allow_other, w_allow_other_num, w_class, w_attr_name, w_attr_value,  w_property,  w_property_values, w_quantity, w_quantity_value, w_choices_params)
{
	document.getElementById("element_type").value = "type_paypal_radio";
	delete_last_child();

	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');	
	var edit_main_tr7  = document.createElement('tr');	
	var edit_main_tr10  = document.createElement('tr');	
	var edit_main_tr11  = document.createElement('tr');	
	var edit_main_tr12  = document.createElement('tr');
	var edit_main_tr13  = document.createElement('tr');

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
		edit_main_td4_1.style.cssText = "padding:20px 0 0 25px; vertical-align:top;";
		edit_main_td4.setAttribute("id", "choices");
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');	  		  
	var edit_main_td11 = document.createElement('td');
	var edit_main_td11_1 = document.createElement('td');	
	var edit_main_td12 = document.createElement('td');
	var edit_main_td12_1 = document.createElement('td');
		edit_main_td12_1.style.cssText = "padding-top:10px";		
	var edit_main_td13 = document.createElement('td');
	var edit_main_td13_1 = document.createElement('td');
	  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.style.cssText = "width:200px;";
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";
	
	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");
		el_label_position1.setAttribute("checked", "checked");
		
	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
        el_label_left.innerHTML = "Left";
		
	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");
	
	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos == "top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");
	
	var el_option_position_label = document.createElement('label');
		el_option_position_label.setAttribute("class", "fm-field-label");
		el_option_position_label.innerHTML = "Field option label position";
	
	var el_option_position1 = document.createElement('input');
		el_option_position1.setAttribute("id", "edit_for_option_position_right");
		el_option_position1.setAttribute("type", "radio");        
		el_option_position1.setAttribute("name", "edit_for_option_position");
		el_option_position1.setAttribute("onchange", "option_left("+i+",'radio')");
		
	var el_option_left = document.createElement('label');
		el_option_left.setAttribute("for", "edit_for_option_position_right");
        el_option_left.innerHTML = "Left";
		
	var el_option_position2 = document.createElement('input');
		el_option_position2.setAttribute("id", "edit_for_option_position_left");
		el_option_position2.setAttribute("type", "radio");
    	el_option_position2.setAttribute("name", "edit_for_option_position");
		el_option_position2.setAttribute("onchange", "option_right("+i+",'radio')");
		
	var el_option_right = document.createElement('label');
		el_option_right.setAttribute("for", "edit_for_option_position_left");
        el_option_right.innerHTML = "Right";
		
	if(w_field_option_pos == "right")
		el_option_position2.setAttribute("checked", "checked");
	else
		el_option_position1.setAttribute("checked", "checked");			
	
	var el_label_flow = document.createElement('label');
		el_label_flow.setAttribute("class", "fm-field-label");
		el_label_flow.innerHTML = "Relative Position";

	var el_flow_vertical = document.createElement('input');
		el_flow_vertical.setAttribute("id", "edit_for_flow_vertical");
		el_flow_vertical.setAttribute("type", "radio");
		el_flow_vertical.setAttribute("value", "ver");
		el_flow_vertical.setAttribute("name", "edit_for_flow");
		el_flow_vertical.setAttribute("onchange", "flow_ver("+i+")");
		
	var el_label_vertical = document.createElement('label');
		el_label_vertical.setAttribute("for", "edit_for_flow_vertical");
        el_label_vertical.innerHTML = "Vertical";	
		
	var el_flow_horizontal = document.createElement('input');
            el_flow_horizontal.setAttribute("id", "edit_for_flow_horizontal");
            el_flow_horizontal.setAttribute("type", "radio");
            el_flow_horizontal.setAttribute("value", "hor");
            el_flow_horizontal.setAttribute("name", "edit_for_flow");
            el_flow_horizontal.setAttribute("onchange", "flow_hor("+i+")");
			
	var el_label_horizontal = document.createElement('label');
		el_label_horizontal.setAttribute("for", "edit_for_flow_horizontal");
        el_label_horizontal.innerHTML = "Horizontal";
		
	if(w_flow == "hor")
		el_flow_horizontal.setAttribute("checked", "checked");
	else
		el_flow_vertical.setAttribute("checked", "checked");
				
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
		
	var el_style_textarea = document.createElement('input');
        el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
        el_style_textarea.style.cssText = "width:200px;";
        el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");
	
	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_required");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required == "yes")
			el_required.setAttribute("checked", "checked");

	var el_quantity_label = document.createElement('label');
	    el_quantity_label.setAttribute("class", "fm-field-label");
	    el_quantity_label.setAttribute("for", "el_quantity");
		el_quantity_label.innerHTML = "Quantity property";
		
	var el_quantity = document.createElement('input');
        el_quantity.setAttribute("id", "el_quantity");
        el_quantity.setAttribute("type", "checkbox");
        el_quantity.setAttribute("value", "yes");
        el_quantity.setAttribute("onclick", "add_quantity('"+i+"',"+w_quantity_value+")");
		if(w_quantity == "yes")
			el_quantity.setAttribute("checked", "checked");

	var el_product_option_label = document.createElement('label');
	    el_product_option_label.setAttribute("class", "fm-field-label");
		el_product_option_label.innerHTML = "Product properties";
	
	var el_product_option_add_a = document.createElement('a');
		el_product_option_add_a.setAttribute("onclick","tb_show('', 'admin-ajax.php?action=product_option&field_id="+i+"&width=530&height=370&TB_iframe=1')");
	//	el_product_option_add_a.setAttribute("href", url_for_ajax + "?action=product_option&field_id=" + i + "&url_for_ajax=" + url_for_ajax + "&width=600&height=400&TB_iframe=1");
		el_product_option_add_a.setAttribute("class","thickbox-preview");

	var el_product_option_add_img = document.createElement('img');
		el_product_option_add_img.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		
	var el_product_option_add_ul = document.createElement('ul');
		el_product_option_add_ul.setAttribute("id", 'option_ul');
		el_product_option_add_ul.style.cssText="list-style-type: none; padding:0px"
							
	el_product_option_add_a.appendChild(el_product_option_add_img);

	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");    
		el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');       
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_checkbox')");
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
		el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n = w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.style.cssText = "width:100px";
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_checkbox')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.style.cssText = "width:100px";
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_checkbox')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');	
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_checkbox')");
			
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
	}

	var el_choices_label = document.createElement('label');
		el_choices_label.setAttribute("class", "fm-field-label");
		el_choices_label.innerHTML = "Options ";

	var el_choices_add = document.createElement('img');
		el_choices_add.setAttribute("id", "el_choices_add");
		el_choices_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');	
		el_choices_add.style.cssText = 'cursor:pointer;';
		el_choices_add.setAttribute("title", 'add');
		el_choices_add.setAttribute("onClick", "add_choise_price('radio',"+i+")");
	
	var	el_choices_add_text = document.createElement("span");
		el_choices_add_text.style.cssText ="font-size: 12px; padding-left:7px; font-weight:bold; cursor:pointer;";
		el_choices_add_text.innerHTML ="Add option(s)";	
		el_choices_add_text.setAttribute("onClick", "add_choise_price('radio',"+i+")");
	
	var el_choices_select = document.createElement('a');
	    el_choices_select.style.cssText ="color:#000; font-weight:bold; font-size: 13px; cursor:pointer;  padding-top:10px; display:block;";
		el_choices_select.innerHTML = "Select options from database";
		el_choices_select.setAttribute("rel", "{handler: 'iframe', size: {x: 530, y: 370}}"	);
		el_choices_select.setAttribute("onclick","tb_show('', 'admin-ajax.php?action=select_data_from_db&field_id="+i+"&field_type=paypal_shipping&width=530&height=370&TB_iframe=1')");
		el_choices_select.setAttribute("class","modal");			
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');

	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td12.appendChild(el_label_size_label);
	edit_main_td12_1.appendChild(el_label_size);

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_label_flow);
	edit_main_td3_1.appendChild(el_flow_vertical);
	edit_main_td3_1.appendChild(el_label_vertical);
	edit_main_td3_1.appendChild(br1);
	edit_main_td3_1.appendChild(el_flow_horizontal);
	edit_main_td3_1.appendChild(el_label_horizontal);

	edit_main_td6.appendChild(el_style_label);
	edit_main_td6_1.appendChild(el_style_textarea);
	
	edit_main_td5.appendChild(el_required_label);
	edit_main_td5_1.appendChild(el_required);
	
	edit_main_td13.appendChild(el_option_position_label);
	edit_main_td13_1.appendChild(el_option_position1);
	edit_main_td13_1.appendChild(el_option_left);
	edit_main_td13_1.appendChild(br2);
	edit_main_td13_1.appendChild(el_option_position2);
	edit_main_td13_1.appendChild(el_option_right);

	edit_main_td11.appendChild(el_quantity_label);
	edit_main_td11_1.appendChild(el_quantity);

	edit_main_td10.appendChild(el_product_option_label);
	edit_main_td10.appendChild(el_product_option_add_ul);
	edit_main_td10_1.appendChild(el_product_option_add_a);
	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br3);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");
	
	edit_main_td4.appendChild(el_choices_label);
	edit_main_td4_1.appendChild(br4);
	edit_main_td4_1.appendChild(el_choices_add);
	edit_main_td4_1.appendChild(el_choices_add_text);
	edit_main_td4_1.appendChild(el_choices_select);

	var div_ = document.createElement('div');
		div_.style.cssText = 'border-bottom:1px dotted black; width: 220px;';
	var br = document.createElement('br');
	
	var el_choices_mini_label = document.createElement('b');
		el_choices_mini_label.innerHTML="Product name";
		el_choices_mini_label.style.cssText='padding-right: 20px; padding-left: 20px; font-size:9px';
		
	var el_choices_price_mini_label = document.createElement('b');
		el_choices_price_mini_label.innerHTML="Price";
		el_choices_price_mini_label.style.cssText='padding-right: 20px; padding-left: 20px;  font-size:9px';

	var el_choices_remove_mini_label = document.createElement('b');
		el_choices_remove_mini_label.innerHTML="Empty value";
		el_choices_remove_mini_label.style.cssText='padding-right: 3px; padding-left: 3px; font-size:9px; font-weight:bold;';
		
	var el_choices_dis_mini_label = document.createElement('b');
		el_choices_dis_mini_label.innerHTML="Delete";
		el_choices_dis_mini_label.style.cssText='padding-left: 2px; padding-right: 2px; font-size:9px';
	
	var el_choices_move_mini_label = document.createElement('b');
		el_choices_move_mini_label.innerHTML="Move";
		el_choices_move_mini_label.style.cssText='padding-left: 3px; padding-right: 3px; font-size:9px; font-weight:bold;';
		
	div_.appendChild(br);
	div_.appendChild(el_choices_mini_label);
	div_.appendChild(el_choices_price_mini_label);
	div_.appendChild(el_choices_dis_mini_label);
	div_.appendChild(el_choices_move_mini_label);
	edit_main_td4.appendChild(div_);

	n = w_choices.length;
	for(j=0; j<n; j++)
	{	
		var div = document.createElement('div');
			div.setAttribute("id", j);
			div.setAttribute("class", "change_pos");
			
		var el_choices = document.createElement('input');
			el_choices.setAttribute("id", "el_choices"+j);
			el_choices.setAttribute("type", "text");
			el_choices.setAttribute("value", w_choices[j]);
			el_choices.setAttribute("checked", w_choices_checked[j]);
			el_choices.setAttribute("class", "fm-field-choice");
			el_choices.setAttribute("onKeyUp", "change_label('"+i+"_label_element"+j+"', this.value); change_label_1('"+i+"_elementlabel_form_id_temp"+j+"', this.value); ");
			if(w_choices_params[j])
				el_choices.setAttribute("disabled", 'disabled');	
	
		var el_choices_price = document.createElement('input');
			el_choices_price.setAttribute("id", "el_option_price"+j);
			el_choices_price.setAttribute("type", "text");
			el_choices_price.setAttribute("value", w_choices_price[j]);
			el_choices_price.setAttribute("class", "fm-field-paypal-choice");
			el_choices_price.setAttribute("onKeyUp", "change_value_price('"+i+"_elementform_id_temp"+j+"', this.value)");
			el_choices_price.setAttribute("onKeyPress", "return check_isnum_point(event)");
			if(w_choices_params[j])
				el_choices_price.setAttribute("disabled", 'disabled');	
		
		var el_choices_params = document.createElement('input');
			el_choices_params.setAttribute("id", "el_option_params"+j);
			el_choices_params.setAttribute("class", "el_option_params");
			el_choices_params.setAttribute("type", "hidden");
			el_choices_params.setAttribute("value", w_choices_params[j]);
		
		var el_choices_remove = document.createElement('img');
			el_choices_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');	
			el_choices_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin: 3px;';
			el_choices_remove.setAttribute("align", 'top');
			el_choices_remove.setAttribute("onClick", "remove_choise_price("+j+","+i+")");
		
		var el_choices_handle = document.createElement('img');
			el_choices_handle.setAttribute("class", "el_choices_sortable");
			el_choices_handle.setAttribute("src", plugin_url + '/images/move_cursor.png?ver=1.8.0');		
			el_choices_handle.style.cssText = 'cursor:move; vertical-align:middle; margin: 2px;';
			el_choices_handle.setAttribute("align", 'top');
		
		div.appendChild(el_choices);
		div.appendChild(el_choices_price);
		div.appendChild(el_choices_remove);
		div.appendChild(el_choices_handle);
		div.appendChild(el_choices_params);
		edit_main_td4.appendChild(div);
	}

	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr12.appendChild(edit_main_td12);
	edit_main_tr12.appendChild(edit_main_td12_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr13.appendChild(edit_main_td13);
	edit_main_tr13.appendChild(edit_main_td13_1);
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr11.appendChild(edit_main_td11);
	edit_main_tr11.appendChild(edit_main_td11_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr12);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr13);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr11);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr7);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);

	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_paypal_radio");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
			
	var adding_required = document.createElement("input");
		adding_required.setAttribute("type", "hidden");
		adding_required.setAttribute("value", w_required);
		adding_required.setAttribute("name", i+"_requiredform_id_temp");			
		adding_required.setAttribute("id", i+"_requiredform_id_temp");
	    
	var adding_randomize = document.createElement("input");
		adding_randomize.setAttribute("type", "hidden");
		adding_randomize.setAttribute("value", w_randomize);
		adding_randomize.setAttribute("name", i+"_randomizeform_id_temp");			
		adding_randomize.setAttribute("id", i+"_randomizeform_id_temp");
	    
	var adding_allow_other = document.createElement("input");
		adding_allow_other.setAttribute("type", "hidden");
		adding_allow_other.setAttribute("value", w_allow_other);
		adding_allow_other.setAttribute("name", i+"_allow_otherform_id_temp");			
		adding_allow_other.setAttribute("id", i+"_allow_otherform_id_temp");
	 
	var adding_option_left_right = document.createElement("input");
		adding_option_left_right.setAttribute("type", "hidden");
		adding_option_left_right.setAttribute("value", w_field_option_pos);	
		adding_option_left_right.setAttribute("id", i+"_option_left_right");	
			
	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
			
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width=w_field_label_size+"px";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");

	var table_little_t = document.createElement('div');
		table_little_t.style.display="table";
		
	var table_little = document.createElement('div');
		table_little.setAttribute("id", i+"_table_little");
		table_little.style.display="table-row-group";
		
	table_little_t.appendChild(table_little);

	var tr_little1 = document.createElement('div');
		tr_little1.setAttribute("id", i+"_element_tr1");
		tr_little1.style.display="table-row";
	
	var tr_little2 = document.createElement('div');
		tr_little2.setAttribute("id", i+"_element_tr2");
		tr_little2.style.display="table-row";
		
	var td_little1 = document.createElement('div');
		td_little1.setAttribute("valign", 'top');
		td_little1.setAttribute("id", i+"_td_little1");
		td_little1.style.display="table-cell";
		
	var td_little2 = document.createElement('div');
		td_little2.setAttribute("valign", 'top');
		td_little2.setAttribute("id", i+"_td_little2");
		td_little2.style.display="table-cell";

	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "wd_form_label");
		label.style.verticalAlign="top";
			
 	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
		required.style.verticalAlign="top";
		if(w_required == "yes")
			required.innerHTML = " *";
	
	n = w_choices.length;
	for(j=0; j<n; j++)
	{      	
		var tr_little = document.createElement('div');
			tr_little.setAttribute("id", i+"_element_tr"+j);
			tr_little.style.display="table-row";
				
		var td_little = document.createElement('div');
			td_little.setAttribute("valign", 'top');
			td_little.setAttribute("id", i+"_td_little"+j);
			td_little.setAttribute("idi", j);
			td_little.style.display="table-cell";
	
		var adding = document.createElement('input');
			adding.setAttribute("type", 'radio');
			adding.setAttribute("id", i+"_elementform_id_temp"+j);
			adding.setAttribute("name", i+"_elementform_id_temp");
			adding.setAttribute("value", w_choices_price[j]);
			if(w_field_option_pos == "right")
				adding.style.cssText = "float: left !important";
			adding.setAttribute("onclick", "set_default('"+i+"','"+j+"','form_id_temp')");
			if(w_choices_checked[j] == '1')
				adding.setAttribute("checked", "checked");
					
		var label_adding = document.createElement('label');
			label_adding.setAttribute("id", i+"_label_element"+j);
			label_adding.setAttribute("class","ch-rad-label");
			label_adding.setAttribute("for",i+"_elementform_id_temp"+j);
			label_adding.innerHTML = w_choices[j];
			if(w_field_option_pos == "right")
				label_adding.style.cssText = "float: none !important";
			if(w_choices_params[j])
			{
				w_params = w_choices_params[j].split("[where_order_by]");
				label_adding.setAttribute("where", w_params[0]);
				w_params = w_params[1].split("[db_info]");		
				label_adding.setAttribute("order_by", w_params[0]);
				label_adding.setAttribute("db_info", w_params[1]);	
			}	
				
		var adding_ch_label = document.createElement('input');
			adding_ch_label.setAttribute("type", "hidden");
			adding_ch_label.setAttribute("id", i+"_elementlabel_form_id_temp"+j);
			adding_ch_label.setAttribute("name", i+"_elementform_id_temp"+j+"_label");
			adding_ch_label.setAttribute("value", w_choices[j]);
			
		td_little.appendChild(adding);
		td_little.appendChild(label_adding);
		td_little.appendChild(adding_ch_label);
		tr_little.appendChild(td_little);
		table_little.appendChild(tr_little);
	}			
	
	var div_ = document.createElement('div');
		div_.setAttribute("id", i+"_divform_id_temp");
	
	var main_td  = document.getElementById('show_table');

	div_label.appendChild(label);
	div_label.appendChild(required);
	div_element.appendChild(adding_type);
	div_element.appendChild(adding_required);
	div_element.appendChild(adding_randomize);
	div_element.appendChild(adding_allow_other);
	div_element.appendChild(adding_option_left_right);
	div_element.appendChild(table_little_t);
	div_element.appendChild(div_);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element); 
	div.appendChild(div_field);
	div.appendChild(br3);
	main_td.appendChild(div);
	
	add_id_and_name(i, 'type_radio');

	if(w_field_label_pos == "top")
		label_top(i);
		
	if(w_flow == "hor")	
		flow_hor(i);
		
	if(w_quantity == "yes")
		add_quantity(i, w_quantity_value);
				
	change_class(w_class, i);
	refresh_attr(i, 'type_checkbox');

	add_properties(i, w_property, w_property_values);
//	fm_popup();
	jQuery(function() {
		jQuery( "#choices" ).sortable({ 
			items: ".change_pos" ,
			handle: ".el_choices_sortable",
			update: function(event, ui) {		
				refresh_paypal_fields(i,'radio');
				refresh_id_name(i, 'type_radio');
			}
		});	
	});
}


function type_paypal_shipping(i, w_field_label, w_field_label_size, w_field_label_pos, w_field_option_pos, w_flow, w_choices, w_choices_price, w_choices_checked, w_required, w_randomize, w_allow_other, w_allow_other_num, w_class, w_attr_name, w_attr_value,  w_property,  w_property_values, w_choices_params ){

	document.getElementById("element_type").value="type_paypal_shipping";
	delete_last_child();
	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10  = document.createElement('tr');
	var edit_main_tr11  = document.createElement('tr');
    var edit_main_tr12  = document.createElement('tr');   		
	
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');

	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
		edit_main_td4_1.style.cssText = "padding:20px 0 0 25px; vertical-align:top;";
		edit_main_td4.setAttribute("id", "choices");
	
	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');

	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
		
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
		  
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
	
	var edit_main_td11 = document.createElement('td');
	var edit_main_td11_1 = document.createElement('td');
	
	var edit_main_td12 = document.createElement('td');
	var edit_main_td12_1 = document.createElement('td');
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");

	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");
				
	var el_option_position_label = document.createElement('label');
		el_option_position_label.setAttribute("class", "fm-field-label");
		el_option_position_label.innerHTML = "Field option label position";
	
	var el_option_position1 = document.createElement('input');
		el_option_position1.setAttribute("id", "edit_for_option_position_right");
		el_option_position1.setAttribute("type", "radio");        
		el_option_position1.setAttribute("name", "edit_for_option_position");
		el_option_position1.setAttribute("onchange", "option_left("+i+",'radio')");
		
	var el_option_left = document.createElement('label');
		el_option_left.setAttribute("for", "edit_for_option_position_right");
        el_option_left.innerHTML = "Left";
		
	var el_option_position2 = document.createElement('input');
		el_option_position2.setAttribute("id", "edit_for_option_position_left");
		el_option_position2.setAttribute("type", "radio");
    	el_option_position2.setAttribute("name", "edit_for_option_position");
		el_option_position2.setAttribute("onchange", "option_right("+i+",'radio')");
		
	var el_option_right = document.createElement('label');
		el_option_right.setAttribute("for", "edit_for_option_position_left");
        el_option_right.innerHTML = "Right";
		
	if(w_field_option_pos == "right")
		el_option_position2.setAttribute("checked", "checked");
	else
		el_option_position1.setAttribute("checked", "checked");	
	
	var el_label_flow = document.createElement('label');
		el_label_flow.setAttribute("class", "fm-field-label");
		el_label_flow.innerHTML = "Relative Position";

	var el_flow_vertical = document.createElement('input');
		el_flow_vertical.setAttribute("id", "edit_for_flow_vertical");
		el_flow_vertical.setAttribute("type", "radio");
		el_flow_vertical.setAttribute("value", "ver");
		el_flow_vertical.setAttribute("name", "edit_for_flow");
		el_flow_vertical.setAttribute("onchange", "flow_ver("+i+")");
		
	var el_label_vertical = document.createElement('label');
		el_label_vertical.setAttribute("for", "edit_for_flow_vertical");
        el_label_vertical.innerHTML = "Vertical";	
		
	var el_flow_horizontal = document.createElement('input');
            el_flow_horizontal.setAttribute("id", "edit_for_flow_horizontal");
            el_flow_horizontal.setAttribute("type", "radio");
            el_flow_horizontal.setAttribute("value", "hor");
            el_flow_horizontal.setAttribute("name", "edit_for_flow");
            el_flow_horizontal.setAttribute("onchange", "flow_hor("+i+")");
			
	var el_label_horizontal = document.createElement('label');
		el_label_horizontal.setAttribute("for", "edit_for_flow_horizontal");
        el_label_horizontal.innerHTML = "Horizontal";
		
	if(w_flow == "hor")
		el_flow_horizontal.setAttribute("checked", "checked");
	else
		el_flow_vertical.setAttribute("checked", "checked");
				
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
	    el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
        el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
        
        el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");
	
	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_required");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required=="yes")
			el_required.setAttribute("checked", "checked");

				
	var el_randomize_label = document.createElement('label');
		el_randomize_label.setAttribute("class", "fm-field-label");
		el_randomize_label.setAttribute("for", "el_randomize");
		el_randomize_label.innerHTML = "Randomize in frontend";
	
	var el_randomize = document.createElement('input');
		el_randomize.setAttribute("id", "el_randomize");
		el_randomize.setAttribute("type", "checkbox");
		el_randomize.setAttribute("value", "yes");
		el_randomize.setAttribute("onclick", "set_randomize('"+i+"_randomizeform_id_temp')");
		if(w_randomize=="yes")
			el_randomize.setAttribute("checked", "checked");

	var el_allow_other_label = document.createElement('label');
		el_allow_other_label.setAttribute("class", "fm-field-label");
		el_allow_other_label.innerHTML = "Allow other";
	
	var el_allow_other = document.createElement('input');
                el_allow_other.setAttribute("id", "el_allow_other");
                el_allow_other.setAttribute("type", "checkbox");
                el_allow_other.setAttribute("value", "yes");
                el_allow_other.setAttribute("onclick", "set_allow_other('"+i+"','radio')");
	if(w_allow_other=="yes")
			    el_allow_other.setAttribute("checked", "checked");

	var el_product_option_label = document.createElement('label');
	    el_product_option_label.setAttribute("class", "fm-field-label");
		el_product_option_label.innerHTML = "Product properties";
	
	var el_product_option_add_a = document.createElement('a');
		el_product_option_add_a.setAttribute("onclick","tb_show('', 'admin-ajax.php?action=product_option&field_id="+i+"&width=530&height=370&TB_iframe=1')");
	//	el_product_option_add_a.setAttribute("href", url_for_ajax + "?action=product_option&field_id=" + i + "&url_for_ajax=" + url_for_ajax + "&width=600&height=400&TB_iframe=1");
		el_product_option_add_a.setAttribute("class","thickbox-preview");

	var el_product_option_add_img = document.createElement('img');
		el_product_option_add_img.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		
	var el_product_option_add_ul = document.createElement('ul');
		el_product_option_add_ul.setAttribute("id", 'option_ul');
		el_product_option_add_ul.style.cssText="list-style-type: none; padding:0px"
				
				
	el_product_option_add_a.appendChild(el_product_option_add_img);

	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
                
           	el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_checkbox')");
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_checkbox')");
			
		var el_attr_value = document.createElement('input');
	
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_checkbox')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_checkbox')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}

	var el_choices_label = document.createElement('label');
		el_choices_label.setAttribute("class", "fm-field-label");
		el_choices_label.innerHTML = "Options ";

	var el_choices_add = document.createElement('img');
		el_choices_add.setAttribute("id", "el_choices_add");
		el_choices_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_choices_add.style.cssText = 'cursor:pointer;';
		el_choices_add.setAttribute("title", 'add');
		el_choices_add.setAttribute("onClick", "add_choise_price('radio',"+i+")");
	var	el_choices_add_text = document.createElement("span");
		el_choices_add_text.style.cssText ="font-size: 12px; padding-left:7px; font-weight:bold; cursor:pointer;";
		el_choices_add_text.innerHTML ="Add option(s)";				
		el_choices_add_text.setAttribute("onClick", "add_choise_price('radio',"+i+")");
		
	var el_choices_select = document.createElement('a');
	    el_choices_select.style.cssText ="color:#000; font-weight:bold; font-size: 13px; cursor:pointer; padding-top:10px; display:block;";
		el_choices_select.innerHTML = "Select options from database";
		el_choices_select.setAttribute("rel", "{handler: 'iframe', size: {x: 600, y: 400}}"	);
		el_choices_select.setAttribute("onclick","tb_show('', 'admin-ajax.php?action=select_data_from_db&field_id="+i+"&field_type=paypal_shipping&width=530&height=370&TB_iframe=1')");
		el_choices_select.setAttribute("class","modal");
		
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	var br7 = document.createElement('br');

	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td11.appendChild(el_label_size_label);
	edit_main_td11_1.appendChild(el_label_size);

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_label_flow);
	edit_main_td3_1.appendChild(el_flow_vertical);
	edit_main_td3_1.appendChild(el_label_vertical);
	edit_main_td3_1.appendChild(br1);
	edit_main_td3_1.appendChild(el_flow_horizontal);
	edit_main_td3_1.appendChild(el_label_horizontal);

	edit_main_td6.appendChild(el_style_label);
	edit_main_td6_1.appendChild(el_style_textarea);
	
	edit_main_td5.appendChild(el_required_label);
	edit_main_td5_1.appendChild(el_required);
	
	edit_main_td12.appendChild(el_option_position_label);
	edit_main_td12_1.appendChild(el_option_position1);
	edit_main_td12_1.appendChild(el_option_left);
	edit_main_td12_1.appendChild(br2);
	edit_main_td12_1.appendChild(el_option_position2);
	edit_main_td12_1.appendChild(el_option_right);
	
	edit_main_td8.appendChild(el_randomize_label);
	edit_main_td8_1.appendChild(el_randomize);
	
	edit_main_td9.appendChild(el_allow_other_label);
	edit_main_td9_1.appendChild(el_allow_other);
	
	edit_main_td10.appendChild(el_product_option_label);
	edit_main_td10.appendChild(el_product_option_add_ul);
	edit_main_td10_1.appendChild(el_product_option_add_a);
	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br6);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");
	
	edit_main_td4.appendChild(el_choices_label);
	edit_main_td4_1.appendChild(br7);
	edit_main_td4_1.appendChild(el_choices_add);
	edit_main_td4_1.appendChild(el_choices_add_text);
	edit_main_td4_1.appendChild(el_choices_select);

		var div_ = document.createElement('div');
			div_.style.cssText = 'border-bottom:1px dotted black; width: 250px;';
		var br = document.createElement('br');
		
		var el_choices_mini_label = document.createElement('b');
			el_choices_mini_label.innerHTML="Shipping type";
			el_choices_mini_label.style.cssText='padding-right: 20px; padding-left: 20px; font-size:9px';
			
		var el_choices_price_mini_label = document.createElement('b');
			el_choices_price_mini_label.innerHTML="Price";
			el_choices_price_mini_label.style.cssText='padding-right: 20px; padding-left: 20px;  font-size:9px';
	
		var el_choices_remove_mini_label = document.createElement('b');
			el_choices_remove_mini_label.innerHTML="Empty value";
			el_choices_remove_mini_label.style.cssText='padding-right: 3px; padding-left: 3px; font-size:9px; font-weight:bold;';
			
		var el_choices_dis_mini_label = document.createElement('b');
			el_choices_dis_mini_label.innerHTML="Delete";
			el_choices_dis_mini_label.style.cssText='padding-left: 3px; padding-right: 3px; font-size:9px; font-weight:bold;';
		var el_choices_move_mini_label = document.createElement('b');
			el_choices_move_mini_label.innerHTML="Move";
			el_choices_move_mini_label.style.cssText='padding-left: 3px; padding-right: 3px; font-size:9px; font-weight:bold;';
			
		div_.appendChild(br);
		div_.appendChild(el_choices_mini_label);
		div_.appendChild(el_choices_price_mini_label);
		div_.appendChild(el_choices_dis_mini_label);
		div_.appendChild(el_choices_move_mini_label);
		edit_main_td4.appendChild(div_);

	
	
	n=w_choices.length;
	for(j=0; j<n; j++)
	{	
		var div = document.createElement('div');
			div.setAttribute("id", j);
			div.setAttribute("class", "change_pos");
			
		var el_choices = document.createElement('input');
			el_choices.setAttribute("id", "el_choices"+j);
			el_choices.setAttribute("type", "text");
			el_choices.setAttribute("value", w_choices[j]);
			el_choices.setAttribute("checked", w_choices_checked[j]);
			el_choices.setAttribute("class", "fm-field-choice");
			el_choices.setAttribute("onKeyUp", "change_label('"+i+"_label_element"+j+"', this.value); change_label_1('"+i+"_elementlabel_form_id_temp"+j+"', this.value); ");
			if(w_choices_params[j])
				el_choices.setAttribute("disabled", 'disabled');
	
		var el_choices_price = document.createElement('input');
			el_choices_price.setAttribute("id", "el_option_price"+j);
			el_choices_price.setAttribute("type", "text");
			el_choices_price.setAttribute("value", w_choices_price[j]);
			el_choices_price.setAttribute("class", "fm-field-paypal-choice");
			el_choices_price.setAttribute("onKeyUp", "change_value_price('"+i+"_elementform_id_temp"+j+"', this.value)");
			el_choices_price.setAttribute("onKeyPress", "return check_isnum_point(event)");
            if(w_choices_params[j])
				el_choices_price.setAttribute("disabled", 'disabled');

		var el_choices_params = document.createElement('input');
			el_choices_params.setAttribute("id", "el_option_params"+j);
			el_choices_params.setAttribute("class", "el_option_params");
			el_choices_params.setAttribute("type", "hidden");
			el_choices_params.setAttribute("value", w_choices_params[j]);
			
		var el_choices_remove = document.createElement('img');
			el_choices_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');		
			el_choices_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_choices_remove.setAttribute("align", 'top');
			el_choices_remove.setAttribute("onClick", "remove_choise_price("+j+","+i+")");
			
		var el_choices_handle = document.createElement('img');
			el_choices_handle.setAttribute("class", "el_choices_sortable");
			el_choices_handle.setAttribute("src", plugin_url + '/images/move_cursor.png?ver=1.8.0');		
			el_choices_handle.style.cssText = 'cursor:move; vertical-align:middle; margin: 2px;';
			el_choices_handle.setAttribute("align", 'top');

		div.appendChild(el_choices);
		div.appendChild(el_choices_price);
		div.appendChild(el_choices_remove);
		div.appendChild(el_choices_handle);
		div.appendChild(el_choices_params);
		edit_main_td4.appendChild(div);
	
	}
	
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr11.appendChild(edit_main_td11);
	edit_main_tr11.appendChild(edit_main_td11_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr8.style.display="none";
	edit_main_tr12.appendChild(edit_main_td12);
	edit_main_tr12.appendChild(edit_main_td12_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr9.style.display="none";
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr10.style.display="none";
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr11);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr12);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr7);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	
	element='input'; type='radio';
	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_paypal_shipping");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required = document.createElement("input");
		adding_required.setAttribute("type", "hidden");
		adding_required.setAttribute("value", w_required);
		adding_required.setAttribute("name", i+"_requiredform_id_temp");			
		adding_required.setAttribute("id", i+"_requiredform_id_temp");
	    
	var adding_randomize = document.createElement("input");
		adding_randomize.setAttribute("type", "hidden");
		adding_randomize.setAttribute("value", w_randomize);
		adding_randomize.setAttribute("name", i+"_randomizeform_id_temp");			
		adding_randomize.setAttribute("id", i+"_randomizeform_id_temp");
	    
	var adding_allow_other= document.createElement("input");
		adding_allow_other.setAttribute("type", "hidden");
		adding_allow_other.setAttribute("value", w_allow_other);
		adding_allow_other.setAttribute("name", i+"_allow_otherform_id_temp");			
		adding_allow_other.setAttribute("id", i+"_allow_otherform_id_temp");
	var adding_option_left_right= document.createElement("input");
		adding_option_left_right.setAttribute("type", "hidden");
		adding_option_left_right.setAttribute("value", w_field_option_pos);	
		adding_option_left_right.setAttribute("id", i+"_option_left_right");
		
    var div = document.createElement('div');
      	    div.setAttribute("id", "main_div");
			
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width=w_field_label_size+"px";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");

	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	
	var table_little_t = document.createElement('div');
		table_little_t.style.display="table";
		
	var table_little = document.createElement('div');
		table_little.setAttribute("id", i+"_table_little");
		table_little.style.display="table-row-group";
		
	table_little_t.appendChild(table_little);

	var tr_little1 = document.createElement('div');
		tr_little1.setAttribute("id", i+"_element_tr1");
		tr_little1.style.display="table-row";
	
	var tr_little2 = document.createElement('div');
		tr_little2.setAttribute("id", i+"_element_tr2");
		tr_little2.style.display="table-row";
		
	var td_little1 = document.createElement('div');
		td_little1.setAttribute("valign", 'top');
		td_little1.setAttribute("id", i+"_td_little1");
		td_little1.style.display="table-cell";
		
	var td_little2 = document.createElement('div');
		td_little2.setAttribute("valign", 'top');
		td_little2.setAttribute("id", i+"_td_little2");
		td_little2.style.display="table-cell";

	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
		label.style.verticalAlign="top";
	
	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
		required.style.verticalAlign="top";
		if(w_required=="yes")
			required.innerHTML = " *";
		
	n=w_choices.length;
	for(j=0; j<n; j++)
	{      	
		var tr_little = document.createElement('div');
			tr_little.setAttribute("id", i+"_element_tr"+j);
			tr_little.style.display="table-row";
				
		var td_little = document.createElement('td');
			td_little.setAttribute("valign", 'top');
			td_little.setAttribute("id", i+"_td_little"+j);
			td_little.setAttribute("idi", j);
			td_little.style.display="table-cell";
	
		var adding = document.createElement(element);
			adding.setAttribute("type", type);
			adding.setAttribute("id", i+"_elementform_id_temp"+j);
			adding.setAttribute("name", i+"_elementform_id_temp");
			adding.setAttribute("value", w_choices_price[j]);
			if(w_field_option_pos=="right")
				adding.style.cssText = "float: left !important";
			adding.setAttribute("onclick", "set_default('"+i+"','"+j+"','form_id_temp')");
			if(w_choices_checked[j]=='1')
				adding.setAttribute("checked", "checked");
	
		var label_adding = document.createElement('label');
			label_adding.setAttribute("id", i+"_label_element"+j);
			label_adding.setAttribute("class","ch-rad-label");
			label_adding.setAttribute("for",i+"_elementform_id_temp"+j);
			label_adding.innerHTML = w_choices[j];
			if(w_field_option_pos=="right")
				label_adding.style.cssText = "float: none !important";
			if(w_choices_params[j])
			{
				w_params = w_choices_params[j].split("[where_order_by]");
				label_adding.setAttribute("where", w_params[0]);
				w_params = w_params[1].split("[db_info]");		
				label_adding.setAttribute("order_by", w_params[0]);
				label_adding.setAttribute("db_info", w_params[1]);
			}		
		var adding_ch_label = document.createElement('input');
			adding_ch_label.setAttribute("type", "hidden");
			adding_ch_label.setAttribute("id", i+"_elementlabel_form_id_temp"+j);
			adding_ch_label.setAttribute("name", i+"_elementform_id_temp"+j+"_label");
			adding_ch_label.setAttribute("value", w_choices[j]);
				
				
		td_little.appendChild(adding);
		td_little.appendChild(label_adding);
		td_little.appendChild(adding_ch_label);
		tr_little.appendChild(td_little);
		table_little.appendChild(tr_little);
	}			
	
	var div_ = document.createElement('div');
		div_.setAttribute("id", i+"_divform_id_temp");
	
	var main_td  = document.getElementById('show_table');

  
	div_label.appendChild(label);
	div_label.appendChild(required);
	div_element.appendChild(adding_type);

	div_element.appendChild(adding_required);
	div_element.appendChild(adding_randomize);
	div_element.appendChild(adding_allow_other);
	div_element.appendChild(adding_option_left_right);
	div_element.appendChild(table_little_t);
	div_element.appendChild(div_);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
	
  
	div.appendChild(div_field);
	div.appendChild(br3);
	main_td.appendChild(div);
	add_id_and_name(i, 'type_radio');

	if(w_field_label_pos=="top")
		label_top(i);
	
	if(w_flow=="hor")
		flow_hor(i);
				
	change_class(w_class, i);
	refresh_attr(i, 'type_checkbox');
	
	add_properties(i, w_property, w_property_values);

//	fm_popup();
	jQuery(function() {
		jQuery( "#choices" ).sortable({ 
			items: ".change_pos" ,
			handle: ".el_choices_sortable",
			update: function(event, ui) {		
				refresh_paypal_fields(i,'radio');
				refresh_id_name(i, 'type_radio');
			}
		});	
	});
}

function type_paypal_total(i, w_field_label, w_field_label_size, w_field_label_pos, w_class, w_size ){

	document.getElementById("element_type").value="type_paypal_total";
	delete_last_child();
	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
	
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');	
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');

		  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
				
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");			
		
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");
	
	var el_style_label = document.createElement('label');
	    el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "element_style");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
        el_style_textarea.setAttribute("id", "element_style");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
        el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");
	
	var el_size_label = document.createElement('label');
	    el_size_label.setAttribute("for", "edit_for_input_size");
		el_size_label.setAttribute("class", "fm-field-label");
		el_size_label.innerHTML = "Field size(px) ";
		
	var el_size = document.createElement('input');
		el_size.setAttribute("id", "edit_for_input_size");
		el_size.setAttribute("type", "text");
		el_size.setAttribute("value", w_size);
		el_size.setAttribute("onKeyPress", "return check_isnum(event)");
		el_size.setAttribute("onKeyUp", "change_w_style('"+i+"paypal_totalform_id_temp', this.value)");
	
	
	var t  = document.getElementById('edit_table');
	var br = document.createElement('br');
		
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);

	edit_main_td4.appendChild(el_label_size_label);
	edit_main_td4_1.appendChild(el_label_size);
	
	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_style_label);
	edit_main_td3_1.appendChild(el_style_textarea);
	
	edit_main_td5.appendChild(el_size_label);
	edit_main_td5_1.appendChild(el_size);

	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr3);
	
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	
	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_paypal_total");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
	  
	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
			
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width=w_field_label_size+"px";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");

	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');

	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
		
	var div_paypal = document.createElement('div');
		div_paypal.setAttribute("id", i+"paypal_totalform_id_temp");
		div_paypal.setAttribute("class", "wdform_paypal_total paypal_totalform_id_temp");
		div_paypal.style.cssText = 'width:'+w_size+'px;';
	
	var div_total = document.createElement('div');
		div_total.setAttribute("id", i+"div_totalform_id_temp");
		div_total.setAttribute("class", "div_totalform_id_temp");
		div_total.style.cssText = 'margin-bottom:10px;';
		div_total.innerHTML = '<!--repstart-->$300<!--repend-->';
	
	var div_products = document.createElement('div');
		div_products.setAttribute("id", i+"paypal_productsform_id_temp");
		div_products.setAttribute("class", "paypal_productsform_id_temp");
		div_products.style.cssText = 'border-spacing: 2px;';
	
	var div_product1 = document.createElement('div');
		div_product1.style.cssText = 'border-spacing: 2px;';
		div_product1.innerHTML = '<!--repstart-->product 1 $100<!--repend-->';
	
	var div_product2 = document.createElement('div');
		div_product2.style.cssText = 'border-spacing: 2px;';
		div_product2.innerHTML = '<!--repstart-->product 2 $200<!--repend-->';
	
	var div_tax = document.createElement('div');
		div_tax.style.cssText = 'border-spacing: 2px; margin-top:7px;';
		div_tax.setAttribute("id", i+"paypal_taxform_id_temp");
		div_tax.setAttribute("class", "paypal_taxform_id_temp");
		
	var input_for_total = document.createElement("input");
		input_for_total.setAttribute("type", "hidden");
		input_for_total.setAttribute("value", '');
		input_for_total.setAttribute("name", i+"_paypal_totalform_id_temp");	
		input_for_total.setAttribute("class", "input_paypal_totalform_id_temp");
	
	div_paypal.appendChild(input_for_total);
	div_products.appendChild(div_product1);
	div_products.appendChild(div_product2);
	div_paypal.appendChild(div_total);
	div_paypal.appendChild(div_products);
	div_paypal.appendChild(div_tax);
	    
	var main_td  = document.getElementById('show_table');
	
	div_label.appendChild(label);
	div_element.appendChild(adding_type);

	div_element.appendChild(div_paypal);
   
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
	div.appendChild(div_field);
	div.appendChild(br3);
	main_td.appendChild(div);
	
	change_class(w_class, i);
}

function type_stripe(i, w_size, w_field_label_size, w_field_label_pos, w_class ){

	document.getElementById("element_type").value="type_stripe";

	delete_last_child();
// edit table	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		edit_div.setAttribute("style", "border-top:1px dotted black;padding:10px; padding:10px;  padding-top:0px; padding-bottom:0px; margin-top:10px;");
		
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "0");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
      		edit_main_tr1.setAttribute("valing", "top");
		
	var edit_main_tr2  = document.createElement('tr');
      		edit_main_tr2.setAttribute("valing", "top");
		
	var edit_main_tr3  = document.createElement('tr');
      		edit_main_tr3.setAttribute("valing", "top");
			
	var edit_main_tr4  = document.createElement('tr');
      		edit_main_tr4.setAttribute("valing", "top");		
	
	var edit_main_tr5  = document.createElement('tr');
      		edit_main_tr5.setAttribute("valing", "top");		
	
        
        
	var edit_main_td1 = document.createElement('td');
		edit_main_td1.style.cssText = "padding-top:10px";	
	var edit_main_td1_1 = document.createElement('td');
		edit_main_td1_1.style.cssText = "padding-top:10px";		
	var edit_main_td2 = document.createElement('td');
		edit_main_td2.style.cssText = "padding-top:10px";
	var edit_main_td2_1 = document.createElement('td');
		edit_main_td2_1.style.cssText = "padding-top:10px";
	var edit_main_td3 = document.createElement('td');
		edit_main_td3.style.cssText = "padding-top:10px";
	var edit_main_td3_1 = document.createElement('td');
		edit_main_td3_1.style.cssText = "padding-top:10px";	
	var edit_main_td4 = document.createElement('td');
		edit_main_td4.style.cssText = "padding-top:10px";
	var edit_main_td4_1 = document.createElement('td');
		edit_main_td4_1.style.cssText = "padding-top:10px";		
	var edit_main_td5 = document.createElement('td');
		edit_main_td5.style.cssText = "padding-top:10px";
	var edit_main_td5_1 = document.createElement('td');
		edit_main_td5_1.style.cssText = "padding-top:10px";		

	var el_size_label = document.createElement('label');
	    el_size_label.setAttribute("for", "edit_for_input_size");
		el_size_label.innerHTML = "Field size(px) ";
		
	var el_size = document.createElement('input');
		el_size.setAttribute("id", "edit_for_input_size");
		el_size.setAttribute("type", "text");
		el_size.setAttribute("value", w_size);
		el_size.setAttribute("onKeyPress", "return check_isnum(event)");
		el_size.setAttribute("onKeyUp", "change_w_style('"+i+"_elementform_id_temp', this.value)");
		
	var el_label_position_label = document.createElement('label');
                el_label_position_label.style.cssText ="color:#00aeef; font-weight:bold; font-size: 13px";
		el_label_position_label.innerHTML = "Field label position";
	
	var el_label_position1 = document.createElement('input');
                el_label_position1.setAttribute("id", "edit_for_label_position_top");
                el_label_position1.setAttribute("type", "radio");
                el_label_position1.setAttribute("value", "left");
                

                el_label_position1.setAttribute("name", "edit_for_label_position");
                el_label_position1.setAttribute("onchange", "label_left("+i+")");
				el_label_position1.setAttribute("checked", "checked");
		Left = document.createTextNode("Left");
		
	var el_label_position2 = document.createElement('input');
                el_label_position2.setAttribute("id", "edit_for_label_position_left");
                el_label_position2.setAttribute("type", "radio");

                el_label_position2.setAttribute("value", "top");
	

                el_label_position2.setAttribute("name", "edit_for_label_position");
                el_label_position2.setAttribute("onchange", "label_top("+i+")");
		Top = document.createTextNode("Top");
		
	if(w_field_label_pos=="top")
	
				el_label_position2.setAttribute("checked", "checked");
	else
				el_label_position1.setAttribute("checked", "checked");
	
	var el_label_size_label = document.createElement('label');
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
            el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
            el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
        
	var el_style_label = document.createElement('label');
	    el_style_label.style.cssText ="color:#00aeef; font-weight:bold; font-size: 13px";
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
        el_style_textarea.setAttribute("id", "element_style");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
        el_style_textarea.style.cssText = "width:200px;";
        el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");
	
		
				
	var t  = document.getElementById('edit_table');
	var br = document.createElement('br');
		

	edit_main_td4.appendChild(el_size_label);
	edit_main_td4_1.appendChild(el_size);
	
	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(Left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(Top);
	
	
	edit_main_td3.appendChild(el_style_label);
	edit_main_td3_1.appendChild(el_style_textarea);

        edit_main_td5.appendChild(el_label_size_label);
	edit_main_td5_1.appendChild(el_label_size);

	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	
	
	edit_main_table.appendChild(edit_main_tr4);
        edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);

//show table

	
            var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_stripe");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
            
	var div = document.createElement('div');
      	    div.setAttribute("id", "main_div");
			
	var div_field = document.createElement('div');
           	div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
      	var div_label = document.createElement('div');
         	div_label.setAttribute("align", 'left');
         	div_label.style.display="table-cell";
           	div_label.setAttribute("id", i+"_label_sectionform_id_temp");
                div_label.style.width= w_field_label_size+'px';
			
      	var div_element = document.createElement('div');
         	div_element.setAttribute("align", 'left');
          	div_element.style.display="table-cell";
          	div_element.setAttribute("id", i+"_element_sectionform_id_temp");

      	var br1 = document.createElement('br');
      	var br2 = document.createElement('br');
     	var br3 = document.createElement('br');
      	var br4 = document.createElement('br');

		var label = document.createElement('span');
			label.setAttribute("id", i+"_element_labelform_id_temp");
			label.innerHTML = "stripe";
			label.setAttribute("class", "label");
         	label.style.display="none";
				    
      	var main_td  = document.getElementById('show_table');
	
      
      	div_label.appendChild(label);
	
       	div_element.innerHTML="<div id='"+i+"_elementform_id_temp' style='width:"+w_size+"px; margin:10px; border: 1px solid #000; min-width:80px;text-align:center;'> Stripe Section</div><input type='hidden' id='is_stripe' />";
       	div_element.appendChild(adding_type);
       
    	div_field.appendChild(div_label);
      	div_field.appendChild(div_element);
      	
      
      	div.appendChild(div_field);
      	div.appendChild(br3);
      	main_td.appendChild(div);
		
	if(w_field_label_pos=="top")
				label_top(i);
		
change_class(w_class, i);
}

function type_star_rating(i, w_field_label, w_field_label_size, w_field_label_pos, w_field_label_col, w_star_amount, w_required, w_class, w_attr_name, w_attr_value){

    document.getElementById("element_type").value="type_star_rating";

	delete_last_child();
// edit table	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');	
	var edit_main_tr8  = document.createElement('tr');
	
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');	
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');

	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
		
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");		
		
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_star_size_label = document.createElement('label');
		el_star_size_label.setAttribute("class", "fm-field-label");
		el_star_size_label.setAttribute("for", "edit_for_star_size");
		el_star_size_label.innerHTML = "Star Amount ";
	
	var el_star_size_input = document.createElement('input');
		el_star_size_input.setAttribute("type", "text");		
		el_star_size_input.setAttribute("id", "edit_for_star_size");		
		el_star_size_input.setAttribute("value", w_star_amount);
		el_star_size_input.setAttribute("onKeyPress", "return check_isnum(event)");	
		el_star_size_input.setAttribute("onKeyUp", "change_star_amount(this.value,"+i+",'form_id_temp')");
           
	var el_star_color_label = document.createElement('label');
	    el_star_color_label.setAttribute("class", "fm-field-label");
	    el_star_color_label.setAttribute("for", "edit_for_label_color");
		el_star_color_label.innerHTML = "Star Color";
	
	var el_star_color = document.createElement('select');
		el_star_color.setAttribute("id", "edit_for_label_color");
		el_star_color.setAttribute("name", "edit_for_label_color");
		el_star_color.setAttribute("onchange", "label_color(this.value,"+i+")");
		el_star_color.style.cssText = 'width:200px';
                
	var el_star_color1 = document.createElement('option');
		el_star_color1.setAttribute("id", "edit_for_label_color_yellow");
		el_star_color1.setAttribute("value", "yellow");
		Yellow = document.createTextNode("Yellow");

    var el_star_color2 = document.createElement('option');
		el_star_color2.setAttribute("id", "edit_for_label_color_green");
		el_star_color2.setAttribute("value", "green");
		Green = document.createTextNode("Green");

    var el_star_color3 = document.createElement('option');
		el_star_color3.setAttribute("id", "edit_for_label_color_blue");
		el_star_color3.setAttribute("value", "blue");
		Blue = document.createTextNode("Blue");

    var el_star_color4 = document.createElement('option');
		el_star_color4.setAttribute("id", "edit_for_label_color_red");
		el_star_color4.setAttribute("value", "red");				
		Red = document.createTextNode("Red");              
	
		if(w_field_label_col=="yellow")
			el_star_color1.setAttribute("selected", "selected");
		else
		{
			if(w_field_label_col=="green")
				el_star_color2.setAttribute("selected", "selected");
			else{
				if(w_field_label_col=="blue")
					el_star_color3.setAttribute("selected", "selected");
				else{
					if(w_field_label_col=="red")
						el_star_color4.setAttribute("selected", "selected");
				}
			}
		}

	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "element_style");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "element_style");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("disabled", "disabled");
		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_send");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_send");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("value", "yes");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required=="yes")
			el_required.setAttribute("checked", "checked");
	
	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
			
	var el_attr_add = document.createElement('img');
		el_attr_add.setAttribute("id", "el_choices_add");
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_star_rating')");
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
		el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++) {	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_star_rating')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_star_rating')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("align", 'top');
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_star_rating')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
	}
		
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	edit_main_td8.appendChild(el_label_size_label);
	edit_main_td8_1.appendChild(el_label_size);

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_star_size_label);
	edit_main_td3_1.appendChild(el_star_size_input);

    edit_main_td4.appendChild(el_star_color_label);
	el_star_color1.appendChild(Yellow);
	el_star_color2.appendChild(Green);
	el_star_color3.appendChild(Blue);
	el_star_color4.appendChild(Red);
	
	el_star_color.appendChild(el_star_color1);
	el_star_color.appendChild(el_star_color2);
	el_star_color.appendChild(el_star_color3);
	el_star_color.appendChild(el_star_color4);
	
	edit_main_td4_1.appendChild(el_star_color);
	
	edit_main_td5.appendChild(el_style_label);
	edit_main_td5_1.appendChild(el_style_textarea);
	edit_main_td6.appendChild(el_required_label);
	edit_main_td6_1.appendChild(el_required);
	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br1);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
    edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr7);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);

	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_star_rating");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required = document.createElement("input");
		adding_required.setAttribute("type", "hidden");
		adding_required.setAttribute("value", w_required);
		adding_required.setAttribute("name", i+"_requiredform_id_temp");
		adding_required.setAttribute("id", i+"_requiredform_id_temp");
		
	var adding_star_amount = document.createElement("input");
		adding_star_amount.setAttribute("type", "hidden");
		adding_star_amount.setAttribute("value", w_star_amount);
		adding_star_amount.setAttribute("id", i+"_star_amountform_id_temp");
		adding_star_amount.setAttribute("name", i+"_star_amountform_id_temp");
			
	var adding_star_color = document.createElement("input");
		adding_star_color.setAttribute("type", "hidden");
		adding_star_color.setAttribute("value", w_field_label_col);
		adding_star_color.setAttribute("name", i+"_star_colorform_id_temp");	
		adding_star_color.setAttribute("id", i+"_star_colorform_id_temp");		
			
	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
	
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
	
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.cssText = "display:table-cell; vertical-align:top; width:"+w_field_label_size+"px;";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");
	
	var div1 = document.createElement('div');	
		div1.setAttribute("id", i+"_elementform_id_temp");
		div1.setAttribute("class", "wdform_stars");
		
	var br1 = document.createElement('br');

	
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
	
	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
		if(w_required=="yes")
			required.innerHTML = " *";
	var main_td  = document.getElementById('show_table');
  
	div_label.appendChild(label);
	div_label.appendChild(required);
	div_element.appendChild(adding_type);
	div_element.appendChild(adding_required);
	div_element.appendChild(adding_star_amount);
	div_element.appendChild(adding_star_color);
		    		
    for(var j=0;j<w_star_amount;j++){	
		var adding = document.createElement("img");
			adding.setAttribute('id', i+'_star_'+j);
			adding.setAttribute('src', plugin_url + '/images/star.png');
			adding.setAttribute('onmouseover', "change_src("+j+","+i+",'form_id_temp')");
			adding.setAttribute('onmouseout', "reset_src("+j+","+i+")");
			adding.setAttribute('onclick', "select_star_rating("+j+","+i+",'form_id_temp')");
	   
      	div1.appendChild(adding);
	}	
	
	div_element.appendChild(div1);
		
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
  
	div.appendChild(div_field);
	div.appendChild(br1);
	main_td.appendChild(div);
	if(w_field_label_pos=="top")
		label_top(i);
	
	change_class(w_class, i);
	refresh_attr(i, 'type_star_rating');
}

function change_src(b,id,form_id)
{
	for(var j=0;j<=b;j++)
	document.getElementById(id+'_star_'+j).src=plugin_url + "/images/star_"+document.getElementById(id+'_star_colorform_id_temp').value+".png";
}


function reset_src(b,id)
{
	for(var j=0;j<=b;j++)
	document.getElementById(id+'_star_'+j).src=plugin_url + "/images/star.png";
}

function select_star_rating(id,a,form_id){}

function change_star_amount(b,id,form_id)
{
	var td=document.getElementById(id+"_element_sectionform_id_temp");
	var div=document.getElementById(id+"_elementform_id_temp");
	td.removeChild(div);

	var div1 = document.createElement('div');	
				div1.setAttribute("id", id+"_elementform_id_temp");
			
	for(var j=0;j<b;j++)
	{	
		var adding_img=document.createElement("img");
			adding_img.setAttribute('id', id+'_star_'+j);
			adding_img.setAttribute('src', plugin_url + '/images/star.png');
			adding_img.setAttribute('onmouseover', "change_src("+j+","+id+",'form_id_temp')");
			adding_img.setAttribute('onmouseout', "reset_src("+j+","+id+")");
			adding_img.setAttribute('onclick', "select_star_rating("+j+","+id+",'form_id_temp')");
			
      	div1.appendChild(adding_img);
		
	}
	
	td.appendChild(div1);
	document.getElementById(id+'_star_amountform_id_temp').value=b;
}

function label_color(b,id)
{
	document.getElementById(id+'_star_colorform_id_temp').value=b;
}


function type_scale_rating(i, w_field_label, w_field_label_size, w_field_label_pos, w_mini_labels, w_scale_amount, w_required, w_class, w_attr_name, w_attr_value){

    document.getElementById("element_type").value="type_scale_rating";
	delete_last_child();

	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');		
	var edit_main_tr2  = document.createElement('tr');	
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');	
	var edit_main_tr5  = document.createElement('tr');		
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');

	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
		
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
		  
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
	
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
		
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");		
		
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_scale_amount_label = document.createElement('label');
		el_scale_amount_label.setAttribute("class", "fm-field-label");
		el_scale_amount_label.setAttribute("for", "edit_for_scale_amount");
		el_scale_amount_label.innerHTML = "Scale Amount ";
	
	var el_scale_amount_input = document.createElement('input');
		el_scale_amount_input.setAttribute("type", "text");		
		el_scale_amount_input.setAttribute("id", "edit_for_scale_amount");		
		el_scale_amount_input.setAttribute("value", w_scale_amount);	
		el_scale_amount_input.setAttribute("onKeyPress", "return check_isnum(event)");	
		el_scale_amount_input.setAttribute("onKeyUp", "change_scale_amount(this.value,"+i+",'form_id_temp')");
           
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "element_style");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "element_style");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_send");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_send");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("value", "yes");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required=="yes")
			el_required.setAttribute("checked", "checked");
	
	var el_attr_label = document.createElement('label');
	    el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
			
	var el_attr_add = document.createElement('img');
		el_attr_add.setAttribute("id", "el_choices_add");
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_scale_rating')");
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
		el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_scale_rating')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_scale_rating')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("align", 'top');
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_scale_rating')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}
		
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);

	edit_main_td9.appendChild(el_label_size_label);
	edit_main_td9_1.appendChild(el_label_size);
edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_scale_amount_label);
	edit_main_td3_1.appendChild(el_scale_amount_input);
	
	edit_main_td6.appendChild(el_style_label);
	edit_main_td6_1.appendChild(el_style_textarea);
	edit_main_td7.appendChild(el_required_label);
	edit_main_td7_1.appendChild(el_required);
	
	
	
	edit_main_td8.appendChild(el_attr_label);
	edit_main_td8.appendChild(el_attr_add);
	edit_main_td8.appendChild(br1);
	edit_main_td8.appendChild(el_attr_table);
	edit_main_td8.setAttribute("colspan", "2");
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);

	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
 
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr8);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);

	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_scale_rating");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required = document.createElement("input");
		adding_required.setAttribute("type", "hidden");
		adding_required.setAttribute("value", w_required);
		adding_required.setAttribute("name", i+"_requiredform_id_temp");	
		adding_required.setAttribute("id", i+"_requiredform_id_temp");

	var adding_scale_amount = document.createElement("input");
		adding_scale_amount.setAttribute("type", "hidden");
		adding_scale_amount.setAttribute("value", w_scale_amount);
		adding_scale_amount.setAttribute("id", i+"_scale_amountform_id_temp");
		adding_scale_amount.setAttribute("name", i+"_scale_amountform_id_temp");
	
	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
	
	edit_labels = document.createTextNode("The labels of the fields are editable. Please, click the label to edit.");
	
	var div_for_editable_labels = document.createElement('div');
		div_for_editable_labels.setAttribute("class", "fm-editable-label");
		
	div_for_editable_labels.appendChild(edit_labels);  
	
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.cssText = "display:table-cell; vertical-align:top; width:"+w_field_label_size+"px;";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");

	var div1 = document.createElement('div');	
		div1.setAttribute("id", i+"_elementform_id_temp");
		
	var scale_table = document.createElement('div');
		scale_table.setAttribute("id", i+"_scale_tableform_id_temp");
		scale_table.style.cssText ="display:inline-table;";
		
	var scale_tr0 = document.createElement('div');
		scale_tr0.setAttribute("id", i+"_scale_tr1form_id_temp");
		scale_tr0.style.display="table-row";
		
	var scale_tr1 = document.createElement('div');
		scale_tr1.setAttribute("id", i+"_scale_tr2form_id_temp");
		scale_tr1.style.display="table-row";
		
	var br1 = document.createElement('br');
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
			
	var label1 = document.createElement('label');
		label1.setAttribute("class", "mini_label");	
		label1.setAttribute("id", i+"_mini_label_worst");
		label1.innerHTML= w_mini_labels[0];
		label1.style.cssText ="position:relative; top:6px; font-size:11px; display:inline-table;";
		
	var label2 = document.createElement('label');
		label2.setAttribute("class", "mini_label");	
		label2.setAttribute("id", i+"_mini_label_best");
		label2.innerHTML= w_mini_labels[1];
		label2.style.cssText ="position:relative; top:6px; font-size:11px; display:inline-table;";
		
	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
		if(w_required=="yes")
			required.innerHTML = " *";
	var main_td  = document.getElementById('show_table');
  
	div_label.appendChild(label);
	div_label.appendChild(required);
	div_element.appendChild(adding_type);	
	div_element.appendChild(adding_required);
	div_element.appendChild(adding_scale_amount);
	
	div1.appendChild(label1);
	scale_table.appendChild(scale_tr0);
		 
	for(var l=1;l<=w_scale_amount;l++){	   
		adding_num=document.createElement("span");
		adding_num.innerHTML = l;
				   
		adding_td =	document.createElement('td');
		adding_td.setAttribute("id", i+"_scale_td1_"+l+"form_id_temp");
		adding_td.style.cssText = 'text-align:center;';
		adding_td.style.display="table-cell";
		
		adding_td.appendChild(adding_num);
		scale_tr0.appendChild(adding_td);
    }	
	 
    for(var k=1;k<=w_scale_amount;k++){	
		var adding_radio=document.createElement("input");
			adding_radio.setAttribute('id', i+'_scale_radioform_id_temp_'+k);
			adding_radio.setAttribute('name', i+'_scale_radioform_id_temp');
			adding_radio.setAttribute('value', k);
			adding_radio.setAttribute('type', 'radio');
	
		var adding_td_for_radio=document.createElement("div");
			adding_td_for_radio.setAttribute('id', i+'_scale_td2_'+k+'form_id_temp');
			adding_td_for_radio.style.display="table-cell";
		   
		adding_td_for_radio.appendChild(adding_radio);
		scale_tr1.appendChild(adding_td_for_radio);
		scale_table.appendChild(scale_tr1);
		div1.appendChild(scale_table);
	}	
	  
	scale_table.appendChild(scale_tr1);
	div1.appendChild(scale_table);
	div1.appendChild(label2);

	div_element.appendChild(div1);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);

	div.appendChild(div_field);	
	div.appendChild(br1);
	div.appendChild(div_for_editable_labels);	
	main_td.appendChild(div);
	if(w_field_label_pos=="top")
		label_top(i);
				
	change_class(w_class, i);
	refresh_attr(i, 'type_scale_rating');			
				
	jQuery(document).ready(function() {	
		jQuery("label#"+i+"_mini_label_worst").click(function() {		
			if (jQuery(this).children('input').length == 0) {
				var worst = "<input type='text' class='worst' size='6' style='outline:none; border:none; background:none; font-size:11px;' value=\""+jQuery(this).text()+"\">";		

				jQuery(this).html(worst);		
				jQuery("input.worst").focus();		
				jQuery("input.worst").blur(function() {	
					var value = jQuery(this).val();			
					jQuery("#"+i+"_mini_label_worst").text(value);		
				});		
			}	
		});	

		jQuery("label#"+i+"_mini_label_best").click(function() {		
			if (jQuery(this).children('input').length == 0) {			
				var best = "<input type='text' class='best' size='6'  style='outline:none; border:none; background:none; font-size:11px;' value=\""+jQuery(this).text()+"\">";						
				jQuery(this).html(best);
				jQuery("input.best").focus();			
				jQuery("input.best").blur(function() {		
					var value = jQuery(this).val();			
					jQuery("#"+i+"_mini_label_best").text(value);		
				});	
			}	
		});
	});			
}

function change_scale_amount(b,id,form_id){
	
	var table=document.getElementById(id+"_scale_tableform_id_temp");
	var div=document.getElementById(id+"_elementform_id_temp");

	div.removeChild(table);

		var scale_table = document.createElement('div');
           	scale_table.setAttribute("id", id+"_scale_tableform_id_temp");
			scale_table.style.cssText ="display:inline-table;";
						
		var tr0 = document.createElement('div');
           	tr0.setAttribute("id", id+"_scale_tr1form_id_temp");
			tr0.style.cssText ="display:table-row;";
		
		var tr1 = document.createElement('div');
           	tr1.setAttribute("id", id+"_scale_tr2form_id_temp");
			tr1.style.cssText ="display:table-row;";
			
			scale_table.appendChild(tr0);
	for(var l=1;l<=b;l++){	 

		adding_num=document.createElement("span");
		adding_num.innerHTML = l;
				   
		adding_td =	document.createElement('div');
		adding_td.setAttribute("id", id+"_scale_td1_"+l+"form_id_temp");
		adding_td.style.cssText = 'text-align:center; display:table-cell;';
		
		adding_td.appendChild(adding_num);
		tr0.appendChild(adding_td); 
		
		}	
	 
	for(var k=1;k<=b;k++){	

		
		var adding_radio=document.createElement("input");
			adding_radio.setAttribute('id', id+'_scale_radioform_id_temp_'+k);
			adding_radio.setAttribute('name', id+'_scale_radioform_id_temp');
			adding_radio.setAttribute('value', k);
			adding_radio.setAttribute('type', 'radio');
			

		var adding_td_for_radio=document.createElement("div");
			adding_td_for_radio.setAttribute('id', id+'_scale_td2_'+k+'form_id_temp');
			adding_td_for_radio.style.cssText = ' display:table-cell;';
			
			adding_td_for_radio.appendChild(adding_radio);
		   tr1.appendChild(adding_td_for_radio);
			
	}	
	scale_table.appendChild(tr1);
	div.insertBefore(scale_table,div.childNodes[1])
		  
	document.getElementById(id+'_scale_amountform_id_temp').value = b;
}

function type_spinner(i, w_field_label, w_field_label_size, w_field_label_pos, w_field_width, w_field_min_value, w_field_max_value, w_field_step, w_field_value, w_required, w_class, w_attr_name, w_attr_value){

	document.getElementById("element_type").value="type_spinner";
	delete_last_child();

	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");

	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
  	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10  = document.createElement('tr');
	

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');

	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');  
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');	
		  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
		
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");			
		
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

				
	var el_spinner_width_label = document.createElement('label');
		el_spinner_width_label.setAttribute("class", "fm-field-label");
		el_spinner_width_label.setAttribute("for", "edit_for_spinner_width");
		el_spinner_width_label.innerHTML = "Width ";

	var el_spinner_width_input = document.createElement('input');
		el_spinner_width_input.setAttribute("type", "text");		
		el_spinner_width_input.setAttribute("id", "edit_for_spinner_width");		
		el_spinner_width_input.setAttribute("value", w_field_width);
		el_spinner_width_input.setAttribute("onKeyPress", "return check_isnum(event)");	
		el_spinner_width_input.setAttribute("onKeyUp", "change_spinner_width(this.value,"+i+",'form_id_temp')");			
							
	var el_spinner_min_value_label = document.createElement('label');
		el_spinner_min_value_label.setAttribute("class", "fm-field-label");
		el_spinner_min_value_label.setAttribute("for", "edit_for_spinner_min_value");
		el_spinner_min_value_label.innerHTML = "Min Value ";
	
	var el_spinner_min_value_input = document.createElement('input');
		el_spinner_min_value_input.setAttribute("type", "text");		
		el_spinner_min_value_input.setAttribute("id", "edit_for_spinner_min_value");		
		el_spinner_min_value_input.setAttribute("value", w_field_min_value);
		el_spinner_min_value_input.setAttribute("onKeyPress", "return check_isnum_or_minus(event)");
		el_spinner_min_value_input.setAttribute("onChange", "change_spinner_min_value(this.value,"+i+",'form_id_temp')");
			   
	var el_spinner_max_value_label = document.createElement('label');
		el_spinner_max_value_label.setAttribute("class", "fm-field-label");
		el_spinner_max_value_label.setAttribute("for", "edit_for_spinner_max_value");
		el_spinner_max_value_label.innerHTML = "Max Value ";
	
	var el_spinner_max_value_input = document.createElement('input');
		el_spinner_max_value_input.setAttribute("type", "text");		
		el_spinner_max_value_input.setAttribute("id", "edit_for_spinner_max_value");		
		el_spinner_max_value_input.setAttribute("value", w_field_max_value);
		el_spinner_max_value_input.setAttribute("onKeyPress", "return check_isnum_or_minus(event)");
		el_spinner_max_value_input.setAttribute("onChange", "change_spinner_max_value(this.value,"+i+",'form_id_temp')");     
	
	var el_spinner_step_label = document.createElement('label');
		el_spinner_step_label.setAttribute("class", "fm-field-label");
		el_spinner_step_label.setAttribute("for", "edit_for_spinner_step");
		el_spinner_step_label.innerHTML = "Step";
		
	var el_spinner_step_input = document.createElement('input');
		el_spinner_step_input.setAttribute("type", "text");		
		el_spinner_step_input.setAttribute("id", "edit_for_spinner_step");		
		el_spinner_step_input.setAttribute("value", w_field_step);
		el_spinner_step_input.setAttribute("onKeyPress", "return check_isnum_or_minus(event)");
		el_spinner_step_input.setAttribute("onChange", "change_spinner_step(this.value,"+i+",'form_id_temp')");
	
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "element_style");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "element_style");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_required_label = document.createElement('label');
	    el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_send");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_send");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("value", "yes");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required=="yes")
			el_required.setAttribute("checked", "checked");
	
	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.setAttribute("for", "el_choices_add");
		el_attr_label.innerHTML = "Additional Attributes";
		
	var el_attr_add = document.createElement('img');
                el_attr_add.setAttribute("id", "el_choices_add");
           	el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_spinner')");
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_spinner')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_spinner')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("align", 'top');
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_spinner')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}
		
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td10.appendChild(el_label_size_label);
	edit_main_td10_1.appendChild(el_label_size);

edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	
	edit_main_td3.appendChild(el_spinner_width_label);
	edit_main_td3_1.appendChild(el_spinner_width_input);
	
	edit_main_td4.appendChild(el_spinner_min_value_label);
	edit_main_td4_1.appendChild(el_spinner_min_value_input);

    edit_main_td5.appendChild(el_spinner_max_value_label);	
	edit_main_td5_1.appendChild(el_spinner_max_value_input);
	
	edit_main_td6.appendChild(el_spinner_step_label);	
	edit_main_td6_1.appendChild(el_spinner_step_input);
	
	edit_main_td7.appendChild(el_style_label);
	edit_main_td7_1.appendChild(el_style_textarea);
	edit_main_td8.appendChild(el_required_label);
	edit_main_td8_1.appendChild(el_required);
	

	edit_main_td9.appendChild(el_attr_label);
	edit_main_td9.appendChild(el_attr_add);
	edit_main_td9.appendChild(br1);
	edit_main_td9.appendChild(el_attr_table);
	edit_main_td9.setAttribute("colspan", "2");
	
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr9.appendChild(edit_main_td9);
	
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
    edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr9);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_spinner');

	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_spinner");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required = document.createElement("input");
		adding_required.setAttribute("type", "hidden");
		adding_required.setAttribute("value", w_required);
		adding_required.setAttribute("name", i+"_requiredform_id_temp");
		adding_required.setAttribute("id", i+"_requiredform_id_temp");
		
	var adding_width= document.createElement("input");
		adding_width.setAttribute("type", "hidden");
		adding_width.setAttribute("value", w_field_width);
		adding_width.setAttribute("name", i+"_spinner_widthform_id_temp");	
		adding_width.setAttribute("id", i+"_spinner_widthform_id_temp");		
			
	var adding_min_value = document.createElement("input");
		adding_min_value.setAttribute("type", "hidden");
		adding_min_value.setAttribute("value", w_field_min_value);
		adding_min_value.setAttribute("id", i+"_min_valueform_id_temp");
		adding_min_value.setAttribute("name", i+"_min_valueform_id_temp");
			
	var adding_max_value = document.createElement("input");
		adding_max_value.setAttribute("type", "hidden");
		adding_max_value.setAttribute("value", w_field_max_value);
		adding_max_value.setAttribute("name", i+"_max_valueform_id_temp");	
		adding_max_value.setAttribute("id", i+"_max_valueform_id_temp");
			
	var adding_step = document.createElement("input");
		adding_step.setAttribute("type", "hidden");
		adding_step.setAttribute("value", w_field_step);
		adding_step.setAttribute("name", i+"_stepform_id_temp");	
		adding_step.setAttribute("id", i+"_stepform_id_temp");
	
   var adding_spinner_input = document.createElement("input");
		adding_spinner_input.setAttribute("type", "");
		adding_spinner_input.style.cssText="width:"+w_field_width+"px"; 
		adding_spinner_input.setAttribute("name", i+"_elementform_id_temp");	
		adding_spinner_input.setAttribute("id", i+"_elementform_id_temp");
		adding_spinner_input.setAttribute("value", w_field_value);
		adding_spinner_input.setAttribute("onClick", "check_isnum_or_minus(event)");
		adding_spinner_input.setAttribute("onKeyPress", "return check_isnum_or_minus(event)");
			
	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
				
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width=w_field_label_size+"px";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");
 	
	var br1 = document.createElement('br');

	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
	
	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
		if(w_required=="yes")
			required.innerHTML = " *";
	var main_td  = document.getElementById('show_table');
  
  
	div_label.appendChild(label);
	div_label.appendChild(required);
	div_element.appendChild(adding_type);

	div_element.appendChild(adding_required);
	div_element.appendChild(adding_width);
	div_element.appendChild(adding_min_value);
	div_element.appendChild(adding_max_value);
	div_element.appendChild(adding_step);
	div_element.appendChild(adding_spinner_input);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
  
	div.appendChild(div_field);
	div.appendChild(br1);
	main_td.appendChild(div);
	if(w_field_label_pos=="top")
		label_top(i);
	
	change_class(w_class, i);
	refresh_attr(i, 'type_spinner');

	jQuery( "#"+i+"_elementform_id_temp" ).spinner();
	var spinner = jQuery( "#"+i+"_elementform_id_temp" ).spinner();
		spinner.spinner( "value", w_field_value );
	jQuery( "#"+i+"_elementform_id_temp" ).spinner({ min: w_field_min_value});    
	jQuery( "#"+i+"_elementform_id_temp" ).spinner({ max: w_field_max_value});
	jQuery( "#"+i+"_elementform_id_temp" ).spinner({ step: w_field_step});
}

function change_spinner_width(a,id,form_id)
{
	document.getElementById( id+"_elementform_id_temp" ).style.cssText="width:"+a+"px";
	document.getElementById( id+"_spinner_widthform_id_temp" ).value=a;
}

function change_spinner_max_value(a,id,form_id)
{
	jQuery( "#"+id+"_elementform_id_temp" ).spinner({ max: a});
	document.getElementById( id+"_max_valueform_id_temp" ).value=a;
}

function change_spinner_min_value(a,id,form_id)
{
	jQuery( "#"+id+"_elementform_id_temp" ).spinner({ min: a});
	document.getElementById( id+"_min_valueform_id_temp" ).value=a;
}	

function change_spinner_step(a,id,form_id)
{
	jQuery( "#"+id+"_elementform_id_temp" ).spinner({ step: a});
	document.getElementById( id+"_stepform_id_temp" ).value=a;
}

function type_slider(i, w_field_label, w_field_label_size, w_field_label_pos,  w_field_width, w_field_min_value, w_field_max_value, w_field_value, w_required, w_class, w_attr_name, w_attr_value){

	document.getElementById("element_type").value="type_slider";
	delete_last_child();
	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");

	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
  	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
		  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
		
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
		
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");
				
	var el_slider_size_label = document.createElement('label');
		el_slider_size_label.setAttribute("class", "fm-field-label");
		el_slider_size_label.setAttribute("for", "edit_for_slider_width");
		el_slider_size_label.innerHTML = "Width";			
				
    var el_slider_size_input = document.createElement('input');
		el_slider_size_input.setAttribute("type", "text");		
		el_slider_size_input.setAttribute("id", "edit_for_slider_width");		
		el_slider_size_input.setAttribute("value", w_field_width);	
		el_slider_size_input.setAttribute("onKeyPress", "return check_isnum(event)");	
		el_slider_size_input.setAttribute("onKeyUp", "change_slider_width(this.value,"+i+",'form_id_temp')");
	
	var el_slider_min_value_label = document.createElement('label');
		el_slider_min_value_label.setAttribute("class", "fm-field-label");
		el_slider_min_value_label.setAttribute("for", "edit_for_slider_min_value");
		el_slider_min_value_label.innerHTML = "Min Value ";
	
	var el_slider_min_value_input = document.createElement('input');
		el_slider_min_value_input.setAttribute("type", "text");		
		el_slider_min_value_input.setAttribute("id", "edit_for_slider_min_value");		
		el_slider_min_value_input.setAttribute("value", w_field_min_value);
		el_slider_min_value_input.setAttribute("onKeyPress", "return check_isnum(event)");	
		el_slider_min_value_input.setAttribute("onKeyUp", "change_slider_min_or_max_value(this.value,"+i+",'form_id_temp','min')");
		el_slider_min_value_input.setAttribute("onChange", "change_slider_min_value(this.value,"+i+",'form_id_temp')");
           
	var el_slider_max_value_label = document.createElement('label');
		el_slider_max_value_label.setAttribute("class", "fm-field-label");
		el_slider_max_value_label.setAttribute("for", "edit_for_slider_max_value");		
		el_slider_max_value_label.innerHTML = "Max Value ";
	
	var el_slider_max_value_input = document.createElement('input');
		el_slider_max_value_input.setAttribute("type", "text");		
		el_slider_max_value_input.setAttribute("id", "edit_for_slider_max_value");		
		el_slider_max_value_input.setAttribute("value", w_field_max_value);
		el_slider_max_value_input.setAttribute("onKeyPress", "return check_isnum(event)");	
		el_slider_max_value_input.setAttribute("onKeyUp", "change_slider_min_or_max_value(this.value,"+i+",'form_id_temp','max')");
		el_slider_max_value_input.setAttribute("onChange", "change_slider_max_value(this.value,"+i+",'form_id_temp')");
           
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "element_style");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "element_style");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_required_label = document.createElement('label');
	        el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_send");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_send");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("value", "yes");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required=="yes")
			el_required.setAttribute("checked", "checked");
	
	var el_attr_label = document.createElement('label');
	                el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.setAttribute("for", "el_choices_add");
			el_attr_label.innerHTML = "Additional Attributes";
			
	var el_attr_add = document.createElement('img');
                el_attr_add.setAttribute("id", "el_choices_add");
           	el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_slider')");
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_slider')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_slider')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("align", 'top');
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_slider')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}
		
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	edit_main_td9.appendChild(el_label_size_label);
	edit_main_td9_1.appendChild(el_label_size);

edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_slider_size_label);	
	edit_main_td3_1.appendChild(el_slider_size_input);
	
	edit_main_td4.appendChild(el_slider_min_value_label);
	edit_main_td4_1.appendChild(el_slider_min_value_input);
	
	edit_main_td5.appendChild(el_slider_max_value_label);
	edit_main_td5_1.appendChild(el_slider_max_value_input);
	
	edit_main_td6.appendChild(el_style_label);
	edit_main_td6_1.appendChild(el_style_textarea);
	edit_main_td7.appendChild(el_required_label);
	edit_main_td7_1.appendChild(el_required);
	
	
	
	edit_main_td8.appendChild(el_attr_label);
	edit_main_td8.appendChild(el_attr_add);
	edit_main_td8.appendChild(br1);
	edit_main_td8.appendChild(el_attr_table);
	edit_main_td8.setAttribute("colspan", "2");
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_tr8.appendChild(edit_main_td8);
	
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
    edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr8);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_slider');

	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_slider");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required = document.createElement("input");
		adding_required.setAttribute("type", "hidden");
		adding_required.setAttribute("value", w_required);
		adding_required.setAttribute("name", i+"_requiredform_id_temp");
		adding_required.setAttribute("id", i+"_requiredform_id_temp");
		
	var adding_slider_min_value = document.createElement("input");
		adding_slider_min_value.setAttribute("type", "hidden");
		adding_slider_min_value.setAttribute("value", w_field_min_value);
		adding_slider_min_value.setAttribute("id", i+"_slider_min_valueform_id_temp");
		adding_slider_min_value.setAttribute("name", i+"_slider_min_valueform_id_temp");		
			
	var adding_slider_max_value = document.createElement("input");
		adding_slider_max_value.setAttribute("type", "hidden");
		adding_slider_max_value.setAttribute("value", w_field_max_value);
		adding_slider_max_value.setAttribute("id", i+"_slider_max_valueform_id_temp");
		adding_slider_max_value.setAttribute("name", i+"_slider_max_valueform_id_temp");
			
	var adding_slider_value = document.createElement("input");
		adding_slider_value.setAttribute("type", "hidden");
		adding_slider_value.setAttribute("value", w_field_value);
		adding_slider_value.setAttribute("id", i+"_slider_valueform_id_temp");
		adding_slider_value.setAttribute("name", i+"_slider_valueform_id_temp");

	var adding_slider_width = document.createElement("input");
		adding_slider_width.setAttribute("type", "hidden");
		adding_slider_width.setAttribute("value", w_field_width);
		adding_slider_width.setAttribute("name", i+"_slider_widthform_id_temp");	
		adding_slider_width.setAttribute("id", i+"_slider_widthform_id_temp");
			
    var adding_slider_div = document.createElement("div");
		adding_slider_div.style.cssText="width:"+w_field_width+"px"; 
		adding_slider_div.setAttribute("name", i+"_elementform_id_temp");	
		adding_slider_div.setAttribute("id", i+"_elementform_id_temp");
	
	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
				
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.cssText = "display:table-cell; vertical-align:top; width:"+w_field_label_size+"px;";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");
		
	var slider_table = document.createElement('div');
		slider_table.setAttribute("id", i+"_slider_tableform_id_temp");	
		
	var slider_tr1 = document.createElement('div');	
	var slider_tr2 = document.createElement('div');	

	var slider_td1 = document.createElement('div');
		slider_td1.setAttribute("id", i+"_slider_td1form_id_temp");

	var slider_td2 = document.createElement('div');
		slider_td2.setAttribute("align", 'left');
		slider_td2.setAttribute("id", i+"_slider_td2form_id_temp");
		slider_td2.style.cssText = "display:inline-table; width:33.3%; text-align:left;";
			
	var slider_td3 = document.createElement('div');
		slider_td3.setAttribute("align", 'right');
		slider_td3.setAttribute("id", i+"_slider_td3form_id_temp");
		slider_td3.style.cssText = "display:inline-table; width:33.3%; text-align:center;";
			
	var slider_td4 = document.createElement('div');
		slider_td4.setAttribute("align", 'right');
		slider_td4.setAttribute("id", i+"_slider_td4form_id_temp");		
		slider_td4.style.cssText = "display:inline-table; width:33.3%; text-align:right; ";
		
	var br1 = document.createElement('br');
	
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
	
	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
		if(w_required=="yes")
			required.innerHTML = " *";
	var main_td  = document.getElementById('show_table');
      
	div_label.appendChild(label);
	div_label.appendChild(required);
	div_element.appendChild(adding_type);
	div_element.appendChild(adding_required);
	div_element.appendChild(adding_slider_width);
	div_element.appendChild(adding_slider_min_value);
	div_element.appendChild(adding_slider_max_value);
	div_element.appendChild(adding_slider_value);

	var slider_min = document.createElement('span');
		slider_min.setAttribute("id", i+"_element_minform_id_temp");
		slider_min.innerHTML = w_field_min_value;
		slider_min.setAttribute("class", "label");
		
	var slider_max = document.createElement('span');
		slider_max.setAttribute("id", i+"_element_maxform_id_temp");
		slider_max.innerHTML = w_field_max_value;
		slider_max.setAttribute("class", "label");

	var slider_value = document.createElement('span');
		slider_value.setAttribute("id", i+"_element_valueform_id_temp");
		slider_value.innerHTML = w_field_value;
		slider_value.setAttribute("class", "label");		
		
	slider_td1.appendChild(adding_slider_div);
	slider_tr1.appendChild(slider_td1);
	slider_table.appendChild(slider_tr1);

	slider_td2.appendChild(slider_min);
	slider_tr2.appendChild(slider_td2);
	slider_table.appendChild(slider_tr2);

	slider_td3.appendChild(slider_value);
	slider_tr2.appendChild(slider_td3);
	slider_table.appendChild(slider_tr2);

	slider_td4.appendChild(slider_max);
	slider_tr2.appendChild(slider_td4);
	slider_table.appendChild(slider_tr2);

	div_element.appendChild(slider_table);
	
	
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
  
	div.appendChild(div_field);
	div.appendChild(br1);
	main_td.appendChild(div);
	if(w_field_label_pos=="top")
		label_top(i);
	change_class(w_class, i);
	refresh_attr(i, 'type_slider');
	jQuery("#"+i+"_elementform_id_temp")[0].slide = null;

	jQuery(function() {
		jQuery( "#"+i+"_elementform_id_temp").slider({
			range: "min",
			value: eval(w_field_value),
			min: eval(w_field_min_value),
			max: eval(w_field_max_value),
			slide: function( event, ui ) {
				document.getElementById( i+"_element_valueform_id_temp" ).innerHTML = "" + ui.value ;
				document.getElementById( i+"_slider_valueform_id_temp" ).value = "" + ui.value; 	
			}
		});
	});
}


function change_slider_min_or_max_value(a,id,form_id, min_or_max)
{ 
	document.getElementById( id+"_element_"+min_or_max+"form_id_temp" ).innerHTML=a;
}


function change_slider_width(a,id,form_id)
{
	document.getElementById( id+"_elementform_id_temp" ).style.cssText="width:"+a+"px";
	document.getElementById( id+"_slider_widthform_id_temp" ).value=a;
}

function change_slider_min_value(a,id,form_id)
{
	document.getElementById(id+"_slider_min_valueform_id_temp" ).value=a;

	if(eval(a)> document.getElementById(id+"_element_valueform_id_temp" ).innerHTML)
	{

		document.getElementById(id+"_element_valueform_id_temp" ).innerHTML = a;
		document.getElementById(id+"_slider_valueform_id_temp" ).value = a;
			
		jQuery( "#"+id+"_elementform_id_temp").slider({
				min: eval(a),
			slide: function( event, ui ) {
			document.getElementById(id+"_element_valueform_id_temp").innerHTML = "" + ui.value ;
			document.getElementById(id+"_slider_valueform_id_temp" ).value = "" + ui.value;
			}
		});

	}
	else
	{
		jQuery( "#"+id+"_elementform_id_temp").slider({
			min: eval(a),
			slide: function( event, ui ) {
			document.getElementById(id+"_element_valueform_id_temp" ).innerHTML = "" + ui.value ;
			document.getElementById(id+"_slider_valueform_id_temp" ).value = "" + ui.value;	
			}
		});
	}

}

function change_slider_max_value(a,id,form_id)
{
	document.getElementById(id+"_slider_max_valueform_id_temp" ).value=a;
	if(eval(a) < parseInt(document.getElementById(id+"_slider_valueform_id_temp" ).value)) {
		document.getElementById(id+"_element_valueform_id_temp" ).innerHTML = a;
		document.getElementById(id+"_slider_valueform_id_temp" ).value = a;
			
		jQuery( "#"+id+"_elementform_id_temp").slider({
			min: eval(document.getElementById(id+"_slider_min_valueform_id_temp" ).value),
			max: eval(a),
			value: eval(document.getElementById(id+"_slider_valueform_id_temp" ).value),
			slide: function( event, ui ) {
			document.getElementById(id+"_element_valueform_id_temp" ).innerHTML = "" + ui.value ;
			document.getElementById(id+"_slider_valueform_id_temp" ).value = "" + ui.value;	
			}
		});
	}
	else {
		jQuery( "#"+id+"_elementform_id_temp").slider({
			min: eval(document.getElementById(id+"_slider_min_valueform_id_temp" ).value),
			max: eval(a),
			value: eval(document.getElementById(id+"_slider_valueform_id_temp" ).value),
			slide: function( event, ui ) {
				document.getElementById(id+"_element_valueform_id_temp" ).innerHTML = "" + ui.value ;
				document.getElementById(id+"_slider_valueform_id_temp" ).value = "" + ui.value;	
			}
		});
	}
}

function type_range(i, w_field_label, w_field_label_size, w_field_label_pos, w_field_range_width, w_field_range_step, w_field_value1, w_field_value2, w_mini_labels, w_required, w_class, w_attr_name, w_attr_value){

	document.getElementById("element_type").value="type_range";
	delete_last_child();	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
  	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
    var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10  = document.createElement('tr');

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');

	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');  
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');	 	
	var edit_main_td8 = document.createElement('td');
    var edit_main_td8_1 = document.createElement('td');	 
    var edit_main_td9 = document.createElement('td');
	var edit_main_td10 = document.createElement('td');
    var edit_main_td10_1 = document.createElement('td');	 
	
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;

	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");	
		
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");
		
	var el_range_width_label = document.createElement('label');
		el_range_width_label.setAttribute("class", "fm-field-label");
	    el_range_width_label.setAttribute("for", "edit_for_spinner_width");
		el_range_width_label.innerHTML = "Width ";
	
	var el_range_width_input = document.createElement('input');
		el_range_width_input.setAttribute("type", "text");		
		el_range_width_input.setAttribute("id", "edit_for_spinner_width");		
		el_range_width_input.setAttribute("value", w_field_range_width);	
		el_range_width_input.setAttribute("onKeyPress", "return check_isnum(event)");	
		el_range_width_input.setAttribute("onKeyUp", "change_range_width(this.value,"+i+",'form_id_temp')");			
				
	var el_range_step_label = document.createElement('label');
	    el_range_step_label.setAttribute("class", "fm-field-label");
	    el_range_step_label.setAttribute("for", "edit_for_spinner_step");
		el_range_step_label.innerHTML = "Step";
		
	var el_range_step_input = document.createElement('input');
		el_range_step_input.setAttribute("type", "text");		
		el_range_step_input.setAttribute("id", "edit_for_spinner_step");		
		el_range_step_input.setAttribute("value", w_field_range_step);
		el_range_step_input.setAttribute("onKeyPress", "return check_isnum_or_minus(event)");
		el_range_step_input.setAttribute("onChange", "change_range_step(this.value,"+i+",'form_id_temp')");
    
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "element_style");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "element_style");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_send");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_send");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("value", "yes");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required=="yes")
			el_required.setAttribute("checked", "checked");
	
	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.setAttribute("for", "el_choices_add");
		el_attr_label.innerHTML = "Additional Attributes";
			
	var el_attr_add = document.createElement('img');
		el_attr_add.setAttribute("id", "el_choices_add");
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_range')");
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
				el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_range')");
			
		var el_attr_value = document.createElement('input');
	
			el_attr_value.setAttribute("type", "text");
	
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_range')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("align", 'top');
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_range')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}
		
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);

	edit_main_td10.appendChild(el_label_size_label);
	edit_main_td10_1.appendChild(el_label_size);
edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	
	edit_main_td3.appendChild(el_range_width_label);
	edit_main_td3_1.appendChild(el_range_width_input);
	
	edit_main_td4.appendChild(el_range_step_label);	
	edit_main_td4_1.appendChild(el_range_step_input);
	
	edit_main_td5.appendChild(el_style_label);
	edit_main_td5_1.appendChild(el_style_textarea);
	edit_main_td6.appendChild(el_required_label);
	edit_main_td6_1.appendChild(el_required);
	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br1);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");
	
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	

	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
    edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr7);
	
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_range');
	
	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_range");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required = document.createElement("input");
		adding_required.setAttribute("type", "hidden");
		adding_required.setAttribute("value", w_required);
		adding_required.setAttribute("name", i+"_requiredform_id_temp");
		adding_required.setAttribute("id", i+"_requiredform_id_temp");
		
	var adding_width= document.createElement("input");
		adding_width.setAttribute("type", "hidden");
		adding_width.setAttribute("value", w_field_range_width);
		adding_width.setAttribute("name", i+"_range_widthform_id_temp");	
		adding_width.setAttribute("id", i+"_range_widthform_id_temp");		
			
	var adding_step = document.createElement("input");
		adding_step.setAttribute("type", "hidden");
		adding_step.setAttribute("value", w_field_range_step);
		adding_step.setAttribute("name", i+"_range_stepform_id_temp");	
		adding_step.setAttribute("id", i+"_range_stepform_id_temp");

    var adding_range_input_from = document.createElement("input");
		adding_range_input_from.setAttribute("type", "");
		adding_range_input_from.setAttribute("value", w_field_value1);
		adding_range_input_from.style.cssText="width:"+w_field_range_width+"px"; 
		adding_range_input_from.setAttribute("name", i+"_elementform_id_temp0");	
		adding_range_input_from.setAttribute("id", i+"_elementform_id_temp0");
		adding_range_input_from.setAttribute("onKeyPress", "return check_isnum_or_minus(event)");
			
    var adding_range_input_to = document.createElement("input");
		adding_range_input_to.setAttribute("type", "");
		adding_range_input_to.setAttribute("value", w_field_value2);
		adding_range_input_to.style.cssText="width:"+w_field_range_width+"px"; 
		adding_range_input_to.setAttribute("name", i+"_elementform_id_temp1");	
		adding_range_input_to.setAttribute("id", i+"_elementform_id_temp1");
		adding_range_input_to.setAttribute("onKeyPress", "return check_isnum_or_minus(event)");
			
	var adding_range_label_from = document.createElement("label");
		adding_range_label_from.setAttribute("class", "mini_label");
		adding_range_label_from.setAttribute("id", i+"_mini_label_from");
		adding_range_label_from.innerHTML=w_mini_labels[0];

	var adding_range_label_to = document.createElement("label");
		adding_range_label_to.setAttribute("class", "mini_label");	
		adding_range_label_to.setAttribute("id", i+"_mini_label_to");
		adding_range_label_to.innerHTML=w_mini_labels[1];
		
	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
	
	edit_labels = document.createTextNode("The labels of the fields are editable. Please, click the label to edit.");
	var div_for_editable_labels = document.createElement('div');
		div_for_editable_labels.setAttribute("class", "fm-editable-label");

	div_for_editable_labels.appendChild(edit_labels);  

	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width=w_field_label_size+"px";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		

	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");

	var table_little = document.createElement('div');
		table_little.setAttribute("id", i+"_elemet_table_littleform_id_temp");
		table_little.style.display="table";
		
	var tr1 = document.createElement('div');
		tr1.style.display="table-row";
	var tr2 = document.createElement('div');
		tr2.style.display="table-row";
		
	var td1_1 = document.createElement('div');
		td1_1.setAttribute("valign", 'middle');
		td1_1.setAttribute("align", 'left');
		td1_1.style.display="table-cell";
	  
		
	var td1_2 = document.createElement('div');
		td1_2.setAttribute("valign", 'middle');
		td1_2.setAttribute("align", 'left');
		td1_2.style.cssText="display:table-cell; padding-left:4px;";
	   
		
	var td2_1 = document.createElement('div');
		td2_1.setAttribute("valign", 'top');
		td2_1.setAttribute("align", 'left');
		td2_1.style.display="table-cell";
	   
	var td2_2 = document.createElement('div');
		td2_2.setAttribute("valign", 'top');
		td2_2.setAttribute("align", 'left');
		td2_2.style.display="table-cell";
		
	var br1 = document.createElement('br');
	
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
	
	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
	if(w_required=="yes")
		required.innerHTML = " *";
	var main_td  = document.getElementById('show_table');
  
	div_label.appendChild(label);
	div_label.appendChild(required);
		
	div_element.appendChild(adding_type);
	div_element.appendChild(adding_required);
	div_element.appendChild(adding_width);
	div_element.appendChild(adding_step);
	
	td1_1.appendChild(adding_range_input_from);
	td1_2.appendChild(adding_range_input_to);
	td2_1.appendChild(adding_range_label_from);
	td2_2.appendChild(adding_range_label_to);

	tr1.appendChild(td1_1);
	tr1.appendChild(td1_2);
	tr2.appendChild(td2_1);
	tr2.appendChild(td2_2);
	
	table_little.appendChild(tr1);
	table_little.appendChild(tr2);
	
	div_element.appendChild(table_little);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
  
	div.appendChild(div_field);
	div.appendChild(br1);
	div.appendChild(div_for_editable_labels);

    main_td.appendChild(div);
	if(w_field_label_pos=="top")
		label_top(i);
	change_class(w_class, i);
	refresh_attr(i, 'type_range');

	jQuery( "#"+i+"_elementform_id_temp0" ).spinner();
	var spinner1 = jQuery( "#"+i+"_elementform_id_temp0" ).spinner();
		spinner1.spinner( "value", w_field_value1 );
	jQuery( "#"+i+"_elementform_id_temp0" ).spinner({ step: w_field_range_step});

	jQuery( "#"+i+"_elementform_id_temp1" ).spinner();
	var spinner2 = jQuery( "#"+i+"_elementform_id_temp1" ).spinner();
		spinner2.spinner( "value", w_field_value2 );
	jQuery( "#"+i+"_elementform_id_temp1" ).spinner({ step: w_field_range_step});

	jQuery(document).ready(function() {	
		jQuery("label#"+i+"_mini_label_from").click(function() {		
			if (jQuery(this).children('input').length == 0) {				
				var form = "<input type='text' class='form' size='8' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
				jQuery(this).html(form);							
				jQuery("input.form").focus();			
				jQuery("input.form").blur(function() {	
					var value = jQuery(this).val();			
					jQuery("#"+i+"_mini_label_from").text(value);		
				});	
			}	
		});		

		jQuery("label#"+i+"_mini_label_to").click(function() {	
			if (jQuery(this).children('input').length == 0) {		
				var to = "<input type='text' class='to' size='8' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
				jQuery(this).html(to);			
				jQuery("input.to").focus();					
				jQuery("input.to").blur(function() {			
					var value = jQuery(this).val();			
					jQuery("#"+i+"_mini_label_to").text(value);	
				});	
			}	
		});
	});	
}


function change_range_width(a,id,form_id)
{
	document.getElementById( id+"_elementform_id_temp0" ).style.cssText="width:"+a+"px";
	document.getElementById( id+"_elementform_id_temp1" ).style.cssText="width:"+a+"px";
	document.getElementById( id+"_range_widthform_id_temp" ).value=a;
}

function change_range_step(a,id,form_id)
{
	jQuery( "#"+id+"_elementform_id_temp0" ).spinner({ step: a});
	jQuery( "#"+id+"_elementform_id_temp1" ).spinner({ step: a});
	
	document.getElementById( id+"_range_stepform_id_temp" ).value=a;
}


function type_grading(i, w_field_label, w_field_label_size, w_field_label_pos, w_items, w_total, w_required, w_class, w_attr_name, w_attr_value) {

	document.getElementById("element_type").value="type_grading";
	delete_last_child();
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");

	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
  	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
    var edit_main_tr7  = document.createElement('tr');	
	var edit_main_tr8  = document.createElement('tr');

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');	
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
		edit_main_td4.style.cssText = "vertical-align:top" ; 	
		edit_main_td4.setAttribute("id", "items");
		
	var edit_main_td4_1 = document.createElement('td');
		edit_main_td4_1.style.cssText = "vertical-align:top";
     
	var edit_main_td5 = document.createElement('td');
		edit_main_td5.setAttribute("id", "columns");
	var edit_main_td5_1 = document.createElement('td');
				
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	
	var edit_main_td7 = document.createElement('td');
		
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
		  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
		
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");				
		
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");
	
	var el_total_label = document.createElement('label');
		el_total_label.setAttribute("class", "fm-field-label");
		el_total_label.setAttribute("for", "element_total");
		el_total_label.innerHTML = "Total";
	
	var el_total_input = document.createElement('input');
		el_total_input.setAttribute("id", "element_total");
		el_total_input.setAttribute("type", "text");
		el_total_input.setAttribute("value", w_total);
		el_total_input.setAttribute("onKeyPress", "return check_isnum_or_minus(event)");
		el_total_input.setAttribute("onKeyUp", "change_total(this.value,'"+i+"')");
	
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "element_style");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "element_style");
		el_style_textarea.setAttribute("type", "text");
 		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");
				
	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_send");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_send");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("value", "yes");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required=="yes")
			el_required.setAttribute("checked", "checked");
		
	var el_attr_label = document.createElement('label');
	                el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.setAttribute("for", "el_choices_add");
			el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
                el_attr_add.setAttribute("id", "el_choices_add");
           	el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_grading')");
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_grading')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");	
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_grading')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("align", 'top');
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_grading')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}

	var el_items_label = document.createElement('label');
		el_items_label.setAttribute("class", "fm-field-label");
		el_items_label.setAttribute("for", "el_items_add");
		el_items_label.innerHTML = "Items ";
	var el_items_add = document.createElement('img');
		el_items_add.setAttribute("id", "el_items_add");
		el_items_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_items_add.style.cssText = 'cursor:pointer;';
		el_items_add.setAttribute("title", 'add');
		el_items_add.setAttribute("onClick", "add_grading_items("+i+")");
				
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	edit_main_td8.appendChild(el_label_size_label);
	edit_main_td8_1.appendChild(el_label_size);
	
	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);

    edit_main_td3.appendChild(el_total_label);
	edit_main_td3_1.appendChild(el_total_input);
		
	edit_main_td4.appendChild(el_items_label);
	edit_main_td4_1.appendChild(el_items_add);
	
	edit_main_td5.appendChild(el_required_label);
	edit_main_td5_1.appendChild(el_required);

	edit_main_td6.appendChild(el_style_label);
	edit_main_td6_1.appendChild(el_style_textarea);
	
	
	
	edit_main_td7.appendChild(el_attr_label);
	edit_main_td7.appendChild(el_attr_add);
	edit_main_td7.appendChild(br6);
	edit_main_td7.appendChild(el_attr_table);
	edit_main_td7.setAttribute("colspan", "2");
	
	n=w_items.length;
	for(k=0; k<n; k++)
	{	
		var br = document.createElement('br');
			br.setAttribute("id", "britems"+k);
			
		var el_items = document.createElement('input');
			el_items.setAttribute("id", "el_items"+k);
			el_items.setAttribute("type", "text");
			el_items.setAttribute("class", "fm-field-choice");
			el_items.setAttribute("value", w_items[k]);
			el_items.setAttribute("onKeyUp", "change_label('"+i+"_label_elementform_id_temp"+k+"', this.value); change_in_value('"+i+"_label_elementform_id_temp"+k+"', this.value)");
	
		var el_items_remove = document.createElement('img');
			el_items_remove.setAttribute("id", "el_items"+k+"_remove");
			el_items_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');		
			el_items_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_items_remove.setAttribute("align", 'top');
			el_items_remove.setAttribute("onClick", "remove_grading_items("+k+","+i+")");
			
		edit_main_td4.appendChild(br);
		edit_main_td4.appendChild(el_items);
		edit_main_td4.appendChild(el_items_remove);
	}

	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
    edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr7);

	
	edit_div.appendChild(edit_main_table);
	t.appendChild(edit_div);
	
	element='input';	type='grading'; 
	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_grading");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required = document.createElement("input");
            adding_required.setAttribute("type", "hidden");
            adding_required.setAttribute("value", w_required);
            adding_required.setAttribute("name", i+"_requiredform_id_temp");
            adding_required.setAttribute("id", i+"_requiredform_id_temp");
			
 	var adding_total = document.createElement("input");
            adding_total.setAttribute("type", "hidden");
            adding_total.setAttribute("value", w_total);
            adding_total.setAttribute("name", i+"_grading_totalform_id_temp");
            adding_total.setAttribute("id", i+"_grading_totalform_id_temp");
	    
	var div = document.createElement('div');
       	div.setAttribute("id", "main_div");

	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.cssText = "display:table-cell; vertical-align:top; width:"+w_field_label_size+"px;";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");
		
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');

	var div_grading = document.createElement('div');
	    div_grading.setAttribute("id", i+"_elementform_id_temp");

	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");

	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
	if(w_required=="yes")
			required.innerHTML = " *";
	
	var main_td  = document.getElementById('show_table');

	div_label.appendChild(label);
	div_label.appendChild(required);
	div_element.appendChild(adding_type);
	div_element.appendChild(adding_required);
	div_element.appendChild(adding_total);
	div_element.appendChild(div_grading);
  
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
  
	div.appendChild(div_field);
	div.appendChild(br3);
	main_td.appendChild(div);

	if(w_field_label_pos=="top")
		label_top(i);
				
	change_class(w_class, i);
	refresh_attr(i, 'type_grading');
	refresh_grading_items(i);
	add_id_and_name(i, 'type_grading');
}

function change_total(value,id)
{
	document.getElementById(id+"_grading_totalform_id_temp").value = value;
	document.getElementById(id+"_total_elementform_id_temp").innerHTML = value;
}

function type_matrix(i, w_field_label, w_field_label_size, w_field_label_pos, w_field_input_type, w_rows, w_columns, w_required, w_class, w_attr_name, w_attr_value, w_textbox_size) {

	document.getElementById("element_type").value="type_matrix";
	delete_last_child();
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');	
	var edit_main_tr2  = document.createElement('tr');	
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10  = document.createElement('tr');
		edit_main_tr10.setAttribute("id", "el_textbox");
	if(w_field_input_type!="text")
        edit_main_tr10.style.cssText = "display:none;";		

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');	
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');	
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
		edit_main_td4.setAttribute("id", "rows");
		
	var edit_main_td4_1 = document.createElement('td');
		edit_main_td4_1.style.cssText = "vertical-align:top";
     
	var edit_main_td5 = document.createElement('td');
		edit_main_td5.setAttribute("id", "columns");
	var edit_main_td5_1 = document.createElement('td');
		edit_main_td5_1.style.cssText = "vertical-align:top ";
				
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');	
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');	  
	var edit_main_td8 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');

	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');

	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
				
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");					
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_input_type_label = document.createElement('label');
		el_input_type_label.setAttribute("class", "fm-field-label");
		el_input_type_label.setAttribute("for", "edit_for_select_input_type");
		el_input_type_label.innerHTML = "Input Type";
	
	var el_input_type = document.createElement('select');
		el_input_type.setAttribute("id", "edit_for_select_input_type");
		el_input_type.setAttribute("name", "edit_for_select_input_type");
		el_input_type.setAttribute("onchange", "change_input_type("+i+",this.value); refresh_matrix("+i+")");
		el_input_type.style.cssText = 'width:200px';
                
	var el_input_type1 = document.createElement('option');
		el_input_type1.setAttribute("id", "edit_for_input_type_radio");
		el_input_type1.setAttribute("value", "radio");
	Radio_Button = document.createTextNode("Radio Button");

    var el_input_type2 = document.createElement('option');
		el_input_type2.setAttribute("id", "edit_for_input_type_checkbox");
		el_input_type2.setAttribute("value", "checkbox");
	Check_Box = document.createTextNode("Check Box");

    var el_input_type3 = document.createElement('option');
		el_input_type3.setAttribute("id", "edit_for_input_type_text");
		el_input_type3.setAttribute("value", "text");
	Text_Box= document.createTextNode("Text Box");

    var el_input_type4 = document.createElement('option');
		el_input_type4.setAttribute("id", "edit_for_input_type_select");
		el_input_type4.setAttribute("value", "select");				
	Drop_Down = document.createTextNode("Drop Down");              
	
	var el_textbox_size_label = document.createElement('label');
	    el_textbox_size_label.setAttribute("class", "fm-field-label");
	    el_textbox_size_label.setAttribute("for", "edit_for_textbox_size_label");
		el_textbox_size_label.innerHTML = "Text Box size(px) ";
		
	var el_textbox_size = document.createElement('input');
	    el_textbox_size.setAttribute("id", "edit_for_label_textbox_size");
	    el_textbox_size.setAttribute("type", "text");
	    el_textbox_size.setAttribute("value", w_textbox_size);
		el_textbox_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_textbox_size.setAttribute("onKeyUp", "refresh_matrix("+i+")");

	if(w_field_input_type=="radio")
		el_input_type1.setAttribute("selected", "selected");
	else
	{
	if(w_field_input_type=="checkbox")
		el_input_type2.setAttribute("selected", "selected");
		else{
		   if(w_field_input_type=="text")
			el_input_type3.setAttribute("selected", "selected");
		else{
		if(w_field_input_type=="select")
			el_input_type4.setAttribute("selected", "selected");
		
		}
		}
	}
		
	var el_style_label = document.createElement('label');
	        el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "element_style");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "element_style");
		el_style_textarea.setAttribute("type", "text");
 		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_required_label = document.createElement('label');
	        el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_send");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_send");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("value", "yes");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
	if(w_required=="yes")
        el_required.setAttribute("checked", "checked");
		
	
	var el_attr_label = document.createElement('label');
	                el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.setAttribute("for", "el_choices_add");
			el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
                el_attr_add.setAttribute("id", "el_choices_add");
           	el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_matrix')");
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_matrix')");
			
		var el_attr_value = document.createElement('input');
	
			el_attr_value.setAttribute("type", "text");	
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_matrix')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("align", 'top');
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_matrix')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}

	var el_rows_label = document.createElement('label');
		el_rows_label.style.cssText ="color:#000; font-weight:bold; font-size: 13px";
		el_rows_label.innerHTML = "Rows ";
	var el_rows_add = document.createElement('img');
		el_rows_add.setAttribute("id", "el_rows_add");
		el_rows_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_rows_add.style.cssText = 'cursor:pointer;';
		el_rows_add.setAttribute("title", 'add');
		el_rows_add.setAttribute("onClick", "add_to_matrix('rows',  "+i+")");
				
	var el_columns_label = document.createElement('label');
		el_columns_label.style.cssText ="color:#000; font-weight:bold; font-size: 13px";
		el_columns_label.innerHTML = "Columns ";
	var el_columns_add = document.createElement('img');
		el_columns_add.setAttribute("id", "el_columns_add");
		el_columns_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_columns_add.style.cssText = 'cursor:pointer;';
		el_columns_add.setAttribute("title", 'add');
		el_columns_add.setAttribute("onClick", "add_to_matrix('columns',  "+i+")");			
	
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	edit_main_td9.appendChild(el_label_size_label);
	edit_main_td9_1.appendChild(el_label_size);
	

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
    edit_main_td3.appendChild(el_input_type_label);
	
	el_input_type1.appendChild(Radio_Button);
	el_input_type2.appendChild(Check_Box);
	el_input_type3.appendChild(Text_Box);
	el_input_type4.appendChild(Drop_Down);
	
	el_input_type.appendChild(el_input_type1);
	el_input_type.appendChild(el_input_type2);
	el_input_type.appendChild(el_input_type3);
	el_input_type.appendChild(el_input_type4);
	
	edit_main_td3_1.appendChild(el_input_type);
	
	edit_main_td10.appendChild(el_textbox_size_label);
	edit_main_td10_1.appendChild(el_textbox_size);
	
	edit_main_td4.appendChild(el_rows_label);
	edit_main_td4_1.appendChild(el_rows_add);
	
	edit_main_td5.appendChild(el_columns_label);
	edit_main_td5_1.appendChild(el_columns_add);
	
	edit_main_td6.appendChild(el_required_label);
	edit_main_td6_1.appendChild(el_required);
	

	edit_main_td7.appendChild(el_style_label);
	edit_main_td7_1.appendChild(el_style_textarea);
	
	
	
	edit_main_td8.appendChild(el_attr_label);
	edit_main_td8.appendChild(el_attr_add);
	edit_main_td8.appendChild(br6);
	edit_main_td8.appendChild(el_attr_table);
	edit_main_td8.setAttribute("colspan", "2");
	
	n=w_rows.length;
	for(k=1; k<n; k++)
	{	
		var br = document.createElement('br');
			br.setAttribute("id", "brrows"+k);
			
		var el_rows = document.createElement('input');
			el_rows.setAttribute("id", "el_rows"+k);
			el_rows.setAttribute("type", "text");
			el_rows.setAttribute("value", w_rows[k]);
			el_rows.setAttribute("class", "fm-field-choice");
			el_rows.setAttribute("onKeyUp", "change_label('"+i+"_label_elementform_id_temp"+k+"_0', this.value); change_in_value('"+i+"_label_elementform_id_temp"+k+"_0', this.value)");
	
		var el_rows_remove = document.createElement('img');
			el_rows_remove.setAttribute("id", "el_rows"+k+"_remove");
			el_rows_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');		
			el_rows_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_rows_remove.setAttribute("align", 'top');
			el_rows_remove.setAttribute("onClick", "remove_rowcols("+k+","+i+",'rows')");
			
		edit_main_td4.appendChild(br);
		edit_main_td4.appendChild(el_rows);
		edit_main_td4.appendChild(el_rows_remove);
	
	}
	
	m=w_columns.length;
	for(k=1; k<m; k++)
	{	
		var br = document.createElement('br');
			br.setAttribute("id", "brcolumns"+k);
			
		var el_columns = document.createElement('input');
			el_columns.setAttribute("id", "el_columns"+k);
			el_columns.setAttribute("type", "text");
			el_columns.setAttribute("value", w_columns[k]);
			el_columns.setAttribute("class", "fm-field-choice");
			el_columns.setAttribute("onKeyUp", "change_label('"+i+"_label_elementform_id_temp0_"+k+"', this.value); change_in_value('"+i+"_label_elementform_id_temp0_"+k+"', this.value)");
	
		var el_columns_remove = document.createElement('img');
			el_columns_remove.setAttribute("id", "el_columns"+k+"_remove");
			el_columns_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');		
			el_columns_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_columns_remove.setAttribute("align", 'top');
			el_columns_remove.setAttribute("onClick", "remove_rowcols("+k+","+i+",'columns')");
			
		edit_main_td5.appendChild(br);
		edit_main_td5.appendChild(el_columns);
		edit_main_td5.appendChild(el_columns_remove);
	}

	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
    edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr10.appendChild(edit_main_td10);
    edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);	
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_tr8.appendChild(edit_main_td8);
	
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr8);
	
	edit_div.appendChild(edit_main_table);
	t.appendChild(edit_div);
	element='input';	
	type='matrix'; 
	var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_matrix");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required = document.createElement("input");
            adding_required.setAttribute("type", "hidden");
            adding_required.setAttribute("value", w_required);
            adding_required.setAttribute("name", i+"_requiredform_id_temp");
            adding_required.setAttribute("id", i+"_requiredform_id_temp");
			
 	var adding_input_type = document.createElement("input");
            adding_input_type.setAttribute("type", "hidden");
            adding_input_type.setAttribute("value", w_field_input_type);
            adding_input_type.setAttribute("name", i+"_input_typeform_id_temp");
            adding_input_type.setAttribute("id", i+"_input_typeform_id_temp");
	
	var adding_textbox_size = document.createElement("input");
		adding_textbox_size.setAttribute("type", "hidden");
		adding_textbox_size.setAttribute("value", w_textbox_size);
		adding_textbox_size.setAttribute("name", i+"_textbox_sizeform_id_temp");
		adding_textbox_size.setAttribute("id", i+"_textbox_sizeform_id_temp");
		
   var div = document.createElement('div');
       	div.setAttribute("id", "main_div");
		
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width= w_field_label_size+'px';
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");

	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');

	var table_little_t = document.createElement('div');
	    table_little_t.setAttribute("id", i+"_elementform_id_temp");
		table_little_t.style.display="table";
		
	var table_little = document.createElement('div');
		table_little.setAttribute("id", i+"_table_little");
		table_little.style.display="table-row-group";
	
	table_little_t.appendChild(table_little);


	
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");

	
	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
		if(w_required=="yes")
			required.innerHTML = " *";
	
	var main_td  = document.getElementById('show_table');
	
		div_label.appendChild(label);
      	div_label.appendChild(required);
      	div_element.appendChild(adding_type);
      	div_element.appendChild(adding_required);
      	div_element.appendChild(adding_input_type);
		div_element.appendChild(adding_textbox_size);
      	div_element.appendChild(table_little_t);
      	div_field.appendChild(div_label);
      	div_field.appendChild(div_element);
      
      	div.appendChild(div_field);
       	div.appendChild(br3);
      	main_td.appendChild(div);
	
		
	if(w_field_label_pos=="top")
				label_top(i);
				
	
change_class(w_class, i);
refresh_attr(i, 'type_matrix');
refresh_matrix(i);
}

function change_input_type(id, value)
{
	document.getElementById(id+"_input_typeform_id_temp").value = value;
}


function type_country(i, w_field_label, w_field_label_size, w_countries, w_field_label_pos, w_size, w_required, w_class, w_attr_name, w_attr_value) {
	
	document.getElementById("element_type").value="type_country";
	delete_last_child();
	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
			
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
      				
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');	
		  
	var el_label_label = document.createElement('label');
	    el_label_label.setAttribute("class", "fm-field-label");
			        el_label_label.setAttribute("for", "edit_for_label");
			el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
                el_label_textarea.setAttribute("id", "edit_for_label");
                el_label_textarea.setAttribute("rows", "4");
                
                el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
				el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");
	
	var el_size_label = document.createElement('label');
		el_size_label.setAttribute("class", "fm-field-label");
	    el_size_label.setAttribute("for", "edit_for_input_size");
		el_size_label.innerHTML = "Field size(px) ";
		
	var el_size = document.createElement('input');
		el_size.setAttribute("id", "edit_for_input_size");
		el_size.setAttribute("type", "text");
		el_size.setAttribute("value", w_size);
		
		el_size.setAttribute("onKeyPress", "return check_isnum(event)");
		el_size.setAttribute("onKeyUp", "change_w_style('"+i+"_elementform_id_temp', this.value)");
		
	var el_edit_list = document.createElement('a');
	    el_edit_list.style.cssText ="color:#000; font-weight:bold; font-size: 11px; font-style:italic; cursor:pointer";
		el_edit_list.innerHTML = "Edit country list";
		el_edit_list.setAttribute("onclick", "tb_show('', 'admin-ajax.php?action=fromeditcountryinpopup&field_id="+i+"&width=530&height=370&TB_iframe=1')");
		el_edit_list.setAttribute("class","thickbox-preview");
		
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
	    el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
        el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
        
        el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");
		
	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
	    el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
                el_required.setAttribute("id", "el_required");
                el_required.setAttribute("type", "checkbox");
                
                el_required.setAttribute("onclick", "set_required('"+i+"_required')");
	if(w_required=="yes")
			
                el_required.setAttribute("checked", "checked");
	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");           
		el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
                
           	el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_text')");
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_text')");
			
		var el_attr_value = document.createElement('input');
	
			el_attr_value.setAttribute("type", "text");
	
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_text')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_text')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}

	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
		br3.setAttribute("id", "br1");
	var br4 = document.createElement('br');
		br4.setAttribute("id", "br2");
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td8.appendChild(el_label_size_label);
	edit_main_td8_1.appendChild(el_label_size);

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_size_label);
	edit_main_td3_1.appendChild(el_size);
	
	edit_main_td4.appendChild(el_style_label);
	edit_main_td4_1.appendChild(el_style_textarea);
	edit_main_td5.appendChild(el_required_label);
	edit_main_td5_1.appendChild(el_required);
	
	
	
	
	edit_main_td6.appendChild(el_attr_label);
	edit_main_td6.appendChild(el_attr_add);
	edit_main_td6.appendChild(br3);
	edit_main_td6.appendChild(el_attr_table);
	edit_main_td6.setAttribute("colspan", "2");
	
	edit_main_td7.appendChild(el_edit_list);
	edit_main_td7.setAttribute("colspan", "2");
	
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_text');
	
//show table
	var adding_type = document.createElement("input");
            adding_type.setAttribute("type", "hidden");
            adding_type.setAttribute("value", "type_country");
            adding_type.setAttribute("name", i+"_typeform_id_temp");
            adding_type.setAttribute("id", i+"_typeform_id_temp");
	var adding_required = document.createElement("input");
            adding_required.setAttribute("type", "hidden");
            adding_required.setAttribute("value", w_required);
            adding_required.setAttribute("name", i+"_requiredform_id_temp");
			
            adding_required.setAttribute("id", i+"_requiredform_id_temp");
			
     	var div = document.createElement('div');
      	    div.setAttribute("id", "main_div");
			
		var div_field = document.createElement('div');
           	div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
      	var div_label = document.createElement('div');
         	div_label.setAttribute("align", 'left');
         	div_label.style.display="table-cell";
			div_label.style.width=w_field_label_size+"px";
           	div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
      	var div_element = document.createElement('div');
         	div_element.setAttribute("align", 'left');
          	div_element.style.display="table-cell";
			div_element.style.width=w_field_label_size+"px";
          	div_element.setAttribute("id", i+"_element_sectionform_id_temp");


      	var br1 = document.createElement('br');
      	var br2 = document.createElement('br');
     	var br3 = document.createElement('br');
      	var br4 = document.createElement('br');
		
	var table_little = document.createElement('div');
           	table_little.setAttribute("id", i+"_table_little");
			table_little.style.display="table";
			
      	var tr_little1 = document.createElement('div');
	        tr_little1.setAttribute("id", i+"_element_tr1");
			tr_little1.style.display="table-row";
		
      	var tr_little2 = document.createElement('div');
 	        tr_little2.setAttribute("id", i+"_element_tr2");
			tr_little2.style.display="table-row";
			
      	var td_little1 = document.createElement('div');
         	td_little1.setAttribute("valign", 'top');
           	td_little1.setAttribute("id", i+"_td_little1");
			td_little1.style.display="table-cell";
			
      	var td_little2 = document.createElement('div');
        	td_little2.setAttribute("valign", 'top');
           	td_little2.setAttribute("id", i+"_td_little2");
			td_little2.style.display="table-cell";
			

      	var label = document.createElement('span');
			label.setAttribute("id", i+"_element_labelform_id_temp");
			label.innerHTML = w_field_label;
			label.setAttribute("class", "label");
			label.style.verticalAlign="top";
	    
      	var required = document.createElement('span');
			required.setAttribute("id", i+"_required_elementform_id_temp");
			required.innerHTML = "";
			required.setAttribute("class", "required");
			required.style.verticalAlign="top";
	if(w_required=="yes")
			required.innerHTML = " *";
			
	var select_ = document.createElement('select');
		select_.setAttribute("id", i+"_elementform_id_temp");
		select_.setAttribute("name", i+"_elementform_id_temp");
		select_.style.cssText = "width:"+w_size+"px";
				
		for(r=0;r<w_countries.length;r++)
		{
		var option_ = document.createElement('option');
			option_.setAttribute("value", w_countries[r]);
			option_.innerHTML=w_countries[r];
		select_.appendChild(option_);
		}
		
      	var main_td  = document.getElementById('show_table');
	
      
	div_label.appendChild(label);
	div_label.appendChild(required);
	div_element.appendChild(adding_type);
	
	div_element.appendChild(adding_required);
	div_element.appendChild(select_);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
      
	div.appendChild(div_field);
	div.appendChild(br3);
	main_td.appendChild(div);
	
	if(w_field_label_pos=="top")
		label_top(i);
	
	change_class(w_class, i);
	refresh_attr(i, 'type_text');

//	fm_popup();
}

function type_file_upload(i, w_field_label, w_field_label_size, w_field_label_pos, w_destination, w_extension, w_max_size, w_required, w_multiple, w_class, w_attr_name, w_attr_value){

    document.getElementById("element_type").value="type_file_upload";
	delete_last_child();
	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10  = document.createElement('tr');
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');
			
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_max_size_label = document.createElement('label');
		el_max_size_label.setAttribute("class", "fm-field-label");
		el_max_size_label.setAttribute("for", "edit_for_max_size");
		el_max_size_label.innerHTML = "Maximum size(KB) ";
	
	var el_max_size_input = document.createElement('input');
		el_max_size_input.setAttribute("type", "text");
		el_max_size_input.setAttribute("id", "edit_for_max_size");
		el_max_size_input.setAttribute("value", w_max_size);
		el_max_size_input.style.cssText = "width:100px;";
		el_max_size_input.setAttribute("onKeyPress", "return check_isnum(event)");
		el_max_size_input.setAttribute("onChange", "change_file_value(this.value,'"+i+"_max_size', '***max_sizeskizb"+i+"***', '***max_sizeverj"+i+"***')");
				
	var el_destination_label = document.createElement('label');
		el_destination_label.setAttribute("class", "fm-field-label");
		el_destination_label.setAttribute("for", "el_destination_input");
		el_destination_label.innerHTML = "Destination";
	
	var el_destination_input = document.createElement('input');
		el_destination_input.setAttribute("id", "el_destination_input");
		el_destination_input.setAttribute("type", "text");
		el_destination_input.setAttribute("value", w_destination);
		el_destination_input.setAttribute("onChange", "change_file_value(this.value,'"+i+"_destination', '***destinationskizb"+i+"***', '***destinationverj"+i+"***')");

	var el_extension_label = document.createElement('label');
		el_extension_label.setAttribute("class", "fm-field-label");
		el_extension_label.setAttribute("for", "edit_for_extension");
		el_extension_label.innerHTML = "Allowed file extensions&nbsp;";
	
	var el_extension_textarea = document.createElement('textarea');
		el_extension_textarea.setAttribute("id", "edit_for_extension");
		el_extension_textarea.setAttribute("rows", "4");
		el_extension_textarea.setAttribute("onChange", "change_file_value(this.value,'"+i+"_extension', '***extensionskizb"+i+"***', '***extensionverj"+i+"***')");
		el_extension_textarea.innerHTML=w_extension;
		
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_required_label = document.createElement('label');
		el_required_label.setAttribute("class", "fm-field-label");
		el_required_label.setAttribute("for", "el_required");
		el_required_label.innerHTML = "Required";
	
	var el_required = document.createElement('input');
		el_required.setAttribute("id", "el_required");
		el_required.setAttribute("type", "checkbox");
		el_required.setAttribute("onclick", "set_required('"+i+"_required')");
		if(w_required=="yes")
			el_required.setAttribute("checked", "checked");
	
	var el_multiple_label = document.createElement('label');
		el_multiple_label.setAttribute("class", "fm-field-label");
	    el_multiple_label.setAttribute("for", "el_multiple");
		el_multiple_label.innerHTML = "Allow Uploading Multiple Files";
	
	var el_multiple = document.createElement('input');
        el_multiple.setAttribute("id", "el_multiple");
        el_multiple.setAttribute("type", "checkbox");
        el_multiple.setAttribute("onclick", "set_multiple('"+i+"', this.checked)");
		if(w_multiple=="yes")
			el_multiple.setAttribute("checked", "checked");
	
	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
			
	var el_attr_add = document.createElement('img');
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_text')");
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
		el_attr_value_label.setAttribute("class", "fm-field-label");
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_text')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_text')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
		el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_text')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
	}
		
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td9.appendChild(el_label_size_label);
	edit_main_td9_1.appendChild(el_label_size);

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_max_size_label);
	edit_main_td3_1.appendChild(el_max_size_input);

	edit_main_td4.appendChild(el_destination_label);
	edit_main_td4_1.appendChild(el_destination_input);
	
	edit_main_td5.appendChild(el_extension_label);
	edit_main_td5_1.appendChild(el_extension_textarea);
	
	edit_main_td6.appendChild(el_style_label);
	edit_main_td6_1.appendChild(el_style_textarea);
	
	edit_main_td7.appendChild(el_required_label);
	edit_main_td7_1.appendChild(el_required);
	
	edit_main_td10.appendChild(el_multiple_label);
	edit_main_td10_1.appendChild(el_multiple);
	
	
	
	edit_main_td8.appendChild(el_attr_label);
	edit_main_td8.appendChild(el_attr_add);
	edit_main_td8.appendChild(br3);
	edit_main_td8.appendChild(el_attr_table);
	edit_main_td8.setAttribute("colspan", "2");
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr8);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_text');

	element='input';	type='file'; 
	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_file_upload");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
			
	var adding_required = document.createElement("input");
		adding_required.setAttribute("type", "hidden");
		adding_required.setAttribute("value", w_required);
		adding_required.setAttribute("name", i+"_requiredform_id_temp");
		adding_required.setAttribute("id", i+"_requiredform_id_temp");
			
	var adding = document.createElement(element);
		adding.setAttribute("type", type);
		adding.setAttribute("class", "file_upload");
		adding.setAttribute("id", i+"_elementform_id_temp");
		adding.setAttribute("name", i+"_fileform_id_temp");
		if(w_multiple=="yes")
			adding.setAttribute("multiple", "multiple");
			
			
	var adding_max_size = document.createElement("input");
		adding_max_size.setAttribute("type", "hidden");
		adding_max_size.setAttribute("value", '***max_sizeskizb'+i+'***'+w_max_size+'***max_sizeverj'+i+'***');
		adding_max_size.setAttribute("id", i+"_max_size");
		adding_max_size.setAttribute("name", i+"_max_size");
			
	var adding_destination = document.createElement("input");
		adding_destination.setAttribute("type", "hidden");
		adding_destination.setAttribute("value", '***destinationskizb'+i+'***'+w_destination+'***destinationverj'+i+'***');
		adding_destination.setAttribute("id", i+"_destination");
		adding_destination.setAttribute("name", i+"_destination");
	var adding_extension = document.createElement("input");
		adding_extension.setAttribute("type", "hidden");
		adding_extension.setAttribute("value", '***extensionskizb'+i+'***'+w_extension+'***extensionverj'+i+'***');
		adding_extension.setAttribute("id", i+"_extension");
		adding_extension.setAttribute("name", i+"_extension");

	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
				
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width=w_field_label_size+"px";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");
		
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
  
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
		label.style.verticalAlign="top";
	
	var required = document.createElement('span');
		required.setAttribute("id", i+"_required_elementform_id_temp");
		required.innerHTML = "";
		required.setAttribute("class", "required");
		required.style.verticalAlign="top";
		if(w_required=="yes")
			required.innerHTML = " *";
	var main_td  = document.getElementById('show_table');
  
	div_label.appendChild(label);
	div_label.appendChild(required );
	div_element.appendChild(adding_type);
	div_element.appendChild(adding_required);

	div_element.appendChild(adding_max_size);
	div_element.appendChild(adding_destination);
	div_element.appendChild(adding_extension);
	div_element.appendChild(adding);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
  
	div.appendChild(div_field);
	div.appendChild(br3);
	main_td.appendChild(div);
	if(w_field_label_pos=="top")
		label_top(i);
	change_class(w_class, i);
	refresh_attr(i, 'type_text');
}

function set_multiple(i, status)
{
	if(status)
		document.getElementById(i+"_elementform_id_temp").setAttribute('multiple', 'multiple');
	else
		document.getElementById(i+"_elementform_id_temp").removeAttribute('multiple');
}

function type_recaptcha(i,w_field_label, w_field_label_size, w_field_label_pos, w_public, w_private, w_theme, w_class, w_attr_name, w_attr_value){
	
    document.getElementById("element_type").value="type_recaptcha";
	delete_last_child();	
	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9 = document.createElement('tr');

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
		  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
	    el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
	    el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
        el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
        el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_public_label = document.createElement('label');
	    el_public_label.setAttribute("class", "fm-field-recaptcha-label");
		el_public_label.setAttribute("for", "public_key");
		el_public_label.innerHTML = "Public key";
	
	var el_public_textarea = document.createElement('input');
        el_public_textarea.setAttribute("id", "public_key");
		el_public_textarea.setAttribute("type", "text");
		el_public_textarea.setAttribute("value", w_public);
        el_public_textarea.setAttribute("onChange", "change_key(this.value, 'public_key')");

	var el_private_label = document.createElement('label');
		el_private_label.setAttribute("class", "fm-field-recaptcha-label");
		el_private_label.setAttribute("for", "private_key");
		el_private_label.innerHTML = "Private key";
	
	var el_private_textarea = document.createElement('input');
        el_private_textarea.setAttribute("id", "private_key");
		el_private_textarea.setAttribute("type", "text");
		el_private_textarea.setAttribute("value", w_private);
        el_private_textarea.setAttribute("onChange", "change_key(this.value, 'private_key')");

	var el_theme_label = document.createElement('label');
	    el_theme_label.setAttribute("class", "fm-field-label");
	    el_theme_label.setAttribute("for", "el_theme_select");
		el_theme_label.innerHTML = "Recaptcha Theme";
	
	var el_theme_select = document.createElement('select');
        el_theme_select.setAttribute("id", "el_theme_select");
        el_theme_select.setAttribute("onChange", "change_key(this.value, 'theme')");
		el_theme_select.style.cssText = 'width:200px;';
		
	var el_theme_option1 = document.createElement('option');
		el_theme_option1.value="red";
		el_theme_option1.innerHTML="Red";
		
	var el_theme_option2= document.createElement('option');
		el_theme_option2.value="white";
		el_theme_option2.innerHTML="White";
		
	var el_theme_option3= document.createElement('option');
		el_theme_option3.value="blackglass";
		el_theme_option3.innerHTML="Blackglass";
	
	var el_theme_option4= document.createElement('option');
		el_theme_option4.value="clean";
		el_theme_option4.innerHTML="Clean";
	
	el_theme_select.appendChild(el_theme_option1);
	el_theme_select.appendChild(el_theme_option2);
	el_theme_select.appendChild(el_theme_option3);
	el_theme_select.appendChild(el_theme_option4);
	
	el_theme_select.value=w_theme;
	

	var el_attr_label = document.createElement('label');
	    el_attr_label.setAttribute("class", "fm-field-label");            
		el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
                
           	el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_recaptcha')");
	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_recaptcha')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_recaptcha')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_recaptcha')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}
		
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td9.appendChild(el_label_size_label);
	edit_main_td9_1.appendChild(el_label_size);

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td4.appendChild(el_style_label);
	edit_main_td4_1.appendChild(el_style_textarea);
	
	edit_main_td6.appendChild(el_public_label);
	edit_main_td6_1.appendChild(el_public_textarea);
	
	edit_main_td7.appendChild(el_private_label);
	edit_main_td7_1.appendChild(el_private_textarea);
	
	edit_main_td8.appendChild(el_theme_label);
	edit_main_td8_1.appendChild(el_theme_select);
	

	edit_main_td5.appendChild(el_attr_label);
	edit_main_td5.appendChild(el_attr_add);
	edit_main_td5.appendChild(br3);
	edit_main_td5.appendChild(el_attr_table);
	edit_main_td5.setAttribute("colspan", "2");

	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_text');

	element='img';	type='captcha'; 
	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_recaptcha");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");

	var adding = document.createElement('div');
		adding.setAttribute("id", "wd_recaptchaform_id_temp");
		adding.setAttribute("public_key", w_public);
		adding.setAttribute("private_key", w_private);
		adding.setAttribute("theme", w_theme);
		
	var adding_text = document.createElement('span');
		adding_text.style.color="red";
		adding_text.style.fontStyle="italic";
		adding_text.innerHTML="Recaptcha doesn't display in back end";
		
	adding.appendChild(adding_text);
	
	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
				
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width=w_field_label_size+"px";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");
		
	

	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
  

	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
		label.style.verticalAlign="top";
	
	var main_td  = document.getElementById('show_table');
  
	div_label.appendChild(label);
	div_element.appendChild(adding_type);
	div_element.appendChild(adding);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);

	div.appendChild(div_field);
	div.appendChild(br3);
	main_td.appendChild(div);
	if(w_field_label_pos=="top")
		label_top(i);
	change_class(w_class, i);
	refresh_attr(i, 'type_recaptcha');
}

function type_captcha(i,w_field_label, w_field_label_size, w_field_label_pos, w_digit, w_class, w_attr_name, w_attr_value){
   
	document.getElementById("element_type").value="type_captcha";
	delete_last_child();
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
      			
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');	
		  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
	    el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
        el_label_textarea.setAttribute("id", "edit_for_label");
        el_label_textarea.setAttribute("rows", "4");
        
        el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_size_label = document.createElement('label');
		el_size_label.setAttribute("class", "fm-field-label");
	    el_size_label.setAttribute("for", "captcha_digit");
		el_size_label.innerHTML = "Captcha size";
	
	var el_captcha_digit = document.createElement('input');
        el_captcha_digit.setAttribute("id", "captcha_digit");
        el_captcha_digit.setAttribute("type", "text");
        el_captcha_digit.setAttribute("value", w_digit);
		el_captcha_digit.setAttribute("name", "captcha_digit");
 		el_captcha_digit.setAttribute("onKeyPress", "return check_isnum_3_10(event)");
        el_captcha_digit.setAttribute("onKeyUp", "change_captcha_digit(this.value, '"+i+"')");
	    el_captcha_digit.style.cssText ="margin-right:18px";

	Digits = document.createTextNode("Digits (3 - 9)");
	
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
	    el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
        el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
        el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_attr_label = document.createElement('label');
	    el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
		
	var el_attr_add = document.createElement('img');
        el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
        el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
        el_attr_add.setAttribute("title", 'add');
        el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_captcha')");
		
	var el_attr_table = document.createElement('table');
        el_attr_table.setAttribute("id", 'attributes');
        el_attr_table.setAttribute("border", '0');
        el_attr_table.style.cssText = 'margin-left:0px';
		
	var el_attr_tr_label = document.createElement('tr');
        el_attr_tr_label.setAttribute("idi", '0');
		
	var el_attr_td_name_label = document.createElement('th');
        el_attr_td_name_label.style.cssText = 'width:100px';
		
	var el_attr_td_value_label = document.createElement('th');
        el_attr_td_value_label.style.cssText = 'width:100px';
		
	var el_attr_td_X_label = document.createElement('th');
        el_attr_td_X_label.style.cssText = 'width:10px';
		
	var el_attr_name_label = document.createElement('label');
	    el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	    el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_captcha')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_captcha')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
		el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_captcha')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}
		
	var t  = document.getElementById('edit_table');
	
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td7.appendChild(el_label_size_label);
	edit_main_td7_1.appendChild(el_label_size);

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_size_label);
	edit_main_td3_1.appendChild(el_captcha_digit);
	edit_main_td3_1.appendChild(Digits);
	
	edit_main_td4.appendChild(el_style_label);
	edit_main_td4_1.appendChild(el_style_textarea);
	
	
	
	edit_main_td5.appendChild(el_attr_label);
	edit_main_td5.appendChild(el_attr_add);
	edit_main_td5.appendChild(br3);
	edit_main_td5.appendChild(el_attr_table);
	edit_main_td5.setAttribute("colspan", "2");

	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_captcha');

	element='img';	type='captcha'; 
	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_captcha");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");

	var adding = document.createElement(element);
		adding.setAttribute("type", type);
		adding.setAttribute("digit", w_digit);
		adding.setAttribute("src", url_for_ajax + "?action=formmakerwdcaptcha&digit="+w_digit+"&i=form_id_temp");
		adding.setAttribute("id", "_wd_captchaform_id_temp");
		adding.setAttribute("class", "captcha_img");
		adding.setAttribute("onClick", "captcha_refresh('_wd_captcha','form_id_temp')");
			
   	var refresh_captcha = document.createElement("div");
		refresh_captcha.setAttribute("class", "captcha_refresh");
		refresh_captcha.setAttribute("id", "_element_refreshform_id_temp");
		refresh_captcha.setAttribute("onClick", "captcha_refresh('_wd_captcha','form_id_temp')");

	var input_captcha = document.createElement("input");
		input_captcha.setAttribute("type", "text");
		input_captcha.style.cssText = "width:"+(w_digit*10+15)+"px;";
		input_captcha.setAttribute("class", "captcha_input");
		input_captcha.setAttribute("id", "_wd_captcha_inputform_id_temp");
		input_captcha.setAttribute("name", "captcha_input");

	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
				
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width=w_field_label_size+"px";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");
			
	var captcha_table = document.createElement('div');
		captcha_table.style.display="table";
	
	var captcha_tr1 = document.createElement('div');
		captcha_tr1.style.display="table-row";
	var captcha_tr2 = document.createElement('div');
		captcha_tr2.style.display="table-row";

	var captcha_td1 = document.createElement('div');
		captcha_td1.setAttribute("valign", 'middle');
		captcha_td1.style.display="table-cell";

	var captcha_td2 = document.createElement('div');
		captcha_td2.setAttribute("valign", 'middle');
		captcha_td2.style.display="table-cell";
	var captcha_td3 = document.createElement('div');
		captcha_td3.style.display="table-cell";
	
	captcha_table.appendChild(captcha_tr1);
	captcha_table.appendChild(captcha_tr2);
	captcha_tr1.appendChild(captcha_td1);
	captcha_tr1.appendChild(captcha_td2);
	captcha_tr2.appendChild(captcha_td3);
	
	captcha_td1.appendChild(adding);
	captcha_td2.appendChild(refresh_captcha);
	captcha_td3.appendChild(input_captcha);
	
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
     
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
		label.style.verticalAlign="top";
	
	var main_td  = document.getElementById('show_table');
      
	div_label.appendChild(label);
	div_element.appendChild(adding_type);
	div_element.appendChild(captcha_table);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);

  
	div.appendChild(div_field);
	div.appendChild(br3);
	main_td.appendChild(div);
	if(w_field_label_pos=="top")
		label_top(i);
	change_class(w_class, i);
	refresh_attr(i, 'type_captcha');
}

function type_arithmetic_captcha(i,w_field_label, w_field_label_size, w_field_label_pos, w_count, w_operations, w_class, w_input_size, w_attr_name, w_attr_value){
	
    document.getElementById("element_type").value="type_arithmetic_captcha";
	delete_last_child();

	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');		
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
		  
	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
	    el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
        el_label_textarea.setAttribute("id", "edit_for_label");
        el_label_textarea.setAttribute("rows", "4");
        
        el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";

	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");

	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
		el_label_left.innerHTML = "Left";	

	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
		el_label_top.innerHTML = "Top";
		
	if(w_field_label_pos=="top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var el_operations_label = document.createElement('label');
		el_operations_label.setAttribute("class", "fm-field-label");
	    el_operations_label.setAttribute("for", "el_operations");
		el_operations_label.innerHTML = "Arithmetic operations";
	
	var el_operations = document.createElement('input');
        el_operations.setAttribute("id", "el_operations");
		el_operations.setAttribute("type", "text");
		el_operations.setAttribute("value", w_operations);
		el_operations.setAttribute("onKeyPress", "return check_is_operation_valid(event)");
        el_operations.setAttribute("onChange", "change_arithmetic_captcha(this.value, 'operations')");
	
	var el_size_label = document.createElement('label');
		el_size_label.setAttribute("class", "fm-field-label");
	    el_size_label.setAttribute("for", "el_oper_count");
		el_size_label.innerHTML = "Operations count";
	
	var el_oper_count = document.createElement('input');
        el_oper_count.setAttribute("id", "el_oper_count");
        el_oper_count.setAttribute("type", "text");
        el_oper_count.setAttribute("value", w_count);
		el_oper_count.setAttribute("name", "el_oper_count");
 		el_oper_count.setAttribute("onKeyPress", "return check_isnum_less_then_5(event)");
        el_oper_count.setAttribute("onKeyUp", "change_arithmetic_captcha(this.value, 'oper_count')");

	Digits = document.createTextNode("Digits (1 - 5)");
	
	var el_size_captcha_label = document.createElement('label');
		el_size_captcha_label.setAttribute("class", "fm-field-label");
	    el_size_captcha_label.setAttribute("for", "el_captcha_input_size");
		el_size_captcha_label.innerHTML = "Captcha input size";
	
	var el_size_captcha_input = document.createElement('input');
        el_size_captcha_input.setAttribute("id", "el_captcha_input_size");
        el_size_captcha_input.setAttribute("type", "text");
        el_size_captcha_input.setAttribute("value", w_input_size);
		el_size_captcha_input.setAttribute("name", "el_captcha_input_size");
 		el_size_captcha_input.setAttribute("onKeyPress", "return check_isnum(event)");
		el_size_captcha_input.setAttribute("onKeyUp", "change_w_style('_wd_arithmetic_captcha_inputform_id_temp', this.value)");
	
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
	    el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
        el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
		el_style_textarea.setAttribute("value", w_class);
        
        el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");
		el_attr_label.innerHTML = "Additional Attributes";
		
	var el_attr_add = document.createElement('img');
        el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
        el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
        el_attr_add.setAttribute("title", 'add');
        el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_arithmetic_captcha')");
		
	var el_attr_table = document.createElement('table');
        el_attr_table.setAttribute("id", 'attributes');
        el_attr_table.setAttribute("border", '0');
        el_attr_table.style.cssText = 'margin-left:0px';
		
	var el_attr_tr_label = document.createElement('tr');
        el_attr_tr_label.setAttribute("idi", '0');
		
	var el_attr_td_name_label = document.createElement('th');
        el_attr_td_name_label.style.cssText = 'width:100px';
		
	var el_attr_td_value_label = document.createElement('th');
        el_attr_td_value_label.style.cssText = 'width:100px';
		
	var el_attr_td_X_label = document.createElement('th');
        el_attr_td_X_label.style.cssText = 'width:10px';
		
	var el_attr_name_label = document.createElement('label');
	    el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	    el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_arithmetic_captcha')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_arithmetic_captcha')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_arithmetic_captcha')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
	}
		
	var t  = document.getElementById('edit_table');
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td7.appendChild(el_label_size_label);
	edit_main_td7_1.appendChild(el_label_size);

	edit_main_td2.appendChild(el_label_position_label);
	edit_main_td2_1.appendChild(el_label_position1);
	edit_main_td2_1.appendChild(el_label_left);
	edit_main_td2_1.appendChild(br);
	edit_main_td2_1.appendChild(el_label_position2);
	edit_main_td2_1.appendChild(el_label_top);
	
	edit_main_td3.appendChild(el_size_label);
	edit_main_td3_1.appendChild(el_oper_count);
	edit_main_td3_1.appendChild(Digits);
	
	edit_main_td8.appendChild(el_size_captcha_label);
	edit_main_td8_1.appendChild(el_size_captcha_input);
	
	edit_main_td6.appendChild(el_operations_label);
	edit_main_td6_1.appendChild(el_operations);
	
	edit_main_td4.appendChild(el_style_label);
	edit_main_td4_1.appendChild(el_style_textarea);
	
	
	
	edit_main_td5.appendChild(el_attr_label);
	edit_main_td5.appendChild(el_attr_add);
	edit_main_td5.appendChild(br3);
	edit_main_td5.appendChild(el_attr_table);
	edit_main_td5.setAttribute("colspan", "2");
	
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr6);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	add_id_and_name(i, 'type_arithmetic_captcha');

	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_arithmetic_captcha");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
		
	var adding = document.createElement('img');
		adding.setAttribute("type", type);
		adding.setAttribute("operations_count", w_count);
		adding.setAttribute("operations", w_operations);
		adding.setAttribute("input_size", w_input_size);
		adding.setAttribute("src", url_for_ajax + "?action=formmakerwdmathcaptcha&operations_count="+w_count+"&operations="+w_operations.replace("+", "@")+"&i=form_id_temp");
		adding.setAttribute("id", "_wd_arithmetic_captchaform_id_temp");
		adding.setAttribute("class", "arithmetic_captcha_img");
		adding.setAttribute("onClick", "captcha_refresh('_wd_arithmetic_captcha','form_id_temp')");
			
	var refresh_captcha = document.createElement("div");
		refresh_captcha.setAttribute("class", "captcha_refresh");
		refresh_captcha.setAttribute("id", "_element_refreshform_id_temp");
		refresh_captcha.setAttribute("onClick", "captcha_refresh('_wd_arithmetic_captcha','form_id_temp')");

	var input_captcha = document.createElement("input");
		input_captcha.setAttribute("type", "text");
		input_captcha.style.cssText = "width:"+w_input_size+"px;";
		input_captcha.setAttribute("class", "arithmetic_captcha_input");
		input_captcha.setAttribute("id", "_wd_arithmetic_captcha_inputform_id_temp");
		input_captcha.setAttribute("name", "arithmetic_captcha_input");
		input_captcha.setAttribute("onKeyPress", "return check_isnum(event)");

	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
				
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width=w_field_label_size+"px";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
			
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");
			
	var captcha_table = document.createElement('div');
		captcha_table.style.display="table";
	
	var captcha_tr1 = document.createElement('div');
		captcha_tr1.style.display="table-row";
	var captcha_tr2 = document.createElement('div');
		captcha_tr2.style.display="table-row";

	var captcha_td1 = document.createElement('div');
		captcha_td1.style.display="table-cell";

	var captcha_td2 = document.createElement('div');
		captcha_td2.style.cssText = "display:table-cell; vertical-align:middle;";
	var captcha_td3 = document.createElement('div');
		captcha_td3.style.display="table-cell";
	
	captcha_table.appendChild(captcha_tr1);
	captcha_table.appendChild(captcha_tr2);
	captcha_tr1.appendChild(captcha_td1);
	captcha_tr1.appendChild(captcha_td3);
	captcha_tr1.appendChild(captcha_td2);
	captcha_td1.appendChild(adding);
	captcha_td2.appendChild(refresh_captcha);
	captcha_td3.appendChild(input_captcha);
	
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
      
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "label");
		label.style.verticalAlign="top";
	    
	var main_td  = document.getElementById('show_table');
      
	div_label.appendChild(label);
	div_element.appendChild(adding_type);
	div_element.appendChild(captcha_table);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
	div.appendChild(div_field);
	div.appendChild(br3);
	main_td.appendChild(div);
	
	if(w_field_label_pos=="top")
		label_top(i);
	change_class(w_class, i);
	refresh_attr(i, 'type_arithmetic_captcha');
}

function type_map(i, w_center_x, w_center_y, w_long, w_lat, w_zoom, w_width, w_height, w_class, w_info, w_attr_name, w_attr_value)
{
    document.getElementById("element_type").value = "type_map";
	delete_last_child();

	var edit_div = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");

	var edit_main_table = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');			
	var edit_main_td7 = document.createElement('td');
		edit_main_td7.setAttribute("colspan", "4");
		edit_main_td7.setAttribute("id", "markers");
		
	var center1 = document.createElement('p');
        center1.setAttribute("id", "center1");
		center1.setAttribute("class", "fm-editable-label");
		center1.innerHTML = "Drag the marker to change marker position.";
	  
	var el_label_location = document.createElement('label');
	    el_label_location.setAttribute("class", "fm-field-label");
		el_label_location.innerHTML = "Location";
		
	var el_img_add_marker = document.createElement('img');
        el_img_add_marker.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
	    el_img_add_marker.style.cssText ="cursor:pointer";
        el_img_add_marker.setAttribute("onClick", "add_marker('"+i+"', -1)");

	var el_label_map_size = document.createElement('label');
		el_label_map_size.setAttribute("class", "fm-field-label");
		el_label_map_size.innerHTML = "Map size";
	
	var el_map_width = document.createElement('input');
        el_map_width.setAttribute("type", "text");
        el_map_width.setAttribute("value", w_width);
        el_map_width.style.cssText ="margin-left:18px";
 		el_map_width.setAttribute("onKeyPress", "return check_isnum(event)");
        el_map_width.setAttribute("onKeyUp", "change_w_style('"+i+"_elementform_id_temp', this.value);");

	Width = document.createTextNode("Width");
		
	var el_map_height = document.createElement('input');
        el_map_height.setAttribute("type", "text");
        el_map_height.setAttribute("value", w_height);
		el_map_height.style.cssText = "margin-left:15px";
      	el_map_height.setAttribute("onKeyPress", "return check_isnum(event)");
	    el_map_height.setAttribute("onKeyUp", "change_h_style('"+i+"_elementform_id_temp', this.value);");
	
	Height = document.createTextNode("Height");
	
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
 		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.style.cssText = "width:200px;";
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");        
		el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_text')");
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
		el_attr_value_label.style.cssText = "color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n = w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.style.cssText = "width:100px";
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_text')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.style.cssText = "width:100px";
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_text')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';	
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_text')");
			
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
	}
		
	var t  = document.getElementById('edit_table');
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	
	edit_main_td2.appendChild(el_label_location);
	edit_main_td2.appendChild(center1);
	edit_main_td2.appendChild(el_img_add_marker);
	edit_main_td2.setAttribute("colspan", "2");

	edit_main_td3.appendChild(el_label_map_size);
	edit_main_td3_1.appendChild(Width);
	edit_main_td3_1.appendChild(el_map_width);
	edit_main_td3_1.appendChild(br);
	edit_main_td3_1.appendChild(Height);
	edit_main_td3_1.appendChild(el_map_height);

	edit_main_td5.appendChild(el_style_label);
	edit_main_td5_1.appendChild(el_style_textarea);
	
	
	
	edit_main_td6.appendChild(el_attr_label);
	edit_main_td6.appendChild(el_attr_add);
	edit_main_td6.appendChild(br1);
	edit_main_td6.appendChild(el_attr_table);
	edit_main_td6.setAttribute("colspan", "2");	
	
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);	
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_div.appendChild(edit_main_table);
	t.appendChild(edit_div);

	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_map");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
	
	var adding = document.createElement('div');
		adding.setAttribute("id", i+"_elementform_id_temp");
		adding.style.cssText = "width:"+w_width+"px; height: "+w_height+"px";
		adding.setAttribute("zoom", w_zoom);
		adding.setAttribute("center_x", w_center_x);
		adding.setAttribute("center_y", w_center_y);
		
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = "map_"+i;
		label.style.cssText = 'display:none';
		
	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
				
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");

	var main_td  = document.getElementById('show_table');
      
	div_label.appendChild(label);
	div_element.appendChild(adding_type);
	div_element.appendChild(adding);
	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
	div.appendChild(div_field);
	div.appendChild(br2);
	main_td.appendChild(div);
	
	change_class(w_class, i);
	refresh_attr(i, 'type_text');
	if_gmap_init(i);
	
	n = w_long.length;
	for(j=0; j<n; j++)
		add_marker(i,j, w_long[j], w_lat[j], w_info[j]);
}


function add_marker(id, i, w_long, w_lat, w_info) {
	edit_main_td7=document.getElementById('markers');
	if(i==-1) {
		if(edit_main_td7.lastChild)
			i = parseInt(edit_main_td7.lastChild.getAttribute("idi"))+1;
		else
			i = 0;
		w_long = null;
		w_lat = null;
		w_info = '';
	}
	
	var table_marker = document.createElement('table');
		table_marker.setAttribute("width", "100%");
		table_marker.setAttribute("border", "0");
		table_marker.setAttribute("id", "marker_opt"+i);
		table_marker.setAttribute("idi", i);

	var tr_marker = document.createElement('tr');
	var tr_hr = document.createElement('tr');
	
	var td_marker = document.createElement('td');
	var td_X = document.createElement('td');
	var td_hr = document.createElement('td');
		td_hr.setAttribute("colspan", "3");
		
	tr_hr.appendChild(td_hr);
	tr_marker.appendChild(td_marker);
	tr_marker.appendChild(td_X);
	table_marker.appendChild(tr_marker);
	table_marker.appendChild(tr_hr);
		
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');

	var hr = document.createElement('hr');
		hr.setAttribute("id", "br"+i);
		
	var el_info_textarea = document.createElement('textarea');
		el_info_textarea.setAttribute("id", "info"+i);
		el_info_textarea.setAttribute("rows", "3");
		el_info_textarea.setAttribute("value", w_info);
		el_info_textarea.setAttribute("onKeyUp", "change_info(this.value,'"+id+"','"+i+"')");
		el_info_textarea.innerHTML=w_info;
	
	var Marker_info = document.createElement('label');
		Marker_info.style.cssText =" font-size: 12px; vertical-align:top; margin-right:38px; font-weight:bold;";
		Marker_info.innerHTML = "Marker Info";
	
	var el_map_address = document.createElement('input');
		el_map_address.setAttribute("id", "addrval"+i);
		el_map_address.setAttribute("type", "text");
		el_map_address.setAttribute("value", "");
		el_map_address.setAttribute("size", "40");
		el_map_address.setAttribute("onchange", "changeAddress("+id+","+i+")");

	var Address = document.createElement('label');
		Address.style.cssText =" font-size: 12px; vertical-align:top; margin-right:59px; font-weight:bold;";
		Address.innerHTML = "Address";
	
	var el_map_longitude = document.createElement('input');
		el_map_longitude.setAttribute("id", "longval"+i);
		el_map_longitude.setAttribute("type", "text");
		el_map_longitude.setAttribute("value", w_long);
		el_map_longitude.setAttribute("size", "10");
		el_map_longitude.setAttribute("onkeyup", "update_position("+id+", "+i+");");
		
	var Longitude = document.createElement('label');
		Longitude.style.cssText =" font-size: 12px; vertical-align:top; margin-right:47px; font-weight:bold;";
		Longitude.innerHTML = "Longitude";
		
	var el_map_latitude = document.createElement('input');
		el_map_latitude.setAttribute("id", "latval"+i);
		el_map_latitude.setAttribute("type", "text");
		el_map_latitude.setAttribute("value", w_lat);
		el_map_latitude.setAttribute("size", "10");
		el_map_latitude.setAttribute("onkeyup", "update_position("+id+", "+i+");");
	
	var Latitude = document.createElement('label');
		Latitude.style.cssText =" font-size: 12px; vertical-align:top; margin-right:57px; font-weight:bold;";
		Latitude.innerHTML = "Latitude";
		
	var el_choices_remove = document.createElement('img');
		el_choices_remove.setAttribute("id", "el_button"+i+"_remove");
		el_choices_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
		el_choices_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
		el_choices_remove.setAttribute("align", 'top');
		el_choices_remove.setAttribute("onClick", "remove_map("+id+","+i+")");
			
		td_hr.appendChild(hr);
		
		
		td_marker.appendChild(Address);
		td_marker.appendChild(el_map_address);
		td_marker.appendChild(br1);
		td_marker.appendChild(Longitude);
		td_marker.appendChild(el_map_longitude);
		td_marker.appendChild(br2);
		td_marker.appendChild(Latitude);
		td_marker.appendChild(el_map_latitude);
		td_marker.appendChild(br3);
		td_marker.appendChild(Marker_info);
		td_marker.appendChild(el_info_textarea);
		td_X.appendChild(el_choices_remove);
		edit_main_td7.appendChild(table_marker);
	
	var adding = document.getElementById(id+"_elementform_id_temp")
		adding.setAttribute("long"+i, w_long);
		adding.setAttribute("lat"+i, w_lat);
 		adding.setAttribute("info"+i, w_info);
  
	add_marker_on_map(id, i, w_long, w_lat, w_info, true);
}

function remove_map(id,i)
{
	table=document.getElementById('marker_opt'+i);
	table.parentNode.removeChild(table);
	map=document.getElementById(id+"_elementform_id_temp");
	map.removeAttribute("long"+i);
	map.removeAttribute("lat"+i);
 	map.removeAttribute("info"+i);

	reomve_marker(id,i);
}



function type_mark_map(i, w_field_label, w_field_label_size, w_field_label_pos, w_center_x, w_center_y, w_long, w_lat, w_zoom, w_width, w_height, w_class, w_info, w_attr_name, w_attr_value)
{
    document.getElementById("element_type").value = "type_mark_map";
	delete_last_child();
	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10  = document.createElement('tr');
	var edit_main_tr11  = document.createElement('tr');
	
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');		
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');	
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');
	var edit_main_td11 = document.createElement('td');
	var edit_main_td11_1 = document.createElement('td');

	var el_label_label = document.createElement('label');
		el_label_label.setAttribute("class", "fm-field-label");
		el_label_label.setAttribute("for", "edit_for_label");
		el_label_label.innerHTML = "Field label";
	
	var el_label_textarea = document.createElement('textarea');
		el_label_textarea.setAttribute("id", "edit_for_label");
		el_label_textarea.setAttribute("rows", "4");
		el_label_textarea.style.cssText = "width:200px;";
		el_label_textarea.setAttribute("onKeyUp", "change_label('"+i+"_element_labelform_id_temp', this.value)");
		el_label_textarea.innerHTML = w_field_label;
	
	var el_label_size_label = document.createElement('label');
		el_label_size_label.setAttribute("class", "fm-field-label");
	    el_label_size_label.setAttribute("for", "edit_for_label_size");
		el_label_size_label.innerHTML = "Field label size(px) ";
		
	var el_label_size = document.createElement('input');
	    el_label_size.setAttribute("id", "edit_for_label_size");
	    el_label_size.setAttribute("type", "text");
	    el_label_size.setAttribute("value", w_field_label_size);
		el_label_size.setAttribute("onKeyPress", "return check_isnum(event)");
        el_label_size.setAttribute("onKeyUp", "change_w_style('"+i+"_label_sectionform_id_temp', this.value)");
	
	var el_label_position_label = document.createElement('label');
		el_label_position_label.setAttribute("class", "fm-field-label");
		el_label_position_label.innerHTML = "Field label position";
	
	var el_label_position1 = document.createElement('input');
		el_label_position1.setAttribute("id", "edit_for_label_position_top");
		el_label_position1.setAttribute("type", "radio");
		el_label_position1.setAttribute("name", "edit_for_label_position");
		el_label_position1.setAttribute("onchange", "label_left("+i+")");
		el_label_position1.setAttribute("checked", "checked");
		
	var el_label_left = document.createElement('label');
		el_label_left.setAttribute("for", "edit_for_label_position_top");
        el_label_left.innerHTML = "Left";
		
	var el_label_position2 = document.createElement('input');
		el_label_position2.setAttribute("id", "edit_for_label_position_left");
		el_label_position2.setAttribute("type", "radio");
		el_label_position2.setAttribute("name", "edit_for_label_position");
		el_label_position2.setAttribute("onchange", "label_top("+i+")");

	var el_label_top = document.createElement('label');
		el_label_top.setAttribute("for", "edit_for_label_position_left");
        el_label_top.innerHTML = "Top";	
		
	if(w_field_label_pos == "top")
		el_label_position2.setAttribute("checked", "checked");
	else
		el_label_position1.setAttribute("checked", "checked");

	var center1 = document.createElement('p');
		center1.setAttribute("class", "fm-field-label");
		center1.innerHTML = "Drag the marker to change default marker position.";
	  
	var el_label_location = document.createElement('label');
		el_label_location.setAttribute("class", "fm-field-label");
		el_label_location.innerHTML = "Default Location";
	
	var el_map_address = document.createElement('input');
		el_map_address.setAttribute("id", "addrval0");
		el_map_address.setAttribute("type", "text");
		el_map_address.setAttribute("value", "");
		el_map_address.setAttribute("size", "40");
        el_map_address.setAttribute("onchange", "changeAddress("+i+",0)");
	
	var el_map_address_label = document.createElement('label');
		el_map_address_label.setAttribute("class", "fm-field-label");
		el_map_address_label.setAttribute("for", "addrval0");
		el_map_address_label.innerHTML = "Address";
	
	var el_map_longitude = document.createElement('input');
		el_map_longitude.setAttribute("id", "longval0");
		el_map_longitude.setAttribute("type", "text");
		el_map_longitude.setAttribute("value", w_long);
		el_map_longitude.setAttribute("size", "10");
		el_map_longitude.setAttribute("onkeyup", "update_position("+i+", 0);");
	
	var el_map_longitude_label = document.createElement('label');
		el_map_longitude_label.setAttribute("class", "fm-field-label");
		el_map_longitude_label.setAttribute("for", "longval0");
		el_map_longitude_label.innerHTML = "Longitude";
		
	var el_map_latitude = document.createElement('input');
		el_map_latitude.setAttribute("id", "latval0");
		el_map_latitude.setAttribute("type", "text");
		el_map_latitude.setAttribute("value", w_lat);
		el_map_latitude.setAttribute("size", "10");
		el_map_latitude.setAttribute("onkeyup", "update_position("+i+", 0);");
		
	var el_map_latitude_label = document.createElement('label');
		el_map_latitude_label.setAttribute("class", "fm-field-label");
		el_map_latitude_label.setAttribute("for", "latval0");
		el_map_latitude_label.innerHTML = "Latitude";			

	var el_label_map_size = document.createElement('label');
		el_label_map_size.setAttribute("class", "fm-field-label");
		el_label_map_size.innerHTML = "Map size";
	
	var el_map_width = document.createElement('input');
		el_map_width.setAttribute("type", "text");
		el_map_width.setAttribute("value", w_width);
		el_map_width.style.cssText ="margin-left:10px; width:157px;";
 		el_map_width.setAttribute("onKeyPress", "return check_isnum(event)");
		el_map_width.setAttribute("onKeyUp", "change_w_style('"+i+"_elementform_id_temp', this.value);");

	Width = document.createTextNode("Width");
		
	var el_map_height = document.createElement('input');
		el_map_height.setAttribute("type", "text");
		el_map_height.setAttribute("value", w_height);
		el_map_height.style.cssText = "margin-left:6px; width:157px;";
		el_map_height.setAttribute("onKeyPress", "return check_isnum(event)");
		el_map_height.setAttribute("onKeyUp", "change_h_style('"+i+"_elementform_id_temp', this.value);");
		
	Height = document.createTextNode("Height");
	
	var el_info_label = document.createElement('label');
		el_info_label.setAttribute("class", "fm-field-label");
		el_info_label.setAttribute("for", "info0");
		el_info_label.innerHTML = "Marker Info";
		
	
	var el_info_textarea = document.createElement('textarea');
		el_info_textarea.setAttribute("id", "info0");
		el_info_textarea.setAttribute("rows", "3");
 		el_info_textarea.setAttribute("value", w_class);
		el_info_textarea.style.cssText = "width:200px; margin-left:2px";
		el_info_textarea.setAttribute("onKeyUp", "change_info(this.value,'"+i+"','"+0+"')");
		el_info_textarea.innerHTML = w_info;
		
	var el_style_label = document.createElement('label');
		el_style_label.setAttribute("class", "fm-field-label");
		el_style_label.setAttribute("for", "el_style_textarea");
		el_style_label.innerHTML = "Class name";
	
	var el_style_textarea = document.createElement('input');
		el_style_textarea.setAttribute("id", "el_style_textarea");
		el_style_textarea.setAttribute("type", "text");
 		el_style_textarea.setAttribute("value", w_class);
		el_style_textarea.style.cssText = "width:200px;";
		el_style_textarea.setAttribute("onChange", "change_class(this.value,'"+i+"')");

	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");       
		el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');        
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr("+i+", 'type_text')");
	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
		el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n = w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_text')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_text')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_text')");
			
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
	}
		
	var t  = document.getElementById('edit_table');
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	
	edit_main_td1.appendChild(el_label_label);
	edit_main_td1_1.appendChild(el_label_textarea);
	
	edit_main_td9.appendChild(el_label_size_label);
	edit_main_td9_1.appendChild(el_label_size);
	
	edit_main_td8.appendChild(el_label_position_label);
	edit_main_td8_1.appendChild(el_label_position1);
	edit_main_td8_1.appendChild(el_label_left);
	edit_main_td8_1.appendChild(br);
	edit_main_td8_1.appendChild(el_label_position2);
	edit_main_td8_1.appendChild(el_label_top);

	edit_main_td2.appendChild(el_label_location);
	edit_main_td2.appendChild(center1);
	edit_main_td2.setAttribute("colspan", "2");
	
	edit_main_td7.appendChild(el_map_address_label);
	edit_main_td7_1.appendChild(el_map_address);
	
	edit_main_td10.appendChild(el_map_longitude_label);
	edit_main_td10_1.appendChild(el_map_longitude);
	
	edit_main_td11.appendChild(el_map_latitude_label);
	edit_main_td11_1.appendChild(el_map_latitude);
	
	edit_main_td3.appendChild(el_label_map_size);
	edit_main_td3_1.appendChild(Width);
	edit_main_td3_1.appendChild(el_map_width);
	edit_main_td3_1.appendChild(br1);
	edit_main_td3_1.appendChild(Height);
	edit_main_td3_1.appendChild(el_map_height);

	edit_main_td4.appendChild(el_info_label);
	edit_main_td4_1.appendChild(el_info_textarea);
	
	edit_main_td5.appendChild(el_style_label);
	edit_main_td5_1.appendChild(el_style_textarea);
	
	
	
	edit_main_td6.appendChild(el_attr_label);
	edit_main_td6.appendChild(el_attr_add);
	edit_main_td6.appendChild(br2);
	edit_main_td6.appendChild(el_attr_table);
	edit_main_td6.setAttribute("colspan", "2");
		
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr11.appendChild(edit_main_td11);
	edit_main_tr11.appendChild(edit_main_td11_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_tr6.appendChild(edit_main_td6_1);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr2);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr11);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr6);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	
	element='div';
	var adding_type = document.createElement("input");
		adding_type.setAttribute("type", "hidden");
		adding_type.setAttribute("value", "type_mark_map");
		adding_type.setAttribute("name", i+"_typeform_id_temp");
		adding_type.setAttribute("id", i+"_typeform_id_temp");
	
	var adding = document.createElement('div');
		adding.setAttribute("id", i+"_elementform_id_temp");
		adding.setAttribute("long0", w_long);
		adding.setAttribute("lat0", w_lat);
		adding.setAttribute("zoom", w_zoom);
		adding.style.cssText = "width:"+w_width+"px; height: "+w_height+"px";
 		adding.setAttribute("info0", w_info);
 		adding.setAttribute("center_x", w_center_x);
		adding.setAttribute("center_y", w_center_y);
		
     
	var label = document.createElement('span');
		label.setAttribute("id", i+"_element_labelform_id_temp");
		label.innerHTML = w_field_label;
		label.setAttribute("class", "wd_form_label");
		label.style.verticalAlign="top";
		
	var div = document.createElement('div');
		div.setAttribute("id", "main_div");
				
	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
					
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.style.width= w_field_label_size+"px";
		div_label.style.verticalAlign="top";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");
		
	var main_td  = document.getElementById('show_table');
  
	div_label.appendChild(label);
	div_element.appendChild(adding_type);
	div_element.appendChild(adding);

	div_field.appendChild(div_label);
	div_field.appendChild(div_element);
	
  
	div.appendChild(div_field);
	div.appendChild(br3);
	main_td.appendChild(div);

	if(w_field_label_pos=="top")
		label_top(i);
	change_class(w_class, i);
	refresh_attr(i, 'type_text');
	if_gmap_init(i);
	add_marker_on_map(i, 0, w_long, w_lat, w_info, true);

}

//////////////////////////////////////////////
///////////  type_page_break   //////////////////
///////////////////////////////////////////////
	
function type_page_navigation(w_type, w_show_title, w_show_numbers, w_attr_name, w_attr_value)
{
	if(need_enable)
		enable2();

	document.getElementById("element_type").value="type_page_navigation";
	delete_last_child();
// edit table	
	var edit_div  = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
		edit_div.setAttribute("style", "border:0px;padding:10px;  padding-top:0px; padding-bottom:0px; margin-top:10px;");
		
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');

	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	edit_main_td6.setAttribute("colspan", "2");
		  
		  
	var el_pagination_opt_label = document.createElement('label');
			el_pagination_opt_label.style.cssText ="color:#000; font-weight:bold; font-size: 13px";
			el_pagination_opt_label.innerHTML = "Pagination Options";
		
	var el_pagination_steps = document.createElement('input');
			el_pagination_steps.setAttribute("id", "el_pagination_steps");
			el_pagination_steps.setAttribute("type", "radio");
			el_pagination_steps.setAttribute("name", "el_pagination");
			el_pagination_steps.setAttribute("value", "steps");
			el_pagination_steps.style.cssText =   "margin-left:20px;  padding:0; border-width: 1px";
            el_pagination_steps.setAttribute("onclick", "pagination_type('steps')");
		Steps = document.createTextNode("Steps");
			
	var el_pagination_percentage = document.createElement('input');
			el_pagination_percentage.setAttribute("id", "el_pagination_percentage");
			el_pagination_percentage.setAttribute("type", "radio");
			el_pagination_percentage.setAttribute("name", "el_pagination");
			el_pagination_percentage.setAttribute("value", "percentage");
			el_pagination_percentage.style.cssText =   "margin-left:20px;  padding:0; border-width: 1px";
            el_pagination_percentage.setAttribute("onclick", "pagination_type('percentage')");
		Percentage = document.createTextNode("Percentage");
		
	var el_pagination_none = document.createElement('input');
			el_pagination_none.setAttribute("id", "el_pagination_none");
			el_pagination_none.setAttribute("type", "radio");
			el_pagination_none.setAttribute("name", "el_pagination");
			el_pagination_none.setAttribute("value", "none");
			el_pagination_none.style.cssText =   "margin-left:20px;  padding:0; border-width: 1px";
            el_pagination_none.setAttribute("onclick", "pagination_type('none')");
		 No_Context = document.createTextNode(" No Context");
		
	if(w_type=='steps')
		el_pagination_steps.setAttribute("checked","checked");
	else
		if(w_type=='percentage')
			el_pagination_percentage.setAttribute("checked","checked");
		else
			el_pagination_none.setAttribute("checked","checked");
				
	var el_show_title_label = document.createElement('label');
			el_show_title_label.style.cssText ="color:#000; font-weight:bold; font-size: 13px";
			el_show_title_label.innerHTML = "Show Page Titles in Progress Bar";
		
	var el_show_title_input = document.createElement('input');
			el_show_title_input.setAttribute("id", "el_show_title_input");
			el_show_title_input.setAttribute("type", "checkbox");
			el_show_title_input.setAttribute("onClick", "show_title_pagebreak();");
			
	if(w_show_title)
		el_show_title_input.setAttribute("checked","checked");
		
	var el_show_numbers_label = document.createElement('label');
			el_show_numbers_label.style.cssText ="color:#000; font-weight:bold; font-size: 13px";
			el_show_numbers_label.innerHTML = "Show Page Numbers in Footer";
		
	var el_show_numbers_input = document.createElement('input');
			el_show_numbers_input.setAttribute("id", "el_show_numbers_input");
			el_show_numbers_input.setAttribute("type", "checkbox");
			el_show_numbers_input.setAttribute("onClick", "show_numbers_pagebreak();");
			
	if(w_show_numbers)
		el_show_numbers_input.setAttribute("checked","checked");
		
	var el_pagination_class_label = document.createElement('label');
	        el_pagination_class_label.style.cssText ="color:#000; font-weight:bold; font-size: 13px";
			el_pagination_class_label.innerHTML = "Pagination Class name";
	
	var el_pagination_class_input = document.createElement('input');
            el_pagination_class_input.setAttribute("id", "next_element_style");
			el_pagination_class_input.setAttribute("type", "text");
			el_pagination_class_input.setAttribute("value", "");
            el_pagination_class_input.style.cssText = "width:100px; margin-left:20px";
            el_pagination_class_input.setAttribute("onChange", "change_pagebreak_class(this.value, 'next')");		
		


	var el_page_titles_label = document.createElement('label');
	        el_page_titles_label.style.cssText ="color:#000; font-weight:bold; font-size: 13px";
			el_page_titles_label.innerHTML = "Pages Title";
			
	edit_main_td6.appendChild(el_page_titles_label);
	w_pages=[];	
	k=0;
	for(j=1; j<=form_view_max; j++)
	{
		if(document.getElementById('form_id_tempform_view'+j))
		{
			k++;
			var br_temp = document.createElement('br');
			var el_page_title_input= document.createElement('input');
			el_page_title_input.setAttribute("type", "text");
			el_page_title_input.style.cssText = "width:100px";
			if(document.getElementById('form_id_tempform_view'+j).getAttribute('page_title')==null)
				el_page_title_input.setAttribute("value", "Untitled Page");
			else
				el_page_title_input.setAttribute("value", document.getElementById('form_id_tempform_view'+j).getAttribute('page_title'));
			
			el_page_title_input.setAttribute("id", "page_title_"+j);
			el_page_title_input.setAttribute("onKeyUp", "set_page_title(this.value,'"+j+"')");
			if(document.getElementById('form_id_tempform_view'+j).getAttribute('page_title'))
				w_pages[j]=document.getElementById('form_id_tempform_view'+j).getAttribute('page_title');
			else
				w_pages[j]="Untitled Page"
				
			page_num=document.createTextNode(k+'. ');
			
			edit_main_td6.appendChild(br_temp);
			edit_main_td6.appendChild(page_num);
			edit_main_td6.appendChild(el_page_title_input);

		}
	
	}	




		
	var el_attr_label = document.createElement('label');
	                
			el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');
                
           	el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
            	el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
            	el_attr_add.setAttribute("title", 'add');
                el_attr_add.setAttribute("onClick", "add_attr( 'type_checkbox')");

	var el_attr_table = document.createElement('table');
                el_attr_table.setAttribute("id", 'attributes');
                el_attr_table.setAttribute("border", '0');
        	el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
                el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
            	el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
            	el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
            	el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
	                el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
	                el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
			el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n=w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
	
			el_attr_name.setAttribute("type", "text");
	
			el_attr_name.setAttribute("class", "fm-field-choice");
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_checkbox')");
			
		var el_attr_value = document.createElement('input');
	
			el_attr_value.setAttribute("type", "text");
	
			el_attr_value.setAttribute("class", "fm-field-choice");
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_checkbox')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_checkbox')");
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
		
	}

	var t  = document.getElementById('edit_table');
	
	var hr = document.createElement('hr');
	var br = document.createElement('br');
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	
	edit_main_td1.appendChild(el_pagination_opt_label);
	edit_main_td1.appendChild(br4);
	edit_main_td1.appendChild(el_pagination_steps);
	edit_main_td1.appendChild(Steps);
	edit_main_td1.appendChild(br6);
	edit_main_td1.appendChild(el_pagination_percentage);
	edit_main_td1.appendChild(Percentage);
	edit_main_td1.appendChild(br5);
	edit_main_td1.appendChild(el_pagination_none);
	edit_main_td1.appendChild(No_Context);
	edit_main_td1.setAttribute("colspan", "2");
	
	edit_main_td3.appendChild(el_show_title_label);
	edit_main_td3_1.appendChild(el_show_title_input);
	
	edit_main_td4.appendChild(el_show_numbers_label);
	edit_main_td4_1.appendChild(el_show_numbers_input);
/*	edit_main_td2.appendChild(el_attr_label);
	edit_main_td2.appendChild(el_attr_add);
	edit_main_td2.appendChild(br3);
	edit_main_td2.appendChild(el_attr_table);*/
	
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr2.appendChild(edit_main_td2_1);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr6.appendChild(edit_main_td6);

	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr6);
//	edit_main_table.appendChild(edit_main_tr2);

	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	
//show table

    var div = document.createElement('div');
       	div.setAttribute("id", "main_div");
//tbody sarqac
		
		
	var table = document.createElement('table');
		table.setAttribute("id", "_elemet_tableform_id_temp");
		table.setAttribute("width", "90%");
	
    var tr = document.createElement('tr');
	
      	var td2 = document.createElement('td');
        	td2.setAttribute("valign", 'top');
         	td2.setAttribute("align", 'left');
           	td2.setAttribute("id", "_element_sectionform_id_temp");
			td2.setAttribute("width", "100%");

      	var br1 = document.createElement('br');
      	var br2 = document.createElement('br');
     	var br3 = document.createElement('br');
      	var br4 = document.createElement('br');
	//	table_little -@ sarqaca tbody table_little darela table_little_t
			
		var pages_div = document.createElement('div');
				pages_div.setAttribute("align","left");
				pages_div.setAttribute("id","pages_div");
				pages_div.style.width='100%';
				pages_div.innerHTML="";
		
		
		var numbers_div = document.createElement('div');
				numbers_div.setAttribute("align","center");
				numbers_div.setAttribute("id","numbers_div");
				numbers_div.style.width='100%';
				numbers_div.style.paddingTop='100px';
				numbers_div.innerHTML="";
		
		
				
		td2.appendChild(pages_div);
		td2.appendChild(numbers_div);
      	var main_td  = document.getElementById('show_table');
	
      
      	tr.appendChild(td2);
      	table.appendChild(tr);
      

      	div.appendChild(table);
      	div.appendChild(br1);
      	main_td.appendChild(div);
		
	if(w_type=='steps')
		make_page_steps(w_pages);
	else
		if(w_type=='percentage')
			make_page_percentage(w_pages);
		else
			make_page_none(w_pages);
			
	if(w_show_numbers)
		show_numbers_pagebreak();
		


//refresh_attr(i, 'type_checkbox');
}

function set_page_title(title, id) {
  title = title.replace(/(<([^>]+)>)/ig, "");
	document.getElementById("form_id_tempform_view"+id).setAttribute('page_title',title);
	show_title_pagebreak();
}

function show_numbers_pagebreak()
{
	document.getElementById("numbers_div").innerHTML="";
	if(document.getElementById("el_show_numbers_input").checked)
	{
		k=0;
		for(j=1; j<=form_view_max; j++)
		{
			if(document.getElementById('form_id_tempform_view'+j))
			{
				k++;		
				if(j==form_view)
					page_number=k;
			}
		}
		
		var cur = document.createElement('span');
			cur.setAttribute("class", "page_numbersform_id_temp");
			cur.innerHTML=page_number+'/'+k;
			
		document.getElementById("numbers_div").appendChild(cur);
	}
}

function refresh_page_numbers()
{
	k=0;
	if(document.getElementById('pages').getAttribute('show_numbers')=='true')
		for(j=1; j<=form_view_max; j++)
		{
			if(document.getElementById('page_numbersform_id_temp'+j))
			{
				k++;		
			}
		}
		
	cur_num=0;
	
		for(j=1; j<=form_view_max; j++)
		{
			if(document.getElementById('page_numbersform_id_temp'+j))
			{
				cur_num++;		
		
				document.getElementById("page_numbersform_id_temp"+j).innerHTML='';
				
				if(document.getElementById('pages').getAttribute('show_numbers')=='true')
				{
					var cur = document.createElement('span');
						cur.setAttribute("class", "page_numbersform_id_temp");
						cur.innerHTML=cur_num+'/'+k;
						
					document.getElementById("page_numbersform_id_temp"+j).appendChild(cur);
				}
			}
		}

}

function pagination_type(type)
{
	document.getElementById("pages_div").innerHTML="";
	w_pages=[];	
	k=0;
	for(j=1; j<=form_view_max; j++)
	{
		if(document.getElementById('form_id_tempform_view'+j))
		{
			k++;
			if(document.getElementById('form_id_tempform_view'+j).getAttribute('page_title'))
				w_pages[j]=document.getElementById('form_id_tempform_view'+j).getAttribute('page_title');
			else
				w_pages[j]="none";
		}
		
	}	


	if(type=='steps')
		make_page_steps(w_pages);
	else
		if(type=='percentage')
			make_page_percentage(w_pages);
		else
			make_page_none();
			

}

function show_title_pagebreak()
{
	document.getElementById("pages_div").innerHTML="";

if(document.getElementById("el_pagination_steps").checked)
	pagination_type('steps');
else
	if(document.getElementById("el_pagination_percentage").checked)
		pagination_type('percentage');
}
function make_page_steps(w_pages)
{
	document.getElementById("pages_div").innerHTML="";
	show_title=document.getElementById('el_show_title_input').checked;
	k=0;
	for(j=1; j<=form_view_max; j++)
	{	
		if(w_pages[j])
			{
			k++;
			if(w_pages[j]=="none")	
				w_pages[j]='';	
			page_number = document.createElement('span');
			
			if(j==form_view)
				page_number.setAttribute('class',"page_active");
			else
				page_number.setAttribute('class',"page_deactive");
			if(show_title)
			{
				page_number.innerHTML=w_pages[j];
			}
			else
				page_number.innerHTML=k;
			
			document.getElementById("pages_div").appendChild(page_number);
		}
	}
	
}

function make_page_percentage(w_pages)
{
	document.getElementById("pages_div").innerHTML="";
	show_title=document.getElementById('el_show_title_input').checked;
	
    var div_parent = document.createElement('div');
       	div_parent.setAttribute("class", "page_percentage_deactive");

    var div = document.createElement('div');
       	div.setAttribute("id", "div_percentage");
       	div.setAttribute("class", "page_percentage_active");
		
	var b = document.createElement('b');

	div.appendChild(b);
	
	k=0;
	cur_page_title='';
	for(j=1; j<=form_view_max; j++)
	{	
		if(w_pages[j])
			{
			k++;
				
			if(w_pages[j]=="none")	
				w_pages[j]='';	
			if(j==form_view)
			{
				if(show_title)
				{ 
					var cur_page_title = document.createElement('span');
					if(k==1)
						cur_page_title.style.paddingLeft="30px";
					else
						cur_page_title.style.paddingLeft="5px";
						cur_page_title.innerHTML=w_pages[j];
				}
				page_number=k;

			}
		}
	}
	b.innerHTML=Math.round(((page_number-1)/k)*100)+'%';
	div.style.width=((page_number-1)/k)*100+'%';
	div_parent.appendChild(div);
	if(cur_page_title)
		div_parent.appendChild(cur_page_title);
	document.getElementById("pages_div").appendChild(div_parent);

	
}
function make_page_none()
{
	document.getElementById("pages_div").innerHTML="";
}


function type_page_break(i,w_page_title, w_title , w_type , w_class, w_check, w_attr_name, w_attr_value) {
	var pos = document.getElementsByName("el_pos");
		pos[0].setAttribute("disabled", "disabled");
		pos[1].setAttribute("disabled", "disabled");
		pos[2].setAttribute("disabled", "disabled");
		
	var sel_el_pos = document.getElementById("sel_el_pos");
		sel_el_pos.setAttribute("disabled", "disabled");

	document.getElementById("element_type").value="type_page_break";
	delete_last_child();
	
	var edit_div = document.createElement('div');
		edit_div.setAttribute("id", "edit_div");
	
	var edit_main_table  = document.createElement('table');
		edit_main_table.setAttribute("id", "edit_main_table");
		edit_main_table.setAttribute("cellpadding", "3");
		edit_main_table.setAttribute("cellspacing", "0");
		
	var edit_main_tr1  = document.createElement('tr');
	var edit_main_tr2  = document.createElement('tr');
	var edit_main_tr3  = document.createElement('tr');
	var edit_main_tr4  = document.createElement('tr');
	var edit_main_tr5  = document.createElement('tr');
	var edit_main_tr6  = document.createElement('tr');
	var edit_main_tr7  = document.createElement('tr');
	var edit_main_tr8  = document.createElement('tr');
	var edit_main_tr9  = document.createElement('tr');
	var edit_main_tr10 = document.createElement('tr');
	var edit_main_tr11  = document.createElement('tr');
	
	var edit_main_td1 = document.createElement('td');
	var edit_main_td1_1 = document.createElement('td');
	var edit_main_td2 = document.createElement('td');
	var edit_main_td2_1 = document.createElement('td');
	var edit_main_td3 = document.createElement('td');
	var edit_main_td3_1 = document.createElement('td');
	var edit_main_td4 = document.createElement('td');
	var edit_main_td4_1 = document.createElement('td');
	var edit_main_td5 = document.createElement('td');
	var edit_main_td5_1 = document.createElement('td');
	var edit_main_td6 = document.createElement('td');
	var edit_main_td6_1 = document.createElement('td');
	var edit_main_td7 = document.createElement('td');
	var edit_main_td7_1 = document.createElement('td');
	var edit_main_td8 = document.createElement('td');
	var edit_main_td8_1 = document.createElement('td');
	var edit_main_td9 = document.createElement('td');
	var edit_main_td9_1 = document.createElement('td');
	var edit_main_td10 = document.createElement('td');
	var edit_main_td10_1 = document.createElement('td');
	var edit_main_td11 = document.createElement('td');
	var edit_main_td11_1 = document.createElement('td');
		  
	var el_page_title_label = document.createElement('label');
		el_page_title_label.setAttribute("class", "fm-field-label");
		el_page_title_label.setAttribute("for", "el_page_title_input");
		el_page_title_label.innerHTML = "Page Title";
		
	var el_page_title_input = document.createElement('input');
		el_page_title_input.setAttribute("id", "el_page_title_input");
		el_page_title_input.setAttribute("type", "text");
		el_page_title_input.setAttribute("name", "el_page_title_input");
		el_page_title_input.setAttribute("value", w_page_title);
		el_page_title_input.setAttribute("onKeyup", "pagebreak_title_change(this.value,'"+i+"')");
		  	  
	var el_type_next_label = document.createElement('label');
		el_type_next_label.setAttribute("class", "fm-field-label");
		el_type_next_label.setAttribute("for", "el_type_next_text");
		el_type_next_label.innerHTML = "Next Type";
		
	var el_type_next_text = document.createElement('input');
		el_type_next_text.setAttribute("id", "el_type_next_text");
		el_type_next_text.setAttribute("type", "radio");
		el_type_next_text.setAttribute("name", "el_type_next");
		el_type_next_text.setAttribute("value", "text");
		el_type_next_text.setAttribute("onclick", "pagebreak_type_change('next','text')");
		
	var el_label_text_next = document.createElement('label');
		el_label_text_next.setAttribute("for", "el_type_next_text");
        el_label_text_next.innerHTML = "Text";	

	var el_type_next_img = document.createElement('input');
		el_type_next_img.setAttribute("id", "el_type_next_img");
		el_type_next_img.setAttribute("type", "radio");
		el_type_next_img.setAttribute("name", "el_type_next");
		el_type_next_img.setAttribute("value", "img");
		el_type_next_img.setAttribute("onclick", "pagebreak_type_change('next','img')");
		
	var el_label_image_next = document.createElement('label');
		el_label_image_next.setAttribute("for", "el_type_next_img");
        el_label_image_next.innerHTML = "Image";		

	if(w_type[0] == 'text')
		el_type_next_text.setAttribute("checked","checked");
	else
		el_type_next_img.setAttribute("checked","checked");
				
	var el_title_next_label = document.createElement('label');
		el_title_next_label.setAttribute("class", "fm-field-label");
		el_title_next_label.setAttribute("for", "el_title_next");
		el_title_next_label.setAttribute("id", "next_label");
		el_title_next_label.innerHTML = "Next text name";
		
	var el_title_next = document.createElement('input');
		el_title_next.setAttribute("id", "el_title_next");
		el_title_next.setAttribute("type", "text");
		el_title_next.setAttribute("value", w_title[0]);
		el_title_next.setAttribute("onKeyUp", "change_pagebreak_label( this.value, 'next');");
		el_title_next.setAttribute("onChange", "change_pagebreak_label( this.value, 'next');");
			
	var el_style_next_label = document.createElement('label');
		el_style_next_label.setAttribute("class", "fm-field-label");
		el_style_next_label.setAttribute("for", "next_element_style");
		el_style_next_label.innerHTML = "Next class name";
	
	var el_style_next_textarea = document.createElement('input');
		el_style_next_textarea.setAttribute("id", "next_element_style");
		el_style_next_textarea.setAttribute("type", "text");
		el_style_next_textarea.setAttribute("value", w_class[0]);
		el_style_next_textarea.setAttribute("onChange", "change_pagebreak_class(this.value, 'next')");

	var el_check_next_label = document.createElement('label');
		el_check_next_label.setAttribute("class", "fm-field-label");
		el_check_next_label.setAttribute("for", "el_check_next_input");
		el_check_next_label.innerHTML = "Check the required fields";
		
	var el_check_next_input = document.createElement('input');
		el_check_next_input.setAttribute("id", "el_check_next_input");
		el_check_next_input.setAttribute("type", "checkbox");
		el_check_next_input.setAttribute("onClick", "set_checkable('next');");
			
	if(w_check[0] == "true")
		el_check_next_input.setAttribute("checked","checked");
				
	var el_type_previous_label = document.createElement('label');
		el_type_previous_label.setAttribute("class", "fm-field-label");
		el_type_previous_label.setAttribute("for", "el_type_previous_text");
		el_type_previous_label.innerHTML = "Previous Type";
			
	var el_type_previous_text = document.createElement('input');
		el_type_previous_text.setAttribute("id", "el_type_previous_text");
		el_type_previous_text.setAttribute("type", "radio");
		el_type_previous_text.setAttribute("name", "el_type_previous");
		el_type_previous_text.setAttribute("value", "text");
		el_type_previous_text.setAttribute("onclick", "pagebreak_type_change('previous','text')");
		
	var el_label_text_previous = document.createElement('label');
		el_label_text_previous.setAttribute("for", "el_type_previous_text");
        el_label_text_previous.innerHTML = "Text";	
		
	var el_type_previous_img = document.createElement('input');
		el_type_previous_img.setAttribute("id", "el_type_previous_img");
		el_type_previous_img.setAttribute("type", "radio");
		el_type_previous_img.setAttribute("name", "el_type_previous");
		el_type_previous_img.setAttribute("value", "img");
		el_type_previous_img.setAttribute("onclick", "pagebreak_type_change('previous','img')");
		
	var el_label_image_previous = document.createElement('label');
		el_label_image_previous.setAttribute("for", "el_type_previous_img");
        el_label_image_previous.innerHTML = "Image";	

	if(w_type[1] == 'text')
		el_type_previous_text.setAttribute("checked","checked");
	else
		el_type_previous_img.setAttribute("checked","checked");
				
	var el_title_previous_label = document.createElement('label');
		el_title_previous_label.setAttribute("class", "fm-field-label");
		el_title_previous_label.setAttribute("id", "previous_label");
		el_title_previous_label.innerHTML = "Previous text name";
		
	var el_title_previous = document.createElement('input');
		el_title_previous.setAttribute("id", "el_title_previous");
		el_title_previous.setAttribute("type", "text");
		el_title_previous.setAttribute("value", w_title[1]);
		el_title_previous.setAttribute("onKeyUp", "change_pagebreak_label( this.value, 'previous');");
		el_title_previous.setAttribute("onChange", "change_pagebreak_label( this.value, 'previous');");
			
	var el_style_previous_label = document.createElement('label');
		el_style_previous_label.setAttribute("class", "fm-field-label");
		el_style_previous_label.setAttribute("for", "previous_element_style");
		el_style_previous_label.innerHTML = "Previous class name";
	
	var el_style_previous_textarea = document.createElement('input');
		el_style_previous_textarea.setAttribute("id", "previous_element_style");
		el_style_previous_textarea.setAttribute("type", "text");
		el_style_previous_textarea.setAttribute("value", w_class[1]);
		el_style_previous_textarea.setAttribute("onChange", "change_pagebreak_class(this.value, 'previous')");

	var el_check_previous_label = document.createElement('label');
		el_check_previous_label.setAttribute("class", "fm-field-label");
		el_check_previous_label.setAttribute("for", "el_check_previous_input");
		el_check_previous_label.innerHTML = "Check the required fields";
		
	var el_check_previous_input = document.createElement('input');
		el_check_previous_input.setAttribute("id", "el_check_previous_input");
		el_check_previous_input.setAttribute("type", "checkbox");
		el_check_previous_input.setAttribute("onClick", "set_checkable('previous');");
			
	if(w_check[1] == "true")
		el_check_previous_input.setAttribute("checked","checked");
	
	var el_attr_label = document.createElement('label');
		el_attr_label.setAttribute("class", "fm-field-label");       
		el_attr_label.innerHTML = "Additional Attributes";
	var el_attr_add = document.createElement('img');     
		el_attr_add.setAttribute("src", plugin_url + '/images/add.png?ver=1.8.0');
		el_attr_add.style.cssText = 'cursor:pointer; margin-left:68px';
		el_attr_add.setAttribute("title", 'add');
		el_attr_add.setAttribute("onClick", "add_attr( 'type_checkbox')");

	var el_attr_table = document.createElement('table');
		el_attr_table.setAttribute("id", 'attributes');
		el_attr_table.setAttribute("border", '0');
		el_attr_table.style.cssText = 'margin-left:0px';
	var el_attr_tr_label = document.createElement('tr');
		el_attr_tr_label.setAttribute("idi", '0');
	var el_attr_td_name_label = document.createElement('th');
		el_attr_td_name_label.style.cssText = 'width:100px';
	var el_attr_td_value_label = document.createElement('th');
		el_attr_td_value_label.style.cssText = 'width:100px';
	var el_attr_td_X_label = document.createElement('th');
		el_attr_td_X_label.style.cssText = 'width:10px';
	var el_attr_name_label = document.createElement('label');
		el_attr_name_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_name_label.innerHTML = "Name";
			
	var el_attr_value_label = document.createElement('label');
		el_attr_value_label.style.cssText ="color:#000; font-weight:bold; font-size: 11px";
		el_attr_value_label.innerHTML = "Value";
			
	el_attr_table.appendChild(el_attr_tr_label);
	el_attr_tr_label.appendChild(el_attr_td_name_label);
	el_attr_tr_label.appendChild(el_attr_td_value_label);
	el_attr_tr_label.appendChild(el_attr_td_X_label);
	el_attr_td_name_label.appendChild(el_attr_name_label);
	el_attr_td_value_label.appendChild(el_attr_value_label);
	
	n = w_attr_name.length;
	for(j=1; j<=n; j++)
	{	
		var el_attr_tr = document.createElement('tr');
			el_attr_tr.setAttribute("id", "attr_row_"+j);
			el_attr_tr.setAttribute("idi", j);
		var el_attr_td_name = document.createElement('td');
			el_attr_td_name.style.cssText = 'width:100px';
		var el_attr_td_value = document.createElement('td');
			el_attr_td_value.style.cssText = 'width:100px';
		
		var el_attr_td_X = document.createElement('td');
		var el_attr_name = document.createElement('input');
			el_attr_name.setAttribute("type", "text");
			el_attr_name.style.cssText = "width:100px";
			el_attr_name.setAttribute("value", w_attr_name[j-1]);
			el_attr_name.setAttribute("id", "attr_name"+j);
			el_attr_name.setAttribute("onChange", "change_attribute_name("+i+", this, 'type_checkbox')");
			
		var el_attr_value = document.createElement('input');
			el_attr_value.setAttribute("type", "text");
			el_attr_value.style.cssText = "width:100px";
			el_attr_value.setAttribute("value", w_attr_value[j-1]);
			el_attr_value.setAttribute("id", "attr_value"+j);
			el_attr_value.setAttribute("onChange", "change_attribute_value("+i+", "+j+", 'type_checkbox')");
	
		var el_attr_remove = document.createElement('img');
			el_attr_remove.setAttribute("id", "el_choices"+j+"_remove");
			el_attr_remove.setAttribute("src", plugin_url + '/images/delete.png?ver=1.8.0');
			el_attr_remove.style.cssText = 'cursor:pointer; vertical-align:middle; margin:2px';
			el_attr_remove.setAttribute("onClick", "remove_attr("+j+", "+i+", 'type_checkbox')");
			
		el_attr_table.appendChild(el_attr_tr);
		el_attr_tr.appendChild(el_attr_td_name);
		el_attr_tr.appendChild(el_attr_td_value);
		el_attr_tr.appendChild(el_attr_td_X);
		el_attr_td_name.appendChild(el_attr_name);
		el_attr_td_value.appendChild(el_attr_value);
		el_attr_td_X.appendChild(el_attr_remove);
	}

	var t  = document.getElementById('edit_table');
	var br = document.createElement('br');
	var br1 = document.createElement('br');

	edit_main_td1.appendChild(el_page_title_label);
	edit_main_td1_1.appendChild(el_page_title_input);
	
	edit_main_td3.appendChild(el_type_next_label);
	edit_main_td3_1.appendChild(el_type_next_text);
	edit_main_td3_1.appendChild(el_label_text_next);
	edit_main_td3_1.appendChild(el_type_next_img);
	edit_main_td3_1.appendChild(el_label_image_next);
	
	edit_main_td7.appendChild(el_title_next_label);
	edit_main_td7_1.appendChild(el_title_next);
	
	edit_main_td8.appendChild(el_style_next_label);
	edit_main_td8_1.appendChild(el_style_next_textarea);
	
	edit_main_td9.appendChild(el_check_next_label);
	edit_main_td9_1.appendChild(el_check_next_input);

	edit_main_td4.appendChild(el_type_previous_label);
	edit_main_td4_1.appendChild(el_type_previous_text);
	edit_main_td4_1.appendChild(el_label_text_previous);
	edit_main_td4_1.appendChild(el_type_previous_img);
	edit_main_td4_1.appendChild(el_label_image_previous);
	
	edit_main_td5.appendChild(el_title_previous_label);
	edit_main_td5_1.appendChild(el_title_previous);
	
	edit_main_td10.appendChild(el_style_previous_label);
	edit_main_td10_1.appendChild(el_style_previous_textarea);

	edit_main_td11.appendChild(el_check_previous_label);
	edit_main_td11_1.appendChild(el_check_previous_input);
	
	
	
	edit_main_td2.appendChild(el_attr_label);
	edit_main_td2.appendChild(el_attr_add);
	edit_main_td2.appendChild(br);
	edit_main_td2.appendChild(el_attr_table);
	edit_main_td2.setAttribute("colspan", "2");
	
	edit_main_tr1.appendChild(edit_main_td1);
	edit_main_tr1.appendChild(edit_main_td1_1);
	edit_main_tr2.appendChild(edit_main_td2);
	edit_main_tr3.appendChild(edit_main_td3);
	edit_main_tr3.appendChild(edit_main_td3_1);
	edit_main_tr7.appendChild(edit_main_td7);
	edit_main_tr7.appendChild(edit_main_td7_1);
	edit_main_tr8.appendChild(edit_main_td8);
	edit_main_tr8.appendChild(edit_main_td8_1);
	edit_main_tr9.appendChild(edit_main_td9);
	edit_main_tr9.appendChild(edit_main_td9_1);
	edit_main_tr4.appendChild(edit_main_td4);
	edit_main_tr4.appendChild(edit_main_td4_1);
	edit_main_tr5.appendChild(edit_main_td5);
	edit_main_tr5.appendChild(edit_main_td5_1);
	edit_main_tr10.appendChild(edit_main_td10);
	edit_main_tr10.appendChild(edit_main_td10_1);
	edit_main_tr11.appendChild(edit_main_td11);
	edit_main_tr11.appendChild(edit_main_td11_1);
	edit_main_tr6.appendChild(edit_main_td6);
	edit_main_table.appendChild(edit_main_tr1);
	edit_main_table.appendChild(edit_main_tr3);
	edit_main_table.appendChild(edit_main_tr7);
	edit_main_table.appendChild(edit_main_tr8);
	edit_main_table.appendChild(edit_main_tr9);
	edit_main_table.appendChild(edit_main_tr4);
	edit_main_table.appendChild(edit_main_tr5);
	edit_main_table.appendChild(edit_main_tr10);
	edit_main_table.appendChild(edit_main_tr11);
	edit_main_table.appendChild(edit_main_tr2);
	edit_div.appendChild(edit_main_table);
	
	t.appendChild(edit_div);
	
    var div = document.createElement('div');
       	div.setAttribute("id", "main_div");

	var div_field = document.createElement('div');
		div_field.setAttribute("id", i+"_elemet_tableform_id_temp");
						
	var div_label = document.createElement('div');
		div_label.setAttribute("align", 'left');
		div_label.style.display="table-cell";
		div_label.setAttribute("id", i+"_label_sectionform_id_temp");
		
	var div_element = document.createElement('div');
		div_element.setAttribute("align", 'left');
		div_element.style.display="table-cell";
		div_element.setAttribute("id", i+"_element_sectionform_id_temp");
	
	var adding_next = document.createElement('div');
		adding_next.setAttribute("align","right");
		adding_next.setAttribute("id","_element_section_next");
	
	var adding_next_button =  make_pagebreak_button('next',w_title[0],w_type[0], w_class[0] , 0)	;
			
	adding_next.appendChild(adding_next_button);
	
	var adding_previous = document.createElement('div');
		adding_previous.setAttribute("align","left");
		adding_previous.setAttribute("id","_element_section_previous");
	    
	var adding_previous_button =  make_pagebreak_button('previous',w_title[1],w_type[1], w_class[1] , 0);
				
	adding_previous.appendChild(adding_previous_button);
		
	var div_fields = document.createElement('div');
		div_fields.setAttribute("align","center");
		div_fields.setAttribute("style","border:2px solid blue;padding:20px; margin:20px");
		div_fields.innerHTM = 'FIELDS';
		
	var div_page_title = document.createElement('div');
		div_page_title.innerHTML = w_page_title+'<br/><br/>';
		div_page_title.setAttribute("id", "div_page_title");
		div_page_title.setAttribute("align","center");
	
	var div_between = document.createElement('div');
		div_between.setAttribute("page_title", w_page_title);
		div_between.setAttribute("next_type", w_type[0]);
		div_between.setAttribute("next_title", w_title[0]);
		div_between.setAttribute("next_class", w_class[0]);
		div_between.setAttribute("next_checkable", w_check[0]);
		div_between.setAttribute("previous_type", w_type[1]);
		div_between.setAttribute("previous_title", w_title[1]);
		div_between.setAttribute("previous_class", w_class[1]);
		div_between.setAttribute("previous_checkable", w_check[1]);
		div_between.setAttribute("align","center");
		div_between.setAttribute("id", "_div_between");
		div_between.innerHTML = "--------------------------------------<br />P A G E B R E A K<br />--------------------------------------"
				
	div_element.appendChild(div_page_title);
	div_element.appendChild(div_fields);
	div_element.appendChild(adding_next);
	div_element.appendChild(div_between);
	div_element.appendChild(adding_previous);
		
	var main_td  = document.getElementById('show_table');

	div_field.appendChild(div_element);
	div.appendChild(div_field);
	div.appendChild(br1);
	main_td.appendChild(div);

	refresh_attr(i, 'type_page_break');
}

function set_checkable(type)
{
	document.getElementById("_div_between").setAttribute(type+'_checkable',document.getElementById("el_check_"+type+"_input").checked);
}

function pagebreak_title_change(val) {
  val = val.replace(/(<([^>]+)>)/ig, "");
	document.getElementById("_div_between").setAttribute('page_title',val);
	document.getElementById("div_page_title").innerHTML=val+'<br/><br/>';
}

function change_pagebreak_class(val, type)
{
	document.getElementById("page_"+type+'_0').setAttribute('class', val);
	document.getElementById("_div_between").setAttribute(type+'_class',val);
}

function change_pagebreak_label(val, type)
{
button_type=document.getElementById("_div_between").getAttribute(type+'_type');
if(button_type!="img")
{
	document.getElementById("page_"+type+'_0').value=val;
	document.getElementById("page_"+type+'_0').innerHTML=val;
}
else
{
	document.getElementById("page_"+type+'_0').src=val;
}
	document.getElementById("_div_between").setAttribute(type+'_title',val);

}

function pagebreak_type_change( pagebreak_type, button_type)
{
document.getElementById("_div_between").setAttribute(pagebreak_type+'_type',button_type);
	switch(button_type)
	{
		case 'button': 
		{ 
			document.getElementById("_div_between").setAttribute(pagebreak_type+'_title', pagebreak_type);
			
			var el_title_label = document.createElement('label');
				el_title_label.setAttribute("class", "fm-field-label");
				el_title_label.setAttribute("for", "el_title_"+pagebreak_type);
				el_title_label.setAttribute('id', pagebreak_type+"_label");
				el_title_label.setAttribute('type', "button");
				el_title_label.innerHTML = pagebreak_type[0].toUpperCase() + pagebreak_type.slice(1)+" "+ button_type+" name";
			
			document.getElementById(pagebreak_type+"_label").parentNode.replaceChild(el_title_label, document.getElementById(pagebreak_type+"_label"));
			
			document.getElementById("el_title_"+pagebreak_type).value=pagebreak_type;
			
			var element = document.createElement('button');
				element.setAttribute('id', "page_"+pagebreak_type+'_0');
				element.setAttribute('class', document.getElementById("_div_between").getAttribute(pagebreak_type+'_class'));
				element.style.cursor="pointer";
				element.innerHTML=pagebreak_type;
				
			
			document.getElementById("_element_section_"+pagebreak_type).replaceChild(element, document.getElementById("page_"+pagebreak_type+'_0'));
			
			break;
		}
		case 'text': {	

			document.getElementById("_div_between").setAttribute(pagebreak_type+'_title', pagebreak_type);
		
			var el_title_label = document.createElement('label');
				el_title_label.setAttribute("class", "fm-field-label");
				el_title_label.setAttribute("for", "el_title_"+pagebreak_type);
				el_title_label.setAttribute('id', pagebreak_type+"_label");
				el_title_label.innerHTML = pagebreak_type[0].toUpperCase() + pagebreak_type.slice(1)+" "+ button_type+" name";

			document.getElementById(pagebreak_type+"_label").parentNode.replaceChild(el_title_label, document.getElementById(pagebreak_type+"_label"));
			
			document.getElementById("el_title_"+pagebreak_type).value=pagebreak_type;
			
			var element = document.createElement('span');
				element.setAttribute('id', "page_"+pagebreak_type+'_0');
				element.setAttribute('class', document.getElementById("_div_between").getAttribute(pagebreak_type+'_class'));
				element.style.cursor="pointer";
				element.innerHTML=pagebreak_type;

			document.getElementById("_element_section_"+pagebreak_type).replaceChild(element, document.getElementById("page_"+pagebreak_type+'_0'));
			
			  break;
		}
		case 'img':{ 			
		
		document.getElementById("_div_between").setAttribute(pagebreak_type+'_title', plugin_url + '/images/'+pagebreak_type+'.png');
			
		var el_title_label = document.createElement('label');
				el_title_label.setAttribute("class", "fm-field-label");
				el_title_label.setAttribute("for", "el_title_"+pagebreak_type);
				el_title_label.setAttribute('id', pagebreak_type+"_label");
				el_title_label.innerHTML = pagebreak_type[0].toUpperCase() + pagebreak_type.slice(1)+" "+ button_type+" src";

			document.getElementById(pagebreak_type+"_label").parentNode.replaceChild(el_title_label, document.getElementById(pagebreak_type+"_label"));
			
			document.getElementById("el_title_"+pagebreak_type).value=plugin_url + '/images/'+pagebreak_type+'.png';
			
			var element = document.createElement('img');
				element.setAttribute('id', "page_"+pagebreak_type+'_0');
				element.setAttribute('class', document.getElementById("_div_between").getAttribute(pagebreak_type+'_class'));
				element.style.cursor="pointer";
				element.src=plugin_url + '/images/'+pagebreak_type+'.png';
				
			document.getElementById("_element_section_"+pagebreak_type).replaceChild(element, document.getElementById("page_"+pagebreak_type+'_0'));
			
			  break;
		}

}
}

function addRow(b) 
{

	if(document.getElementById('show_table').innerHTML)
	{
		document.getElementById('show_table').innerHTML="";
		document.getElementById('edit_table').innerHTML="";
	}
	
	alltypes=Array('customHTML','text','checkbox','radio','time_and_date','select','file_upload','captcha','map','button','page_break','section_break','paypal','survey');
	for(x=0; x<14;x++)
	{
		document.getElementById('img_'+alltypes[x]).parentNode.style.backgroundColor='';
	}
	
		document.getElementById('img_'+b).parentNode.style.backgroundColor='#fff';
	/*	document.getElementById('img_'+b).style.width='90px';*/
	
	switch(b)
	{
		case 'customHTML': { el_editor();  break;}
		case 'text': { el_text();  break;}
		case 'checkbox':{ el_checkbox(); break;}
		case 'radio':{ el_radio(); break;}
		case 'time_and_date':{ el_time_and_date(); break; }

		case 'select':{ el_select(); break; }
		case 'file_upload':{ el_file_upload(); break; }
		case 'captcha':{ el_captcha(); break; }
		case 'map':{ el_map(); break; }
		
		case 'button':{ el_button(); break; }
		case 'page_break':{ el_page_break(); break; }
		case 'section_break':{ el_section_break(); break; }
		case 'paypal':{ el_paypal(); break; }
		case 'survey':{ el_survey(); break; }
	}
	
	var pos=document.getElementsByName("el_pos");
			pos[0].checked="checked";

}

function el_survey()
{
	if(document.getElementById("editing_id").value)
		new_id=document.getElementById("editing_id").value;
	else
		new_id=gen;
		
	var td  = document.getElementById('edit_table');
	var br  = document.createElement('br');
	var el_type_label = document.createElement('label');
		el_type_label.setAttribute("class", "fm-field-label");
		el_type_label.style.cssText = "margin-left:16px";
		el_type_label.innerHTML = "Field type";
	
	td.appendChild(br);
	td.appendChild(el_type_label);

	var el_type_star_rating = document.createElement('input');
		el_type_star_rating.setAttribute("id", "el_type_star_rating");
		el_type_star_rating.setAttribute("type", "radio");
		el_type_star_rating.style.cssText = "margin-left:15px";
		el_type_star_rating.setAttribute("value", "star_rating");
		el_type_star_rating.setAttribute("name", "el_type");
		el_type_star_rating.setAttribute("onclick", "go_to_type_star_rating('"+new_id+"')");
		el_type_star_rating.setAttribute("checked", "checked");
		
	var el_type_label_star = document.createElement('label');	
		el_type_label_star.setAttribute("for", "el_type_star_rating");
		el_type_label_star.innerHTML = 'Star Rating';			
		
	var el_type_scale_rating = document.createElement('input');
		el_type_scale_rating.setAttribute("id", "el_type_scale_rating");
		el_type_scale_rating.setAttribute("type", "radio");
		el_type_scale_rating.style.cssText = "margin-left:15px";
		el_type_scale_rating.setAttribute("value", "scale_rating");
		el_type_scale_rating.setAttribute("name", "el_type");
		el_type_scale_rating.setAttribute("onclick", "go_to_type_scale_rating('"+new_id+"')");
		
	var el_type_label_scale = document.createElement('label');	
		el_type_label_scale.setAttribute("for", "el_type_scale_rating");
		el_type_label_scale.innerHTML = 'Scale Rating';				
		
	var el_type_spinner = document.createElement('input');
		el_type_spinner.setAttribute("id", "el_type_spinner");
		el_type_spinner.setAttribute("type", "radio");
		el_type_spinner.style.cssText = "margin-left:15px";
		el_type_spinner.setAttribute("value", "spinner");
		el_type_spinner.setAttribute("name", "el_type");
		el_type_spinner.setAttribute("onclick", "go_to_type_spinner('"+new_id+"')");
		
	var el_type_label_spinner = document.createElement('label');	
		el_type_label_spinner.setAttribute("for", "el_type_spinner");
		el_type_label_spinner.innerHTML = 'Spinner';				

	var el_type_slider = document.createElement('input');
		el_type_slider.setAttribute("id", "el_type_slider");
		el_type_slider.setAttribute("type", "radio");
		el_type_slider.style.cssText = "margin-left:15px";
		el_type_slider.setAttribute("value", "slider");
		el_type_slider.setAttribute("name", "el_type");
		el_type_slider.setAttribute("onclick", "go_to_type_slider('"+new_id+"')");
				
	var el_type_label_slider = document.createElement('label');	
		el_type_label_slider.setAttribute("for", "el_type_slider");
		el_type_label_slider.innerHTML = 'Slider';				
	
    var el_type_range = document.createElement('input');
		el_type_range.setAttribute("id", "el_type_range");
		el_type_range.setAttribute("type", "radio");
		el_type_range.style.cssText = "margin-left:15px";
		el_type_range.setAttribute("value", "range");
		el_type_range.setAttribute("name", "el_type");
		el_type_range.setAttribute("onclick", "go_to_type_range('"+new_id+"')");
		
	var el_type_label_range = document.createElement('label');	
		el_type_label_range.setAttribute("for", "el_type_range");
		el_type_label_range.innerHTML = 'Range';					
		
	var el_type_grading = document.createElement('input');
		el_type_grading.setAttribute("id", "el_type_grading");
		el_type_grading.setAttribute("type", "radio");
		el_type_grading.style.cssText = "margin-left:15px";
		el_type_grading.setAttribute("value", "grading");
		el_type_grading.setAttribute("name", "el_type");
		el_type_grading.setAttribute("onclick", "go_to_type_grading('"+new_id+"')");
		
	var el_type_label_grading = document.createElement('label');	
		el_type_label_grading.setAttribute("for", "el_type_grading");
		el_type_label_grading.innerHTML = 'Grading';					
	
	var el_type_matrix = document.createElement('input');
		el_type_matrix.setAttribute("id", "el_type_matrix");
		el_type_matrix.setAttribute("type", "radio");
		el_type_matrix.style.cssText = "margin-left:15px";
		el_type_matrix.setAttribute("value", "matrix");
		el_type_matrix.setAttribute("name", "el_type");
		el_type_matrix.setAttribute("onclick", "go_to_type_matrix('"+new_id+"')");
		
	var el_type_label_matrix = document.createElement('label');	
		el_type_label_matrix.setAttribute("for", "el_type_matrix");
		el_type_label_matrix.innerHTML = 'Matrix';				

	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	var br7 = document.createElement('br');

	td.appendChild(br1);
	td.appendChild(el_type_star_rating);
	td.appendChild(el_type_label_star);
	td.appendChild(br2);
	td.appendChild(el_type_scale_rating);
	td.appendChild(el_type_label_scale);
	td.appendChild(br3);
	td.appendChild(el_type_spinner);
	td.appendChild(el_type_label_spinner);
	td.appendChild(br4);
	td.appendChild(el_type_slider);
	td.appendChild(el_type_label_slider);
	td.appendChild(br5);
	td.appendChild(el_type_range);
	td.appendChild(el_type_label_range);
	td.appendChild(br6);
	td.appendChild(el_type_grading);
	td.appendChild(el_type_label_grading);
	td.appendChild(br7);
	td.appendChild(el_type_matrix);
	td.appendChild(el_type_label_matrix);
	
	
	var pos=document.getElementsByName("el_pos");
		pos[0].removeAttribute("disabled");
		pos[1].removeAttribute("disabled");
		pos[2].removeAttribute("disabled");
			
	var sel_el_pos=document.getElementById("sel_el_pos");
		sel_el_pos.removeAttribute("disabled", "disabled");
			
	go_to_type_star_rating(new_id);
	type_star_rating(new_id,'Star Rating:', '100', 'left', 'yellow', '5', 'no', 'wdform_star_rating',w_attr_name, w_attr_value);			
}

function go_to_type_star_rating(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	type_star_rating(new_id,'Star Rating:', '100', 'left', 'yellow', '5', 'no', 'wdform_star_rating', w_attr_name, w_attr_value);			
}


function go_to_type_scale_rating(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	w_mini_labels=['Worst', 'Best'];
	type_scale_rating(new_id,'Scale Rating:', '100', 'left', w_mini_labels, '5', 'no','wdform_scale_rating',w_attr_name, w_attr_value);			
}

function go_to_type_spinner(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
type_spinner(new_id,'Spinner:', '100', 'left', '50', '', '', '1', '', 'no','',w_attr_name, w_attr_value);			

}

function go_to_type_slider(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
type_slider(new_id,'Slider:', '100', 'left', '200', '0', '100', '0', 'no','',w_attr_name, w_attr_value);				
}

function go_to_type_range(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	w_mini_labels = ['From', 'To'];
type_range (new_id,'Range:', '100', 'left', '40', '1' , '', '', w_mini_labels, 'no','',w_attr_name, w_attr_value);			

}

function go_to_type_grading(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	w_items = ['item1','item2','item3'];

type_grading(new_id,'Grading:', '100', 'left', w_items, '100', 'no','wdform_grading',w_attr_name, w_attr_value);			

}

function go_to_type_matrix(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	
	w_rows = ['','row1','row2'];
	w_columns = ['','column1','column2'];
	type_matrix(new_id,'Matrix:', '100', 'left', 'radio', w_rows, w_columns, 'no','wdform_matrix',w_attr_name, w_attr_value, '100');				
}


function el_paypal()
{
	
if(document.getElementById("editing_id").value)
	new_id=document.getElementById("editing_id").value;
else
	new_id=gen;
	

//edit table
	var td  = document.getElementById('edit_table');
	//type select		
	var el_type_label = document.createElement('label');
	
	el_type_label.style.cssText = "color: #000; font-weight: bold; font-size: 13px";
	//el_type_label.setAttribute("style" , "color: #000; font-weight: bold; font-size: 13px", 0 );
	el_type_label.innerHTML = "<br />&nbsp;&nbsp;Field type";
	td.appendChild(el_type_label);

	var el_type_radio_text = document.createElement('input');
                el_type_radio_text.setAttribute("id", "el_type_radio_amount");
                el_type_radio_text.setAttribute("type", "radio");

				el_type_radio_text.style.cssText = "margin-left:15px";
                el_type_radio_text.setAttribute("name", "el_type");
                el_type_radio_text.setAttribute("onclick", "go_to_type_paypal_price('"+new_id+"')");
		el_type_radio_text.setAttribute("checked", "checked");
		
		var el_type_label_text = document.createElement('label');	
		el_type_label_text.setAttribute("for", "el_type_radio_amount");
		el_type_label_text.innerHTML = 'Amount (Price)';	
		
		
	var el_type_radio_password = document.createElement('input');
               el_type_radio_password.setAttribute("id", "el_type_radio_select");
                el_type_radio_password.setAttribute("type", "radio");
				el_type_radio_password.style.cssText = "margin-left:15px";
                el_type_radio_password.setAttribute("value", "password");
                el_type_radio_password.setAttribute("name", "el_type");
                el_type_radio_password.setAttribute("onclick", "go_to_type_paypal_select('"+new_id+"')");
				
	var el_type_label_select = document.createElement('label');	
		el_type_label_select.setAttribute("for", "el_type_radio_select");
		el_type_label_select.innerHTML = 'Select';	
				
	var el_type_radio_textarea = document.createElement('input');
                el_type_radio_textarea.setAttribute("id", "el_type_radio_checkbox");
                el_type_radio_textarea.setAttribute("type", "radio");
				el_type_radio_textarea.style.cssText = "margin-left:15px";
                el_type_radio_textarea.setAttribute("value", "textarea");
                el_type_radio_textarea.setAttribute("name", "el_type");
                el_type_radio_textarea.setAttribute("onclick", "go_to_type_paypal_checkbox('"+new_id+"')");
				
	var el_type_label_checkbox = document.createElement('label');	
		el_type_label_checkbox.setAttribute("for", "el_type_radio_checkbox");
		el_type_label_checkbox.innerHTML = 'Checkbox';				

		
	var el_type_radio_name = document.createElement('input');
		el_type_radio_name.setAttribute("id", "el_type_radio_radio"); 
		el_type_radio_name.setAttribute("type", "radio");	
		el_type_radio_name.style.cssText = "margin-left:15px";
		el_type_radio_name.setAttribute("value", "name"); 
		el_type_radio_name.setAttribute("name", "el_type");
		el_type_radio_name.setAttribute("onclick", "go_to_type_paypal_radio('"+new_id+"')");
		
	var el_type_label_radio = document.createElement('label');	
		el_type_label_radio.setAttribute("for", "el_type_radio_radio");
		el_type_label_radio.innerHTML = 'Radio';				
	
	var el_type_shipping_name = document.createElement('input');    
		el_type_shipping_name.setAttribute("id", "el_type_shipping_name"); 
		el_type_shipping_name.setAttribute("type", "radio");	
		el_type_shipping_name.style.cssText = "margin-left:15px";     
		el_type_shipping_name.setAttribute("value", "name");       
		el_type_shipping_name.setAttribute("name", "el_type");     
		el_type_shipping_name.setAttribute("onclick", "go_to_type_paypal_shipping('"+new_id+"')");
		
	var el_type_label_shipping = document.createElement('label');	
		el_type_label_shipping.setAttribute("for", "el_type_shipping_name");
		el_type_label_shipping.innerHTML = 'Shipping';		


	var el_type_total_name = document.createElement('input');    
		el_type_total_name.setAttribute("id", "el_type_total_name"); 
		el_type_total_name.setAttribute("type", "radio");	
		el_type_total_name.style.cssText = "margin-left:15px";     
		el_type_total_name.setAttribute("value", "name");       
		el_type_total_name.setAttribute("name", "el_type");     
		el_type_total_name.setAttribute("onclick", "go_to_type_paypal_total('"+new_id+"')");

	var el_type_label_total = document.createElement('label');	
		el_type_label_total.setAttribute("for", "el_type_total_name");
		el_type_label_total.innerHTML = 'Total';		

		var el_type_stripe_name = document.createElement('input');    
		el_type_stripe_name.setAttribute("id", "el_type_stripe_name"); 
		el_type_stripe_name.setAttribute("type", "radio");	
		el_type_stripe_name.style.cssText = "margin-left:15px";     
		el_type_stripe_name.setAttribute("value", "name");       
		el_type_stripe_name.setAttribute("name", "el_type");     
		el_type_stripe_name.setAttribute("onclick", "go_to_type_stripe('"+new_id+"')");
         
		if(document.getElementById('is_stripe') || is_addon_stripe_active == 0 || is_stripe_enabled == 0) {
      el_type_stripe_name.setAttribute("disabled", "disabled");
		}

	var el_type_label_stripe = document.createElement('label');	
		el_type_label_stripe.setAttribute("for", "el_type_stripe_name");
		el_type_label_stripe.innerHTML = 'Credit Card details (for Stripe)';
    el_type_label_stripe.setAttribute("onclick", "go_to_type_stripe('"+new_id+"')");
	
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	var br7 = document.createElement('br');
	var br8 = document.createElement('br');
	var br9 = document.createElement('br');
	var br10 = document.createElement('br');
	

	td.appendChild(br1);
	td.appendChild(el_type_radio_text);
	td.appendChild(el_type_label_text);
	td.appendChild(br2);
	td.appendChild(el_type_radio_password);
	td.appendChild(el_type_label_select);
	td.appendChild(br3);
	td.appendChild(el_type_radio_textarea);
	td.appendChild(el_type_label_checkbox);
	td.appendChild(br4);
	td.appendChild(el_type_radio_name);
	td.appendChild(el_type_label_radio);
	td.appendChild(br5);
	td.appendChild(el_type_shipping_name);
	td.appendChild(el_type_label_shipping);	
	td.appendChild(br6);	
	td.appendChild(el_type_total_name);
	td.appendChild(el_type_label_total);
  td.appendChild(br7);	
	td.appendChild(el_type_stripe_name);
	td.appendChild(el_type_label_stripe);
	
	var pos=document.getElementsByName("el_pos");
			pos[0].removeAttribute("disabled");
			pos[1].removeAttribute("disabled");
			pos[2].removeAttribute("disabled");
		
	var sel_el_pos=document.getElementById("sel_el_pos");
		sel_el_pos.removeAttribute("disabled", "disabled");

			
	go_to_type_paypal_price(new_id);
	
}

function go_to_type_paypal_price(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
 	w_first_val=['',''];
 	w_title=['',''];
	w_mini_labels=['Dollars','Cents'];
	type_paypal_price(new_id,'Amount:', '100', 'left', w_first_val, w_title, w_mini_labels, '100', 'no', 'no', '',w_attr_name, w_attr_value, '', '')
}

function go_to_type_paypal_select(new_id)
{

 	w_choices=[ "Select product", "product 1", "product 2"];
 	w_choices_price=[ "", "100", "200"];
 	w_choices_checked=["1", "0", "0"];
	w_choices_params=["", "", ""];
	w_choices_disabled=[true, false, false];
 	w_attr_name=[];
 	w_attr_value=[];
 	w_property=[];
 	w_property_values=[];
	
	type_paypal_select(new_id, 'Select Product:', '100', 'left', '200',w_choices, w_choices_price, w_choices_checked, 'no','no', '1', 'wdform_select',w_attr_name, w_attr_value, w_choices_disabled, w_property, w_property_values, w_choices_params);
}

function go_to_type_paypal_checkbox(new_id)
{
 	w_choices=[ "product 1", "product 2"];
 	w_choices_price=[ "100", "200"];
 	w_choices_checked=["0", "0"];
    w_choices_params=["", "", ""];
	
 	w_attr_name=[];
 	w_attr_value=[];
 	w_property=[];
 	w_property_values=[];
	
	type_paypal_checkbox(new_id,'Checkbox:', '100', 'left', 'left', 'ver', w_choices,w_choices_price, w_choices_checked, 'no', 'no', 'no','0', '',w_attr_name, w_attr_value, w_property, w_property_values, 'no','1', w_choices_params);
}

function go_to_type_paypal_radio(new_id)
{
 	w_choices=[ "product 1", "product 2"];  
	w_choices_price=[ "100", "200"];	
	w_choices_checked=["0", "0"];	
	w_choices_params=["", "", ""];
 	w_attr_name=[]; 
	w_attr_value=[]; 
	w_property=[];
 	w_property_values=[];	
		
	type_paypal_radio(new_id,'Radio:', '100', 'left', 'left', 'ver', w_choices, w_choices_price, w_choices_checked, 'no', 'no', 'no','0','',w_attr_name, w_attr_value,  w_property, w_property_values,'no', '1', w_choices_params);
}
	
function go_to_type_paypal_shipping(new_id){

 	w_choices=[ "type 1", "type 2"];

  	w_choices_price=[ "100", "200"];

	w_choices_checked=["0", "0"];
	w_choices_params=["", "", ""];

	w_attr_name=[];

 	w_attr_value=[];

 	w_property=[]; 

	w_property_values=[];	

	type_paypal_shipping(new_id,'Shipping:', '100', 'left', 'left', 'ver', w_choices, w_choices_price, w_choices_checked, 'no', 'no', 'no','0','',w_attr_name, w_attr_value,  w_property, w_property_values, w_choices_params);
	
}

function go_to_type_paypal_total(new_id){
 	
	type_paypal_total(new_id,'Total:', '100', 'left', '', '300');
	
}

function go_to_type_stripe(new_id){
  if (is_addon_stripe_active == 0) {
    alert('Please install "Form Maker Stripe Integration" add-on to use this feature.');
    return false;
  }
  if (is_stripe_enabled == 0) {
    alert('To use this feature, please go to Form Options > Payment Options and select "Stripe" as the Payment Method.');
    return false;
  }
  if (document.getElementById('is_stripe')) return false;
	type_stripe(new_id, '300', '130', 'left', '');
}

function el_section_break()
{
	if(document.getElementById("editing_id").value)
		new_id=document.getElementById("editing_id").value;
	else
		new_id=gen;
	

	var pos=document.getElementsByName("el_pos");
			pos[0].removeAttribute("disabled");
			pos[1].removeAttribute("disabled");
			pos[2].removeAttribute("disabled");
			
	var sel_el_pos=document.getElementById("sel_el_pos");
		sel_el_pos.removeAttribute("disabled", "disabled");
	
	type_section_break(new_id,"<div class='wdform-section-break-div' style='min-width: 300px; border-top:1px solid'></div>");
}



function el_button()
{
	
if(document.getElementById("editing_id").value)
	new_id=document.getElementById("editing_id").value;
else
	new_id=gen;
	


//edit table
	var td  = document.getElementById('edit_table');
	//type select		
	var el_type_label = document.createElement('label');
	
	el_type_label.style.cssText = "color: #000; font-weight: bold; font-size: 13px";
	el_type_label.innerHTML = "<br />&nbsp;&nbsp;Field type";
	td.appendChild(el_type_label);
	var el_type_radio_submit_reset = document.createElement('input');
				el_type_radio_submit_reset.setAttribute("id", "el_type_submit_reset");
                el_type_radio_submit_reset.setAttribute("type", "radio");
		el_type_radio_submit_reset.style.cssText = "margin-left:15px";
                el_type_radio_submit_reset.setAttribute("name", "el_type");
                el_type_radio_submit_reset.setAttribute("onclick", "go_to_type_submit_reset('"+new_id+"')");
		el_type_radio_submit_reset.setAttribute("checked", "checked");
		
	var el_type_label_submit_reset = document.createElement('label');	
		el_type_label_submit_reset.setAttribute("for", "el_type_submit_reset");
		el_type_label_submit_reset.innerHTML = 'Submit and Reset';	

		
	var el_type_radio_custom = document.createElement('input');
		el_type_radio_custom.setAttribute("id", "el_type_custom");
        el_type_radio_custom.setAttribute("type", "radio");
		el_type_radio_custom.style.cssText = "margin-left:15px";         
	    el_type_radio_custom.setAttribute("name", "el_type");
        el_type_radio_custom.setAttribute("onclick", "go_to_type_button('"+new_id+"')");
				
	var el_type_label_custom = document.createElement('label');	
		el_type_label_custom.setAttribute("for", "el_type_custom");
		el_type_label_custom.innerHTML = 'Custom';			
		
		
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	

	td.appendChild(br1);
	td.appendChild(el_type_radio_submit_reset);
	td.appendChild(el_type_label_submit_reset);
	td.appendChild(br2);
	td.appendChild(el_type_radio_custom);
	td.appendChild(el_type_label_custom);

	var pos=document.getElementsByName("el_pos");
			pos[0].removeAttribute("disabled");
			pos[1].removeAttribute("disabled");
			pos[2].removeAttribute("disabled");
			
	var sel_el_pos=document.getElementById("sel_el_pos");
		sel_el_pos.removeAttribute("disabled", "disabled");

	go_to_type_submit_reset(new_id);
	
}

function go_to_type_hidden(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	type_hidden(new_id,'', '', '', w_attr_name, w_attr_value);
}

function go_to_type_submit_reset(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	type_submit_reset(new_id,'Submit', 'Reset', '', true, w_attr_name, w_attr_value);
}

function go_to_type_mark_map(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	type_mark_map(new_id, 'Mark your place on map:', '100', 'left', '2.294254', '48.858334', "2.294254", "48.858334", "13", "400","300", 'wdform_map', '', w_attr_name, w_attr_value);
}

function el_map()
{
	if(document.getElementById("editing_id").value)
		new_id=document.getElementById("editing_id").value;
	else
		new_id=gen;
	
 	w_long=['2.294254'];
 	w_lat=['48.858334'];
 	w_info=[''];

	var pos=document.getElementsByName("el_pos");
			pos[0].removeAttribute("disabled");
			pos[1].removeAttribute("disabled");
			pos[2].removeAttribute("disabled");
		
	var sel_el_pos=document.getElementById("sel_el_pos");
		sel_el_pos.removeAttribute("disabled", "disabled");

 	w_attr_name=[];
 	w_attr_value=[];
	type_map(new_id, '2.294254', '48.858334', w_long, w_lat, "13", "400","300", 'wdform_map', w_info, w_attr_name, w_attr_value);
}

function el_editor()
{
	if(document.getElementById("editing_id").value)
	new_id=document.getElementById("editing_id").value;
else
	new_id=gen;
	

	var pos=document.getElementsByName("el_pos");
			pos[0].removeAttribute("disabled");
			pos[1].removeAttribute("disabled");
			pos[2].removeAttribute("disabled");
	
	var sel_el_pos=document.getElementById("sel_el_pos");
		sel_el_pos.removeAttribute("disabled", "disabled");

	type_editor(new_id,'');
}

function el_text()
{
	if(document.getElementById("editing_id").value)
		new_id=document.getElementById("editing_id").value;
	else
		new_id=gen;

	//edit table
	var td  = document.getElementById('edit_table');
	//type select		
	var el_type_label = document.createElement('label');
	
	el_type_label.style.cssText = "color: #000; font-weight: bold; font-size: 13px";
	//el_type_label.setAttribute("style" , "color: #000; font-weight: bold; font-size: 13px", 0 );
	el_type_label.innerHTML = "<br />&nbsp;&nbsp;Field type";
	td.appendChild(el_type_label);

	var el_type_radio_text = document.createElement('input');
                el_type_radio_text.setAttribute("id", "el_type_radio_text");
                el_type_radio_text.setAttribute("type", "radio");
				el_type_radio_text.style.cssText = "margin-left:15px";
                el_type_radio_text.setAttribute("value", "text");
                el_type_radio_text.setAttribute("name", "el_type");
                el_type_radio_text.setAttribute("onclick", "go_to_type_text('"+new_id+"')");
		el_type_radio_text.setAttribute("checked", "checked");
		
	var el_type_label_text = document.createElement('label');	
		el_type_label_text.setAttribute("for", "el_type_radio_text");
		el_type_label_text.innerHTML = 'Simple text';

		
	var el_type_radio_password = document.createElement('input');
                el_type_radio_password.setAttribute("id", "el_type_radio_password");
                el_type_radio_password.setAttribute("type", "radio");
				el_type_radio_password.style.cssText = "margin-left:15px";
                el_type_radio_password.setAttribute("value", "password");
                el_type_radio_password.setAttribute("name", "el_type");
                el_type_radio_password.setAttribute("onclick", "go_to_type_password('"+new_id+"')");
				
	var el_type_label_password = document.createElement('label');	
		el_type_label_password.setAttribute("for", "el_type_radio_password");
		el_type_label_password.innerHTML = 'Password';
	

	var el_type_radio_textarea = document.createElement('input');
                el_type_radio_textarea.setAttribute("id", "el_type_radio_textarea");
                el_type_radio_textarea.setAttribute("type", "radio");
				el_type_radio_textarea.style.cssText = "margin-left:15px";
                el_type_radio_textarea.setAttribute("value", "textarea");
                el_type_radio_textarea.setAttribute("name", "el_type");
                el_type_radio_textarea.setAttribute("onclick", "go_to_type_textarea('"+new_id+"')");
				
	var el_type_label_textarea = document.createElement('label');	
		el_type_label_textarea.setAttribute("for", "el_type_radio_textarea");
		el_type_label_textarea.innerHTML = 'Text area';

	/*var el_type_radio_editor = document.createElement('input');
                el_type_radio_editor.setAttribute("id", "el_type_radio_editor");
                el_type_radio_editor.setAttribute("type", "radio");
				el_type_radio_editor.style.cssText = "margin-left:15px";
                el_type_radio_editor.setAttribute("value", "editor");
                el_type_radio_editor.setAttribute("name", "el_type");
                el_type_radio_editor.setAttribute("onclick", "go_to_type_wdeditor('"+new_id+"')");
	
	var el_type_label_editor = document.createElement('label');	
		el_type_label_editor.setAttribute("for", "el_type_radio_editor");
		el_type_label_editor.innerHTML = 'Editor';*/

		
	var el_type_radio_name = document.createElement('input');
                el_type_radio_name.setAttribute("id", "el_type_radio_name");
                el_type_radio_name.setAttribute("type", "radio");
				el_type_radio_name.style.cssText = "margin-left:15px";
                el_type_radio_name.setAttribute("value", "name");
                el_type_radio_name.setAttribute("name", "el_type");
                el_type_radio_name.setAttribute("onclick", "go_to_type_name('"+new_id+"')");
				
	var el_type_label_name = document.createElement('label');	
		el_type_label_name.setAttribute("for", "el_type_radio_name");
		el_type_label_name.innerHTML = 'Name';
				
			
	var el_type_radio_submitter_mail= document.createElement('input');
                el_type_radio_submitter_mail.setAttribute("id", "el_type_radio_submitter_mail");
                el_type_radio_submitter_mail.setAttribute("type", "radio");
				el_type_radio_submitter_mail.style.cssText = "margin-left:15px";
                el_type_radio_submitter_mail.setAttribute("value", "submitter_mail");
                el_type_radio_submitter_mail.setAttribute("name", "el_type");
                el_type_radio_submitter_mail.setAttribute("onclick", "go_to_type_submitter_mail('"+new_id+"')");
				
	var el_type_label_submitter_mail = document.createElement('label');	
		el_type_label_submitter_mail.setAttribute("for", "el_type_radio_submitter_mail");
		el_type_label_submitter_mail.innerHTML = 'E-mail';
				
	var el_type_radio_send_copy= document.createElement('input');
                el_type_radio_send_copy.setAttribute("id", "el_type_radio_send_copy");
                el_type_radio_send_copy.setAttribute("type", "radio");
				el_type_radio_send_copy.style.cssText = "margin-left:15px";
                el_type_radio_send_copy.setAttribute("value", "submitter_mail");
                el_type_radio_send_copy.setAttribute("name", "el_type");
                el_type_radio_send_copy.setAttribute("onclick", "go_to_type_send_copy('"+new_id+"')");
				
	var el_type_label_send_copy = document.createElement('label');	
		el_type_label_send_copy.setAttribute("for", "el_type_radio_send_copy");
		el_type_label_send_copy.innerHTML = 'Send copy to submitter';
				
	
	var el_type_radio_number= document.createElement('input');
                el_type_radio_number.setAttribute("id", "el_type_radio_number");
                el_type_radio_number.setAttribute("type", "radio");
				el_type_radio_number.style.cssText = "margin-left:15px";
                el_type_radio_number.setAttribute("value", "number");
                el_type_radio_number.setAttribute("name", "el_type");
                el_type_radio_number.setAttribute("onclick", "go_to_type_number('"+new_id+"')");
				
	var el_type_label_number = document.createElement('label');	
		el_type_label_number.setAttribute("for", "el_type_radio_number");
		el_type_label_number.innerHTML = 'Number';
				
	
	var el_type_radio_phone= document.createElement('input');
                el_type_radio_phone.setAttribute("id", "el_type_radio_phone");
                el_type_radio_phone.setAttribute("type", "radio");
				el_type_radio_phone.style.cssText = "margin-left:15px";
                el_type_radio_phone.setAttribute("value", "phone");
                el_type_radio_phone.setAttribute("name", "el_type");
                el_type_radio_phone.setAttribute("onclick", "go_to_type_phone('"+new_id+"')");
				
	var el_type_label_phone = document.createElement('label');	
		el_type_label_phone.setAttribute("for", "el_type_radio_phone");
		el_type_label_phone.innerHTML = 'Phone';
				
	
	var el_type_radio_hidden = document.createElement('input');
				el_type_radio_hidden.setAttribute("id", "el_type_hidden");
                el_type_radio_hidden.setAttribute("type", "radio");
				el_type_radio_hidden.style.cssText = "margin-left:15px";
                el_type_radio_hidden.setAttribute("name", "el_type");
                el_type_radio_hidden.setAttribute("onclick", "go_to_type_hidden('"+new_id+"')");
				
	var el_type_label_hidden = document.createElement('label');	
		el_type_label_hidden.setAttribute("for", "el_type_hidden");
		el_type_label_hidden.innerHTML = 'Hidden field';
				
			
var el_type_radio_address = document.createElement('input');
                el_type_radio_address.setAttribute("id", "el_type_radio_address");
                el_type_radio_address.setAttribute("type", "radio");
				el_type_radio_address.style.cssText = "margin-left:15px";
                el_type_radio_address.setAttribute("value", "address");
                el_type_radio_address.setAttribute("name", "el_type");
                el_type_radio_address.setAttribute("onchange", "go_to_type_address('"+new_id+"')");
				
	var el_type_label_address = document.createElement('label');	
		el_type_label_address.setAttribute("for", "el_type_radio_address");
		el_type_label_address.innerHTML = 'Address';
				
			
var el_type_radio_mark_map = document.createElement('input');
                el_type_radio_mark_map.setAttribute("id", "el_type_radio_mark_map");
                el_type_radio_mark_map.setAttribute("type", "radio");
				el_type_radio_mark_map.style.cssText = "margin-left:15px";
                el_type_radio_mark_map.setAttribute("value", "mark_map");
                el_type_radio_mark_map.setAttribute("name", "el_type");
                el_type_radio_mark_map.setAttribute("onchange", "go_to_type_mark_map('"+new_id+"')");
				
	var el_type_label_mark_map = document.createElement('label');	
		el_type_label_mark_map.setAttribute("for", "el_type_radio_mark_map");
		el_type_label_mark_map.innerHTML = 'Address(mark on map)';
				
		
	
	
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	var br4 = document.createElement('br');
	var br5 = document.createElement('br');
	var br6 = document.createElement('br');
	var br7 = document.createElement('br');
	var br8 = document.createElement('br');
	var br9 = document.createElement('br');
	var br10 = document.createElement('br');
	var br11 = document.createElement('br');
	var br12 = document.createElement('br');
	

	td.appendChild(br1);
	td.appendChild(el_type_radio_text);
	td.appendChild(el_type_label_text);
	td.appendChild(br2);
	td.appendChild(el_type_radio_password);
	td.appendChild(el_type_label_password);
	td.appendChild(br3);
	td.appendChild(el_type_radio_textarea);
	td.appendChild(el_type_label_textarea);
	td.appendChild(br4);
	// td.appendChild(el_type_radio_editor);
	// td.appendChild(el_type_label_editor);
	// td.appendChild(br11);
	td.appendChild(el_type_radio_name);
	td.appendChild(el_type_label_name);
	td.appendChild(br5);
	td.appendChild(el_type_radio_address);
	td.appendChild(el_type_label_address);
	td.appendChild(br10);
	td.appendChild(el_type_radio_mark_map);
	td.appendChild(el_type_label_mark_map);
	td.appendChild(br12);
	td.appendChild(el_type_radio_submitter_mail);
	td.appendChild(el_type_label_submitter_mail);
	td.appendChild(br6);
	td.appendChild(el_type_radio_send_copy);
	td.appendChild(el_type_label_send_copy);
	td.appendChild(br9);
	td.appendChild(el_type_radio_number);
	td.appendChild(el_type_label_number);
	td.appendChild(br7);
	td.appendChild(el_type_radio_phone);
	td.appendChild(el_type_label_phone);
	td.appendChild(br8);
	td.appendChild(el_type_radio_hidden);
	td.appendChild(el_type_label_hidden);
	
	var pos=document.getElementsByName("el_pos");
			pos[0].removeAttribute("disabled");
			pos[1].removeAttribute("disabled");
			pos[2].removeAttribute("disabled");
			
	var sel_el_pos=document.getElementById("sel_el_pos");
		sel_el_pos.removeAttribute("disabled", "disabled");
			
	go_to_type_text(new_id);
	
}

function go_to_type_text(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	type_text(new_id,'Text:', '100', 'left', '200', '', '', 'no', 'no', '', '', '', 'Incorrect Value', 'no', w_attr_name, w_attr_value);
}

function go_to_type_send_copy(new_id)
{
	if(jQuery('#take').find(jQuery("div[type='type_send_copy']")).length != 0)
	{
		alert("This field already has been created.");
		document.getElementById("el_type_radio_text").checked=true;
		go_to_type_text(new_id);
		return;
	}
 	w_attr_name=[];
 	w_attr_value=[];
	type_send_copy(new_id,'Send a copy of this message to yourself', '300', 'left', false, 'no', w_attr_name, w_attr_value);
}

function go_to_type_number(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	type_number(new_id,'Number:', '100', 'left', '200', '', '', 'no', 'no', '',w_attr_name, w_attr_value);
}

function go_to_type_password(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	type_password(new_id,'Password:', '100', 'left', '200', 'no', 'no', 'wdform_input',w_attr_name, w_attr_value);
}

function go_to_type_textarea(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	type_textarea(new_id,'Textarea:', '100', 'left', '200', '100', '','', 'no', 'no', '',w_attr_name, w_attr_value)
}

function go_to_type_wdeditor(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	type_wdeditor(new_id,'Editor:', '100', 'left', '380', '200', '', 'no', '',w_attr_name, w_attr_value)
}



function go_to_type_name(new_id)
{
 	w_attr_name = [];
 	w_attr_value = [];
 	w_first_val = ['', '', '', ''];
 	w_title = ['', '', '', ''];
	w_mini_labels = ['Title','First','Last','Middle'];
	w_name_fields = ['no', 'no'];
	type_name(new_id,'Name:', '100', 'left', w_first_val, w_title, w_mini_labels, '100', 'normal', 'no', 'no', '',w_attr_name, w_attr_value, w_name_fields)
}
	
function go_to_type_address(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	w_mini_labels=['Street Address', 'Street Address Line 2', 'City', 'State / Province / Region', 'Postal / Zip Code', 'Country',];
	w_disabled_fields=['no', 'no', 'no', 'no', 'no', 'no', 'no'];
	type_address(new_id,'Address:', '100', 'left', '300', w_mini_labels, w_disabled_fields, 'no', 'wdform_address', w_attr_name, w_attr_value)
}

function go_to_type_phone(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
 	w_first_val=['',''];
 	w_title=['',''];
	w_mini_labels = ['Area Code','Phone Number'];
	type_phone(new_id,'Phone:', '100', 'left', '135', w_first_val, w_title, w_mini_labels, 'no', 'no', '',w_attr_name, w_attr_value)
}

function go_to_type_submitter_mail(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	type_submitter_mail(new_id,'E-mail:', '100', 'left', '200', '', '', 'no', '', w_attr_name, w_attr_value);
}

function go_to_type_time(new_id)
{
	
 	w_attr_name=[];
 	w_attr_value=[];
	w_mini_labels = ['HH','MM','SS', 'AM/PM'];
	type_time(new_id, 'Time:', '100', 'left', '24', '0', '1','','','', w_mini_labels, 'no', '',w_attr_name, w_attr_value);
	
}

function go_to_type_date(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	
	type_date(new_id, 'Date:', '100', 'left', '', 'no', '', '%Y-%m-%d', '...',w_attr_name, w_attr_value, 'no');
}

function go_to_type_date_fields(new_id)
{
	
 	w_attr_name=[];
 	w_attr_value=[];
	var current_date = new Date();
	w_to=current_date.getFullYear();

	type_date_fields(new_id, 'Date:', '100', 'left', '', '', '', 'SELECT', 'SELECT', 'SELECT', 'day', 'month', 'year', '60', '100', '80', 'no', 'wdform_date_fields', '1901', w_to, '&nbsp;/&nbsp;', w_attr_name, w_attr_value);

}

function go_to_type_button(new_id)
{
 	w_title=[ "Button"];
 	w_func=[""];
	
 	w_attr_name=[];
 	w_attr_value=[];
	
	type_button(new_id, w_title, w_func, 'wdform_button',w_attr_name, w_attr_value);
}

function el_checkbox()
{
if(document.getElementById("editing_id").value)
	new_id=document.getElementById("editing_id").value;
else
	new_id=gen;
	


	var pos=document.getElementsByName("el_pos");
			pos[0].removeAttribute("disabled");
			pos[1].removeAttribute("disabled");
			pos[2].removeAttribute("disabled");
		
	var sel_el_pos=document.getElementById("sel_el_pos");
		sel_el_pos.removeAttribute("disabled", "disabled");


 	w_choices=[ "option 1", "option 2"];
 	w_choices_checked=[false, false];
	w_choices_value=[ "option 1", "option 2"]; 
	w_choices_params=["", ""];
	
 	w_attr_name=[];
 	w_attr_value=[];
	type_checkbox(new_id,'Checkbox:', '100', 'left', 'left', 'ver', w_choices, w_choices_checked, '1', 'no', 'no', 'no','0', '',w_attr_name, w_attr_value, 'no', w_choices_value, w_choices_params);
}

function el_radio()
{
	
if(document.getElementById("editing_id").value)
	new_id=document.getElementById("editing_id").value;
else
	new_id=gen;
	
	var pos=document.getElementsByName("el_pos");
			pos[0].removeAttribute("disabled");
			pos[1].removeAttribute("disabled");
			pos[2].removeAttribute("disabled");
		
	var sel_el_pos=document.getElementById("sel_el_pos");
		sel_el_pos.removeAttribute("disabled", "disabled");


 	w_choices=[ "option 1", "option 2"];
 	w_choices_checked=[false, false];
	w_choices_value=[ "option 1", "option 2"]; 
	w_choices_params=["", ""];
	
 	w_attr_name=[];
 	w_attr_value=[];
	
	type_radio(new_id,'Radio:', '100', 'left', 'left', 'ver', w_choices, w_choices_checked, '1', 'no', 'no', 'no','0','',w_attr_name, w_attr_value, 'no', w_choices_value, w_choices_params);
}

function el_time_and_date()
{
if(document.getElementById("editing_id").value)
	new_id=document.getElementById("editing_id").value;
else
	new_id=gen;
	
	
//edit table

	//type select		
	var el_type_label = document.createElement('label');
                el_type_label.style.cssText = "color:#000; font-weight:bold; font-size: 13px";
		el_type_label.innerHTML = "<br />&nbsp;&nbsp;Field type";
	
	var el_type_radio_time = document.createElement('input');
                el_type_radio_time.setAttribute("id", "el_type_radio_time");
                el_type_radio_time.setAttribute("type", "radio");
                el_type_radio_time.setAttribute("value", "time");
                el_type_radio_time.style.cssText = "margin-left:15px";
                el_type_radio_time.setAttribute("name", "el_type_radio_time");
                el_type_radio_time.setAttribute("onclick", "go_to_type_time('"+new_id+"')");
				
	var el_type_label_time = document.createElement('label');	
		el_type_label_time.setAttribute("for", "el_type_radio_time");
		el_type_label_time.innerHTML = 'Time';				


	var el_type_radio_date = document.createElement('input');
                el_type_radio_date.setAttribute("id", "el_type_radio_date");
                el_type_radio_date.setAttribute("type", "radio");
                el_type_radio_date.setAttribute("value", "date");
                el_type_radio_date.style.cssText = "margin-left:15px";
                el_type_radio_date.setAttribute("name", "el_type_radio_time");
                el_type_radio_date.setAttribute("onclick", "go_to_type_date('"+new_id+"')");
				el_type_radio_date.setAttribute("checked", "checked");

	var el_type_label_date = document.createElement('label');	
		el_type_label_date.setAttribute("for", "el_type_radio_date");
		el_type_label_date.innerHTML = 'Date (Single fileld with a picker)';				
				
	
		
	var el_type_radio_date_fields = document.createElement('input');
                el_type_radio_date_fields.setAttribute("id", "el_type_radio_date_fields");
                el_type_radio_date_fields.setAttribute("type", "radio");
                el_type_radio_date_fields.setAttribute("value", "date_fields");
                el_type_radio_date_fields.style.cssText = "margin-left:15px";
                el_type_radio_date_fields.setAttribute("name", "el_type_radio_time");
                el_type_radio_date_fields.setAttribute("onclick", "go_to_type_date_fields('"+new_id+"')");
		
		
		var el_type_label_date_fields = document.createElement('label');	
		el_type_label_date_fields.setAttribute("for", "el_type_radio_date_fields");
		el_type_label_date_fields.innerHTML = 'Date (3 separate fields)';		

	var td  = document.getElementById('edit_table');
	
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	
	td.appendChild(el_type_label);
	td.appendChild(br1);
	td.appendChild(el_type_radio_date);
	td.appendChild(el_type_label_date);
	td.appendChild(br2);
	td.appendChild(el_type_radio_date_fields);
	td.appendChild(el_type_label_date_fields);
	td.appendChild(br3);
	td.appendChild(el_type_radio_time);
	td.appendChild(el_type_label_time);
	var pos=document.getElementsByName("el_pos");
			pos[0].removeAttribute("disabled");
			pos[1].removeAttribute("disabled");
			pos[2].removeAttribute("disabled");
			
	var sel_el_pos=document.getElementById("sel_el_pos");
		sel_el_pos.removeAttribute("disabled", "disabled");


	go_to_type_date(new_id);
	
}

function go_to_type_own_select(new_id)
{
 	w_choices=[ "Select value", "option 1", "option 2"];
	w_choices_value=[ "", "option 1", "option 2"];
	w_choices_params=["", "", ""];
 	w_choices_checked=["1", "0", "0"];
	w_choices_disabled=[true, false, false];
 	w_attr_name=[];
 	w_attr_value=[];
	type_own_select(new_id, 'Select:', '100', 'left', '200',w_choices, w_choices_checked, 'no', 'no','wdform_select',w_attr_name, w_attr_value, w_choices_disabled, w_choices_value, w_choices_params);
}

function go_to_type_country(new_id)
{
 	w_countries=["","Afghanistan","Albania",	"Algeria","Andorra","Angola","Antigua and Barbuda","Argentina","Armenia","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bhutan","Bolivia","Bosnia and Herzegovina","Botswana","Brazil","Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde","Central African Republic","Chad","Chile","China","Colombia","Comoros","Congo (Brazzaville)","Congo","Costa Rica","Cote d'Ivoire","Croatia","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","East Timor (Timor Timur)","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Fiji","Finland","France","Gabon","Gambia, The","Georgia","Germany","Ghana","Greece","Grenada","Guatemala","Guinea","Guinea-Bissau","Guyana","Haiti","Honduras","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Israel","Italy","Jamaica","Japan","Jordan","Kazakhstan","Kenya","Kiribati","Korea, North","Korea, South","Kuwait","Kyrgyzstan","Laos","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Mauritania","Mauritius","Mexico","Micronesia","Moldova","Monaco","Mongolia","Morocco","Mozambique","Myanmar","Namibia","Nauru","Nepal","Netherlands","New Zealand","Nicaragua","Niger","Nigeria","Norway","Oman","Pakistan","Palau","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Poland","Portugal","Qatar","Romania","Russia","Rwanda","Saint Kitts and Nevis","Saint Lucia","Saint Vincent","Samoa","San Marino","Sao Tome and Principe","Saudi Arabia","Senegal","Serbia and Montenegro","Seychelles","Sierra Leone","Singapore","Slovakia","Slovenia","Solomon Islands","Somalia","South Africa","Spain","Sri Lanka","Sudan","Suriname","Swaziland","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Togo","Tonga","Trinidad and Tobago","Tunisia","Turkey","Turkmenistan","Tuvalu","Uganda","Ukraine","United Arab Emirates","United Kingdom","United States","Uruguay","Uzbekistan","Vanuatu","Vatican City","Venezuela","Vietnam","Yemen","Zambia","Zimbabwe"];	
 	w_attr_name=[];
 	w_attr_value=[];
	type_country(new_id,'Country:', '100', w_countries, 'left', '200', 'no', 'wdform_select',w_attr_name, w_attr_value);
}

function el_select()
{
//edit table
if(document.getElementById("editing_id").value)
	new_id=document.getElementById("editing_id").value;
else
	new_id=gen;
	

	//type select		
	var el_type_label = document.createElement('label');
                el_type_label.style.cssText ="color:#000; font-weight:bold; font-size: 13px";
		el_type_label.innerHTML = "<br />&nbsp;&nbsp;Field type";
	
	var el_type_radio_own_select = document.createElement('input');
                el_type_radio_own_select.setAttribute("id", "el_type_radio_own_select");
                el_type_radio_own_select.setAttribute("type", "radio");
                el_type_radio_own_select.setAttribute("value", "own_select");
                el_type_radio_own_select.style.cssText = "margin-left:15px";
                el_type_radio_own_select.setAttribute("name", "el_type_radio_select");
                el_type_radio_own_select.setAttribute("onclick", "go_to_type_own_select('"+new_id+"')");
		el_type_radio_own_select.setAttribute("checked", "checked");
		
	var el_type_label_own_select = document.createElement('label');	
		el_type_label_own_select.setAttribute("for", "el_type_radio_own_select");
		el_type_label_own_select.innerHTML = 'Custom Select';		

		
	var el_type_radio_country = document.createElement('input');
                el_type_radio_country.setAttribute("id", "el_type_radio_country");
                el_type_radio_country.setAttribute("type", "radio");
                el_type_radio_country.setAttribute("value", "country");
                el_type_radio_country.style.cssText = "margin-left:15px";
                el_type_radio_country.setAttribute("name", "el_type_radio_select");
                el_type_radio_country.setAttribute("onclick", "go_to_type_country('"+new_id+"')");
				
	var el_type_label_country = document.createElement('label');	
		el_type_label_country.setAttribute("for", "el_type_radio_country");
		el_type_label_country.innerHTML = 'Country List';		
		

	var td  = document.getElementById('edit_table');
	
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	
	td.appendChild(el_type_label);
	td.appendChild(br1);
	td.appendChild(el_type_radio_own_select);
	td.appendChild(el_type_label_own_select);
	td.appendChild(br2);
	td.appendChild(el_type_radio_country);
	td.appendChild(el_type_label_country);
	var pos=document.getElementsByName("el_pos");
			pos[0].removeAttribute("disabled");
			pos[1].removeAttribute("disabled");
			pos[2].removeAttribute("disabled");
		
	var sel_el_pos=document.getElementById("sel_el_pos");
		sel_el_pos.removeAttribute("disabled", "disabled");

	go_to_type_own_select(new_id);
}

function el_file_upload()
{
//edit table
if(document.getElementById("editing_id").value)
	new_id=document.getElementById("editing_id").value;
else
	new_id=gen;
	
	var pos=document.getElementsByName("el_pos");
			pos[0].removeAttribute("disabled");
			pos[1].removeAttribute("disabled");
			pos[2].removeAttribute("disabled");
		
	var sel_el_pos=document.getElementById("sel_el_pos");
		sel_el_pos.removeAttribute("disabled", "disabled");
	
 	w_attr_name=[];
 	w_attr_value=[];
	type_file_upload(new_id,'Upload a File:', '100', 'left', content_url + "/uploads/form-maker" , 'jpg, jpeg, png, gif, doc, docx, xls, xlsx', '2000', 'no', 'no','',w_attr_name, w_attr_value);
}

function el_captcha()
{
	//edit table
	if(document.getElementById("editing_id").value)
		new_id=document.getElementById("editing_id").value;
	else
		new_id=gen;
		
	if(document.getElementById('_wd_captchaform_id_temp'))
	{
		alert("The captcha already has been created.");
		return;
	}
	
	if(document.getElementById('_wd_arithmetic_captchaform_id_temp'))
	{
		alert("The captcha already has been created.");
		return;
	}
	
	if(document.getElementById('wd_recaptchaform_id_temp'))
	{
		alert("The captcha already has been created.");
		return;
	}
	
	var el_type_label = document.createElement('label');
		el_type_label.style.cssText ="color:#000; font-weight:bold; font-size: 13px";
		el_type_label.innerHTML = "<br />&nbsp;&nbsp;Field type";
	
	var el_type_radio_captcha = document.createElement('input');
		el_type_radio_captcha.setAttribute("id", "el_type_captcha");
		el_type_radio_captcha.setAttribute("type", "radio");
		el_type_radio_captcha.setAttribute("value", "captcha");
		el_type_radio_captcha.style.cssText = "margin-left:15px";
		el_type_radio_captcha.setAttribute("name", "el_type_captcha");
		el_type_radio_captcha.setAttribute("onclick", "go_to_type_captcha('"+new_id+"')");
		el_type_radio_captcha.setAttribute("checked", "checked");
		
	var el_type_label_captcha = document.createElement('label');	
		el_type_label_captcha.setAttribute("for", "el_type_captcha");
		el_type_label_captcha.innerHTML = 'Simple Captcha';		
		
	var el_type_radio_arithmetic_captcha = document.createElement('input');
		el_type_radio_arithmetic_captcha.setAttribute("id", "el_type_arithmetic_captcha");
		el_type_radio_arithmetic_captcha.setAttribute("type", "radio");
		el_type_radio_arithmetic_captcha.setAttribute("value", "arithmetic_captcha");
		el_type_radio_arithmetic_captcha.style.cssText = "margin-left:15px";
		el_type_radio_arithmetic_captcha.setAttribute("name", "el_type_captcha");
		el_type_radio_arithmetic_captcha.setAttribute("onclick", "go_to_type_arithmetic_captcha('"+new_id+"')");
		
	var el_type_label_arithmetic_captcha = document.createElement('label');	
		el_type_label_arithmetic_captcha.setAttribute("for", "el_type_arithmetic_captcha");
		el_type_label_arithmetic_captcha.innerHTML = 'Arithmetic Captcha';	

	
	var el_type_radio_recaptcha = document.createElement('input');
		el_type_radio_recaptcha.setAttribute("id", "el_type_radio_recaptcha");
		el_type_radio_recaptcha.setAttribute("type", "radio");
		el_type_radio_recaptcha.setAttribute("value", "recaptcha");
		el_type_radio_recaptcha.style.cssText = "margin-left:15px";
		el_type_radio_recaptcha.setAttribute("name", "el_type_captcha");
		el_type_radio_recaptcha.setAttribute("onclick", "go_to_type_recaptcha('"+new_id+"')");
				
	var el_type_label_recaptcha = document.createElement('label');	
		el_type_label_recaptcha.setAttribute("for", "el_type_radio_recaptcha");
		el_type_label_recaptcha.innerHTML = 'Recaptcha';					


	var td  = document.getElementById('edit_table');
	
	var br1 = document.createElement('br');
	var br2 = document.createElement('br');
	var br3 = document.createElement('br');
	
	td.appendChild(el_type_label);
	td.appendChild(br1);
	td.appendChild(el_type_radio_captcha);
	td.appendChild(el_type_label_captcha);
	td.appendChild(br2);
	td.appendChild(el_type_radio_arithmetic_captcha);
	td.appendChild(el_type_label_arithmetic_captcha);
	td.appendChild(br3);
	td.appendChild(el_type_radio_recaptcha);
	td.appendChild(el_type_label_recaptcha);
	
	var pos=document.getElementsByName("el_pos");
		pos[0].removeAttribute("disabled");
		pos[1].removeAttribute("disabled");
		pos[2].removeAttribute("disabled");
	
	var sel_el_pos=document.getElementById("sel_el_pos");
		sel_el_pos.removeAttribute("disabled", "disabled");
	
 	w_attr_name=[];
 	w_attr_value=[];
	go_to_type_captcha(new_id);
}


function go_to_type_captcha(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	type_captcha(new_id,'Word Verification:', '100', 'left', '6','',w_attr_name, w_attr_value);
}

function go_to_type_arithmetic_captcha(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	type_arithmetic_captcha(new_id, 'Word Verification:', '100', 'left', '1', '+, -, *, /', '', '60', w_attr_name, w_attr_value);
}

function go_to_type_recaptcha(new_id)
{
 	w_attr_name=[];
 	w_attr_value=[];
	type_recaptcha(new_id,'Recaptcha Word Verification:', '100', 'left', '', '', 'red', '',w_attr_name, w_attr_value);
}



///////////////////////////////////////////////
///////////  el_page_break   //////////////////
///////////////////////////////////////////////

function el_page_break()
{
		for(t=form_view_max; t>0; t--)
		{
			if(document.getElementById('form_id_tempform_view'+t))
			{
					last_view=t;
					break;
			}
		}
	if(document.getElementById('form_id_tempform_view'+t).getAttribute('page_title'))
		w_page_title=document.getElementById('form_id_tempform_view'+t).getAttribute('page_title');
	else
		w_page_title='Untitled Page';
	
	w_title	=[ "Next","Previous"];
 	w_type	=["text","text"];
 	w_class	=["wdform-page-button","wdform-page-button"];
 	w_check	=['false', 'false'];
	
 	w_attr_name=[];
 	w_attr_value=[];
	
	type_page_break("0",w_page_title , w_title, w_type, w_class, w_check, w_attr_name, w_attr_value);
}
function el_page_navigation()
{
	
	w_type=document.getElementById('pages').getAttribute('type');
	w_show_numbers=false;
	w_show_title=false;

	if(document.getElementById('pages').getAttribute('show_numbers')=="true")
		w_show_numbers=true;
	
	if(document.getElementById('pages').getAttribute('show_title')=="true")
		w_show_title=true;
	
 	w_attr_name=[];
 	w_attr_value=[];
	
	type_page_navigation( w_type, w_show_title , w_show_numbers , w_attr_name, w_attr_value);
}

function remove_section_break(id)
{
	var wdform_section_break=document.getElementById( "wdform_field"+id).parentNode;
	

	move=wdform_section_break.nextSibling;
	to=wdform_section_break.previousSibling;
	
	
	l=move.childNodes.length;
	for(k=0;k<l;k++)
	{
		if(to.childNodes[k])
		{
			while(move.childNodes[k].firstChild)
				to.childNodes[k].appendChild(move.childNodes[k].firstChild);
		}
		else
			to.appendChild(move.childNodes[k]);			
	}
	
	wdform_section_break.parentNode.removeChild(wdform_section_break.nextSibling);
		
	wdform_section_break.parentNode.removeChild(wdform_section_break);
	
}

function remove_row(id)
{
	var wdform_row=document.getElementById( "wdform_field"+id).parentNode;
	var wdform_column=wdform_row.parentNode;

	wdform_column.removeChild(wdform_row);
	
}

function destroyChildren(node)
{
  while (node.firstChild)
      node.removeChild(node.firstChild);
}

function make_pagebreak_button(next_or_previous,title,type, class_ ,id)
{
	switch(type)
	{
		case 'button': 
		{ 
		
			var element = document.createElement('button');
				element.setAttribute('id', "page_"+next_or_previous+"_"+id);
				element.setAttribute('type', "button");
				element.setAttribute('class', class_);
				element.style.cursor="pointer";
				element.innerHTML=title;
				
			return element;
			
			break;
		}
		case 'text': {	
			
			var element = document.createElement('span');
				element.setAttribute('id', "page_"+next_or_previous+"_"+id);
				element.setAttribute('class', class_);
				element.style.cursor="pointer";
				element.innerHTML=title;
				
			return element;
			
			break;
		}
		case 'img':{ 			
		
			var element = document.createElement('img');
				element.setAttribute('id', "page_"+next_or_previous+"_"+id);
				element.setAttribute('class', class_);
				element.style.cursor="pointer";
				element.src=title;
				
			return element;
			
			break;
		}
	}
}

function show_or_hide(id) {
	if (!jQuery("#form_id_tempform_view"+id).is(":visible")) {
		show_form_view(id);
  }
	else {
		hide_form_view(id);
  }
}

function show_form_view(id) {
	jQuery("#form_id_tempform_view_img"+id).attr( "style", "float: right;" );
	jQuery("#form_id_tempform_view_img"+id).children().eq(0).css( "float", "none" );
	jQuery("#form_id_tempform_view_img"+id).children().eq(1).remove();
	jQuery("#show_page_img_"+id).attr( "src", plugin_url + "/images/minus.png" );
	jQuery("#show_page_img_"+id).attr( "onmouseover", "chnage_icons_src(this,'minus')" );
	jQuery("#show_page_img_"+id).attr( "onmouseout", "chnage_icons_src(this,'minus')" );
	jQuery("#form_id_tempform_view"+id).show('medium');
}

function hide_form_view(id) {
	jQuery("#form_id_tempform_view"+id).hide('medium', function() {
    jQuery("#form_id_tempform_view_img"+id).attr("style", "height: 40px; float: none;");
    jQuery("#form_id_tempform_view_img"+id).children().eq(0).css( "float", "right" );
    jQuery("#form_id_tempform_view_img"+id).append("<div style='float: left;line-height: 40px;margin-left: 20px;'>"+jQuery("#form_id_tempform_view"+id).attr('page_title')+"</div>")
    jQuery("#show_page_img_"+id).attr( "src", plugin_url + "/images/plus.png" );
    jQuery("#show_page_img_"+id).attr( "onmouseover", "chnage_icons_src(this,'plus')" );
    jQuery("#show_page_img_"+id).attr( "onmouseout", "chnage_icons_src(this,'plus')" );
	});
}

function generate_buttons(id)
{

	form_view_elemet=document.getElementById("form_id_tempform_view"+id);
			var td = document.createElement("div");
				td.setAttribute("valign", "middle");
				td.setAttribute("align", "left");
				td.style.display="table-cell";
				td.style.width="40%";
			page_nav.appendChild(td);

	if(form_view_elemet.parentNode.previousSibling)
	{
		if(form_view_elemet.parentNode.previousSibling.tagName=="DIV")
			table=true;
		else
			if(form_view_elemet.parentNode.previousSibling.previousSibling)
				if(form_view_elemet.parentNode.previousSibling.previousSibling.tagName=="DIV")
					table=true;
				else
					table=false;
			else
				table=false;
				
		if(table)
		{
			/*if(!table.firstChild.tagName)
				table.removeChild(table.firstChild);*/

			if(form_view_elemet.getAttribute('previous_title'))
				{
						previous_title	= form_view_elemet.getAttribute('previous_title');
						previous_type	= form_view_elemet.getAttribute('previous_type');
						previous_class	= form_view_elemet.getAttribute('previous_class');
				}
					else
					{
						previous_title	= "Previous";
						previous_type	= "button";
						previous_class	= "";
					}
			next_or_previous="previous";

			previous=make_pagebreak_button(next_or_previous, previous_title, previous_type, previous_class, id);
			td.appendChild(previous);
		}
	}


	var td = document.createElement("div");
		td.setAttribute("id", "page_numbersform_id_temp"+id);
		td.setAttribute("valign", "middle");
		td.setAttribute("align", "center");
		td.style.display="table-cell";
	page_nav.appendChild(td);


			var td = document.createElement("div");
				td.setAttribute("valign", "middle");
				td.setAttribute("align", "right");
				td.style.display="table-cell";
				td.style.width="40%";
				page_nav.appendChild(td);
		

	if(form_view_elemet.parentNode.nextSibling)
	{
		if(form_view_elemet.parentNode.nextSibling.tagName=="DIV")
			table=true;
		else
			if(form_view_elemet.parentNode.nextSibling.nextSibling)
			{
				if(form_view_elemet.parentNode.nextSibling.nextSibling.tagName=="DIV")
					table=true;
				else
					table=false;
			}
			else
				table=false;
				
		if(table)
		{
			if(form_view_elemet.getAttribute('previous_title')){
						next_title	=form_view_elemet.getAttribute('next_title');
						next_type	=form_view_elemet.getAttribute('next_type');
						next_class	=form_view_elemet.getAttribute('next_class');
					}
					else
					{
						next_title	= "Next";
						next_type	= "button";
						next_class	= "";
					}
		
			next_or_previous="next";
		
			next=make_pagebreak_button(next_or_previous,next_title,next_type,next_class, id);
			td.appendChild(next);
		}
	}

}

function generate_page_nav(id)
{
form_view=id;
document.getElementById('form_id_tempform_view'+id).parentNode.style.borderWidth="1px";
////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
for(t=1; t<=form_view_max; t++)
	if(document.getElementById('form_id_tempform_view'+t))
	{
		page_nav=document.getElementById("form_id_temppage_nav"+t);
		destroyChildren(page_nav);
		generate_buttons(t);
	}

generate_page_bar();
refresh_page_numbers();

////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

function remove_page(id)
{
	if(confirm('Do you want to delete the page?'))
	{
		refresh_pages_without_deleting(id);
	}
}

function remove_page_all(id)
{
	if(confirm('Do you want to delete the all fields in this page?'))
	{
		form_view_elemet=document.getElementById("form_id_tempform_view"+id);
		
				form_view_count=0;
			
		for(i=1; i<=30; i++)
		{
			if(document.getElementById('form_id_tempform_view'+i))
			{
				form_view_count++;
			}
		}

	
		if(form_view_count==1)
		{
	 
			form_view_elemet.innerHTML='';
			
			tbody=form_view_elemet;		
				
			tr=document.createElement('div');
				tr.setAttribute('class','wdform_section');
				tr.style.display="table-row";
				
			tr_page_nav=document.createElement('div');
				tr_page_nav.setAttribute('valign','top');
				tr_page_nav.setAttribute('class','wdform_footer');
				tr_page_nav.style.width="100%";
				
			td_page_nav=document.createElement('div');
				td_page_nav.style.width="100%";
				
			table_min_page_nav=document.createElement('div');
				table_min_page_nav.style.width="100%";
				table_min_page_nav.style.display="table";
				
			tbody_min_page_nav=document.createElement('div');
				tbody_min_page_nav.style.display="table-row-group";
			tr_min_page_nav=document.createElement('div');
				tr_min_page_nav.setAttribute('id','form_id_temppage_nav'+form_view);
				tr_min_page_nav.style.display="table-row";
				
				
			table_min=document.createElement('div');
				table_min.setAttribute('class','wdform_column');

			tr.appendChild(table_min);
			
			tbody_min_page_nav.appendChild(tr_min_page_nav);
			table_min_page_nav.appendChild(tbody_min_page_nav);
			td_page_nav.appendChild(table_min_page_nav);
			tr_page_nav.appendChild(td_page_nav);
			tbody.appendChild(tr);
			tbody.appendChild(tr_page_nav);
			
		return;
		}
		

		
		form_view_table=form_view_elemet.parentNode;
		document.getElementById("take").removeChild(form_view_table);
		refresh_pages(id);
	}
}

function refresh_pages(id)
{
	temp=1;
	form_view_count=0;
	destroyChildren(document.getElementById("pages"));

	for(i=1; i<=30; i++)
	{
		if(document.getElementById('form_id_tempform_view'+i))
		{
			form_view_count++;
		}
	}

	if(form_view_count>1)
	{
		for(i=1; i<=30; i++)
		{
			if(document.getElementById('form_id_tempform_view'+i))
			{
				page_number = document.createElement('span');
				page_number.setAttribute('id','page_'+i);
				page_number.setAttribute('class','page_deactive');
				page_number.innerHTML=(temp);
				temp++;
				document.getElementById("pages").appendChild(page_number);
			}
		}
	}
	
	else
	{
		destroyChildren(document.getElementById("edit_page_navigation"));
		for(i=1; i<=30; i++)
		{
			if(document.getElementById('form_id_tempform_view'+i))
			{
				document.getElementById('form_id_tempform_view'+i).parentNode.style.borderWidth="0px";
				document.getElementById('form_id_tempform_view'+i).style.display="block";
				document.getElementById("form_id_temppage_nav"+i).innerHTML="";
				
				
	jQuery("#form_id_tempform_view_img"+i).attr( "style", "float: right;" );
	jQuery("#form_id_tempform_view_img"+i).children().eq(0).css( "float", "none" );
	jQuery("#form_id_tempform_view_img"+i).children().eq(1).remove();
	jQuery("#show_page_img_"+i).attr( "src", plugin_url + "/images/minus.png" );
	jQuery("#show_page_img_"+id).attr( "onmouseover", "chnage_icons_src(this,'minus')" );
	jQuery("#show_page_img_"+id).attr( "onmouseout", "chnage_icons_src(this,'minus')" );

				
				
				form_view=i;
				return;
			}
		}	
	}
	
	for(i=parseInt(id)+1; i<=30; i++)
		if(document.getElementById('form_id_tempform_view'+i))
		{
			generate_page_nav(i);
			return;
		}
		
	for(i=parseInt(id)-1; i>0; i--)
		if(document.getElementById('form_id_tempform_view'+i))
		{
			generate_page_nav(i);
			return;
		}
	
}

function refresh_pages_without_deleting(id)
{
	form_view_elemet=document.getElementById("form_id_tempform_view"+id);
	
		
	form_view_count=0;
	for(i=1; i<=30; i++)
	{
		if(document.getElementById('form_id_tempform_view'+i))
		{
			form_view_count++;
		}
	}


	
	if(form_view_count==1)
	{
	
		form_view_elemet.innerHTML='';
 
		tbody=form_view_elemet;		
			
		tr=document.createElement('div');
			tr.setAttribute('class','wdform_section');
			tr.style.display="table-row";
		//td=document.createElement('td');
			//td.setAttribute('class','wdform_td1');
			
		tr_page_nav=document.createElement('div');
			tr_page_nav.setAttribute('valign','top');
			tr_page_nav.setAttribute('class','wdform_footer');
			tr_page_nav.style.width="100%";
			
		td_page_nav=document.createElement('div');
			td_page_nav.style.width="100%";
			
		table_min_page_nav=document.createElement('div');
			table_min_page_nav.style.width="100%";
			table_min_page_nav.style.display="table";
			
		tbody_min_page_nav=document.createElement('div');
			tbody_min_page_nav.style.display="table-row-group";
		tr_min_page_nav=document.createElement('div');
			tr_min_page_nav.setAttribute('id','form_id_temppage_nav'+form_view);
			tr_min_page_nav.style.display="table-row";
			
		table_min=document.createElement('div');
			table_min.setAttribute('class','wdform_column');
			
		tr.appendChild(table_min);
		
		tbody_min_page_nav.appendChild(tr_min_page_nav);
		table_min_page_nav.appendChild(tbody_min_page_nav);
		td_page_nav.appendChild(table_min_page_nav);
		tr_page_nav.appendChild(td_page_nav);
		tbody.appendChild(tr);
		tbody.appendChild(tr_page_nav);
		
	return;
	}
	

	
	
	table=form_view_elemet.parentNode.previousSibling;
	
	while(table)
	{
		if(table.tagName=="DIV")
			break;
		else
			table=table.previousSibling;
	}
				
	if(!table)
	{
		table=form_view_elemet.parentNode.nextSibling;
		while(table)
		{
			if(table.tagName=="DIV")
				break;
			else
				table=table.nextSibling;
		}

	}
			table_form_view=table.firstChild;

	////////////////////////////////////////////////////
			i=gen;
			gen++;
			
			
			var wdform_row = document.createElement('div');
				wdform_row.setAttribute("wdid", i);
				wdform_row.setAttribute("type", "type_section_break");
				wdform_row.setAttribute("class", "wdform_tr_section_break");
		
			var wdform_field = document.createElement('div');
				wdform_field.setAttribute("id", "wdform_field"+i);
				wdform_field.setAttribute("type", "type_section_break");
				wdform_field.setAttribute("class", "wdform_field_section_break");
				
			var wdform_arrows = document.createElement('div');
				wdform_arrows.setAttribute("id", "wdform_arrows"+i);
				wdform_arrows.setAttribute("class", "wdform_arrows");
				
			wdform_field.appendChild(wdform_arrows);
		//	wdform_row.appendChild(wdform_arrows);
			wdform_row.appendChild(wdform_field);

			var select_ = document.getElementById('sel_el_pos');
			var option = document.createElement('option');
				option.setAttribute("id", i+"_sel_el_pos");
				option.setAttribute("value", i);
				option.innerHTML="custom_"+i;
				
			wdform_page=document.getElementById('form_id_tempform_view'+form_view);

			var img_X = document.createElement("img");
					img_X.setAttribute("src", plugin_url + "/images/delete_el.png");
					img_X.setAttribute("title", "Remove the field");
					img_X.setAttribute("onclick", 'remove_section_break("'+i+'")');
					img_X.setAttribute("onmouseover", 'chnage_icons_src(this,"delete_el")');
					img_X.setAttribute("onmouseout", 'chnage_icons_src(this,"delete_el")');
					
			var td_X = document.createElement("div");
					td_X.setAttribute("id", "X_"+i);
					td_X.setAttribute("class", "element_toolbar");
					td_X.appendChild(img_X);
//image pah@					
			var img_EDIT = document.createElement("img");
					img_EDIT.setAttribute("src", plugin_url + "/images/edit.png");
					img_EDIT.setAttribute("title", "Edit the field");
					img_EDIT.setAttribute("onclick", 'edit("'+i+'")');
					img_EDIT.setAttribute("onmouseover", 'chnage_icons_src(this,"edit")');
					img_EDIT.setAttribute("onmouseout", 'chnage_icons_src(this,"edit")');
					
			var td_EDIT = document.createElement("div");
					td_EDIT.setAttribute("id", "edit_"+i);
					td_EDIT.setAttribute("class", "element_toolbar");
					td_EDIT.appendChild(img_EDIT);
		
			var img_DUBLICATE = document.createElement("img");
					img_DUBLICATE.setAttribute("src", plugin_url + "/images/duplicate.png");
					img_DUBLICATE.setAttribute("title", "Duplicate the field");
					img_DUBLICATE.setAttribute("onclick", 'duplicate("'+i+'")');
					img_DUBLICATE.setAttribute("onmouseover", 'chnage_icons_src(this,"duplicate")');
					img_DUBLICATE.setAttribute("onmouseout", 'chnage_icons_src(this,"duplicate")');
					
			var td_DUBLICATE = document.createElement("div");
					td_DUBLICATE.setAttribute("id", "duplicate_"+i);
					td_DUBLICATE.setAttribute("class", "element_toolbar");
					td_DUBLICATE.appendChild(img_DUBLICATE);
					
			var in_editor = document.createElement("div");
					in_editor.setAttribute("id", i+"_element_sectionform_id_temp");
         			in_editor.setAttribute("align", 'left');
         			in_editor.setAttribute("class", 'wdform_section_break');

				in_editor.innerHTML="<div class='wdform-section-break-div' style='min-width: 300px; border-top:1px solid'></div>";
			
			
			var label = document.createElement('span');
					label.setAttribute("id", i+"_element_labelform_id_temp");
					label.innerHTML = "custom_"+i;
					label.style.cssText = 'display:none';
					
			wdform_field.appendChild(in_editor);
			td_EDIT.appendChild(label);

			wdform_arrows.appendChild(td_X);
			wdform_arrows.appendChild(td_EDIT);
			wdform_arrows.appendChild(td_DUBLICATE);

			
				beforeTr=table_form_view.lastChild;
				table_form_view.insertBefore(wdform_row, beforeTr);
		

	

	while(form_view_elemet.childNodes[1])
	{
		beforeTr=table_form_view.lastChild;
		table_form_view.insertBefore(form_view_elemet.firstChild, beforeTr);
	}
	
	

	
		form_view_table=form_view_elemet.parentNode;
		document.getElementById("take").removeChild(form_view_table);

		refresh_pages(id);
}


function make_page_steps_front()
{
	destroyChildren(document.getElementById("pages"));
	show_title=document.getElementById('el_show_title_input').checked;
	k=0;
	for(j=1; j<=form_view_max; j++)
	{	
		if(document.getElementById('form_id_tempform_view'+j))
			{
			if(document.getElementById('form_id_tempform_view'+j).getAttribute('page_title'))
				w_pages=document.getElementById('form_id_tempform_view'+j).getAttribute('page_title');
			else
				w_pages=""
			k++;
			
			page_number = document.createElement('span');
			page_number.setAttribute('id','page_'+j);
			page_number.setAttribute('onClick','generate_page_nav("'+j+'")');
			if(j==form_view)
				page_number.setAttribute('class',"page_active");
			else
				page_number.setAttribute('class',"page_deactive");
			if(show_title)
			{
				page_number.innerHTML=w_pages;
			}
			else
				page_number.innerHTML=k;
			
			document.getElementById("pages").appendChild(page_number);
		}
	}

}

function make_page_percentage_front()
{
	destroyChildren(document.getElementById("pages"));
	show_title=document.getElementById('el_show_title_input').checked;
	
    var div_parent = document.createElement('div');
       	div_parent.setAttribute("class", "page_percentage_deactive");

    var div = document.createElement('div');
       	div.setAttribute("id", "div_percentage");
       	div.setAttribute("class", "page_percentage_active");
		
	var b = document.createElement('b');

	div.appendChild(b);
	
	k=0;
	cur_page_title='';
	for(j=1; j<=form_view_max; j++)
	{	
		if(document.getElementById('form_id_tempform_view'+j))
			{
			if(document.getElementById('form_id_tempform_view'+j).getAttribute('page_title'))
				w_pages=document.getElementById('form_id_tempform_view'+j).getAttribute('page_title');
			else
				w_pages=""
			k++;
				
			if(j==form_view)
			{
				if(show_title)
				{ 
					var cur_page_title = document.createElement('span');
					if(k==1)
						cur_page_title.style.paddingLeft="30px";
					else
						cur_page_title.style.paddingLeft="5px";
						cur_page_title.innerHTML=w_pages;
				}
				page_number=k;

			}
		}
	}
	b.innerHTML=Math.round(((page_number-1)/k)*100)+'%';
	div.style.width=((page_number-1)/k)*100+'%';
	div_parent.appendChild(div);
	if(cur_page_title)
		div_parent.appendChild(cur_page_title);
	document.getElementById("pages").appendChild(div_parent);

	
}
function make_page_none_front()
{
	var no_pagbar = document.createElement('div');
		no_pagbar.innerHTML = "NO PAGE BAR";
		no_pagbar.style.cssText = 'width:100px; padding:10px; border:1px solid #ccc;';
	
	jQuery('#pages').empty();
	jQuery('#pages').append(no_pagbar);
}

function generate_page_bar()
{
need_enable=false;
el_page_navigation();
add(0, false);
need_enable=true;
}

function remove_add_(id)
{
			attr_name= new Array();
			attr_value= new Array();
			var input = document.getElementById(id); 
			atr=input.attributes;
			for(v=0;v<30;v++)
				if(atr[v] )
				{
					if(atr[v].name.indexOf("add_")==0)
					{
						attr_name.push(atr[v].name.replace('add_',''));
						attr_value.push(atr[v].value);
						input.removeAttribute(atr[v].name);
						v--;
					}
				}
			for(v=0;v<attr_name.length; v++)
			{
				input.setAttribute(attr_name[v],attr_value[v])
			}
}

function show_arrows(id)
{
	if(jQuery("#wdform_field"+id).attr("type")=='type_editor')
		jQuery("#wdform_field"+id).css("margin-top","-5px");
		
	jQuery("#wdform_field"+id).css({"background-color":"rgb(224, 224, 224)","border":"1px solid rgb(213, 213, 213)"});
	jQuery("#wdform_arrows"+id).removeClass("wdform_arrows");
	jQuery("#wdform_arrows"+id).addClass("wdform_arrows_show");
	jQuery("#wdform_arrows"+id).show();

}

function add(key, after_edit, wdid)
{
  if(after_edit && jQuery('#enable_sortable').prop( 'checked' ))
		show_arrows(wdid);
	if(document.getElementById("element_type").value=="type_grading")
	{

	for(k=100;k>0;k--)
	{
		 if(document.getElementById("el_items"+k))
		 {
			break;
		 }
	}	
	 m=k;


	var items_input="";
	
	for(i=0;i<=m;i++){
	if(document.getElementById("el_items"+i)){
	items_input = items_input+document.getElementById("el_items"+i).value+":";	
	}
	}
	
	items_input += document.getElementById("element_total").value;
	
	if(document.getElementById('editing_id').value)
		id=document.getElementById('editing_id').value;
	else
		id=gen;

  
   var hidden_input_item = document.createElement('input');
						hidden_input_item.setAttribute("id", id+"_hidden_itemform_id_temp");
						hidden_input_item.setAttribute("name", id+"_hidden_itemform_id_temp");
						hidden_input_item.setAttribute("type", "hidden");
						hidden_input_item.setAttribute("value", items_input);	
						
	
  var td_for_hidden = document.getElementById(id+"_element_sectionform_id_temp");								
						
	td_for_hidden.appendChild(hidden_input_item);

	}
	
	
	if(document.getElementById("element_type").value=="type_matrix")
	{
		for(i=100;i>0;i--)
		{
			if(document.getElementById("el_rows"+i))
				break;
			
		}	
		m=i;

		for(i=100;i>0;i--)
		{
			if(document.getElementById("el_columns"+i))
				break;
		}	
		n=i;
		var row_input="";
		var column_input="";
		var row_num="";
		var column_num="";
	
		for(i=1;i<=m;i++)
		{
			if(document.getElementById("el_rows"+i)) {
				row_input = row_input+document.getElementById("el_rows"+i).value+"***";	
				row_num += i+',';
			}
		}
	
		for(i=1;i<=n;i++)
		{
			if(document.getElementById("el_columns"+i))
			{
				column_input= column_input+document.getElementById("el_columns"+i).value+"***";	
				column_num += i+',';
			}
		}
		
		
		if(document.getElementById('editing_id').value)
			id=document.getElementById('editing_id').value;
		else
			id=gen;
	  
		var td_for_hidden = document.getElementById(id+"_element_sectionform_id_temp");

		var hidden_input_row = document.createElement('input');
			hidden_input_row.setAttribute("id", id+"_hidden_rowform_id_temp");
			hidden_input_row.setAttribute("name", id+"_hidden_rowform_id_temp");
			hidden_input_row.setAttribute("type", "hidden");
			hidden_input_row.setAttribute("value", row_input);	
	
		var hidden_ids_row = document.createElement('input');
			hidden_ids_row.setAttribute("id", id+"_row_idsform_id_temp");
			hidden_ids_row.setAttribute("name", id+"_row_idsform_id_temp");
			hidden_ids_row.setAttribute("type", "hidden");
			hidden_ids_row.setAttribute("value", row_num);	
				
		var hidden_input_column = document.createElement('input');
			hidden_input_column.setAttribute("id", id+"_hidden_columnform_id_temp");
			hidden_input_column.setAttribute("name", id+"_hidden_columnform_id_temp");
			hidden_input_column.setAttribute("type", "hidden");
			hidden_input_column.setAttribute("value", column_input);

		var hidden_ids_column = document.createElement('input');
			hidden_ids_column.setAttribute("id", id+"_column_idsform_id_temp");
			hidden_ids_column.setAttribute("name", id+"_column_idsform_id_temp");
			hidden_ids_column.setAttribute("type", "hidden");
			hidden_ids_column.setAttribute("value", column_num);								
						
		td_for_hidden.appendChild(hidden_input_row);
		td_for_hidden.appendChild(hidden_ids_row);
		td_for_hidden.appendChild(hidden_input_column);
		td_for_hidden.appendChild(hidden_ids_column);
	}

	if(document.getElementById("element_type").value=="type_section_break")
	{
		form_view=0;
		for(t=form_view_max; t>0; t--)
		{
			if(document.getElementById('form_id_tempform_view'+t))
				if(jQuery("#form_id_tempform_view"+t).is(":visible"))
				{
					form_view=t;
					break;
				}
		}
	
		if(form_view==0)
		{	alert("The pages are closed");
			return;
		}
		
		if(document.getElementById('editing_id').value)
		{
			i=document.getElementById('editing_id').value;		
			document.getElementById('editing_id').value="";
			
			
			wdform_field_in_editor=document.getElementById(i+"_element_sectionform_id_temp");

			
      ifr_id = "form_maker_editor_ifr";	
			ifr=getIFrameDocument(ifr_id);
			if(document.getElementById('form_maker_editor').style.display=="none")
				wdform_field_in_editor.innerHTML=ifr.body.innerHTML;
			else
				wdform_field_in_editor.innerHTML=document.getElementById('form_maker_editor').value;
		}
		else
		{
			i=gen;
			gen++;
			
			
			var wdform_row = document.createElement('div');
				wdform_row.setAttribute("wdid", i);
				wdform_row.setAttribute("type", "type_section_break");
				wdform_row.setAttribute("class", "wdform_tr_section_break");
		
			var wdform_field = document.createElement('div');
				wdform_field.setAttribute("id", "wdform_field"+i);
				wdform_field.setAttribute("type", "type_section_break");
				wdform_field.setAttribute("class", "wdform_field_section_break");
				
			var wdform_arrows = document.createElement('div');
				wdform_arrows.setAttribute("id", "wdform_arrows"+i);
				wdform_arrows.setAttribute("class", "wdform_arrows");
				
			wdform_field.appendChild(wdform_arrows);
		//	wdform_row.appendChild(wdform_arrows);
			wdform_row.appendChild(wdform_field);

			var select_ = document.getElementById('sel_el_pos');
			var option = document.createElement('option');
				option.setAttribute("id", i+"_sel_el_pos");
				option.setAttribute("value", i);
				option.innerHTML="custom_"+i;
				
			wdform_page=document.getElementById('form_id_tempform_view'+form_view);

			var img_X = document.createElement("img");
					img_X.setAttribute("src", plugin_url + "/images/delete_el.png");
					img_X.setAttribute("title", "Remove the field");
					img_X.setAttribute("onclick", 'remove_section_break("'+i+'")');
					img_X.setAttribute("onmouseover", 'chnage_icons_src(this,"delete_el")');
					img_X.setAttribute("onmouseout", 'chnage_icons_src(this,"delete_el")');
					
			var td_X = document.createElement("div");
					td_X.setAttribute("id", "X_"+i);
					td_X.setAttribute("class", "element_toolbar");
					td_X.appendChild(img_X);
//image pah@					
			var img_EDIT = document.createElement("img");
					img_EDIT.setAttribute("src", plugin_url + "/images/edit.png");
					img_EDIT.setAttribute("title", "Edit the field");
					img_EDIT.setAttribute("onclick", 'edit("'+i+'")');
					img_EDIT.setAttribute("onmouseover", 'chnage_icons_src(this,"edit")');
					img_EDIT.setAttribute("onmouseout", 'chnage_icons_src(this,"edit")');
					
			var td_EDIT = document.createElement("div");
					td_EDIT.setAttribute("id", "edit_"+i);
					td_EDIT.setAttribute("class", "element_toolbar");
					td_EDIT.appendChild(img_EDIT);
		
			var img_DUBLICATE = document.createElement("img");
					img_DUBLICATE.setAttribute("src", plugin_url + "/images/duplicate.png");
					img_DUBLICATE.setAttribute("title", "Duplicate the field");
					img_DUBLICATE.setAttribute("onclick", 'duplicate("'+i+'")');
					img_DUBLICATE.setAttribute("onmouseover", 'chnage_icons_src(this,"duplicate")');
					img_DUBLICATE.setAttribute("onmouseout", 'chnage_icons_src(this,"duplicate")');
					
			var td_DUBLICATE = document.createElement("div");
					td_DUBLICATE.setAttribute("id", "duplicate_"+i);
					td_DUBLICATE.setAttribute("class", "element_toolbar");
					td_DUBLICATE.appendChild(img_DUBLICATE);
					
			var in_editor = document.createElement("div");
					in_editor.setAttribute("id", i+"_element_sectionform_id_temp");
         			in_editor.setAttribute("align", 'left');
         			in_editor.setAttribute("class", 'wdform_section_break');


			ifr_id = "form_maker_editor_ifr";
			ifr=getIFrameDocument(ifr_id)

			if(document.getElementById('form_maker_editor').style.display=="none")
			{
				in_editor.innerHTML=ifr.body.innerHTML;
			}
			else
			{
				in_editor.innerHTML=document.getElementById('form_maker_editor').value;
			}
			
			
			var label = document.createElement('span');
					label.setAttribute("id", i+"_element_labelform_id_temp");
					label.innerHTML = "custom_"+i;
					label.style.cssText = 'display:none';
					
			wdform_field.appendChild(in_editor);
			td_EDIT.appendChild(label);

			wdform_arrows.appendChild(td_X);
			wdform_arrows.appendChild(td_EDIT);
			wdform_arrows.appendChild(td_DUBLICATE);

			
			beforeTr=wdform_page.lastChild;
			wdform_page.insertBefore(wdform_row, beforeTr);
				
			wdform_section_new=document.createElement('div');
				wdform_section_new.setAttribute('class','wdform_section');
				
			wdform_column_new=document.createElement('div');
				wdform_column_new.setAttribute('class','wdform_column');
				
			wdform_column_new1=document.createElement('div');
      wdform_column_new1.setAttribute('class','wdform_column');
			
			wdform_section_new.appendChild(wdform_column_new);
			wdform_section_new.appendChild(wdform_column_new1);
			
			beforeTr=wdform_page.lastChild;
			wdform_page.insertBefore(wdform_section_new, beforeTr);
				
			j=2;
			
		}
    sortable_columns();
    if(document.getElementById('enable_sortable').value==0)
      jQuery('.wdform_column').sortable( "disable" );			
    else
      jQuery( ".wdform_arrows" ).hide();

	close_window();
	return;
	}

	
	if(document.getElementById("element_type").value=="type_page_navigation")
	{
		document.getElementById("pages").setAttribute('show_title',document.getElementById("el_show_title_input").checked);
		document.getElementById("pages").setAttribute('show_numbers',document.getElementById("el_show_numbers_input").checked);
	
		if(document.getElementById("el_pagination_steps").checked)
			{
				document.getElementById("pages").setAttribute('type','steps');
				make_page_steps_front();
			}
		else
			if(document.getElementById("el_pagination_percentage").checked)
			{
				document.getElementById("pages").setAttribute('type','percentage');
				make_page_percentage_front();
			}
			else
			{
				document.getElementById("pages").setAttribute('type','none');
				make_page_none_front();
			}
		
		refresh_page_numbers();
		close_window() ;
		
		return;

	}

	if(document.getElementById("element_type").value=="type_page_break")
	{
		if(document.getElementById("editing_id").value)
		{	
			i=document.getElementById("editing_id").value;
			form_view_element	=document.getElementById('form_id_tempform_view'+i);
			page_title			=document.getElementById('_div_between').getAttribute('page_title');
			next_title			=document.getElementById('_div_between').getAttribute('next_title');
			next_type			=document.getElementById('_div_between').getAttribute('next_type');
			next_class			=document.getElementById('_div_between').getAttribute('next_class');
			next_checkable		=document.getElementById('_div_between').getAttribute('next_checkable');
			previous_title		=document.getElementById('_div_between').getAttribute('previous_title');
			previous_type		=document.getElementById('_div_between').getAttribute('previous_type');
			previous_class		=document.getElementById('_div_between').getAttribute('previous_class');
			previous_checkable	=document.getElementById('_div_between').getAttribute('previous_checkable');
			form_view_element.setAttribute('next_title',next_title);
			form_view_element.setAttribute('next_type',next_type);
			form_view_element.setAttribute('next_class',next_class);
			form_view_element.setAttribute('next_checkable',next_checkable);
			form_view_element.setAttribute('previous_title',previous_title);
			form_view_element.setAttribute('previous_type',previous_type);
			form_view_element.setAttribute('previous_class',previous_class);
			form_view_element.setAttribute('previous_checkable',previous_checkable);
			form_view_element.setAttribute('page_title',page_title);
			
			var input = document.getElementById('_div_between'); 
			atr=input.attributes;
			for(v=0;v<30;v++)
				if(atr[v] )
				{
					if(atr[v].name.indexOf("add_")==0)
					{
						form_view_element.setAttribute(atr[v].name,atr[v].value);
					}
				}
				
		if(form_view_count!=1)

			generate_page_nav(form_view);
			sortable_columns();
			if(document.getElementById('enable_sortable').value==0)
				jQuery('.wdform_column').sortable( "disable" );			
			else
				jQuery( ".wdform_arrows" ).hide();
			close_window() ;
			return;
		}
		else
		{	

		for(t=form_view_max; t>0; t--)
		{
			if(document.getElementById('form_id_tempform_view'+t))
			{
					form_view=t;
					break;
			}
		}
		
		
		

		if(form_view_count==1)
		{
			
			var img_EDIT = document.createElement("img");
					img_EDIT.setAttribute("src", plugin_url + "/images/edit.png");
					img_EDIT.setAttribute("title", "Edit the pagination options");
					img_EDIT.style.cssText = "margin-left:40px; cursor:pointer";
					img_EDIT.setAttribute("onclick", 'el_page_navigation()');
					
			var td_EDIT = document.getElementById("edit_page_navigation");
					td_EDIT.appendChild(img_EDIT);
			
			document.getElementById('page_navigation').appendChild(td_EDIT);

		}
		
		old_to_gen=form_view;
		
		form_view_max++;
		form_view_count++;
		form_view=form_view_max;
		
		table=document.createElement('div');
			table.setAttribute('class','wdform-page-and-images');
			table.style.cssText = "display:table; border-top:1px solid black";
 
 
		tbody=document.createElement('div');
			tbody.setAttribute('id','form_id_tempform_view'+form_view);
			tbody.setAttribute('page_title','Untitled Page');
			tbody.setAttribute('class','wdform_page');

		tbody_img=document.createElement('div');
			tbody_img.setAttribute('id','form_id_tempform_view_img'+form_view);
			tbody_img.style.cssText = "float:right";
			
		tr_img=document.createElement('div');

		var	img=document.createElement('img');
			img.setAttribute('src',plugin_url + '/images/minus.png');
			img.setAttribute('title','Show or hide the page');
			img.setAttribute("class", "page_toolbar");
			img.setAttribute('id','show_page_img_'+form_view);
			img.setAttribute('onClick','show_or_hide("'+form_view+'")');
			img.setAttribute("onmouseover", 'chnage_icons_src(this,"minus")');
			img.setAttribute("onmouseout", 'chnage_icons_src(this,"minus")');

		var img_X = document.createElement("img");
			img_X.setAttribute("src", plugin_url + "/images/page_delete.png?ver=1.8.0");
			img_X.setAttribute('title','Delete the page');
			img_X.setAttribute("class", "page_toolbar");
			img_X.setAttribute("onclick", 'remove_page("'+form_view+'")');
			img_X.setAttribute("onmouseover", 'chnage_icons_src(this,"page_delete")');
			img_X.setAttribute("onmouseout", 'chnage_icons_src(this,"page_delete")');
		
		var img_X_all = document.createElement("img");
			img_X_all.setAttribute("src", plugin_url + "/images/page_delete_all.png");
			img_X_all.setAttribute('title','Delete the page with fields');
			img_X_all.setAttribute("class", "page_toolbar");
			img_X_all.setAttribute("onclick", 'remove_page_all("'+form_view+'")');
			img_X_all.setAttribute("onmouseover", 'chnage_icons_src(this,"page_delete_all")');
			img_X_all.setAttribute("onmouseout", 'chnage_icons_src(this,"page_delete_all")');
			
		var img_EDIT = document.createElement("img");
			img_EDIT.setAttribute("src", plugin_url + "/images/page_edit.png");
			img_EDIT.setAttribute('title','Edit the page');
			img_EDIT.setAttribute("class", "page_toolbar");
			img_EDIT.setAttribute("onclick", 'edit_page_break("'+form_view+'")');
			img_EDIT.setAttribute("onmouseover", 'chnage_icons_src(this,"page_edit")');
			img_EDIT.setAttribute("onmouseout", 'chnage_icons_src(this,"page_edit")');
			
		tr_img.appendChild(img);
		tr_img.appendChild(img_X);
		tr_img.appendChild(img_X_all);
		tr_img.appendChild(img_EDIT);
		tbody_img.appendChild(tr_img);
			
			
		tr=document.createElement('div');
			tr.setAttribute('class','wdform_section');

			tr_page_nav=document.createElement('div');
				tr_page_nav.setAttribute('valign','top');
				tr_page_nav.setAttribute('class','wdform_footer');
				tr_page_nav.style.width="100%";
				
			td_page_nav=document.createElement('div');
				td_page_nav.style.width="100%";
				
			table_min_page_nav=document.createElement('div');
				table_min_page_nav.style.width="100%";
				table_min_page_nav.style.display="table";
				
			tbody_min_page_nav=document.createElement('div');
				tbody_min_page_nav.style.display="table-row-group";
			tr_min_page_nav=document.createElement('div');
				tr_min_page_nav.setAttribute('id','form_id_temppage_nav'+form_view);
				tr_min_page_nav.style.display="table-row";
					
		table_min=document.createElement('div');
			table_min.setAttribute('class','wdform_column');

      table_min1=document.createElement('div');
			table_min1.setAttribute('class','wdform_column');
	
      tr.appendChild(table_min);
      tr.appendChild(table_min1);
		
			tbody_min_page_nav.appendChild(tr_min_page_nav);
			table_min_page_nav.appendChild(tbody_min_page_nav);
			td_page_nav.appendChild(table_min_page_nav);
			tr_page_nav.appendChild(td_page_nav);
		tbody.appendChild(tr);
		tbody.appendChild(tr_page_nav);
		table.appendChild(tbody);
		table.appendChild(tbody_img);
		
		document.getElementById('take').appendChild(table);	
	
		form_view_element	=document.getElementById('form_id_tempform_view'+form_view);
		page_title			=document.getElementById('_div_between').getAttribute('page_title');
		next_title			=document.getElementById('_div_between').getAttribute('next_title');
		next_type			=document.getElementById('_div_between').getAttribute('next_type');
		next_class			=document.getElementById('_div_between').getAttribute('next_class');
		next_checkable		=document.getElementById('_div_between').getAttribute('next_checkable');
		previous_title		=document.getElementById('_div_between').getAttribute('previous_title');
		previous_type		=document.getElementById('_div_between').getAttribute('previous_type');
		previous_class		=document.getElementById('_div_between').getAttribute('previous_class');
		previous_checkable	=document.getElementById('_div_between').getAttribute('previous_checkable');
		form_view_element.setAttribute('next_title',next_title);
		form_view_element.setAttribute('next_type',next_type);
		form_view_element.setAttribute('next_class',next_class);
		form_view_element.setAttribute('next_checkable',next_checkable);
		form_view_element.setAttribute('previous_title',previous_title);
		form_view_element.setAttribute('previous_type',previous_type);
		form_view_element.setAttribute('previous_class',previous_class);
		form_view_element.setAttribute('previous_checkable',previous_checkable);
		form_view_element.setAttribute('page_title',page_title);
			
		
		var input = document.getElementById('_div_between'); 
		atr=input.attributes;
		
		for(v=0;v<30;v++)
			if(atr[v] )
			{
				if(atr[v].name.indexOf("add_")==0)
				{
					form_view_element.setAttribute(atr[v].name,atr[v].value);
				}
			}
			
	if(form_view_count==2)
	{
		generate_page_nav(form_view);
		generate_page_nav(old_to_gen);
	/*	show_form_view(form_view);
		show_form_view(old_to_gen);*/
	}
	else
		generate_page_nav(form_view);
    sortable_columns();
		if(document.getElementById('enable_sortable').value==0)
			jQuery('.wdform_column').sortable( "disable" );			
		else
			jQuery( ".wdform_arrows" ).hide();
		close_window() ;

		return;
		
		}  
		
	}
	
	form_view=0;
	for(t=form_view_max; t>0; t--)
	{
		if(document.getElementById('form_id_tempform_view'+t))
			if(jQuery("#form_id_tempform_view"+t).is(":visible"))
			{
				form_view=t;
				break;
			}
	}

	if(form_view==0)
	{	alert("The pages are closed");
		return;
	}

	
	if(document.getElementById('main_editor').style.display=="block")
	{
		if(document.getElementById('editing_id').value)
		{
			i=document.getElementById('editing_id').value;		
				document.getElementById('editing_id').value="";
			wdform_field=document.getElementById("wdform_field"+i);
			destroyChildren(wdform_field);

			
			ifr_id = "form_maker_editor_ifr";
			ifr=getIFrameDocument(ifr_id);
			if(document.getElementById('form_maker_editor').style.display=="none")
			{
				wdform_field.innerHTML=ifr.body.innerHTML;
			}
			else
			{
				wdform_field.innerHTML=document.getElementById('form_maker_editor').value;
			}
			
			j=2;
			
		}
		else
		{
			i=gen;
			gen++;
			
				
			var select_ = document.getElementById('sel_el_pos');
			var option = document.createElement('option');
				option.setAttribute("id", i+"_sel_el_pos");
				option.setAttribute("value", i);
				option.innerHTML="custom_"+i;
				
			l=document.getElementById('form_id_tempform_view'+form_view).childNodes.length;
			wdform_column=document.getElementById('form_id_tempform_view'+form_view).childNodes[l-2].firstChild;

			var wdform_row = document.createElement('div');
				wdform_row.setAttribute("wdid", i);
				wdform_row.setAttribute("class", "wdform_row ui-sortable-handle");
		
			var wdform_field = document.createElement('div');
				wdform_field.setAttribute("id", "wdform_field"+i);
				wdform_field.setAttribute("type", "type_editor");
				wdform_field.setAttribute("class", "wdform_field");
				wdform_field.style.cssText = 'margin-top:0px';
				
			var wdform_arrows = document.createElement('div');
				wdform_arrows.setAttribute("id", "wdform_arrows"+i);
				wdform_arrows.setAttribute("class", "wdform_arrows");
				wdform_arrows.setAttribute("type", "type_editor");
				wdform_arrows.style.cssText = 'margin-top:0px';
				
			wdform_row.appendChild(wdform_arrows);
			wdform_row.appendChild(wdform_field);
			
			var img_X = document.createElement("img");
					img_X.setAttribute("src", plugin_url + "/images/delete_el.png");
					img_X.setAttribute("title", "Remove the field");
					img_X.setAttribute("onclick", 'remove_row("'+i+'")');
					img_X.setAttribute("onmouseover", 'chnage_icons_src(this,"delete_el")');
					img_X.setAttribute("onmouseout", 'chnage_icons_src(this,"delete_el")');
					
			var td_X = document.createElement("div");
					td_X.setAttribute("id", "X_"+i);
					td_X.setAttribute("valign", "middle");
					td_X.setAttribute("align", "right");
					td_X.setAttribute("class", "element_toolbar");
					td_X.appendChild(img_X);
//image pah@
			var img_UP = document.createElement("img");
					img_UP.setAttribute("src", plugin_url + "/images/up.png");
					img_UP.setAttribute("title", "Move the field up");
					img_UP.setAttribute("onclick", 'up_row("'+i+'")');
					img_UP.setAttribute("onmouseover", 'chnage_icons_src(this,"up")');
					img_UP.setAttribute("onmouseout", 'chnage_icons_src(this,"up")');
					
			var td_UP = document.createElement("div");
					td_UP.setAttribute("id", "up_"+i);
					td_UP.setAttribute("valign", "middle");
					td_UP.setAttribute("class", "element_toolbar");
					td_UP.appendChild(img_UP);

			var img_DOWN = document.createElement("img");
					img_DOWN.setAttribute("src", plugin_url + "/images/down.png");
					img_DOWN.setAttribute("title", "Move the field down");
					img_DOWN.setAttribute("onclick", 'down_row("'+i+'")');
					img_DOWN.setAttribute("onmouseover", 'chnage_icons_src(this,"down")');
					img_DOWN.setAttribute("onmouseout", 'chnage_icons_src(this,"down")');
					
			var td_DOWN = document.createElement("div");
					td_DOWN.setAttribute("id", "down_"+i);
					td_DOWN.setAttribute("valign", "middle");
					td_DOWN.setAttribute("class", "element_toolbar");
					td_DOWN.appendChild(img_DOWN);
					
			var img_RIGHT = document.createElement("img");
					img_RIGHT.setAttribute("src", plugin_url + "/images/right.png");
					img_RIGHT.setAttribute("title", "Move the field to the right");
					img_RIGHT.setAttribute("onclick", 'right_row("'+i+'")');
					img_RIGHT.setAttribute("onmouseover", 'chnage_icons_src(this,"right")');
					img_RIGHT.setAttribute("onmouseout", 'chnage_icons_src(this,"right")');
					
			var td_RIGHT = document.createElement("div");
					td_RIGHT.setAttribute("id", "right_"+i);
					td_RIGHT.setAttribute("valign", "middle");
					td_RIGHT.setAttribute("class", "element_toolbar");
					td_RIGHT.appendChild(img_RIGHT);
					
			var img_LEFT = document.createElement("img");
					img_LEFT.setAttribute("src", plugin_url + "/images/left.png");
					img_LEFT.setAttribute("title", "Move the field to the left");
					img_LEFT.setAttribute("onclick", 'left_row("'+i+'")');
					img_LEFT.setAttribute("onmouseover", 'chnage_icons_src(this,"left")');
					img_LEFT.setAttribute("onmouseout", 'chnage_icons_src(this,"left")');
					
			var td_LEFT = document.createElement("div");
					td_LEFT.setAttribute("id", "left_"+i);
					td_LEFT.setAttribute("valign", "middle");
					td_LEFT.setAttribute("class", "element_toolbar");
					td_LEFT.appendChild(img_LEFT);
					
			var img_EDIT = document.createElement("img");
					img_EDIT.setAttribute("src", plugin_url + "/images/edit.png");
					img_EDIT.setAttribute("title", "Edit the field");
					img_EDIT.setAttribute("onclick", 'edit("'+i+'")');
					img_EDIT.setAttribute("onmouseover", 'chnage_icons_src(this,"edit")');
					img_EDIT.setAttribute("onmouseout", 'chnage_icons_src(this,"edit")');
					
			var td_EDIT = document.createElement("div");
					td_EDIT.setAttribute("id", "edit_"+i);
					td_EDIT.setAttribute("valign", "middle");
					td_EDIT.setAttribute("class", "element_toolbar");
					td_EDIT.appendChild(img_EDIT);
		
			var img_DUBLICATE = document.createElement("img");
					img_DUBLICATE.setAttribute("src", plugin_url + "/images/duplicate.png");
					img_DUBLICATE.setAttribute("title", "Duplicate the field");
					img_DUBLICATE.setAttribute("onclick", 'duplicate("'+i+'")');
					img_DUBLICATE.setAttribute("onmouseover", 'chnage_icons_src(this,"duplicate")');
					img_DUBLICATE.setAttribute("onmouseout", 'chnage_icons_src(this,"duplicate")');
					
			var td_DUBLICATE = document.createElement("div");
					td_DUBLICATE.setAttribute("id", "duplicate_"+i);
					td_DUBLICATE.setAttribute("valign", "middle");
					td_DUBLICATE.setAttribute("class", "element_toolbar");
					td_DUBLICATE.appendChild(img_DUBLICATE);
					
			var img_PAGEUP = document.createElement("img");
					img_PAGEUP.setAttribute("src", plugin_url + "/images/page_up.png");
					img_PAGEUP.setAttribute("title", "Move the field to the upper page");
					img_PAGEUP.setAttribute("onclick", 'page_up("'+i+'")');
					img_PAGEUP.setAttribute("onmouseover", 'chnage_icons_src(this,"page_up")');
					img_PAGEUP.setAttribute("onmouseout", 'chnage_icons_src(this,"page_up")');
					
			var td_PAGEUP = document.createElement("div");
					td_PAGEUP.setAttribute("id", "page_up_"+i);
					td_PAGEUP.setAttribute("valign", "middle");
					td_PAGEUP.setAttribute("class", "element_toolbar");
					td_PAGEUP.appendChild(img_PAGEUP);
					
			var img_PAGEDOWN = document.createElement("img");
					img_PAGEDOWN.setAttribute("src", plugin_url + "/images/page_down.png");
					img_PAGEDOWN.setAttribute("title", "Move the field to the lower page");
					img_PAGEDOWN.setAttribute("onclick", 'page_down("'+i+'")');
					img_PAGEDOWN.setAttribute("onmouseover", 'chnage_icons_src(this,"page_down")');
					img_PAGEDOWN.setAttribute("onmouseout", 'chnage_icons_src(this,"page_down")');
					
			var td_PAGEDOWN = document.createElement("div");
					td_PAGEDOWN.setAttribute("id", "page_down_"+i);
					td_PAGEDOWN.setAttribute("valign", "middle");
					td_PAGEDOWN.setAttribute("class", "element_toolbar");
					td_PAGEDOWN.appendChild(img_PAGEDOWN);
					

		ifr_id = "form_maker_editor_ifr";
		ifr=getIFrameDocument(ifr_id)

		if(document.getElementById('form_maker_editor').style.display=="none")
		{
				wdform_field.innerHTML=ifr.body.innerHTML;
		}
		else
		{
				wdform_field.innerHTML=document.getElementById('form_maker_editor').value;
		}
			
			
			
			var label = document.createElement('span');
				label.setAttribute("id", i+"_element_labelform_id_temp");
				label.innerHTML = "custom_"+i;
				label.style.cssText = 'display:none';
					
			td_EDIT.appendChild(label);

			wdform_arrows.appendChild(td_X);
			wdform_arrows.appendChild(td_LEFT);
			wdform_arrows.appendChild(td_UP);
			wdform_arrows.appendChild(td_DOWN);
			wdform_arrows.appendChild(td_RIGHT);
			wdform_arrows.appendChild(td_EDIT);
			wdform_arrows.appendChild(td_DUBLICATE);
			wdform_arrows.appendChild(td_PAGEUP);
			wdform_arrows.appendChild(td_PAGEDOWN);

			if(document.getElementById('pos_end').checked)
			{
				wdform_column.appendChild(wdform_row);
			}
			if(document.getElementById('pos_begin').checked)
			{	
				wdform_column.insertBefore(wdform_row, wdform_column.firstChild);
			}
			if(document.getElementById('pos_before').checked)
			{
				beforeTr=document.getElementById("wdform_field"+document.getElementById('sel_el_pos').value).parentNode;
				wdform_column=beforeTr.parentNode;
				beforeOption=document.getElementById(document.getElementById('sel_el_pos').value+'_sel_el_pos');
				wdform_column.insertBefore(wdform_row, beforeTr);
				select_.insertBefore(option, beforeOption);
			}
			j=2;
			;
		
		}

	close_window();
	}


	else
	if(document.getElementById('show_table').innerHTML)
	{
		
		if(document.getElementById('editing_id').value)
			i=document.getElementById('editing_id').value;		
		else
			i=gen;
			
		type=document.getElementById("element_type").value;
		if(type=="type_hidden")
		{
			if(document.getElementById(i+'_elementform_id_temp').name=="")
			{
				alert("The name of the field is required.");
				return;
			}
		}
		
		if(type=="type_map")
		{
			if_gmap_updateMap(i);
		}
		
		if(type=="type_mark_map")
		{
			if_gmap_updateMap(i);
		}
	
	
		if(document.getElementById(i+'_element_labelform_id_temp').innerHTML)
		{

		if(document.getElementById('editing_id').value)
		{
			Disable();
			i=document.getElementById('editing_id').value;		
			in_lab=false;
			labels_array=new Array();
			for(w=0; w<gen;w++)
			{	
				if(w!=i)
				if(document.getElementById(w+'_element_labelform_id_temp'))
					labels_array.push(document.getElementById(w+'_element_labelform_id_temp').innerHTML);
			}			
	
			for(t=0; t<labels_array.length;t++)
			{	
			if(document.getElementById(i+'_element_labelform_id_temp').innerHTML==labels_array[t])
				{
					in_lab=true;
					break;
				}
			}
			if(in_lab)
			{
				alert('Sorry, the labels must be unique.');
				return;
			}
			else
			{
	
	
	
	
				document.getElementById('editing_id').value="";
	
				wdform_field=document.getElementById("wdform_field"+i);
        wdform_arrows=document.getElementById("wdform_arrows"+i);
				destroyChildren(wdform_field);
	
	
						var add1 = document.getElementById(i+'_label_sectionform_id_temp');
						var add2 = document.getElementById(i+'_element_sectionform_id_temp');
						wdform_field.appendChild(wdform_arrows);
						wdform_field.appendChild(add1);
						wdform_field.appendChild(add2);
	
	
				j=2;
	
				close_window() ;
				
			call(i,key);
			}
		}
		else
		{	
		i=gen;
		in_lab=false;
		labels_array=new Array();
		for(w=0; w<gen;w++)
		{	
			if(document.getElementById(w+'_element_labelform_id_temp'))
				labels_array.push(document.getElementById(w+'_element_labelform_id_temp').innerHTML);
		}			
		for(t=0; t<labels_array.length;t++)
		{	
		if(document.getElementById(i+'_element_labelform_id_temp').innerHTML==labels_array[t])
			{
				in_lab=true;
				break;
			}
		}
		if(in_lab)
		{
			alert('Sorry, the labels must be unique.');
			return
		}
		else
		{
			
			if(type=="type_address")
				gen=gen+6;
			else
				gen++;			
				
			l=document.getElementById('form_id_tempform_view'+form_view).childNodes.length;
			
			wdform_column=document.getElementById('form_id_tempform_view'+form_view).childNodes[l-2].firstChild;
					
			var wdform_row = document.createElement('div');
				wdform_row.setAttribute("wdid", i);
				wdform_row.setAttribute("class", "wdform_row ui-sortable-handle");
		
			var wdform_field = document.createElement('div');
				wdform_field.setAttribute("id", "wdform_field"+i);
				wdform_field.setAttribute("type", type);
				wdform_field.setAttribute("class", "wdform_field");
				wdform_field.style.display="table-cell";
				
			var wdform_arrows = document.createElement('div');
				wdform_arrows.setAttribute("id", "wdform_arrows"+i);
				wdform_arrows.setAttribute("class", "wdform_arrows");
				
			wdform_row.appendChild(wdform_arrows);
			wdform_row.appendChild(wdform_field);
			
			
			
			var select_ = document.getElementById('sel_el_pos');
			var option = document.createElement('option');
				option.setAttribute("id", i+"_sel_el_pos");
				option.setAttribute("value", i);
				option.innerHTML=document.getElementById(i+'_element_labelform_id_temp').innerHTML;

			var img_X = document.createElement("img");
					img_X.setAttribute("src", plugin_url + "/images/delete_el.png");
					img_X.setAttribute("title", "Remove the field");
					img_X.setAttribute("onclick", 'remove_row("'+i+'")');
					img_X.setAttribute("onmouseover", 'chnage_icons_src(this,"delete_el")');
					img_X.setAttribute("onmouseout", 'chnage_icons_src(this,"delete_el")');
					
			var td_X = document.createElement("div");
					td_X.setAttribute("id", "X_"+i);
					td_X.setAttribute("valign", "middle");
					td_X.setAttribute("align", "right");
					td_X.setAttribute("class", "element_toolbar");
					td_X.appendChild(img_X);
//image pah@
			var img_UP = document.createElement("img");
					img_UP.setAttribute("src", plugin_url + "/images/up.png");
					img_UP.setAttribute("title", "Move the field up");
					img_UP.setAttribute("onclick", 'up_row("'+i+'")');
					img_UP.setAttribute("onmouseover", 'chnage_icons_src(this,"up")');
					img_UP.setAttribute("onmouseout", 'chnage_icons_src(this,"up")');
					
			var td_UP = document.createElement("div");
					td_UP.setAttribute("id", "up_"+i);
					td_UP.setAttribute("valign", "middle");
					td_UP.setAttribute("class", "element_toolbar");
					td_UP.appendChild(img_UP);
					
			var img_DOWN = document.createElement("img");
					img_DOWN.setAttribute("src", plugin_url + "/images/down.png");
					img_DOWN.setAttribute("title", "Move the field down");
					img_DOWN.setAttribute("onclick", 'down_row("'+i+'")');
					img_DOWN.setAttribute("onmouseover", 'chnage_icons_src(this,"down")');
					img_DOWN.setAttribute("onmouseout", 'chnage_icons_src(this,"down")');
					
			var td_DOWN = document.createElement("div");
					td_DOWN.setAttribute("id", "down_"+i);
					td_DOWN.setAttribute("valign", "middle");
					td_DOWN.setAttribute("class", "element_toolbar");
					td_DOWN.appendChild(img_DOWN);
					
			var img_RIGHT = document.createElement("img");
					img_RIGHT.setAttribute("src", plugin_url + "/images/right.png");
					img_RIGHT.setAttribute("title", "Move the field to the right");
					img_RIGHT.setAttribute("onclick", 'right_row("'+i+'")');
					img_RIGHT.setAttribute("onmouseover", 'chnage_icons_src(this,"right")');
					img_RIGHT.setAttribute("onmouseout", 'chnage_icons_src(this,"right")');
					
			var td_RIGHT = document.createElement("div");
					td_RIGHT.setAttribute("id", "right_"+i);
					td_RIGHT.setAttribute("valign", "middle");
					td_RIGHT.setAttribute("class", "element_toolbar");
					td_RIGHT.appendChild(img_RIGHT);
					
			var img_LEFT = document.createElement("img");
					img_LEFT.setAttribute("src", plugin_url + "/images/left.png");
					img_LEFT.setAttribute("title", "Move the field to the left");
					img_LEFT.setAttribute("onclick", 'left_row("'+i+'")');
					img_LEFT.setAttribute("onmouseover", 'chnage_icons_src(this,"left")');
					img_LEFT.setAttribute("onmouseout", 'chnage_icons_src(this,"left")');
					
			var td_LEFT = document.createElement("div");
					td_LEFT.setAttribute("id", "left_"+i);
					td_LEFT.setAttribute("valign", "middle");
					td_LEFT.setAttribute("class", "element_toolbar");
					td_LEFT.appendChild(img_LEFT);
					
			var img_EDIT = document.createElement("img");
					img_EDIT.setAttribute("src", plugin_url + "/images/edit.png");
					img_EDIT.setAttribute("title", "Edit the field");
					img_EDIT.setAttribute("onclick", 'edit("'+i+'")');
					img_EDIT.setAttribute("onmouseover", 'chnage_icons_src(this,"edit")');
					img_EDIT.setAttribute("onmouseout", 'chnage_icons_src(this,"edit")');
					
			var td_EDIT = document.createElement("div");
					td_EDIT.setAttribute("id", "edit_"+i);
					td_EDIT.setAttribute("valign", "middle");
					td_EDIT.setAttribute("class", "element_toolbar");
					td_EDIT.appendChild(img_EDIT);
		
			var img_DUBLICATE = document.createElement("img");
					img_DUBLICATE.setAttribute("src", plugin_url + "/images/duplicate.png");
					img_DUBLICATE.setAttribute("title", "Duplicate the field");
					img_DUBLICATE.setAttribute("onclick", 'duplicate("'+i+'")');
					img_DUBLICATE.setAttribute("onmouseover", 'chnage_icons_src(this,"duplicate")');
					img_DUBLICATE.setAttribute("onmouseout", 'chnage_icons_src(this,"duplicate")');
					
			var td_DUBLICATE = document.createElement("div");
					td_DUBLICATE.setAttribute("id", "duplicate_"+i);
					td_DUBLICATE.setAttribute("valign", "middle");
					td_DUBLICATE.setAttribute("class", "element_toolbar");
					td_DUBLICATE.appendChild(img_DUBLICATE);

			var img_PAGEUP = document.createElement("img");
					img_PAGEUP.setAttribute("src", plugin_url + "/images/page_up.png");
					img_PAGEUP.setAttribute("title", "Move the field to the upper page");
					img_PAGEUP.setAttribute("onclick", 'page_up("'+i+'")');
					img_PAGEUP.setAttribute("onmouseover", 'chnage_icons_src(this,"page_up")');
					img_PAGEUP.setAttribute("onmouseout", 'chnage_icons_src(this,"page_up")');
					
			var td_PAGEUP = document.createElement("div");
					td_PAGEUP.setAttribute("id", "page_up_"+i);
					td_PAGEUP.setAttribute("valign", "middle");
					td_PAGEUP.setAttribute("class", "element_toolbar");
					td_PAGEUP.appendChild(img_PAGEUP);
					
			var img_PAGEDOWN = document.createElement("img");
					img_PAGEDOWN.setAttribute("src", plugin_url + "/images/page_down.png");
					img_PAGEDOWN.setAttribute("title", "Move the field to the lower page");
					img_PAGEDOWN.setAttribute("onclick", 'page_down("'+i+'")');
					img_PAGEDOWN.setAttribute("onmouseover", 'chnage_icons_src(this,"page_down")');
					img_PAGEDOWN.setAttribute("onmouseout", 'chnage_icons_src(this,"page_down")');
					
			var td_PAGEDOWN = document.createElement("div");
					td_PAGEDOWN.setAttribute("id", "page_down_"+i);
					td_PAGEDOWN.setAttribute("valign", "middle");
					td_PAGEDOWN.setAttribute("class", "element_toolbar");
					td_PAGEDOWN.appendChild(img_PAGEDOWN);
///////////////////////////////////////////////////////////////////////////////////////////////

			
						var add1 = document.getElementById(i+'_label_sectionform_id_temp');
						var add2 = document.getElementById(i+'_element_sectionform_id_temp');
						
						wdform_field.appendChild(add1);
						wdform_field.appendChild(add2);
	
			wdform_arrows.appendChild(td_X);
			wdform_arrows.appendChild(td_LEFT);
			wdform_arrows.appendChild(td_UP);
			wdform_arrows.appendChild(td_DOWN);
			wdform_arrows.appendChild(td_RIGHT);
			wdform_arrows.appendChild(td_EDIT);
			
			if(type!="type_captcha" && type!="type_arithmetic_captcha" && type!="type_recaptcha" && type!="type_send_copy" && type!="type_stripe")
			{
				wdform_arrows.appendChild(td_DUBLICATE);
			}
			else			
			{
				td_DUBLICATE.removeChild(img_DUBLICATE);
				wdform_arrows.appendChild(td_DUBLICATE);
			}
			
			wdform_arrows.appendChild(td_PAGEUP);
			wdform_arrows.appendChild(td_PAGEDOWN);
			
			if(document.getElementById('pos_end').checked)
			{
				wdform_column.appendChild(wdform_row);
			}
			if(document.getElementById('pos_begin').checked)
			{	
				wdform_column.insertBefore(wdform_row, wdform_column.firstChild);
			}
			if(document.getElementById('pos_before').checked)
			{	

				beforeTr=document.getElementById("wdform_field"+document.getElementById('sel_el_pos').value).parentNode;
				wdform_column=beforeTr.parentNode;
				beforeOption=document.getElementById(document.getElementById('sel_el_pos').value+'_sel_el_pos');
				wdform_column.insertBefore(wdform_row, beforeTr);
				select_.insertBefore(option, beforeOption);
			}
			j=2;
			close_window() ;
		call(i,key);
		
		}
	}	
	}
		else
		{
			alert("The field label is required.");
			return;
		}
	
/*	undo_redo.push(document.getElementById('take').innerHTML);
	undo_redo_num++;*/
	}			
	else alert("Please select an element to add.");
  if(document.getElementById('enable_sortable').value==1)
		jQuery( ".wdform_arrows" ).hide();

	jQuery(".wdform_page input[type='text'], .wdform_page input[type='password'], .wdform_page input[type='file'], .wdform_page textarea, .wdform_page input[type='checkbox'], .wdform_page input[type='radio'], .wdform_page select").prop("disabled", true);

}

function call(i,key)
{
	need_enable=false;
	after_edit= false;
	if(key==0)
	{
		if(document.getElementById("pos_end").getAttribute('disabled')=='disabled')
			after_edit= true;
		edit(i);
		add('1',after_edit, i);
	}
	need_enable=true;
}

function edit_page_break(id)
{
		enable2();
		
	document.getElementById('editing_id').value=id;

		form_view_element	=document.getElementById('form_id_tempform_view'+id);
		page_title			=form_view_element.getAttribute('page_title');
		if(form_view_element.getAttribute('next_title'))
		{
			next_title			=form_view_element.getAttribute('next_title');
			next_type			=form_view_element.getAttribute('next_type');
			next_class			=form_view_element.getAttribute('next_class');
			next_checkable		=form_view_element.getAttribute('next_checkable');
			previous_title		=form_view_element.getAttribute('previous_title');
			previous_type		=form_view_element.getAttribute('previous_type');
			previous_class		=form_view_element.getAttribute('previous_class');
			previous_checkable	=form_view_element.getAttribute('previous_checkable');
			w_title	=[ next_title, previous_title];
			w_type	=[next_type,previous_type];
			w_class	=[next_class,previous_class];
			w_check	=[next_checkable,previous_checkable];
		}
		else
		{
			w_title	=[ "Next","Previous"];
			w_type	=["text","text"];
			w_class	=["",""];
			w_check	=['true', 'true'];
		}
		
	
	//atrs=return_attributes('form_id_tempform_view'+id);
	w_attr_name=[];
	w_attr_value=[];
	type_page_break(id, page_title , w_title, w_type, w_class, w_check, w_attr_name, w_attr_value);

}

function edit(id)
{
	if(need_enable)
		enable2();
	
	document.getElementById('editing_id').value=id;
	type=document.getElementById("wdform_field"+id).getAttribute('type');
	
	
	//////////////////////////////parameter take
	k=0;
	
	w_choices=new Array();	
	w_choices_value=new Array();
	w_choices_params=new Array();
	w_choices_checked=new Array();
	w_choices_disabled=new Array();
	w_allow_other_num=0;
	w_property=new Array();	

	w_property_values=new Array();
	w_choices_price=new Array();

	t=0;
	
	/////////shat handipox
	
	if(document.getElementById(id+'_element_labelform_id_temp').innerHTML)
		w_field_label=document.getElementById(id+'_element_labelform_id_temp').innerHTML;
  else
    w_field_label=" ";
		
	if(document.getElementById(id+'_label_sectionform_id_temp'))
	if(document.getElementById(id+'_label_sectionform_id_temp').style.display=="block")
		w_field_label_pos="top";
	else
		w_field_label_pos="left";
		
	if(document.getElementById(id+"_elementform_id_temp"))
	{
		s=document.getElementById(id+"_elementform_id_temp").style.width;
		 w_size=s.substring(0,s.length-2);
	}
	
	if(document.getElementById(id+"_label_sectionform_id_temp"))
	{
		s=document.getElementById(id+"_label_sectionform_id_temp").style.width;
		w_field_label_size=s.substring(0,s.length-2);
	}
	
	if(document.getElementById(id+"_requiredform_id_temp"))
	  	w_required=document.getElementById(id+"_requiredform_id_temp").value;
		
	if(document.getElementById(id+"_uniqueform_id_temp"))
	  	w_unique=document.getElementById(id+"_uniqueform_id_temp").value;
		
	if(document.getElementById(id+'_label_sectionform_id_temp'))
	{
		w_class=document.getElementById(id+'_label_sectionform_id_temp').getAttribute("class");
		if(!w_class)
			w_class="";
	}
		

	switch(type)
		{
			case 'type_editor':
			{
				w_editor=document.getElementById("wdform_field"+id).innerHTML;
				type_editor(id, w_editor); break;
			}
			case 'type_section_break':
			{
				w_editor=document.getElementById(id+"_element_sectionform_id_temp").innerHTML;
				type_section_break(id, w_editor); break;
			}
			case 'type_send_copy':
			{
				w_first_val=document.getElementById(id+"_elementform_id_temp").checked;
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_send_copy(id, w_field_label, w_field_label_size, w_field_label_pos, w_first_val, w_required, w_attr_name, w_attr_value); break;
			}
			case 'type_text':
			{
				w_first_val=document.getElementById(id+"_elementform_id_temp").value;
				w_title=document.getElementById(id+"_elementform_id_temp").title;
				w_regExp_status = document.getElementById(id+"_regExpStatusform_id_temp").value;
				w_regExp_value = unescape(document.getElementById(id+"_regExp_valueform_id_temp").value);
				w_regExp_common = document.getElementById(id+"_regExp_commonform_id_temp").value;
				w_regExp_arg = document.getElementById(id+"_regArgumentform_id_temp").value;
				w_regExp_alert = document.getElementById(id+"_regExp_alertform_id_temp").value;
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_text(id, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_first_val, w_title, w_required, w_regExp_status, w_regExp_value, w_regExp_common, w_regExp_arg, w_regExp_alert, w_unique, w_attr_name, w_attr_value); break;
			}
			case 'type_number':
			{
				w_first_val=document.getElementById(id+"_elementform_id_temp").value;
				w_title=document.getElementById(id+"_elementform_id_temp").title;
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_number(id, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_first_val, w_title, w_required, w_unique, w_class,  w_attr_name, w_attr_value); break;
			}
			case 'type_password':
			{
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_password(id, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_required, w_unique, w_class, w_attr_name, w_attr_value); break;
			}
			case 'type_textarea':
			{
				w_first_val=document.getElementById(id+"_elementform_id_temp").value;
				w_title=document.getElementById(id+"_elementform_id_temp").title;
				s=document.getElementById(id+"_elementform_id_temp").style.height;
				w_size_h=s.substring(0,s.length-2);

				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_textarea(id, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_size_h, w_first_val, w_title, w_required, w_unique, w_class, w_attr_name, w_attr_value); break;
			}
			
			case 'type_wdeditor':
			{

				w_title=document.getElementById(id+"_elementform_id_temp").title;
				s=document.getElementById(id+"_elementform_id_temp").style.height;
				w_size_h=s.substring(0,s.length-2);
				w=document.getElementById(id+"_elementform_id_temp").style.width;
				w_size_w=w.substring(0,w.length-2);

				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_wdeditor(id, w_field_label, w_field_label_size, w_field_label_pos, w_size_w, w_size_h, w_title, w_required, w_class, w_attr_name, w_attr_value); break;
			}
			
			case 'type_phone':
			{
				w_first_val=[document.getElementById(id+"_element_firstform_id_temp").value, document.getElementById(id+"_element_lastform_id_temp").value];
				w_title=[document.getElementById(id+"_element_firstform_id_temp").title, document.getElementById(id+"_element_lastform_id_temp").title];
				s=document.getElementById(id+"_element_lastform_id_temp").style.width;
				w_size=s.substring(0,s.length-2);

				w_mini_labels= [document.getElementById(id+"_mini_label_area_code").innerHTML, document.getElementById(id+"_mini_label_phone_number").innerHTML];

				atrs=return_attributes(id+'_element_firstform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_phone(id, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_first_val, w_title, w_mini_labels, w_required, w_unique, w_class, w_attr_name, w_attr_value); break;
			}
			case 'type_name':
			{
				if(document.getElementById(id+"_enable_fieldsform_id_temp")) {
					w_name_format="normal";
				
					w_first_val=[document.getElementById(id+"_element_firstform_id_temp").value, document.getElementById(id+"_element_lastform_id_temp").value];
					w_title=[document.getElementById(id+"_element_firstform_id_temp").title, document.getElementById(id+"_element_lastform_id_temp").title];
					
					var title_middle = ['title', 'middle'];
					for(var l=0; l<2; l++)
					{
						w_first_val.push(document.getElementById(id+'_element_'+title_middle[l]+'form_id_temp') ? document.getElementById(id+'_element_'+title_middle[l]+'form_id_temp').value : '');
						w_title.push(document.getElementById(id+'_element_'+title_middle[l]+'form_id_temp') ? document.getElementById(id+'_element_'+title_middle[l]+'form_id_temp').title : '');
					}
					
				}
				else
				{
					if(document.getElementById(id+'_element_middleform_id_temp'))
						w_name_format="extended";
					else
						w_name_format="normal";

					if(w_name_format=="normal")	{
						w_first_val=[document.getElementById(id+"_element_firstform_id_temp").value, document.getElementById(id+"_element_lastform_id_temp").value];
						w_title=[document.getElementById(id+"_element_firstform_id_temp").title, document.getElementById(id+"_element_lastform_id_temp").title];
					}
					else {
						w_first_val=[document.getElementById(id+"_element_firstform_id_temp").value, document.getElementById(id+"_element_lastform_id_temp").value, document.getElementById(id+"_element_titleform_id_temp").value, document.getElementById(id+"_element_middleform_id_temp").value];
						w_title=[document.getElementById(id+"_element_firstform_id_temp").title, document.getElementById(id+"_element_lastform_id_temp").title, document.getElementById(id+"_element_titleform_id_temp").title,document.getElementById(id+"_element_middleform_id_temp").title];
					}
				}
	
				if(document.getElementById(id+"_mini_label_title"))
					w_mini_title = document.getElementById(id+"_mini_label_title").innerHTML;
				else
					w_mini_title = "Title";
			
				if(document.getElementById(id+"_mini_label_middle"))
					w_mini_middle = document.getElementById(id+"_mini_label_middle").innerHTML;
				else
					w_mini_middle = "Middle";
				
				w_mini_labels = [w_mini_title, document.getElementById(id+"_mini_label_first").innerHTML,document.getElementById(id+"_mini_label_last").innerHTML, w_mini_middle];
				w_name_title = 	document.getElementById(id+'_enable_fieldsform_id_temp') ? document.getElementById(id+'_enable_fieldsform_id_temp').getAttribute('title') : (w_name_format=="normal" ? 'no' : 'yes');			
				w_name_middle = document.getElementById(id+'_enable_fieldsform_id_temp') ? document.getElementById(id+'_enable_fieldsform_id_temp').getAttribute('middle') : (w_name_format=="normal" ? 'no' : 'yes');			
				w_name_fields = [w_name_title, w_name_middle]; 	    
				 
				s=document.getElementById(id+"_element_firstform_id_temp").style.width;
				w_size=s.substring(0,s.length-2);
				atrs=return_attributes(id+'_element_firstform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				
				
				type_name(id, w_field_label, w_field_label_size, w_field_label_pos,w_first_val, w_title, w_mini_labels,  w_size, w_name_format, w_required, w_unique, w_class, w_attr_name, w_attr_value, w_name_fields);break;
			}
			
			case 'type_paypal_price':
			{
				w_first_val=[document.getElementById(id+"_element_dollarsform_id_temp").value, document.getElementById(id+"_element_centsform_id_temp").value];
				w_title=[document.getElementById(id+"_element_dollarsform_id_temp").title, document.getElementById(id+"_element_centsform_id_temp").title];

				if(document.getElementById(id+"_td_name_cents").style.display=="none")
					w_hide_cents='yes';
				else
					w_hide_cents='no';
				

				
				s=document.getElementById(id+"_element_dollarsform_id_temp").style.width;
				w_size=s.substring(0,s.length-2);
				atrs=return_attributes(id+'_element_dollarsform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				w_range_min=document.getElementById(id+"_range_minform_id_temp").value;
				w_range_max=document.getElementById(id+"_range_maxform_id_temp").value;
				w_mini_labels = [document.getElementById(id+"_mini_label_dollars").innerHTML,document.getElementById(id+"_mini_label_cents").innerHTML]; 	       
				type_paypal_price(id, w_field_label, w_field_label_size, w_field_label_pos, w_first_val, w_title, w_mini_labels, w_size, w_required, w_hide_cents, w_class, w_attr_name, w_attr_value, w_range_min , w_range_max); break;
			}
			
			case 'type_address':
			{
				s=document.getElementById(id+"_div_address").style.width;
				w_size=s.substring(0,s.length-2);


				if(document.getElementById(id+"_mini_label_street1"))
					w_street1= document.getElementById(id+"_mini_label_street1").innerHTML; 
				else
					w_street1 = document.getElementById(id+"_street1form_id_temp").value;
					
					
				if(document.getElementById(id+"_mini_label_street2"))
					w_street2= document.getElementById(id+"_mini_label_street2").innerHTML;
				else
					w_street2 = document.getElementById(id+"_street2form_id_temp").value;	
					
				if(document.getElementById(id+"_mini_label_city"))
					w_city= document.getElementById(id+"_mini_label_city").innerHTML;
				else
					w_city = document.getElementById(id+"_cityform_id_temp").value;					
					
				if(document.getElementById(id+"_mini_label_state"))
					w_state= document.getElementById(id+"_mini_label_state").innerHTML; 
				else
					w_state = document.getElementById(id+"_stateform_id_temp").value;	
					
				if(document.getElementById(id+"_mini_label_postal"))
					w_postal= document.getElementById(id+"_mini_label_postal").innerHTML; 
				else
					w_postal = document.getElementById(id+"_postalform_id_temp").value;	
					
				if(document.getElementById(id+"_mini_label_country"))
					w_country= document.getElementById(id+"_mini_label_country").innerHTML; 
				else
					w_country = document.getElementById(id+"_countryform_id_temp").value;					
					
				w_mini_labels=[w_street1, w_street2, w_city, w_state, w_postal, w_country];


				var disabled_input = document.getElementById(id+"_disable_fieldsform_id_temp");
				
					w_street1_dis= disabled_input.getAttribute('street1');
					w_street2_dis= disabled_input.getAttribute('street2');
					w_city_dis= disabled_input.getAttribute('city');
					w_state_dis= disabled_input.getAttribute('state');
					w_us_states_dis= disabled_input.getAttribute('us_states');
					w_postal_dis= disabled_input.getAttribute('postal');
					w_country_dis= disabled_input.getAttribute('country');
				
						
				w_disabled_fields=[w_street1_dis, w_street2_dis, w_city_dis, w_state_dis,  w_postal_dis, w_country_dis,w_us_states_dis];

				
				atrs=return_attributes(id+'_street1form_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_address(id, w_field_label, w_field_label_size, w_field_label_pos, w_size,  w_mini_labels, w_disabled_fields, w_required, w_class, w_attr_name, w_attr_value); break;
			}

			case 'type_submitter_mail':
			{
				w_first_val=document.getElementById(id+"_elementform_id_temp").value;
				w_title=document.getElementById(id+"_elementform_id_temp").title;
		
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_submitter_mail(id, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_first_val, w_title, w_required, w_unique, w_class, w_attr_name, w_attr_value); break;
			}
			case 'type_checkbox':
			{	

				w_randomize=document.getElementById(id+"_randomizeform_id_temp").value;
				w_allow_other=document.getElementById(id+"_allow_otherform_id_temp").value;

				if(document.getElementById(id+"_rowcol_numform_id_temp").value)	
				{
				
                if(document.getElementById(id+'_table_little').getAttribute('for_hor'))
					w_flow="hor"	
				else
					w_flow="ver";				
				w_rowcol = 	document.getElementById(id+"_rowcol_numform_id_temp").value;
				}
				else
				{
					if(document.getElementById(id+'_hor'))
						w_flow="hor"	
					else
						w_flow="ver";
					
					w_rowcol = 1;
				}
				
				v=0;
				if(w_flow=="ver")
				{
					var table_little = document.getElementById(id+'_table_little');
					for(k=0;k < table_little.childNodes.length; k++)
					{
						var td_little = table_little.childNodes[k];
							for(m=0; m < td_little.childNodes.length; m++)
							{
								var idi = td_little.childNodes[m].getAttribute('idi');
								if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other'))
									if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other')=='1')
										w_allow_other_num=t;
								w_choices[t]=document.getElementById(id+"_label_element"+idi).innerHTML;
								w_choices_checked[t]=document.getElementById(id+"_elementform_id_temp"+idi).checked;
								w_choices_value[t]=document.getElementById(id+"_elementform_id_temp"+idi).value;
								if(document.getElementById(id+"_label_element"+idi).getAttribute('where'))
									w_choices_params[t]=document.getElementById(id+"_label_element"+idi).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+idi).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+idi).getAttribute('db_info');
								else
									w_choices_params[t]='';
								t++;
								v=idi;
							}
					}
				
				}
				else
				{
					var table_little = document.getElementById(id+'_table_little');
					var	tr_little = table_little.childNodes;
					var td_max = tr_little[0].childNodes;
					
					for(k=0;k < td_max.length; k++)
					{
						for(m=0; m < tr_little.length; m++)
						{
							if(tr_little[m].childNodes[k])
							{
								var td_little = tr_little[m].childNodes[k];
								var idi = td_little.getAttribute('idi');
								if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other'))
									if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other')=='1')
										w_allow_other_num=t;
								w_choices[t]=document.getElementById(id+"_label_element"+idi).innerHTML;
								w_choices_checked[t]=document.getElementById(id+"_elementform_id_temp"+idi).checked;
								w_choices_value[t]=document.getElementById(id+"_elementform_id_temp"+idi).value;
								if(document.getElementById(id+"_label_element"+idi).getAttribute('where'))
									w_choices_params[t]=document.getElementById(id+"_label_element"+idi).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+idi).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+idi).getAttribute('db_info');
								else
									w_choices_params[t]='';
								t++;
								v=idi;
							}
						}
					}
				
				}
					
				if(document.getElementById(id+"_option_left_right"))
					w_field_option_pos = document.getElementById(id+"_option_left_right").value;
				else
					w_field_option_pos = 'left';

				w_value_disabled = document.getElementById(id+"_value_disabledform_id_temp").value;
				
				atrs=return_attributes(id+'_elementform_id_temp'+v);
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_checkbox(id, w_field_label,w_field_label_size, w_field_label_pos, w_field_option_pos, w_flow, w_choices, w_choices_checked, w_rowcol, w_required, w_randomize, w_allow_other, w_allow_other_num, w_class, w_attr_name, w_attr_value, w_value_disabled, w_choices_value, w_choices_params); break;
			}
			
			case 'type_paypal_checkbox':
			{	
			
				if(document.getElementById(id+'_hor'))
					w_flow="hor"	
				else
					w_flow="ver";

				w_randomize=document.getElementById(id+"_randomizeform_id_temp").value;
				w_allow_other=document.getElementById(id+"_allow_otherform_id_temp").value;
		
				v=0;
				var w_allow_other_num =0;
				var table_little = document.getElementById(id+'_table_little');
				for(k=0;k < table_little.childNodes.length; k++)
				{
					var td_little = table_little.childNodes[k];
					for(m=0; m < td_little.childNodes.length; m++)
					{
						var idi = td_little.childNodes[m].getAttribute('idi');
						w_choices[t]=document.getElementById(id+"_label_element"+idi).innerHTML;
						w_choices_price[t]=document.getElementById(id+"_elementform_id_temp"+idi).value;
						w_choices_checked[t]=document.getElementById(id+"_elementform_id_temp"+idi).checked;
						
						if(document.getElementById(id+"_label_element"+idi).getAttribute('where'))
							w_choices_params[t]=document.getElementById(id+"_label_element"+idi).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+idi).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+idi).getAttribute('db_info');
						else
							w_choices_params[t]='';
						
						t++;
						v=idi;
					}
				}	
				
				if(w_flow == 'hor')
					flow_hor(id);
					
				for(k=0;k<100;k++)
					if(document.getElementById(id+"_propertyform_id_temp"+k))
					{
						w_property.push(document.getElementById(id+"_property_label_form_id_temp"+k).innerHTML);
						
						if(document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length)
						{	
							w_property_values[w_property.length-1]=new Array();	
							for(m=0;m < document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length;m++)
							{				
								w_property_values[w_property.length-1].push(document.getElementById(id+"_propertyform_id_temp"+k).childNodes[m].value);
							}
						}
						else
						{
							w_property_values.push('');
						}
					}
				
				w_quantity="no";
				w_quantity_value =1;
				if(document.getElementById(id+"_element_quantityform_id_temp"))
				{
					w_quantity='yes';
					w_quantity_value = document.getElementById(id+"_element_quantityform_id_temp").value;
				}
				if(document.getElementById(id+"_option_left_right"))
					w_field_option_pos = document.getElementById(id+"_option_left_right").value;
				else
					w_field_option_pos = 'left';

				atrs=return_attributes(id+'_elementform_id_temp'+v);
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_paypal_checkbox(id, w_field_label, w_field_label_size, w_field_label_pos, w_field_option_pos, w_flow, w_choices, w_choices_price, w_choices_checked, w_required, w_randomize, w_allow_other, w_allow_other_num, w_class, w_attr_name, w_attr_value,  w_property,  w_property_values,w_quantity, w_quantity_value,  w_choices_params); break;
			}
			
			
			case 'type_radio':
			{	
		
				w_randomize=document.getElementById(id+"_randomizeform_id_temp").value;
				w_allow_other=document.getElementById(id+"_allow_otherform_id_temp").value;

				if(document.getElementById(id+"_rowcol_numform_id_temp").value)	
				{
				
                if(document.getElementById(id+'_table_little').getAttribute('for_hor'))
					w_flow="hor"	
				else
					w_flow="ver";				
				w_rowcol = 	document.getElementById(id+"_rowcol_numform_id_temp").value;
				}
				else
				{
					if(document.getElementById(id+'_table_little').getAttribute('for_hor'))
						w_flow="hor"	
					else
						w_flow="ver";
					
					w_rowcol = 1;
				}
				
				v=0;
				if(w_flow=="ver")
				{	
					var table_little = document.getElementById(id+'_table_little');
					for(k=0;k < table_little.childNodes.length; k++)
					{
						var td_little = table_little.childNodes[k];
							for(m=0; m < td_little.childNodes.length; m++)
							{
								var idi = td_little.childNodes[m].getAttribute('idi');
								if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other'))
									if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other')=='1')
										w_allow_other_num=t;
								w_choices[t]=document.getElementById(id+"_label_element"+idi).innerHTML;
								w_choices_checked[t]=document.getElementById(id+"_elementform_id_temp"+idi).checked;
								w_choices_value[t]=document.getElementById(id+"_elementform_id_temp"+idi).value;
								if(document.getElementById(id+"_label_element"+idi).getAttribute('where'))
									w_choices_params[t]=document.getElementById(id+"_label_element"+idi).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+idi).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+idi).getAttribute('db_info');
								else
									w_choices_params[t]='';
								t++;
								v=idi;
							}
					}
				}
				else
				{
					var table_little = document.getElementById(id+'_table_little');
					var	tr_little = table_little.childNodes;
					var td_max = tr_little[0].childNodes;
					
					for(k=0;k < td_max.length; k++)
					{
						for(m=0; m < tr_little.length; m++)
						{
							if(tr_little[m].childNodes[k])
							{
								var td_little = tr_little[m].childNodes[k];
								var idi = td_little.getAttribute('idi');
								if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other'))
									if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other')=='1')
										w_allow_other_num=t;
								w_choices[t]=document.getElementById(id+"_label_element"+idi).innerHTML;
								w_choices_checked[t]=document.getElementById(id+"_elementform_id_temp"+idi).checked;
								w_choices_value[t]=document.getElementById(id+"_elementform_id_temp"+idi).value;
								if(document.getElementById(id+"_label_element"+idi).getAttribute('where'))
									w_choices_params[t]=document.getElementById(id+"_label_element"+idi).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+idi).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+idi).getAttribute('db_info');
								else
									w_choices_params[t]='';
								t++;
								v=idi;
							}
						}
					}
				
				}

				if(document.getElementById(id+"_option_left_right"))
					w_field_option_pos = document.getElementById(id+"_option_left_right").value;
				else
					w_field_option_pos = 'left';
				
				w_value_disabled = document.getElementById(id+"_value_disabledform_id_temp").value;
				
				atrs=return_attributes(id+'_elementform_id_temp'+v);
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_radio(id, w_field_label, w_field_label_size, w_field_label_pos, w_field_option_pos, w_flow, w_choices, w_choices_checked, w_rowcol, w_required, w_randomize, w_allow_other, w_allow_other_num, w_class, w_attr_name, w_attr_value, w_value_disabled, w_choices_value, w_choices_params); break;
			}
			
			case 'type_paypal_radio':
			{	
				if(document.getElementById(id+'_hor'))
					w_flow="hor"	
				else
					w_flow="ver";
		
				w_randomize=document.getElementById(id+"_randomizeform_id_temp").value;
				w_allow_other=document.getElementById(id+"_allow_otherform_id_temp").value;

				v=0;
				var w_allow_other_num =0;
				var table_little = document.getElementById(id+'_table_little');
				for(k=0;k < table_little.childNodes.length; k++)
				{
					var td_little = table_little.childNodes[k];
					for(m=0; m < td_little.childNodes.length; m++)
					{
						var idi = td_little.childNodes[m].getAttribute('idi');
						w_choices[t]=document.getElementById(id+"_label_element"+idi).innerHTML;
						w_choices_price[t]=document.getElementById(id+"_elementform_id_temp"+idi).value;
						w_choices_checked[t]=document.getElementById(id+"_elementform_id_temp"+idi).checked;
						if(document.getElementById(id+"_label_element"+idi).getAttribute('where'))
							w_choices_params[t]=document.getElementById(id+"_label_element"+idi).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+idi).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+idi).getAttribute('db_info');
						else
							w_choices_params[t]='';
						t++;
						v=idi;
					}
				}	
				
				if(w_flow == 'hor')
					flow_hor(id);
					
				for(k=0;k<100;k++)
				{
					if(document.getElementById(id+"_propertyform_id_temp"+k))
					{
						w_property.push(document.getElementById(id+"_property_label_form_id_temp"+k).innerHTML);
						
						if(document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length)
						{	
							w_property_values[w_property.length-1]=new Array();	
							for(m=0;m < document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length;m++)
							{				
								w_property_values[w_property.length-1].push(document.getElementById(id+"_propertyform_id_temp"+k).childNodes[m].value);
							}
						}
						else
						{
							w_property_values.push('');
						}
					}
				
				}
				
				w_quantity="no";
				w_quantity_value =1;
				if(document.getElementById(id+"_element_quantityform_id_temp"))
				{
					w_quantity='yes';
					w_quantity_value = document.getElementById(id+"_element_quantityform_id_temp").value;
				}
				if(document.getElementById(id+"_option_left_right"))
					w_field_option_pos = document.getElementById(id+"_option_left_right").value;
				else
					w_field_option_pos = 'left';
			
				atrs=return_attributes(id+'_elementform_id_temp'+v);
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_paypal_radio(id, w_field_label, w_field_label_size, w_field_label_pos, w_field_option_pos, w_flow, w_choices, w_choices_price, w_choices_checked, w_required, w_randomize, w_allow_other, w_allow_other_num, w_class, w_attr_name, w_attr_value, w_property,  w_property_values, w_quantity, w_quantity_value, w_choices_params); break;
			}
			
			case 'type_paypal_shipping':
			{	
				if(document.getElementById(id+'_hor'))
					w_flow="hor"	
				else
					w_flow="ver";
		
				w_randomize=document.getElementById(id+"_randomizeform_id_temp").value;
				w_allow_other=document.getElementById(id+"_allow_otherform_id_temp").value;

				v=0;
				var w_allow_other_num =0;
				var table_little = document.getElementById(id+'_table_little');
				for(k=0;k < table_little.childNodes.length; k++)
				{
					var td_little = table_little.childNodes[k];
					for(m=0; m < td_little.childNodes.length; m++)
					{
						var idi = td_little.childNodes[m].getAttribute('idi');
						w_choices[t]=document.getElementById(id+"_label_element"+idi).innerHTML;
						w_choices_price[t]=document.getElementById(id+"_elementform_id_temp"+idi).value;
						w_choices_checked[t]=document.getElementById(id+"_elementform_id_temp"+idi).checked;
						if(document.getElementById(id+"_label_element"+idi).getAttribute('where'))
							w_choices_params[t]=document.getElementById(id+"_label_element"+idi).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+idi).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+idi).getAttribute('db_info');
						else
							w_choices_params[t]='';
						t++;
						v=idi;
					}
				}	
				
				if(w_flow == 'hor')
					flow_hor(id);
					
				var	w_property = [];
				var w_property_values = [];		
				
				if(document.getElementById(id+"_option_left_right"))
					w_field_option_pos = document.getElementById(id+"_option_left_right").value;
				else
					w_field_option_pos = 'left';
				atrs=return_attributes(id+'_elementform_id_temp'+v);
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_paypal_shipping(id, w_field_label, w_field_label_size, w_field_label_pos, w_field_option_pos, w_flow, w_choices, w_choices_price, w_choices_checked, w_required, w_randomize, w_allow_other, w_allow_other_num, w_class, w_attr_name, w_attr_value, w_property,  w_property_values, w_choices_params); break;
			}

			case 'type_paypal_total':
			{
				w_size = jQuery('#'+id+"paypal_totalform_id_temp").css('width') ? jQuery('#'+id+"paypal_totalform_id_temp").css('width').substring(0,jQuery('#'+id+"paypal_totalform_id_temp").css('width').length-2) : '300';
				type_paypal_total(id, w_field_label, w_field_label_size, w_field_label_pos,  w_class, w_size); break;
			}
      
			case 'type_stripe':
			{	
				type_stripe(id, w_size, w_field_label_size, w_field_label_pos,  w_class); break;
			}
			
			case 'type_star_rating':
			{
				w_star_amount  = document.getElementById(id+"_star_amountform_id_temp").value;
				w_field_label_col  = document.getElementById(id+"_star_colorform_id_temp").value;
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				
				type_star_rating(id, w_field_label, w_field_label_size, w_field_label_pos, w_field_label_col, w_star_amount, w_required, w_class, w_attr_name, w_attr_value) ; break;
			}
			
			case 'type_scale_rating':
			{
				w_mini_labels  =[document.getElementById(id+"_mini_label_worst").innerHTML,document.getElementById(id+"_mini_label_best").innerHTML];	
			
				w_scale_amount = document.getElementById(id+"_scale_amountform_id_temp").value;
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				
				type_scale_rating(id, w_field_label, w_field_label_size, w_field_label_pos, w_mini_labels,  w_scale_amount, w_required, w_class, w_attr_name, w_attr_value) ; break;
			}
			
			case 'type_spinner':
			{
				w_field_min_value  = document.getElementById(id+"_min_valueform_id_temp").value;
				w_field_max_value  = document.getElementById(id+"_max_valueform_id_temp").value;
				w_field_width  = document.getElementById(id+"_spinner_widthform_id_temp").value;
				w_field_step = document.getElementById(id+"_stepform_id_temp").value;
				w_field_value  = document.getElementById(id+"_elementform_id_temp").getAttribute("aria-valuenow");
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				
				type_spinner(id, w_field_label, w_field_label_size, w_field_label_pos, w_field_width, w_field_min_value, w_field_max_value, w_field_step, w_field_value, w_required, w_class, w_attr_name, w_attr_value) ; break;
			
			
			}
			
			case 'type_slider':
			{
				w_field_min_value  = document.getElementById(id+"_slider_min_valueform_id_temp").value;
				w_field_max_value  = document.getElementById(id+"_slider_max_valueform_id_temp").value;
				w_field_width  = document.getElementById(id+"_slider_widthform_id_temp").value;
				w_field_value  = document.getElementById(id+"_slider_valueform_id_temp").value;
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_slider(id, w_field_label, w_field_label_size, w_field_label_pos,  w_field_width, w_field_min_value, w_field_max_value, w_field_value, w_required, w_class, w_attr_name, w_attr_value); break;
			}
			
			case 'type_range':
			{
				
				w_field_range_width  = document.getElementById(id+"_range_widthform_id_temp").value;
				w_field_range_step = document.getElementById(id+"_range_stepform_id_temp").value;
				
				w_field_value1  = document.getElementById(id+"_elementform_id_temp0").getAttribute("aria-valuenow");
				w_field_value2  = document.getElementById(id+"_elementform_id_temp1").getAttribute("aria-valuenow");
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				
				w_mini_labels = [document.getElementById(id+"_mini_label_from").innerHTML,document.getElementById(id+"_mini_label_to").innerHTML]; 	 
				
				type_range(id, w_field_label, w_field_label_size, w_field_label_pos, w_field_range_width, w_field_range_step, w_field_value1, w_field_value2, w_mini_labels, w_required, w_class, w_attr_name, w_attr_value) ;  break;
			
			}
			case 'type_grading':
			{
			
				w_total = document.getElementById(id+"_grading_totalform_id_temp").value;
				w_items=[];
				
				for(k=0;k<100;k++)
					if(document.getElementById(id+"_label_elementform_id_temp"+k))
					{
						
						w_items.push(document.getElementById(id+"_label_elementform_id_temp"+k).innerHTML);
						
					}
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				
				type_grading(id, w_field_label, w_field_label_size, w_field_label_pos, w_items, w_total, w_required, w_class, w_attr_name, w_attr_value) ; refresh_grading_items(id); break;
			
			
			}
			case 'type_matrix':
			{	
                w_rows=[];
				w_rows[0]="";
				for(k=1;k<100;k++)
					if(document.getElementById(id+"_label_elementform_id_temp"+k+"_0"))
					{
						
						w_rows.push(document.getElementById(id+"_label_elementform_id_temp"+k+"_0").innerHTML);
						
					}
			
			    w_columns=[];
				w_columns[0]="";
				for(k=1;k<100;k++)
					if(document.getElementById(id+"_label_elementform_id_temp0_"+k))
					{
						
						w_columns.push(document.getElementById(id+"_label_elementform_id_temp0_"+k).innerHTML);
						
					}
					
			w_field_input_type = document.getElementById(id+"_input_typeform_id_temp").value;		
			w_textbox_size = document.getElementById(id+"_textbox_sizeform_id_temp") ? document.getElementById(id+"_textbox_sizeform_id_temp").value : '100';			
			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			type_matrix(id, w_field_label, w_field_label_size, w_field_label_pos, w_field_input_type, w_rows, w_columns, w_required, w_class, w_attr_name, w_attr_value, w_textbox_size); refresh_matrix(id); break; 
			
			
			}
		
			
			case 'type_time':
			{	
				atrs=return_attributes(id+'_hhform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				w_hh=document.getElementById(id+'_hhform_id_temp').value;
				w_mm=document.getElementById(id+'_mmform_id_temp').value;
				if(document.getElementById(id+'_ssform_id_temp'))
				{
					w_ss=document.getElementById(id+'_ssform_id_temp').value;
					w_sec="1";
					w_mini_label_ss=document.getElementById(id+'_mini_label_ss').innerHTML;
				}
				else
				{
					w_ss="";
					w_sec="0";
					w_mini_label_ss='';
				}
				if(document.getElementById(id+'_am_pm_select'))
				{
					w_am_pm=document.getElementById(id+'_am_pmform_id_temp').value;
					w_time_type="12";
					w_mini_labels = [document.getElementById(id+'_mini_label_hh').innerHTML, document.getElementById(id+'_mini_label_mm').innerHTML, w_mini_label_ss, document.getElementById(id+'_mini_label_am_pm').innerHTML];
		
				}
				else
				{
					w_am_pm=0;
					w_time_type="24";
					w_mini_labels = [document.getElementById(id+'_mini_label_hh').innerHTML, document.getElementById(id+'_mini_label_mm').innerHTML, w_mini_label_ss ,'AM/PM'];
			
				}
				type_time(id, w_field_label, w_field_label_size, w_field_label_pos, w_time_type, w_am_pm, w_sec, w_hh, w_mm, w_ss, w_mini_labels, w_required, w_class, w_attr_name, w_attr_value); break;
			}
			case 'type_date':
			{	
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				w_date=document.getElementById(id+'_elementform_id_temp').value;
				w_format=document.getElementById(id+'_buttonform_id_temp').getAttribute("format");
				w_but_val=document.getElementById(id+'_buttonform_id_temp').value;
				w_disable_past_days = document.getElementById(id+'_dis_past_daysform_id_temp') ? document.getElementById(id+'_dis_past_daysform_id_temp').value : 'no';
				type_date(id, w_field_label, w_field_label_size, w_field_label_pos, w_date, w_required, w_class, w_format, w_but_val, w_attr_name, w_attr_value,w_disable_past_days); break;
			}
			case 'type_date_fields':
			{	
				atrs			=return_attributes(id+'_dayform_id_temp');
				w_attr_name		=atrs[0];
				w_attr_value	=atrs[1];
				w_day			=document.getElementById(id+'_dayform_id_temp').value;
				w_month			=document.getElementById(id+'_monthform_id_temp').value;
				w_year			=document.getElementById(id+'_yearform_id_temp').value;
				w_day_type		=document.getElementById(id+'_dayform_id_temp').tagName;
				w_month_type	=document.getElementById(id+'_monthform_id_temp').tagName;
				w_year_type		=document.getElementById(id+'_yearform_id_temp').tagName;
				w_day_label		=document.getElementById(id+'_day_label').innerHTML;
				w_month_label	=document.getElementById(id+'_month_label').innerHTML;
				w_year_label	=document.getElementById(id+'_year_label').innerHTML;
				
				s				=document.getElementById(id+'_dayform_id_temp').style.width;
				w_day_size		=s.substring(0,s.length-2);
				
				s				=document.getElementById(id+'_monthform_id_temp').style.width;
				w_month_size	=s.substring(0,s.length-2);
				
				s				=document.getElementById(id+'_yearform_id_temp').style.width;
				w_year_size		=s.substring(0,s.length-2);
				
				w_from			=document.getElementById(id+'_yearform_id_temp').getAttribute('from');
				w_to			=document.getElementById(id+'_yearform_id_temp').getAttribute('to');
				w_divider		=document.getElementById(id+'_separator1').innerHTML;
				type_date_fields(id, w_field_label, w_field_label_size, w_field_label_pos, w_day, w_month, w_year, w_day_type, w_month_type, w_year_type, w_day_label, w_month_label, w_year_label, w_day_size, w_month_size, w_year_size, w_required, w_class, w_from, w_to, w_divider, w_attr_name, w_attr_value); break;
			}
			case 'type_own_select':
			{	
				jQuery('#'+id+'_elementform_id_temp option').each(function() {
					w_choices[t]=jQuery(this).html();
					w_choices_value[t]=jQuery(this).val();
					w_choices_checked[t]=jQuery(this)[0].selected;
					if(jQuery(this).attr('where'))
						w_choices_params[t]=jQuery(this).attr('where')+'[where_order_by]'+jQuery(this).attr('order_by')+'[db_info]'+jQuery(this).attr('db_info');
					else
						w_choices_params[t]='';
						
					if(jQuery(this).val())
						w_choices_disabled[t]=false;	
					else
						w_choices_disabled[t]=true;
					t++;		
				});

				w_value_disabled = document.getElementById(id+'_value_disabledform_id_temp').value;
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_own_select(id, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_choices, w_choices_checked, w_required, w_value_disabled, w_class, w_attr_name, w_attr_value, w_choices_disabled, w_choices_value, w_choices_params); break;
			}
			
			case 'type_paypal_select':
			{	
				
				jQuery('#'+id+'_elementform_id_temp option').each(function() {
					w_choices[t]=jQuery(this).html();
					w_choices_price[t]=jQuery(this).val();
					w_choices_checked[t]=jQuery(this)[0].selected;
					if(jQuery(this).attr('where'))
						w_choices_params[t]=jQuery(this).attr('where')+'[where_order_by]'+jQuery(this).attr('order_by')+'[db_info]'+jQuery(this).attr('db_info');
					else
						w_choices_params[t]='';
						
					if(jQuery(this)[0].value=="")
							w_choices_disabled[t]=true;
						else
							w_choices_disabled[t]=false;
					t++;		
				});
				
				for(k=0;k<100;k++)
				{
					if(document.getElementById(id+"_propertyform_id_temp"+k))
					{
						w_property.push(document.getElementById(id+"_property_label_form_id_temp"+k).innerHTML);
						
						if(document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length)
						{	
							w_property_values[w_property.length-1]=new Array();	
							for(m=0;m < document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length;m++)
							{				
								w_property_values[w_property.length-1].push(document.getElementById(id+"_propertyform_id_temp"+k).childNodes[m].value);
							}
						}
						else
						{
							w_property_values.push('');
						}
					}
					
				}
				
				w_quantity="no";
				w_quantity_value =1;
				if(document.getElementById(id+"_element_quantityform_id_temp"))
				{
					w_quantity='yes';
					w_quantity_value = document.getElementById(id+"_element_quantityform_id_temp").value;
				}

				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_paypal_select(id, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_choices,w_choices_price, w_choices_checked, w_required,  w_quantity, w_quantity_value, w_class, w_attr_name, w_attr_value, w_choices_disabled, w_property, w_property_values, w_choices_params); break;
			}
			
			case 'type_country':
			{	
				w_countries=[];

				select_=document.getElementById(id+'_elementform_id_temp');
				n=select_.childNodes.length;
				for(i=0; i<n; i++)
				{
					w_countries.push(select_.childNodes[i].value);
				}

				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_country(id, w_field_label, w_field_label_size, w_countries, w_field_label_pos, w_size, w_required, w_class,  w_attr_name, w_attr_value); break;
			}
			case 'type_file_upload':
			{
				w_destination=document.getElementById(id+"_destination").value.replace("***destinationverj"+id+"***", "").replace("***destinationskizb"+id+"***", "");
				w_extension  =document.getElementById(id+"_extension").value.replace("***extensionverj"+id+"***", "").replace("***extensionskizb"+id+"***", "");
				w_max_size   =document.getElementById(id+"_max_size").value.replace("***max_sizeverj"+id+"***", "").replace("***max_sizeskizb"+id+"***", "");
				w_multiple   =(document.getElementById(id+"_elementform_id_temp").getAttribute('multiple') ? 'yes' : 'no');
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_file_upload(id, w_field_label, w_field_label_size, w_field_label_pos, w_destination,w_extension, w_max_size, w_required, w_multiple, w_class,  w_attr_name, w_attr_value); break;
			}
			case 'type_captcha':
			{
				w_digit=document.getElementById("_wd_captchaform_id_temp").getAttribute("digit");
				atrs=return_attributes('_wd_captchaform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				
				type_captcha(id, w_field_label, w_field_label_size, w_field_label_pos, w_digit, w_class,  w_attr_name, w_attr_value); break;
			}
			
			case 'type_arithmetic_captcha':
			{
				w_count = document.getElementById("_wd_arithmetic_captchaform_id_temp").getAttribute("operations_count");
				w_operations = document.getElementById("_wd_arithmetic_captchaform_id_temp").getAttribute("operations");
				w_input_size = document.getElementById("_wd_arithmetic_captchaform_id_temp").getAttribute("input_size");
				atrs=return_attributes('_wd_captchaform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				
				type_arithmetic_captcha(id, w_field_label, w_field_label_size, w_field_label_pos, w_count, w_operations, w_class, w_input_size,  w_attr_name, w_attr_value); break;
			}
			case 'type_recaptcha':
			{
				w_public  = document.getElementById("wd_recaptchaform_id_temp").getAttribute("public_key");
				w_private  = document.getElementById("wd_recaptchaform_id_temp").getAttribute("private_key");
				w_theme  = document.getElementById("wd_recaptchaform_id_temp").getAttribute("theme");
				
				atrs=return_attributes('wd_recaptchaform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_recaptcha(id, w_field_label, w_field_label_size, w_field_label_pos, w_public, w_private, w_theme, w_class,  w_attr_name, w_attr_value); break;
			}
			case 'type_map':
			{
				w_lat=[];
				w_long=[];
				w_info=[];
				
				w_center_x  = document.getElementById(id+"_elementform_id_temp").getAttribute("center_x");
				w_center_y  = document.getElementById(id+"_elementform_id_temp").getAttribute("center_y");
				w_zoom  = document.getElementById(id+"_elementform_id_temp").getAttribute("zoom");
				w_width = parseInt(document.getElementById(id+"_elementform_id_temp").style.width);
				w_height= parseInt(document.getElementById(id+"_elementform_id_temp").style.height);
				
				
				
				for(j=0; j<=20; j++)
					if( document.getElementById(id+"_elementform_id_temp").getAttribute("lat"+j))
					{
						w_lat.push(document.getElementById(id+"_elementform_id_temp").getAttribute("lat"+j));
						w_long.push(document.getElementById(id+"_elementform_id_temp").getAttribute("long"+j));
						w_info.push(document.getElementById(id+"_elementform_id_temp").getAttribute("info"+j));
					}

				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_map(id, w_center_x, w_center_y, w_long, w_lat, w_zoom, w_width, w_height, w_class, w_info, w_attr_name, w_attr_value); break;
			}
			case 'type_mark_map':
			{
				w_info  = document.getElementById(id+"_elementform_id_temp").getAttribute("info0");
				w_long  = document.getElementById(id+"_elementform_id_temp").getAttribute("long0");
				w_lat   = document.getElementById(id+"_elementform_id_temp").getAttribute("lat0");
				w_zoom  = document.getElementById(id+"_elementform_id_temp").getAttribute("zoom");
				w_width = parseInt(document.getElementById(id+"_elementform_id_temp").style.width);
				w_height= parseInt(document.getElementById(id+"_elementform_id_temp").style.height);
				w_center_x  = document.getElementById(id+"_elementform_id_temp").getAttribute("center_x");
				w_center_y  = document.getElementById(id+"_elementform_id_temp").getAttribute("center_y");
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_mark_map(id, w_field_label, w_field_label_size, w_field_label_pos, w_center_x, w_center_y, w_long, w_lat, w_zoom, w_width, w_height, w_class, w_info, w_attr_name, w_attr_value); break;
			}
			case 'type_submit_reset':
			{
				atrs=return_attributes(id+'_element_submitform_id_temp');
				w_act=!(document.getElementById(id+"_element_resetform_id_temp").style.display=="none");
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				w_submit_title = document.getElementById(id+"_element_submitform_id_temp").value;
				w_reset_title  = document.getElementById(id+"_element_resetform_id_temp").value;
				type_submit_reset(id, w_submit_title , w_reset_title , w_class, w_act, w_attr_name, w_attr_value); break;
			}

			case 'type_button':
			{
				w_title	=new Array();	
			
				w_func	=new Array();
				t=0;
				v=0;
				for(k=0;k<100;k++)
					if(document.getElementById(id+"_elementform_id_temp"+k))
					{
						w_title[t]=document.getElementById(id+"_elementform_id_temp"+k).value;
						w_func[t]=document.getElementById(id+"_elementform_id_temp"+k).getAttribute("onclick");
						t++;
						v=k;
					}
				atrs=return_attributes(id+'_elementform_id_temp'+v);
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_button (id, w_title , w_func , w_class,w_attr_name, w_attr_value); break;
			}
			case 'type_hidden':
			{
				w_value  = document.getElementById(id+"_elementform_id_temp").value;
				w_name  = document.getElementById(id+"_elementform_id_temp").name;
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_hidden (id, w_name, w_value , w_attr_name, w_attr_value); break;
			}

		}
	
		
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	var pos=document.getElementsByName("el_pos");
		pos[0].setAttribute("disabled", "disabled");
		pos[1].setAttribute("disabled", "disabled");
		pos[2].setAttribute("disabled", "disabled");
		
	var sel_el_pos=document.getElementById("sel_el_pos");
		sel_el_pos.setAttribute("disabled", "disabled");

}

function duplicate(id) {
  document.getElementById('pos_end').checked = true;
	type=document.getElementById("wdform_field"+id).getAttribute('type');
	//////////////////////////////parameter take
	if(document.getElementById(id+'_element_labelform_id_temp').innerHTML)
		w_field_label=document.getElementById(id+'_element_labelform_id_temp').innerHTML;
	labels=all_labels();
	m=0;
	t=true;
	if(type!="type_section_break")
	{
	while(t)
	{	
		m++;
		for(k=0; k<labels.length; k++)
		{
			t=true;
			if(labels[k]==w_field_label+'('+m+')')
				break;
			t=false;
		}	
	}
	w_field_label=w_field_label+'('+m+')';
	}
	k=0;
	
	w_choices=new Array();	
	w_choices_value=new Array();
	w_choices_params=new Array();
	w_choices_checked=new Array();
	w_choices_disabled=new Array();
	w_allow_other_num=0;
    w_property=new Array();	
	
	w_property_values=new Array();
	w_choices_price=new Array();
	
	t=0;
	
	if(document.getElementById(id+'_label_sectionform_id_temp'))
	if(document.getElementById(id+'_label_sectionform_id_temp').style.display=="block")
		w_field_label_pos="top";
	else
		w_field_label_pos="left";
	
	if(document.getElementById(id+"_elementform_id_temp"))
	{
		s=document.getElementById(id+"_elementform_id_temp").style.width;
		 w_size=s.substring(0,s.length-2);
	}
	
	if(document.getElementById(id+"_label_sectionform_id_temp"))
	{
		s=document.getElementById(id+"_label_sectionform_id_temp").style.width;
		w_field_label_size=s.substring(0,s.length-2);
	}
	
	if(document.getElementById(id+"_requiredform_id_temp"))
	  	w_required=document.getElementById(id+"_requiredform_id_temp").value;
		
	if(document.getElementById(id+"_uniqueform_id_temp"))
	  	w_unique=document.getElementById(id+"_uniqueform_id_temp").value;
		
	if(document.getElementById(id+'_label_sectionform_id_temp'))
	{
		w_class=document.getElementById(id+'_label_sectionform_id_temp').getAttribute("class");
		if(!w_class)
			w_class="";
	}
		

	switch(type)
		{
			case 'type_editor':
			{
				w_editor=document.getElementById("wdform_field"+id).innerHTML;
				type_editor(gen, w_editor); break;
			}
			case 'type_section_break':
			{
				w_editor=document.getElementById(id+"_element_sectionform_id_temp").innerHTML;
				type_section_break(gen, w_editor);  break;
			}
			case 'type_send_copy':
			{
				w_first_val=document.getElementById(id+"_elementform_id_temp").checked;
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_send_copy(id, w_field_label, w_field_label_size, w_field_label_pos, w_first_val, w_required, w_attr_name, w_attr_value); break;
			}
			case 'type_text':
			{
				w_first_val=document.getElementById(id+"_elementform_id_temp").value;
				w_title=document.getElementById(id+"_elementform_id_temp").title;
				w_regExp_status = document.getElementById(id+"_regExpStatusform_id_temp").value;
				w_regExp_value = unescape(document.getElementById(id+"_regExp_valueform_id_temp").value);
				w_regExp_common = document.getElementById(id+"_regExp_commonform_id_temp").value;
				w_regExp_arg = document.getElementById(id+"_regArgumentform_id_temp").value;
				w_regExp_alert = document.getElementById(id+"_regExp_alertform_id_temp").value;
				atrs = return_attributes(id+'_elementform_id_temp');
				w_attr_name = atrs[0];
				w_attr_value = atrs[1];
				type_text(gen, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_first_val, w_title, w_required, w_regExp_status, w_regExp_value, w_regExp_common, w_regExp_arg, w_regExp_alert, w_unique, w_attr_name, w_attr_value);  break;
			}
			case 'type_number':
			{
				w_first_val=document.getElementById(id+"_elementform_id_temp").value;
				w_title=document.getElementById(id+"_elementform_id_temp").title;
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_number(gen, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_first_val, w_title, w_required, w_unique, w_class,  w_attr_name, w_attr_value); break;
			}
			case 'type_password':
			{
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_password(gen, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_required, w_unique, w_class, w_attr_name, w_attr_value);  break;
			}
			case 'type_textarea':
			{
				w_first_val=document.getElementById(id+"_elementform_id_temp").value;
				w_title=document.getElementById(id+"_elementform_id_temp").title;
				s=document.getElementById(id+"_elementform_id_temp").style.height;
				w_size_h=s.substring(0,s.length-2);

				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_textarea(gen, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_size_h, w_first_val, w_title, w_required, w_unique, w_class, w_attr_name, w_attr_value);  break;
			}
			
				case 'type_wdeditor':
			{
			
				w_title=document.getElementById(id+"_elementform_id_temp").title;
				s=document.getElementById(id+"_elementform_id_temp").style.height;
				w_size_h=s.substring(0,s.length-2);
				w=document.getElementById(id+"_elementform_id_temp").style.width;
				w_size_w=w.substring(0,w.length-2);

				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_wdeditor(gen, w_field_label, w_field_label_size, w_field_label_pos, w_size_w, w_size_h, w_title, w_required, w_class, w_attr_name, w_attr_value); break;
			}
			
			case 'type_phone':
			{
				w_first_val=[document.getElementById(id+"_element_firstform_id_temp").value, document.getElementById(id+"_element_lastform_id_temp").value];
				w_title=[document.getElementById(id+"_element_firstform_id_temp").title, document.getElementById(id+"_element_lastform_id_temp").title];
				s=document.getElementById(id+"_element_lastform_id_temp").style.width;
				w_size=s.substring(0,s.length-2);

				w_mini_labels= [document.getElementById(id+"_mini_label_area_code").innerHTML, document.getElementById(id+"_mini_label_phone_number").innerHTML];

				atrs=return_attributes(id+'_element_firstform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_phone(gen, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_first_val, w_title, w_mini_labels, w_required, w_unique, w_class, w_attr_name, w_attr_value); break;
			}
			case 'type_name':
			{
				if(document.getElementById(id+"_enable_fieldsform_id_temp")) {
					w_name_format="normal";
				
					w_first_val=[document.getElementById(id+"_element_firstform_id_temp").value, document.getElementById(id+"_element_lastform_id_temp").value];
					w_title=[document.getElementById(id+"_element_firstform_id_temp").title, document.getElementById(id+"_element_lastform_id_temp").title];
					
					var title_middle = ['title', 'middle'];
					for(var l=0; l<2; l++)
					{
						w_first_val.push(document.getElementById(id+'_element_'+title_middle[l]+'form_id_temp') ? document.getElementById(id+'_element_'+title_middle[l]+'form_id_temp').value : '');
						w_title.push(document.getElementById(id+'_element_'+title_middle[l]+'form_id_temp') ? document.getElementById(id+'_element_'+title_middle[l]+'form_id_temp').title : '');
					}
					
				}
				else
				{
					if(document.getElementById(id+'_element_middleform_id_temp'))
						w_name_format="extended";
					else
						w_name_format="normal";

					if(w_name_format=="normal")	{
						w_first_val=[document.getElementById(id+"_element_firstform_id_temp").value, document.getElementById(id+"_element_lastform_id_temp").value];
						w_title=[document.getElementById(id+"_element_firstform_id_temp").title, document.getElementById(id+"_element_lastform_id_temp").title];
					}
					else {
						w_first_val=[document.getElementById(id+"_element_firstform_id_temp").value, document.getElementById(id+"_element_lastform_id_temp").value, document.getElementById(id+"_element_titleform_id_temp").value, document.getElementById(id+"_element_middleform_id_temp").value];
						w_title=[document.getElementById(id+"_element_firstform_id_temp").title, document.getElementById(id+"_element_lastform_id_temp").title, document.getElementById(id+"_element_titleform_id_temp").title,document.getElementById(id+"_element_middleform_id_temp").title];
					}
				}
	
				if(document.getElementById(id+"_mini_label_title"))
					w_mini_title = document.getElementById(id+"_mini_label_title").innerHTML;
				else
					w_mini_title = "Title";
			
				if(document.getElementById(id+"_mini_label_middle"))
					w_mini_middle = document.getElementById(id+"_mini_label_middle").innerHTML;
				else
					w_mini_middle = "Middle";
				
				w_mini_labels = [w_mini_title, document.getElementById(id+"_mini_label_first").innerHTML,document.getElementById(id+"_mini_label_last").innerHTML, w_mini_middle];
				w_name_title = 	document.getElementById(id+'_enable_fieldsform_id_temp') ? document.getElementById(id+'_enable_fieldsform_id_temp').getAttribute('title') : (w_name_format=="normal" ? 'no' : 'yes');			
				w_name_middle = document.getElementById(id+'_enable_fieldsform_id_temp') ? document.getElementById(id+'_enable_fieldsform_id_temp').getAttribute('middle') : (w_name_format=="normal" ? 'no' : 'yes');			
				w_name_fields = [w_name_title, w_name_middle]; 	    
				 
				s=document.getElementById(id+"_element_firstform_id_temp").style.width;
				w_size=s.substring(0,s.length-2);
				atrs=return_attributes(id+'_element_firstform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				
				type_name(gen, w_field_label, w_field_label_size, w_field_label_pos,w_first_val, w_title, w_mini_labels,  w_size, w_name_format, w_required, w_unique, w_class, w_attr_name, w_attr_value, w_name_fields);break;
			}
			
			case 'type_paypal_price':
			{
				w_first_val=[document.getElementById(id+"_element_dollarsform_id_temp").value, document.getElementById(id+"_element_centsform_id_temp").value];
				w_title=[document.getElementById(id+"_element_dollarsform_id_temp").title, document.getElementById(id+"_element_centsform_id_temp").title];

				if(document.getElementById(id+"_td_name_cents").style.display=="none")
					w_hide_cents='yes';
				else
					w_hide_cents='no';
				

				
				s=document.getElementById(id+"_element_dollarsform_id_temp").style.width;
				w_size=s.substring(0,s.length-2);
				atrs=return_attributes(id+'_element_dollarsform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				w_range_min=document.getElementById(id+"_range_minform_id_temp").value;
				w_range_max=document.getElementById(id+"_range_maxform_id_temp").value;
				w_mini_labels = [document.getElementById(id+"_mini_label_dollars").innerHTML,document.getElementById(id+"_mini_label_cents").innerHTML]; 	       
				type_paypal_price(gen, w_field_label, w_field_label_size, w_field_label_pos, w_first_val, w_title, w_mini_labels, w_size, w_required, w_hide_cents, w_class, w_attr_name, w_attr_value, w_range_min , w_range_max); break;
			}
			
			case 'type_address':
			{
				s=document.getElementById(id+"_div_address").style.width;
				w_size=s.substring(0,s.length-2);


				if(document.getElementById(id+"_mini_label_street1"))
					w_street1= document.getElementById(id+"_mini_label_street1").innerHTML; 
				else
					w_street1 = document.getElementById(id+"_street1form_id_temp").value;
					
					
				if(document.getElementById(id+"_mini_label_street2"))
					w_street2= document.getElementById(id+"_mini_label_street2").innerHTML;
				else
					w_street2 = document.getElementById(id+"_street2form_id_temp").value;	
					
				if(document.getElementById(id+"_mini_label_city"))
					w_city= document.getElementById(id+"_mini_label_city").innerHTML;
				else
					w_city = document.getElementById(id+"_cityform_id_temp").value;					
					
				if(document.getElementById(id+"_mini_label_state"))
					w_state= document.getElementById(id+"_mini_label_state").innerHTML; 
				else
					w_state = document.getElementById(id+"_stateform_id_temp").value;	
					
				if(document.getElementById(id+"_mini_label_postal"))
					w_postal= document.getElementById(id+"_mini_label_postal").innerHTML; 
				else
					w_postal = document.getElementById(id+"_postalform_id_temp").value;	
					
				if(document.getElementById(id+"_mini_label_country"))
					w_country= document.getElementById(id+"_mini_label_country").innerHTML; 
				else
					w_country = document.getElementById(id+"_countryform_id_temp").value;					
					
				w_mini_labels=[w_street1, w_street2, w_city, w_state, w_postal, w_country];


				var disabled_input = document.getElementById(id+"_disable_fieldsform_id_temp");
				
					w_street1_dis= disabled_input.getAttribute('street1');
					w_street2_dis= disabled_input.getAttribute('street2');
					w_city_dis= disabled_input.getAttribute('city');
					w_state_dis= disabled_input.getAttribute('state');
					w_us_states_dis= disabled_input.getAttribute('us_states');
					w_postal_dis= disabled_input.getAttribute('postal');
					w_country_dis= disabled_input.getAttribute('country');
				
						
				w_disabled_fields=[w_street1_dis, w_street2_dis, w_city_dis, w_state_dis, w_postal_dis, w_country_dis,  w_us_states_dis];

				
				atrs=return_attributes(id+'_street1form_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_address(gen, w_field_label, w_field_label_size, w_field_label_pos, w_size,  w_mini_labels, w_disabled_fields, w_required, w_class, w_attr_name, w_attr_value); break;
			}

			case 'type_submitter_mail':
			{
				w_first_val=document.getElementById(id+"_elementform_id_temp").value;
				w_title=document.getElementById(id+"_elementform_id_temp").title;
		
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_submitter_mail(gen, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_first_val, w_title, w_required, w_unique, w_class, w_attr_name, w_attr_value); break;
			}
			case 'type_checkbox':
			{	

				w_randomize=document.getElementById(id+"_randomizeform_id_temp").value;
				w_allow_other=document.getElementById(id+"_allow_otherform_id_temp").value;

				if(document.getElementById(id+"_rowcol_numform_id_temp").value)	
				{
				
                if(document.getElementById(id+'_table_little').getAttribute('for_hor'))
					w_flow="hor"	
				else
					w_flow="ver";				
				w_rowcol = 	document.getElementById(id+"_rowcol_numform_id_temp").value;
				}
				else
				{
					if(document.getElementById(id+'_hor'))
						w_flow="hor"	
					else
						w_flow="ver";
					
					w_rowcol = 1;
				}
				
				v=0;
				if(w_flow=="ver")
				{
					var table_little = document.getElementById(id+'_table_little');
					for(k=0;k < table_little.childNodes.length; k++)
					{
						var td_little = table_little.childNodes[k];
							for(m=0; m < td_little.childNodes.length; m++)
							{
								var idi = td_little.childNodes[m].getAttribute('idi');
								if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other'))
									if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other')=='1')
										w_allow_other_num=t;
								w_choices[t]=document.getElementById(id+"_label_element"+idi).innerHTML;
								w_choices_checked[t]=document.getElementById(id+"_elementform_id_temp"+idi).checked;
								w_choices_value[t]=document.getElementById(id+"_elementform_id_temp"+idi).value;
								if(document.getElementById(id+"_label_element"+idi).getAttribute('where'))
									w_choices_params[t]=document.getElementById(id+"_label_element"+idi).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+idi).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+idi).getAttribute('db_info');
								else
									w_choices_params[t]='';
								t++;
								v=idi;
							}
					}
				
				}
				else
				{
					var table_little = document.getElementById(id+'_table_little');
					var	tr_little = table_little.childNodes;
					var td_max = tr_little[0].childNodes;
					
					for(k=0;k < td_max.length; k++)
					{
						for(m=0; m < tr_little.length; m++)
						{
							if(tr_little[m].childNodes[k])
							{
								var td_little = tr_little[m].childNodes[k];
								var idi = td_little.getAttribute('idi');
								if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other'))
									if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other')=='1')
										w_allow_other_num=t;
								w_choices[t]=document.getElementById(id+"_label_element"+idi).innerHTML;
								w_choices_checked[t]=document.getElementById(id+"_elementform_id_temp"+idi).checked;
								w_choices_value[t]=document.getElementById(id+"_elementform_id_temp"+idi).value;
								if(document.getElementById(id+"_label_element"+idi).getAttribute('where'))
									w_choices_params[t]=document.getElementById(id+"_label_element"+idi).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+idi).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+idi).getAttribute('db_info');
								else
									w_choices_params[t]='';
								t++;
								v=idi;
							}
						}
					}
				
				}
					
				if(document.getElementById(id+"_option_left_right"))
					w_field_option_pos = document.getElementById(id+"_option_left_right").value;
				else
					w_field_option_pos = 'left';

				w_value_disabled = document.getElementById(id+"_value_disabledform_id_temp").value;
				
				atrs=return_attributes(id+'_elementform_id_temp'+v);
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_checkbox(gen, w_field_label,w_field_label_size, w_field_label_pos, w_field_option_pos, w_flow, w_choices, w_choices_checked, w_rowcol, w_required, w_randomize, w_allow_other, w_allow_other_num, w_class, w_attr_name, w_attr_value, w_value_disabled, w_choices_value, w_choices_params); break;
			}
			
			case 'type_paypal_checkbox':
			{	
			
				if(document.getElementById(id+'_hor'))
					w_flow="hor"	
				else
					w_flow="ver";

				w_randomize=document.getElementById(id+"_randomizeform_id_temp").value;
				w_allow_other=document.getElementById(id+"_allow_otherform_id_temp").value;
		
				v=0;
				for(k=0;k<100;k++)
				{
					if(document.getElementById(id+"_elementform_id_temp"+k))
					{
						if(document.getElementById(id+"_elementform_id_temp"+k).getAttribute('other'))
							if(document.getElementById(id+"_elementform_id_temp"+k).getAttribute('other')=='1')
								w_allow_other_num=t;
						w_choices[t]=document.getElementById(id+"_label_element"+k).innerHTML;
						w_choices_price[t]=document.getElementById(id+"_elementform_id_temp"+k).value;
						w_choices_checked[t]=document.getElementById(id+"_elementform_id_temp"+k).checked;
						if(document.getElementById(id+"_label_element"+k).getAttribute('where'))
							w_choices_params[t]=document.getElementById(id+"_label_element"+k).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+k).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+k).getAttribute('db_info');
						else
							w_choices_params[t]='';
						t++;
						v=k;
					}
					
					if(document.getElementById(id+"_propertyform_id_temp"+k))
					{
						w_property.push(document.getElementById(id+"_property_label_form_id_temp"+k).innerHTML);
					
						if(document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length)
						{	
							w_property_values[w_property.length-1]=new Array();	
							for(m=0;m < document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length;m++)
							{				
								w_property_values[w_property.length-1].push(document.getElementById(id+"_propertyform_id_temp"+k).childNodes[m].value);
							}
						}
						else
						{
							w_property_values.push('');
						}
					}
					
				}
				
				w_quantity="no";
				w_quantity_value =1;
				if(document.getElementById(id+"_element_quantityform_id_temp"))
				{
					w_quantity='yes';
					w_quantity_value = document.getElementById(id+"_element_quantityform_id_temp").value;
				}
			
				if(document.getElementById(id+"_option_left_right"))
					w_field_option_pos = document.getElementById(id+"_option_left_right").value;
				else
					w_field_option_pos = 'left';
				atrs=return_attributes(id+'_elementform_id_temp'+v);
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_paypal_checkbox(gen, w_field_label, w_field_label_size, w_field_label_pos, w_field_option_pos, w_flow, w_choices, w_choices_price, w_choices_checked, w_required, w_randomize, w_allow_other, w_allow_other_num, w_class, w_attr_name, w_attr_value,  w_property, w_property_values,w_quantity, w_quantity_value, w_choices_params); break;
			}
			case 'type_radio':
			{	
		
				w_randomize=document.getElementById(id+"_randomizeform_id_temp").value;
				w_allow_other=document.getElementById(id+"_allow_otherform_id_temp").value;

				if(document.getElementById(id+"_rowcol_numform_id_temp").value)	
				{
				
                if(document.getElementById(id+'_table_little').getAttribute('for_hor'))
					w_flow="hor"	
				else
					w_flow="ver";				
				w_rowcol = 	document.getElementById(id+"_rowcol_numform_id_temp").value;
				}
				else
				{
					if(document.getElementById(id+'_table_little').getAttribute('for_hor'))
						w_flow="hor"	
					else
						w_flow="ver";
					
					w_rowcol = 1;
				}
				
				v=0;
				if(w_flow=="ver")
				{	
					var table_little = document.getElementById(id+'_table_little');
					for(k=0;k < table_little.childNodes.length; k++)
					{
						var td_little = table_little.childNodes[k];
							for(m=0; m < td_little.childNodes.length; m++)
							{
								var idi = td_little.childNodes[m].getAttribute('idi');
								if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other'))
									if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other')=='1')
										w_allow_other_num=t;
								w_choices[t]=document.getElementById(id+"_label_element"+idi).innerHTML;
								w_choices_checked[t]=document.getElementById(id+"_elementform_id_temp"+idi).checked;
								w_choices_value[t]=document.getElementById(id+"_elementform_id_temp"+idi).value;
								if(document.getElementById(id+"_label_element"+idi).getAttribute('where'))
									w_choices_params[t]=document.getElementById(id+"_label_element"+idi).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+idi).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+idi).getAttribute('db_info');
								else
									w_choices_params[t]='';
								t++;
								v=idi;
							}
					}
				}
				else
				{
					var table_little = document.getElementById(id+'_table_little');
					var	tr_little = table_little.childNodes;
					var td_max = tr_little[0].childNodes;
					
					for(k=0;k < td_max.length; k++)
					{
						for(m=0; m < tr_little.length; m++)
						{
							if(tr_little[m].childNodes[k])
							{
								var td_little = tr_little[m].childNodes[k];
								var idi = td_little.getAttribute('idi');
								if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other'))
									if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other')=='1')
										w_allow_other_num=t;
								w_choices[t]=document.getElementById(id+"_label_element"+idi).innerHTML;
								w_choices_checked[t]=document.getElementById(id+"_elementform_id_temp"+idi).checked;
								w_choices_value[t]=document.getElementById(id+"_elementform_id_temp"+idi).value;
								if(document.getElementById(id+"_label_element"+idi).getAttribute('where'))
									w_choices_params[t]=document.getElementById(id+"_label_element"+idi).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+idi).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+idi).getAttribute('db_info');
								else
									w_choices_params[t]='';
								t++;
								v=idi;
							}
						}
					}
				
				}

				if(document.getElementById(id+"_option_left_right"))
					w_field_option_pos = document.getElementById(id+"_option_left_right").value;
				else
					w_field_option_pos = 'left';
				
				w_value_disabled = document.getElementById(id+"_value_disabledform_id_temp").value;
				
				atrs=return_attributes(id+'_elementform_id_temp'+v);
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_radio(gen, w_field_label, w_field_label_size, w_field_label_pos, w_field_option_pos, w_flow, w_choices, w_choices_checked, w_rowcol, w_required, w_randomize, w_allow_other, w_allow_other_num, w_class, w_attr_name, w_attr_value, w_value_disabled, w_choices_value, w_choices_params); break;
			}
			case 'type_paypal_radio':
			{	
				if(document.getElementById(id+'_hor'))
					w_flow="hor"	
				else
					w_flow="ver";
		
				w_randomize=document.getElementById(id+"_randomizeform_id_temp").value;
				w_allow_other=document.getElementById(id+"_allow_otherform_id_temp").value;

				v=0;
				for(k=0;k<100;k++)
				{
					if(document.getElementById(id+"_elementform_id_temp"+k))
					{
						if(document.getElementById(id+"_elementform_id_temp"+k).getAttribute('other'))
							if(document.getElementById(id+"_elementform_id_temp"+k).getAttribute('other')=='1')
								w_allow_other_num=t;
						w_choices[t]=document.getElementById(id+"_label_element"+k).innerHTML;
						w_choices_price[t]=document.getElementById(id+"_elementform_id_temp"+k).value;
						w_choices_checked[t]=document.getElementById(id+"_elementform_id_temp"+k).checked;
						if(document.getElementById(id+"_label_element"+k).getAttribute('where'))
							w_choices_params[t]=document.getElementById(id+"_label_element"+k).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+k).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+k).getAttribute('db_info');
						else
							w_choices_params[t]='';
						t++;
						v=k;
					}
					
					if(document.getElementById(id+"_propertyform_id_temp"+k))
					{
						w_property.push(document.getElementById(id+"_property_label_form_id_temp"+k).innerHTML);
						
						if(document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length)
						{	
							w_property_values[w_property.length-1]=new Array();	
							for(m=0;m < document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length;m++)
							{				
								w_property_values[w_property.length-1].push(document.getElementById(id+"_propertyform_id_temp"+k).childNodes[m].value);
							}
						}
						else
						{
							w_property_values.push('');
						}
					}
				
				}
				
				w_quantity="no";
				w_quantity_value =1;
				if(document.getElementById(id+"_element_quantityform_id_temp"))
				{
					w_quantity='yes';
					w_quantity_value = document.getElementById(id+"_element_quantityform_id_temp").value;
				}
				if(document.getElementById(id+"_option_left_right"))
					w_field_option_pos = document.getElementById(id+"_option_left_right").value;
				else
					w_field_option_pos = 'left';
			
				atrs=return_attributes(id+'_elementform_id_temp'+v);
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_paypal_radio(gen, w_field_label, w_field_label_size, w_field_label_pos, w_field_option_pos, w_flow, w_choices, w_choices_price, w_choices_checked, w_required, w_randomize, w_allow_other, w_allow_other_num, w_class, w_attr_name, w_attr_value, w_property,  w_property_values, w_quantity, w_quantity_value, w_choices_params); break;
			}
			
			case 'type_paypal_shipping':
			{	
				if(document.getElementById(id+'_hor'))
					w_flow="hor"	
				else
					w_flow="ver";
		
				w_randomize=document.getElementById(id+"_randomizeform_id_temp").value;
				w_allow_other=document.getElementById(id+"_allow_otherform_id_temp").value;

				v=0;
				for(k=0;k<100;k++)
				{
					if(document.getElementById(id+"_elementform_id_temp"+k))
					{
						if(document.getElementById(id+"_elementform_id_temp"+k).getAttribute('other'))
							if(document.getElementById(id+"_elementform_id_temp"+k).getAttribute('other')=='1')
								w_allow_other_num=t;
						w_choices[t]=document.getElementById(id+"_label_element"+k).innerHTML;
						w_choices_price[t]=document.getElementById(id+"_elementform_id_temp"+k).value;
						w_choices_checked[t]=document.getElementById(id+"_elementform_id_temp"+k).checked;
						if(document.getElementById(id+"_label_element"+k).getAttribute('where'))
							w_choices_params[t]=document.getElementById(id+"_label_element"+k).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+k).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+k).getAttribute('db_info');
						else
							w_choices_params[t]='';
						t++;
						v=k;
					}
					
					if(document.getElementById(id+"_propertyform_id_temp"+k))
					{
						w_property.push(document.getElementById(id+"_property_label_form_id_temp"+k).innerHTML);
						
						if(document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length)
						{	
							w_property_values[w_property.length-1]=new Array();	
							for(m=0;m < document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length;m++)
							{				
								w_property_values[w_property.length-1].push(document.getElementById(id+"_propertyform_id_temp"+k).childNodes[m].value);
							}
						}
						else
						{
							w_property_values.push('');
						}
					}
				
				}
				if(document.getElementById(id+"_option_left_right"))
					w_field_option_pos = document.getElementById(id+"_option_left_right").value;
				else
					w_field_option_pos = 'left';
				
				atrs=return_attributes(id+'_elementform_id_temp'+v);
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_paypal_shipping(gen, w_field_label, w_field_label_size, w_field_label_pos, w_field_option_pos, w_flow, w_choices, w_choices_price, w_choices_checked, w_required, w_randomize, w_allow_other, w_allow_other_num, w_class, w_attr_name, w_attr_value, w_property, w_property_values, w_choices_params);   break;
			}

			case 'type_paypal_total':
			{
				w_size = jQuery('#'+id+"paypal_totalform_id_temp").css('width') ? jQuery('#'+id+"paypal_totalform_id_temp").css('width').substring(0,jQuery('#'+id+"paypal_totalform_id_temp").css('width').length-2) : '300';
				type_paypal_total(gen, w_field_label, w_field_label_size, w_field_label_pos, w_class, w_size); break;
			}
      
      case 'type_stripe':
			{	
				type_stripe(gen, w_size, w_field_label_size, w_field_label_pos,  w_class); break;
			}
			
			case 'type_star_rating':
			{
				w_star_amount  = document.getElementById(id+"_star_amountform_id_temp").value;
				w_field_label_col  = document.getElementById(id+"_star_colorform_id_temp").value;
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				
				type_star_rating(gen, w_field_label, w_field_label_size, w_field_label_pos, w_field_label_col, w_star_amount, w_required, w_class, w_attr_name, w_attr_value) ; break;
			}
			
			case 'type_scale_rating':
			{
				w_mini_labels  =[document.getElementById(id+"_mini_label_worst").innerHTML,document.getElementById(id+"_mini_label_best").innerHTML];	
			
				w_scale_amount = document.getElementById(id+"_scale_amountform_id_temp").value;
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				
				type_scale_rating(gen, w_field_label, w_field_label_size, w_field_label_pos, w_mini_labels,  w_scale_amount, w_required, w_class, w_attr_name, w_attr_value) ; break;
			}
			
			case 'type_spinner':
			{
				w_field_min_value  = document.getElementById(id+"_min_valueform_id_temp").value;
				w_field_max_value  = document.getElementById(id+"_max_valueform_id_temp").value;
				w_field_width  = document.getElementById(id+"_spinner_widthform_id_temp").value;
				w_field_step = document.getElementById(id+"_stepform_id_temp").value;
				w_field_value  = document.getElementById(id+"_elementform_id_temp").getAttribute("aria-valuenow");
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				
				type_spinner(gen, w_field_label, w_field_label_size, w_field_label_pos, w_field_width, w_field_min_value, w_field_max_value, w_field_step, w_field_value, w_required, w_class, w_attr_name, w_attr_value) ; break;
			
			
			}
			
			case 'type_slider':
			{
				w_field_min_value  = document.getElementById(id+"_slider_min_valueform_id_temp").value;
				w_field_max_value  = document.getElementById(id+"_slider_max_valueform_id_temp").value;
				w_field_width  = document.getElementById(id+"_slider_widthform_id_temp").value;
				w_field_value  = document.getElementById(id+"_slider_valueform_id_temp").value;
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_slider(gen, w_field_label, w_field_label_size, w_field_label_pos,  w_field_width, w_field_min_value, w_field_max_value, w_field_value, w_required, w_class, w_attr_name, w_attr_value); break;
			}
			
			case 'type_range':
			{
				
				w_field_range_width  = document.getElementById(id+"_range_widthform_id_temp").value;
				w_field_range_step = document.getElementById(id+"_range_stepform_id_temp").value;
				
				w_field_value1  = document.getElementById(id+"_elementform_id_temp0").getAttribute("aria-valuenow");
				w_field_value2  = document.getElementById(id+"_elementform_id_temp1").getAttribute("aria-valuenow");
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				
				w_mini_labels = [document.getElementById(id+"_mini_label_from").innerHTML,document.getElementById(id+"_mini_label_to").innerHTML]; 	 
				
				type_range(gen, w_field_label, w_field_label_size, w_field_label_pos, w_field_range_width, w_field_range_step, w_field_value1, w_field_value2, w_mini_labels, w_required, w_class, w_attr_name, w_attr_value) ;  break;
			
			}
			case 'type_grading':
			{
			
				w_total = document.getElementById(id+"_grading_totalform_id_temp").value;
				w_items=[];
				
				for(k=0;k<100;k++)
					if(document.getElementById(id+"_label_elementform_id_temp"+k))
					{
						
						w_items.push(document.getElementById(id+"_label_elementform_id_temp"+k).innerHTML);
						
					}
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				
				type_grading(gen, w_field_label, w_field_label_size, w_field_label_pos, w_items, w_total, w_required, w_class, w_attr_name, w_attr_value) ; refresh_grading_items(id); break;
			
			
			}
			case 'type_matrix':
			{	
                w_rows=[];
				w_rows[0]="";
				for(k=1;k<100;k++)
					if(document.getElementById(id+"_label_elementform_id_temp"+k+"_0"))
					{
						
						w_rows.push(document.getElementById(id+"_label_elementform_id_temp"+k+"_0").innerHTML);
						
					}
			
			    w_columns=[];
				w_columns[0]="";
				for(k=1;k<100;k++)
					if(document.getElementById(id+"_label_elementform_id_temp0_"+k))
					{
						
						w_columns.push(document.getElementById(id+"_label_elementform_id_temp0_"+k).innerHTML);
						
					}
					
			w_field_input_type = document.getElementById(id+"_input_typeform_id_temp").value;		
			w_textbox_size = document.getElementById(id+"_textbox_sizeform_id_temp") ? document.getElementById(id+"_textbox_sizeform_id_temp").value : '100';		
			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			type_matrix(gen, w_field_label, w_field_label_size, w_field_label_pos, w_field_input_type, w_rows, w_columns, w_required, w_class, w_attr_name, w_attr_value, w_textbox_size); refresh_matrix(id); break; 
			
			
			}
		
			
			case 'type_time':
			{	
				atrs=return_attributes(id+'_hhform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				w_hh=document.getElementById(id+'_hhform_id_temp').value;
				w_mm=document.getElementById(id+'_mmform_id_temp').value;
				if(document.getElementById(id+'_ssform_id_temp'))
				{
					w_ss=document.getElementById(id+'_ssform_id_temp').value;
					w_sec="1";
					w_mini_label_ss=document.getElementById(id+'_mini_label_ss').innerHTML;
				}
				else
				{
					w_ss="";
					w_sec="0";
					w_mini_label_ss='';
				}
				if(document.getElementById(id+'_am_pm_select'))
				{
					w_am_pm=document.getElementById(id+'_am_pmform_id_temp').value;
					w_time_type="12";
					w_mini_labels = [document.getElementById(id+'_mini_label_hh').innerHTML, document.getElementById(id+'_mini_label_mm').innerHTML, w_mini_label_ss, document.getElementById(id+'_mini_label_am_pm').innerHTML];
		
				}
				else
				{
					w_am_pm=0;
					w_time_type="24";
					w_mini_labels = [document.getElementById(id+'_mini_label_hh').innerHTML, document.getElementById(id+'_mini_label_mm').innerHTML, w_mini_label_ss ,'AM/PM'];
			
				}
				type_time(gen, w_field_label, w_field_label_size, w_field_label_pos, w_time_type, w_am_pm, w_sec, w_hh, w_mm, w_ss, w_mini_labels, w_required, w_class, w_attr_name, w_attr_value); break;
			}
			case 'type_date':
			{	
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				w_date=document.getElementById(id+'_elementform_id_temp').value;
				w_format=document.getElementById(id+'_buttonform_id_temp').getAttribute("format");
				w_but_val=document.getElementById(id+'_buttonform_id_temp').value;
				w_disable_past_days = document.getElementById(id+'_dis_past_daysform_id_temp') ? document.getElementById(id+'_dis_past_daysform_id_temp').value : 'no';
				type_date(gen, w_field_label, w_field_label_size, w_field_label_pos, w_date, w_required, w_class, w_format, w_but_val, w_attr_name, w_attr_value, w_disable_past_days); break;
			}
			case 'type_date_fields':
			{	
				atrs			=return_attributes(id+'_dayform_id_temp');
				w_attr_name		=atrs[0];
				w_attr_value	=atrs[1];
				w_day			=document.getElementById(id+'_dayform_id_temp').value;
				w_month			=document.getElementById(id+'_monthform_id_temp').value;
				w_year			=document.getElementById(id+'_yearform_id_temp').value;
				w_day_type		=document.getElementById(id+'_dayform_id_temp').tagName;
				w_month_type	=document.getElementById(id+'_monthform_id_temp').tagName;
				w_year_type		=document.getElementById(id+'_yearform_id_temp').tagName;
				w_day_label		=document.getElementById(id+'_day_label').innerHTML;
				w_month_label	=document.getElementById(id+'_month_label').innerHTML;
				w_year_label	=document.getElementById(id+'_year_label').innerHTML;
				
				s				=document.getElementById(id+'_dayform_id_temp').style.width;
				w_day_size		=s.substring(0,s.length-2);
				
				s				=document.getElementById(id+'_monthform_id_temp').style.width;
				w_month_size	=s.substring(0,s.length-2);
				
				s				=document.getElementById(id+'_yearform_id_temp').style.width;
				w_year_size		=s.substring(0,s.length-2);
	
				w_from			=document.getElementById(id+'_yearform_id_temp').getAttribute('from');
				w_to			=document.getElementById(id+'_yearform_id_temp').getAttribute('to');
				
				w_divider		=document.getElementById(id+'_separator1').innerHTML;
				type_date_fields(gen, w_field_label, w_field_label_size, w_field_label_pos, w_day, w_month, w_year, w_day_type, w_month_type, w_year_type, w_day_label, w_month_label, w_year_label, w_day_size, w_month_size, w_year_size, w_required, w_class, w_from, w_to, w_divider, w_attr_name, w_attr_value); break;
			}
			
			case 'type_own_select':
			{	
				jQuery('#'+id+'_elementform_id_temp option').each(function() {
					w_choices[t]=jQuery(this).html();
					w_choices_value[t]=jQuery(this).val();
					w_choices_checked[t]=jQuery(this)[0].selected;
					if(jQuery(this).attr('where'))
						w_choices_params[t]=jQuery(this).attr('where')+'[where_order_by]'+jQuery(this).attr('order_by')+'[db_info]'+jQuery(this).attr('db_info');
					else
						w_choices_params[t]='';
						
					if(jQuery(this).val())
						w_choices_disabled[t]=false;	
					else
						w_choices_disabled[t]=true;
					t++;		
				});

				w_value_disabled = document.getElementById(id+'_value_disabledform_id_temp').value;
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_own_select(gen, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_choices, w_choices_checked, w_required, w_value_disabled, w_class, w_attr_name, w_attr_value, w_choices_disabled, w_choices_value, w_choices_params); break;
			}
			
			case 'type_paypal_select':
			{	
				jQuery('#'+id+'_elementform_id_temp option').each(function() {
					w_choices[t]=jQuery(this).html();
					w_choices_price[t]=jQuery(this).val();
					w_choices_checked[t]=jQuery(this)[0].selected;
					if(jQuery(this).attr('where'))
						w_choices_params[t]=jQuery(this).attr('where')+'[where_order_by]'+jQuery(this).attr('order_by')+'[db_info]'+jQuery(this).attr('db_info');
					else
						w_choices_params[t]='';
						
					if(jQuery(this)[0].value=="")
							w_choices_disabled[t]=true;
						else
							w_choices_disabled[t]=false;
					t++;		
				});
				
				for(k=0;k<100;k++)
				{
					if(document.getElementById(id+"_propertyform_id_temp"+k))
					{
						w_property.push(document.getElementById(id+"_property_label_form_id_temp"+k).innerHTML);
						
						if(document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length)
						{	
							w_property_values[w_property.length-1]=new Array();	
							for(m=0;m < document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length;m++)
							{				
								w_property_values[w_property.length-1].push(document.getElementById(id+"_propertyform_id_temp"+k).childNodes[m].value);
							}
						}
						else
						{
							w_property_values.push('');
						}
					}
					
				}
				
				w_quantity="no";
				w_quantity_value =1;
				if(document.getElementById(id+"_element_quantityform_id_temp"))
				{
					w_quantity='yes';
					w_quantity_value = document.getElementById(id+"_element_quantityform_id_temp").value;
				}

				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_paypal_select(gen, w_field_label, w_field_label_size, w_field_label_pos, w_size, w_choices,w_choices_price, w_choices_checked, w_required,  w_quantity, w_quantity_value, w_class, w_attr_name, w_attr_value, w_choices_disabled, w_property, w_property_values, w_choices_params); break;
			}
			
			case 'type_country':
			{	
				w_countries=[];

				select_=document.getElementById(id+'_elementform_id_temp');
				n=select_.childNodes.length;
				for(i=0; i<n; i++)
				{
					w_countries.push(select_.childNodes[i].value);
				}

				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_country(gen, w_field_label, w_field_label_size, w_countries, w_field_label_pos, w_size, w_required, w_class,  w_attr_name, w_attr_value);  break;
			}
			case 'type_file_upload':
			{
				w_destination=document.getElementById(id+"_destination").value.replace("***destinationverj"+id+"***", "").replace("***destinationskizb"+id+"***", "");
				w_extension  =document.getElementById(id+"_extension").value.replace("***extensionverj"+id+"***", "").replace("***extensionskizb"+id+"***", "");
				w_max_size   =document.getElementById(id+"_max_size").value.replace("***max_sizeverj"+id+"***", "").replace("***max_sizeskizb"+id+"***", "");
				w_multiple   =(document.getElementById(id+"_elementform_id_temp").getAttribute('multiple') ? 'yes' : 'no');
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_file_upload(gen, w_field_label, w_field_label_size, w_field_label_pos, w_destination,w_extension, w_max_size, w_required, w_multiple, w_class,  w_attr_name, w_attr_value);  break;
			}
			case 'type_map':
			{
				w_lat=[];
				w_long=[];
				w_info=[];
				
				w_center_x  = document.getElementById(id+"_elementform_id_temp").getAttribute("center_x");
				w_center_y  = document.getElementById(id+"_elementform_id_temp").getAttribute("center_y");
				w_zoom  = document.getElementById(id+"_elementform_id_temp").getAttribute("zoom");
				w_width = parseInt(document.getElementById(id+"_elementform_id_temp").style.width);
				w_height= parseInt(document.getElementById(id+"_elementform_id_temp").style.height);
				
				
				
				for(j=0; j<=20; j++)
					if( document.getElementById(id+"_elementform_id_temp").getAttribute("lat"+j))
					{
						w_lat.push(document.getElementById(id+"_elementform_id_temp").getAttribute("lat"+j));
						w_long.push(document.getElementById(id+"_elementform_id_temp").getAttribute("long"+j));
						w_info.push(document.getElementById(id+"_elementform_id_temp").getAttribute("info"+j));
					}

				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_map(gen, w_center_x, w_center_y, w_long, w_lat, w_zoom, w_width, w_height, w_class, w_info, w_attr_name, w_attr_value); break;
			}
			case 'type_mark_map':
			{
				w_info  = document.getElementById(id+"_elementform_id_temp").getAttribute("info0");
				w_long  = document.getElementById(id+"_elementform_id_temp").getAttribute("long0");
				w_lat   = document.getElementById(id+"_elementform_id_temp").getAttribute("lat0");
				w_zoom  = document.getElementById(id+"_elementform_id_temp").getAttribute("zoom");
				w_width = parseInt(document.getElementById(id+"_elementform_id_temp").style.width);
				w_height= parseInt(document.getElementById(id+"_elementform_id_temp").style.height);
				w_center_x  = document.getElementById(id+"_elementform_id_temp").getAttribute("center_x");
				w_center_y  = document.getElementById(id+"_elementform_id_temp").getAttribute("center_y");
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_mark_map(gen, w_field_label, w_field_label_size, w_field_label_pos, w_center_x, w_center_y, w_long, w_lat, w_zoom, w_width, w_height, w_class, w_info, w_attr_name, w_attr_value);break;
			}
			case 'type_submit_reset':
			{
				atrs=return_attributes(id+'_element_submitform_id_temp');
				w_act=!(document.getElementById(id+"_element_resetform_id_temp").style.display=="none");
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				w_submit_title = document.getElementById(id+"_element_submitform_id_temp").value;
				w_reset_title  = document.getElementById(id+"_element_resetform_id_temp").value;
				type_submit_reset(gen, w_submit_title , w_reset_title , w_class, w_act, w_attr_name, w_attr_value);  break;
			}

			case 'type_button':
			{
				w_title	=new Array();	
			
				w_func	=new Array();
				t=0;
				v=0;
				for(k=0;k<100;k++)
					if(document.getElementById(id+"_elementform_id_temp"+k))
					{
						w_title[t]=document.getElementById(id+"_elementform_id_temp"+k).value;
						w_func[t]=document.getElementById(id+"_elementform_id_temp"+k).getAttribute("onclick");
						t++;
						v=k;
					}
				atrs=return_attributes(id+'_elementform_id_temp'+v);
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_button (gen, w_title , w_func , w_class,w_attr_name, w_attr_value);  break;
			}
			case 'type_hidden':
			{
				w_value  = document.getElementById(id+"_elementform_id_temp").value;
				w_name  = document.getElementById(id+"_elementform_id_temp").name;
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				type_hidden (gen, w_name, w_value , w_attr_name, w_attr_value);  break;
			}

		}
	
	need_enable=false;
		add(0, false);
		need_enable=true;	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}



function gen_form_fields()
{
	switch(wdtype)
	{
		case 'type_editor':
		{
			w_editor=document.getElementById("wdform_field"+id).innerHTML;
									
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_editor+"*:*w_editor*:*";
			form_fields+="*:*new_field*:*";
		
			break;
		}
		case 'type_send_copy':
		{
			w_first_val=document.getElementById(id+"_elementform_id_temp").checked;
			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];

			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_first_val+"*:*w_first_val*:*";
			form_fields+=w_required+"*:*w_required*:*";
									
			for(j=0; j<w_attr_name.length; j++)
			{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";
			break;
			}
		
		case 'type_text':
		{
			w_first_val=document.getElementById(id+"_elementform_id_temp").value;
			w_title=document.getElementById(id+"_elementform_id_temp").title;
			w_regExp_status = document.getElementById(id+"_regExpStatusform_id_temp").value;
			w_regExp_value = document.getElementById(id+"_regExp_valueform_id_temp").value;
			w_regExp_common = document.getElementById(id+"_regExp_commonform_id_temp").value;
			w_regExp_arg = document.getElementById(id+"_regArgumentform_id_temp").value;
			w_regExp_alert = document.getElementById(id+"_regExp_alertform_id_temp").value;
			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
									
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_size+"*:*w_size*:*";
			form_fields+=w_first_val+"*:*w_first_val*:*";
			form_fields+=w_title+"*:*w_title*:*";
			form_fields+=w_required+"*:*w_required*:*";
			form_fields+=w_regExp_status+"*:*w_regExp_status*:*";
			form_fields+=w_regExp_value+"*:*w_regExp_value*:*";
			form_fields+=w_regExp_common+"*:*w_regExp_common*:*";
			form_fields+=w_regExp_arg+"*:*w_regExp_arg*:*";
			form_fields+=w_regExp_alert+"*:*w_regExp_alert*:*";
			form_fields+=w_unique+"*:*w_unique*:*";
									
			for(j=0; j<w_attr_name.length; j++)
			{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";
			break;
		}
		case 'type_number':
		{
			w_first_val=document.getElementById(id+"_elementform_id_temp").value;
			w_title=document.getElementById(id+"_elementform_id_temp").title;
			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_size+"*:*w_size*:*";
			form_fields+=w_first_val+"*:*w_first_val*:*";
			form_fields+=w_title+"*:*w_title*:*";
			form_fields+=w_required+"*:*w_required*:*";
			form_fields+=w_unique+"*:*w_unique*:*";
			form_fields+=w_class+"*:*w_class*:*";
			
			for(j=0; j<w_attr_name.length; j++)
			{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";	
			break;
			
		}
		case 'type_password':
		{
			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			
		
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_size+"*:*w_size*:*";
			form_fields+=w_required+"*:*w_required*:*";
			form_fields+=w_unique+"*:*w_unique*:*";
			form_fields+=w_class+"*:*w_class*:*";
			
			for(j=0; j<w_attr_name.length; j++)
			{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";	
			break;
				
		}
		case 'type_textarea':
		{
			w_first_val=document.getElementById(id+"_elementform_id_temp").value;
			w_title=document.getElementById(id+"_elementform_id_temp").title;
			s=document.getElementById(id+"_elementform_id_temp").style.height;
			w_size_h=s.substring(0,s.length-2);
			w=document.getElementById(id+"_elementform_id_temp").style.width;
			w_size_w=w.substring(0,w.length-2);

			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
		
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_size+"*:*w_size_w*:*";
			form_fields+=w_size_h+"*:*w_size_h*:*";
			form_fields+=w_first_val+"*:*w_first_val*:*";
			form_fields+=w_title+"*:*w_title*:*";
			form_fields+=w_required+"*:*w_required*:*";
			form_fields+=w_unique+"*:*w_unique*:*";
			form_fields+=w_class+"*:*w_class*:*";
			
			for(j=0; j<w_attr_name.length; j++)
			{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";	
			break;
			}
			
		case 'type_wdeditor':
		{
		
			w_title=document.getElementById(id+"_elementform_id_temp").title;
			s=document.getElementById(id+"_elementform_id_temp").style.height;
			w_size_h=s.substring(0,s.length-2);
			w=document.getElementById(id+"_elementform_id_temp").style.width;
			w_size_w=w.substring(0,w.length-2);

			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
		
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_size+"*:*w_size_w*:*";
			form_fields+=w_size_h+"*:*w_size_h*:*";
			form_fields+=w_title+"*:*w_title*:*";
			form_fields+=w_required+"*:*w_required*:*";
			form_fields+=w_class+"*:*w_class*:*";
			
			for(j=0; j<w_attr_name.length; j++)
			{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";	
			break;
		}
		
				
			
		case 'type_phone':
		{
			w_first_val=[document.getElementById(id+"_element_firstform_id_temp").value, document.getElementById(id+"_element_lastform_id_temp").value];
			w_title=[document.getElementById(id+"_element_firstform_id_temp").title, document.getElementById(id+"_element_lastform_id_temp").title];
			s=document.getElementById(id+"_element_lastform_id_temp").style.width;
			w_size=s.substring(0,s.length-2);

			w_mini_labels= [document.getElementById(id+"_mini_label_area_code").innerHTML, document.getElementById(id+"_mini_label_phone_number").innerHTML];
			
			
			atrs=return_attributes(id+'_element_firstform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			
				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_size+"*:*w_size*:*";
				form_fields+=w_first_val.join('***')+"*:*w_first_val*:*";
				form_fields+=w_title.join('***')+"*:*w_title*:*";
				form_fields+=w_mini_labels.join('***')+"*:*w_mini_labels*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_unique+"*:*w_unique*:*";
				form_fields+=w_class+"*:*w_class*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				form_fields+="*:*new_field*:*";	
				break;
				}
		case 'type_name':
		{
			if(document.getElementById(id+"_enable_fieldsform_id_temp")) {
					w_name_format="normal";
				
					w_first_val=[document.getElementById(id+"_element_firstform_id_temp").value, document.getElementById(id+"_element_lastform_id_temp").value];
					w_title=[document.getElementById(id+"_element_firstform_id_temp").title, document.getElementById(id+"_element_lastform_id_temp").title];
					
					var title_middle = ['title', 'middle'];
					for(var l=0; l<2; l++)
					{
						w_first_val.push(document.getElementById(id+'_element_'+title_middle[l]+'form_id_temp') ? document.getElementById(id+'_element_'+title_middle[l]+'form_id_temp').value : '');
						w_title.push(document.getElementById(id+'_element_'+title_middle[l]+'form_id_temp') ? document.getElementById(id+'_element_'+title_middle[l]+'form_id_temp').title : '');
					}
					
				}
				else
				{
					if(document.getElementById(id+'_element_middleform_id_temp'))
						w_name_format="extended";
					else
						w_name_format="normal";

					if(w_name_format=="normal")	{
						w_first_val=[document.getElementById(id+"_element_firstform_id_temp").value, document.getElementById(id+"_element_lastform_id_temp").value];
						w_title=[document.getElementById(id+"_element_firstform_id_temp").title, document.getElementById(id+"_element_lastform_id_temp").title];
					}
					else {
						w_first_val=[document.getElementById(id+"_element_firstform_id_temp").value, document.getElementById(id+"_element_lastform_id_temp").value, document.getElementById(id+"_element_titleform_id_temp").value, document.getElementById(id+"_element_middleform_id_temp").value];
						w_title=[document.getElementById(id+"_element_firstform_id_temp").title, document.getElementById(id+"_element_lastform_id_temp").title, document.getElementById(id+"_element_titleform_id_temp").title,document.getElementById(id+"_element_middleform_id_temp").title];
					}
				}
	
				if(document.getElementById(id+"_mini_label_title"))
					w_mini_title = document.getElementById(id+"_mini_label_title").innerHTML;
				else
					w_mini_title = "Title";
			
				if(document.getElementById(id+"_mini_label_middle"))
					w_mini_middle = document.getElementById(id+"_mini_label_middle").innerHTML;
				else
					w_mini_middle = "Middle";
				
				w_mini_labels = [w_mini_title, document.getElementById(id+"_mini_label_first").innerHTML,document.getElementById(id+"_mini_label_last").innerHTML, w_mini_middle];
				w_name_title = 	document.getElementById(id+'_enable_fieldsform_id_temp') ? document.getElementById(id+'_enable_fieldsform_id_temp').getAttribute('title') : (w_name_format=="normal" ? 'no' : 'yes');			
				w_name_middle = document.getElementById(id+'_enable_fieldsform_id_temp') ? document.getElementById(id+'_enable_fieldsform_id_temp').getAttribute('middle') : (w_name_format=="normal" ? 'no' : 'yes');			
				w_name_fields = [w_name_title, w_name_middle]; 	    
				 
				s=document.getElementById(id+"_element_firstform_id_temp").style.width;
				w_size=s.substring(0,s.length-2);
				atrs=return_attributes(id+'_element_firstform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
	
				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_first_val.join('***')+"*:*w_first_val*:*";
				form_fields+=w_title.join('***')+"*:*w_title*:*";
				form_fields+=w_mini_labels.join('***')+"*:*w_mini_labels*:*";
				form_fields+=w_size+"*:*w_size*:*";
				form_fields+=w_name_format+"*:*w_name_format*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_unique+"*:*w_unique*:*";
				form_fields+=w_class+"*:*w_class*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				form_fields+=w_name_fields.join('***')+"*:*w_name_fields*:*";
				
				form_fields+="*:*new_field*:*";	
				break;
			}
		
		case 'type_paypal_price':
		{
			w_first_val=[document.getElementById(id+"_element_dollarsform_id_temp").value, document.getElementById(id+"_element_centsform_id_temp").value];
			w_title=[document.getElementById(id+"_element_dollarsform_id_temp").title, document.getElementById(id+"_element_centsform_id_temp").title];

			if(document.getElementById(id+"_td_name_cents").style.display=="none")
				w_hide_cents='yes';
			else
				w_hide_cents='no';
			

			
			s=document.getElementById(id+"_element_dollarsform_id_temp").style.width;
			w_size=s.substring(0,s.length-2);
			atrs=return_attributes(id+'_element_dollarsform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			w_range_min=document.getElementById(id+"_range_minform_id_temp").value;
			w_range_max=document.getElementById(id+"_range_maxform_id_temp").value;
			
			w_mini_labels = [document.getElementById(id+"_mini_label_dollars").innerHTML,document.getElementById(id+"_mini_label_cents").innerHTML]; 	
			
				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_first_val.join('***')+"*:*w_first_val*:*";
				form_fields+=w_title.join('***')+"*:*w_title*:*";
				form_fields+=w_mini_labels.join('***')+"*:*w_mini_labels*:*";
				form_fields+=w_size+"*:*w_size*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_hide_cents+"*:*w_hide_cents*:*";
				form_fields+=w_class+"*:*w_class*:*";
				form_fields+=w_range_min+"*:*w_range_min*:*";
				form_fields+=w_range_max+"*:*w_range_max*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				form_fields+="*:*new_field*:*";	
				break;
			
			}
		
		case 'type_address':
		{
			s=document.getElementById(id+"_div_address").style.width;
			w_size=s.substring(0,s.length-2);
			
			if(document.getElementById(id+"_mini_label_street1"))
					w_street1= document.getElementById(id+"_mini_label_street1").innerHTML; 
				else
					w_street1 = document.getElementById(id+"_street1form_id_temp").value;
					
					
				if(document.getElementById(id+"_mini_label_street2"))
					w_street2= document.getElementById(id+"_mini_label_street2").innerHTML;
				else
					w_street2 = document.getElementById(id+"_street2form_id_temp").value;	
					
				if(document.getElementById(id+"_mini_label_city"))
					w_city= document.getElementById(id+"_mini_label_city").innerHTML;
				else
					w_city = document.getElementById(id+"_cityform_id_temp").value;					
					
				if(document.getElementById(id+"_mini_label_state"))
					w_state= document.getElementById(id+"_mini_label_state").innerHTML; 
				else
					w_state = document.getElementById(id+"_stateform_id_temp").value;	
					
				if(document.getElementById(id+"_mini_label_postal"))
					w_postal= document.getElementById(id+"_mini_label_postal").innerHTML; 
				else
					w_postal = document.getElementById(id+"_postalform_id_temp").value;	
					
				if(document.getElementById(id+"_mini_label_country"))
					w_country= document.getElementById(id+"_mini_label_country").innerHTML; 
				else
					w_country = document.getElementById(id+"_countryform_id_temp").value;					
					
				w_mini_labels=[w_street1, w_street2, w_city, w_state, w_postal, w_country];

				
				var disabled_input = document.getElementById(id+"_disable_fieldsform_id_temp");
				
					w_street1_dis= disabled_input.getAttribute('street1');
					w_street2_dis= disabled_input.getAttribute('street2');
					w_city_dis= disabled_input.getAttribute('city');
					w_state_dis= disabled_input.getAttribute('state');
					w_us_states_dis= disabled_input.getAttribute('us_states');
					w_postal_dis= disabled_input.getAttribute('postal');
					w_country_dis= disabled_input.getAttribute('country');
				
						
			w_disabled_fields=[w_street1_dis, w_street2_dis, w_city_dis, w_state_dis,  w_postal_dis, w_country_dis, w_us_states_dis];

			atrs=return_attributes(id+'_street1form_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			
			
				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_size+"*:*w_size*:*";
				form_fields+=w_mini_labels.join('***')+"*:*w_mini_labels*:*";
				form_fields+=w_disabled_fields.join('***')+"*:*w_disabled_fields*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_class+"*:*w_class*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				
				form_fields+="*:*new_field*:*";	
				break;
			}

		case 'type_submitter_mail':
		{
			w_first_val=document.getElementById(id+"_elementform_id_temp").value;
			w_title=document.getElementById(id+"_elementform_id_temp").title;
	
			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			
				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_size+"*:*w_size*:*";
				form_fields+=w_first_val+"*:*w_first_val*:*";
				form_fields+=w_title+"*:*w_title*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_unique+"*:*w_unique*:*";
				form_fields+=w_class+"*:*w_class*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				
				form_fields+="*:*new_field*:*";	
				break;
			}
		case 'type_checkbox':
		{	
			w_randomize=document.getElementById(id+"_randomizeform_id_temp").value;
			w_allow_other=document.getElementById(id+"_allow_otherform_id_temp").value;
			tt=0;
			v=0;
		
			w_randomize=document.getElementById(id+"_randomizeform_id_temp").value;
			w_allow_other=document.getElementById(id+"_allow_otherform_id_temp").value;

			if(document.getElementById(id+"_rowcol_numform_id_temp").value)	
			{
				
                if(document.getElementById(id+'_table_little').getAttribute('for_hor'))
					w_flow="hor"	
				else
					w_flow="ver";				
				w_rowcol = 	document.getElementById(id+"_rowcol_numform_id_temp").value;
			}
			else
			{
				if(document.getElementById(id+'_hor'))
					w_flow="hor"	
				else
					w_flow="ver";
				
				w_rowcol = 1;
			}
				
			if(w_flow=="ver")
			{
				var table_little = document.getElementById(id+'_table_little');
				for(k=0;k < table_little.childNodes.length; k++)
				{
					var td_little = table_little.childNodes[k];
						for(m=0; m < td_little.childNodes.length; m++)
						{
							var idi = td_little.childNodes[m].getAttribute('idi');
							if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other'))
								if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other')=='1')
									w_allow_other_num=tt;
							w_choices[tt]=document.getElementById(id+"_label_element"+idi).innerHTML;
							w_choices_checked[tt]=document.getElementById(id+"_elementform_id_temp"+idi).checked;
							w_choices_value[tt]=document.getElementById(id+"_elementform_id_temp"+idi).value;
							if(document.getElementById(id+"_label_element"+idi).getAttribute('where'))
								w_choices_params[tt]=document.getElementById(id+"_label_element"+idi).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+idi).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+idi).getAttribute('db_info');
							else
								w_choices_params[tt]='';
							tt++;
							v=idi;
						}
				}
			
			}
			else
			{
				var table_little = document.getElementById(id+'_table_little');
				var	tr_little = table_little.childNodes;
				var td_max = tr_little[0].childNodes;
				
				for(k=0;k < td_max.length; k++)
				{
					for(m=0; m < tr_little.length; m++)
					{
						if(tr_little[m].childNodes[k])
						{
							var td_little = tr_little[m].childNodes[k];
							var idi = td_little.getAttribute('idi');
							if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other'))
								if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other')=='1')
									w_allow_other_num=tt;
							w_choices[tt]=document.getElementById(id+"_label_element"+idi).innerHTML;
							w_choices_checked[tt]=document.getElementById(id+"_elementform_id_temp"+idi).checked;
							w_choices_value[tt]=document.getElementById(id+"_elementform_id_temp"+idi).value;
							if(document.getElementById(id+"_label_element"+idi).getAttribute('where'))
								w_choices_params[tt]=document.getElementById(id+"_label_element"+idi).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+idi).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+idi).getAttribute('db_info');
							else
								w_choices_params[tt]='';
							tt++;
							v=idi;
						}
					}
				}
			
			}
			
			if(document.getElementById(id+"_option_left_right"))
				w_field_option_pos = document.getElementById(id+"_option_left_right").value;
			else
				w_field_option_pos = 'left';
				
			w_value_disabled = document.getElementById(id+"_value_disabledform_id_temp").value;

			atrs=return_attributes(id+'_elementform_id_temp'+v);
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_field_option_pos+"*:*w_field_option_pos*:*";
			form_fields+=w_flow+"*:*w_flow*:*";
			form_fields+=w_choices.join('***')+"*:*w_choices*:*";
			form_fields+=w_choices_checked.join('***')+"*:*w_choices_checked*:*";
			form_fields+=w_rowcol+"*:*w_rowcol*:*";
			form_fields+=w_required+"*:*w_required*:*";
			form_fields+=w_randomize+"*:*w_randomize*:*";
			form_fields+=w_allow_other+"*:*w_allow_other*:*";
			form_fields+=w_allow_other_num+"*:*w_allow_other_num*:*";
			form_fields+=w_value_disabled+"*:*w_value_disabled*:*";
			form_fields+=w_choices_value.join('***')+"*:*w_choices_value*:*";
			form_fields+=w_choices_params.join('***')+"*:*w_choices_params*:*";
			form_fields+=w_class+"*:*w_class*:*";
			
			for(j=0; j<w_attr_name.length; j++)
			{
			form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			
			form_fields+="*:*new_field*:*";	
			break;
		}
		
		case 'type_paypal_checkbox':
		{	
			if(document.getElementById(id+'_hor'))
				w_flow="hor"	
			else
				w_flow="ver";

			w_randomize=document.getElementById(id+"_randomizeform_id_temp").value;
			w_allow_other=document.getElementById(id+"_allow_otherform_id_temp").value;
			tt=0;
			v=0;
			for(k=0;k<100;k++)
			{
				if(document.getElementById(id+"_elementform_id_temp"+k))
				{
					if(document.getElementById(id+"_elementform_id_temp"+k).getAttribute('other'))
						if(document.getElementById(id+"_elementform_id_temp"+k).getAttribute('other')=='1')
							w_allow_other_num=tt;
					w_choices[tt]=document.getElementById(id+"_label_element"+k).innerHTML;
					if(w_choices[tt][w_choices[tt].length-1]==' ')
						w_choices[tt]=w_choices[tt].substring(0, w_choices[tt].length-1);
					w_choices_price[tt]=document.getElementById(id+"_elementform_id_temp"+k).value;
					w_choices_checked[tt]=document.getElementById(id+"_elementform_id_temp"+k).checked;
					if(document.getElementById(id+"_label_element"+k).getAttribute('where'))
						w_choices_params[tt]=document.getElementById(id+"_label_element"+k).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+k).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+k).getAttribute('db_info');
					else
						w_choices_params[tt]='';
					tt++;
					v=k;
				}
				
				if(document.getElementById(id+"_propertyform_id_temp"+k))
				{
					w_property.push(document.getElementById(id+"_property_label_form_id_temp"+k).innerHTML);
					
					if(document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length)
					{	
						w_property_values[w_property.length-1]='';	
						for(m=0;m < document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length;m++)
						{				
							w_property_values[w_property.length-1]+='###'+(document.getElementById(id+"_propertyform_id_temp"+k).childNodes[m].value);
						}
					}
					else
					{
						w_property_values.push('');
					}
				}
				
			}
			
			w_quantity="no";
			w_quantity_value =1;
			if(document.getElementById(id+"_element_quantityform_id_temp"))
			{
				w_quantity='yes';
				w_quantity_value = document.getElementById(id+"_element_quantityform_id_temp").value;
			}
			if(document.getElementById(id+"_option_left_right"))
				w_field_option_pos = document.getElementById(id+"_option_left_right").value;
			else
				w_field_option_pos = 'left';
			atrs=return_attributes(id+'_elementform_id_temp'+v);
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			
			
				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_field_option_pos+"*:*w_field_option_pos*:*";
				form_fields+=w_flow+"*:*w_flow*:*";
				form_fields+=w_choices.join('***')+"*:*w_choices*:*";
				form_fields+=w_choices_price.join('***')+"*:*w_choices_price*:*";
				form_fields+=w_choices_checked.join('***')+"*:*w_choices_checked*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_randomize+"*:*w_randomize*:*";
				form_fields+=w_allow_other+"*:*w_allow_other*:*";
				form_fields+=w_allow_other_num+"*:*w_allow_other_num*:*";	
				form_fields+=w_choices_params.join('***')+"*:*w_choices_params*:*";
				form_fields+=w_class+"*:*w_class*:*";
				form_fields+=w_property.join('***')+"*:*w_property*:*";
				
				form_fields+=w_property_values.join('***')+"*:*w_property_values*:*";
				form_fields+=w_quantity+"*:*w_quantity*:*";
				form_fields+=w_quantity_value+"*:*w_quantity_value*:*";
				
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				form_fields+="*:*new_field*:*";	
				break;
		}
		
		
		case 'type_radio':
		{	
			w_randomize=document.getElementById(id+"_randomizeform_id_temp").value;
			w_allow_other=document.getElementById(id+"_allow_otherform_id_temp").value;

			if(document.getElementById(id+"_rowcol_numform_id_temp").value)	
			{
				if(document.getElementById(id+'_table_little').getAttribute('for_hor'))
					w_flow="hor"	
				else
					w_flow="ver";				
				w_rowcol = 	document.getElementById(id+"_rowcol_numform_id_temp").value;
			}
			else
			{
				if(document.getElementById(id+'_table_little').getAttribute('for_hor'))
					w_flow="hor"	
				else
					w_flow="ver";
				
				w_rowcol = 1;
			}
				
			v=0;
			tt=0;
			if(w_flow=="ver")
			{	
				var table_little = document.getElementById(id+'_table_little');
				for(k=0;k < table_little.childNodes.length; k++)
				{
					var td_little = table_little.childNodes[k];
						for(m=0; m < td_little.childNodes.length; m++)
						{
							var idi = td_little.childNodes[m].getAttribute('idi');
							if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other'))
								if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other')=='1')
									w_allow_other_num=tt;
							w_choices[tt]=document.getElementById(id+"_label_element"+idi).innerHTML;
							w_choices_checked[tt]=document.getElementById(id+"_elementform_id_temp"+idi).checked;
							w_choices_value[tt]=document.getElementById(id+"_elementform_id_temp"+idi).value;
							if(document.getElementById(id+"_label_element"+idi).getAttribute('where'))
								w_choices_params[tt]=document.getElementById(id+"_label_element"+idi).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+idi).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+idi).getAttribute('db_info');
							else
								w_choices_params[tt]='';
							tt++;
							v=idi;
						}
				}
			}
			else
			{
				var table_little = document.getElementById(id+'_table_little');
				var	tr_little = table_little.childNodes;
				var td_max = tr_little[0].childNodes;
				
				for(k=0;k < td_max.length; k++)
				{
					for(m=0; m < tr_little.length; m++)
					{
						if(tr_little[m].childNodes[k])
						{
							var td_little = tr_little[m].childNodes[k];
							var idi = td_little.getAttribute('idi');
							if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other'))
								if(document.getElementById(id+"_elementform_id_temp"+idi).getAttribute('other')=='1')
									w_allow_other_num=tt;
							w_choices[tt]=document.getElementById(id+"_label_element"+idi).innerHTML;
							w_choices_checked[tt]=document.getElementById(id+"_elementform_id_temp"+idi).checked;
							w_choices_value[tt]=document.getElementById(id+"_elementform_id_temp"+idi).value;
							if(document.getElementById(id+"_label_element"+idi).getAttribute('where'))
								w_choices_params[tt]=document.getElementById(id+"_label_element"+idi).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+idi).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+idi).getAttribute('db_info');
							else
								w_choices_params[tt]='';
							tt++;
							v=idi;
						}
					}
				}
			
			}

			if(document.getElementById(id+"_option_left_right"))
				w_field_option_pos = document.getElementById(id+"_option_left_right").value;
			else
				w_field_option_pos = 'left';
			
			w_value_disabled = document.getElementById(id+"_value_disabledform_id_temp").value;
	
			atrs=return_attributes(id+'_elementform_id_temp'+v);
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_field_option_pos+"*:*w_field_option_pos*:*";
			form_fields+=w_flow+"*:*w_flow*:*";
			form_fields+=w_choices.join('***')+"*:*w_choices*:*";
			form_fields+=w_choices_checked.join('***')+"*:*w_choices_checked*:*";
			form_fields+=w_rowcol+"*:*w_rowcol*:*";
			form_fields+=w_required+"*:*w_required*:*";
			form_fields+=w_randomize+"*:*w_randomize*:*";
			form_fields+=w_allow_other+"*:*w_allow_other*:*";
			form_fields+=w_allow_other_num+"*:*w_allow_other_num*:*";
			form_fields+=w_value_disabled+"*:*w_value_disabled*:*";
			form_fields+=w_choices_value.join('***')+"*:*w_choices_value*:*";
			form_fields+=w_choices_params.join('***')+"*:*w_choices_params*:*";
			form_fields+=w_class+"*:*w_class*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				
				form_fields+="*:*new_field*:*";	
				break;
			}
		
		case 'type_paypal_radio':
		{	
			if(document.getElementById(id+'_hor'))
				w_flow="hor"	
			else
				w_flow="ver";
	
			w_randomize=document.getElementById(id+"_randomizeform_id_temp").value;
			w_allow_other=document.getElementById(id+"_allow_otherform_id_temp").value;

			v=0;
			tt=0;
			for(k=0;k<100;k++)
			{
				if(document.getElementById(id+"_elementform_id_temp"+k))
				{
					if(document.getElementById(id+"_elementform_id_temp"+k).getAttribute('other'))
						if(document.getElementById(id+"_elementform_id_temp"+k).getAttribute('other')=='1')
							w_allow_other_num=tt;
					w_choices[tt]=document.getElementById(id+"_label_element"+k).innerHTML;
					if(w_choices[tt][w_choices[tt].length-1]==' ')
						w_choices[tt]=w_choices[tt].substring(0, w_choices[tt].length-1);
					w_choices_price[tt]=document.getElementById(id+"_elementform_id_temp"+k).value;
					w_choices_checked[tt]=(document.getElementById(id+"_elementform_id_temp"+k).getAttribute('checked')=='checked');
					if(document.getElementById(id+"_label_element"+k).getAttribute('where'))
						w_choices_params[tt]=document.getElementById(id+"_label_element"+k).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+k).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+k).getAttribute('db_info');
					else
						w_choices_params[tt]='';
					tt++;
					v=k;
				}
				
				if(document.getElementById(id+"_propertyform_id_temp"+k))
				{
					w_property.push(document.getElementById(id+"_property_label_form_id_temp"+k).innerHTML);
					
					if(document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length)
					{	
						w_property_values[w_property.length-1]='';	
						for(m=0;m < document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length;m++)
						{				
							w_property_values[w_property.length-1]+='###'+(document.getElementById(id+"_propertyform_id_temp"+k).childNodes[m].value);
						}
					}
					else
					{
						w_property_values.push('');
					}
				}
			
			}
			
			w_quantity="no";
			w_quantity_value =1;
			if(document.getElementById(id+"_element_quantityform_id_temp"))
			{
				w_quantity='yes';
				w_quantity_value=document.getElementById(id+"_element_quantityform_id_temp").value;
			}
			if(document.getElementById(id+"_option_left_right"))
				w_field_option_pos = document.getElementById(id+"_option_left_right").value;
			else
				w_field_option_pos = 'left';
			atrs=return_attributes(id+'_elementform_id_temp'+v);
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			
				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_field_option_pos+"*:*w_field_option_pos*:*";
				form_fields+=w_flow+"*:*w_flow*:*";
				form_fields+=w_choices.join('***')+"*:*w_choices*:*";
				form_fields+=w_choices_price.join('***')+"*:*w_choices_price*:*";
				form_fields+=w_choices_checked.join('***')+"*:*w_choices_checked*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_randomize+"*:*w_randomize*:*";
				form_fields+=w_allow_other+"*:*w_allow_other*:*";
				form_fields+=w_allow_other_num+"*:*w_allow_other_num*:*";
				form_fields+=w_choices_params.join('***')+"*:*w_choices_params*:*";
				form_fields+=w_class+"*:*w_class*:*";
				form_fields+=w_property.join('***')+"*:*w_property*:*";
				
				form_fields+=w_property_values.join('***')+"*:*w_property_values*:*";
				form_fields+=w_quantity+"*:*w_quantity*:*";
				form_fields+=w_quantity_value+"*:*w_quantity_value*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				form_fields+="*:*new_field*:*";	
				break;
			}
		
		case 'type_paypal_shipping':
		{	
			if(document.getElementById(id+'_hor'))
				w_flow="hor"	
			else
				w_flow="ver";
	
			w_randomize=document.getElementById(id+"_randomizeform_id_temp").value;
			w_allow_other=document.getElementById(id+"_allow_otherform_id_temp").value;

			v=0;
			tt=0;
			for(k=0;k<100;k++)
			{
				if(document.getElementById(id+"_elementform_id_temp"+k))
				{
					if(document.getElementById(id+"_elementform_id_temp"+k).getAttribute('other'))
						if(document.getElementById(id+"_elementform_id_temp"+k).getAttribute('other')=='1')
							w_allow_other_num=tt;
					w_choices[tt]=document.getElementById(id+"_label_element"+k).innerHTML;
					if(w_choices[tt][w_choices[tt].length-1]==' ')
						w_choices[tt]=w_choices[tt].substring(0, w_choices[tt].length-1);
					w_choices_price[tt]=document.getElementById(id+"_elementform_id_temp"+k).value;
					w_choices_checked[tt]=(document.getElementById(id+"_elementform_id_temp"+k).getAttribute('checked')=='checked');
					if(document.getElementById(id+"_label_element"+k).getAttribute('where'))
						w_choices_params[tt]=document.getElementById(id+"_label_element"+k).getAttribute('where')+'[where_order_by]'+document.getElementById(id+"_label_element"+k).getAttribute('order_by')+'[db_info]'+document.getElementById(id+"_label_element"+k).getAttribute('db_info');
					else
						w_choices_params[tt]='';
					tt++;
					v=k;
				}
				
				if(document.getElementById(id+"_propertyform_id_temp"+k))
				{
					w_property.push(document.getElementById(id+"_property_label_form_id_temp"+k).innerHTML);
					
					if(document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length)
					{	
						w_property_values[w_property.length-1]=new Array();	
						for(m=0;m < document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length;m++)
						{				
							w_property_values[w_property.length-1].push(document.getElementById(id+"_propertyform_id_temp"+k).childNodes[m].value);
						}
					}
					else
					{
						w_property_values.push('');
					}
				}
			
			}
			if(document.getElementById(id+"_option_left_right"))
				w_field_option_pos = document.getElementById(id+"_option_left_right").value;
			else
				w_field_option_pos = 'left';
			atrs=return_attributes(id+'_elementform_id_temp'+v);
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			
			
				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_field_option_pos+"*:*w_field_option_pos*:*";
				form_fields+=w_flow+"*:*w_flow*:*";
				form_fields+=w_choices.join('***')+"*:*w_choices*:*";
				form_fields+=w_choices_price.join('***')+"*:*w_choices_price*:*";
				form_fields+=w_choices_checked.join('***')+"*:*w_choices_checked*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_randomize+"*:*w_randomize*:*";
				form_fields+=w_allow_other+"*:*w_allow_other*:*";
				form_fields+=w_allow_other_num+"*:*w_allow_other_num*:*";
				form_fields+=w_choices_params.join('***')+"*:*w_choices_params*:*";
				form_fields+=w_class+"*:*w_class*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				form_fields+="*:*new_field*:*";	
			
			
			
			 break;
		}

		case 'type_paypal_total':
		{	
			w_size = jQuery('#'+id+"paypal_totalform_id_temp").css('width') ? jQuery('#'+id+"paypal_totalform_id_temp").css('width').substring(0,jQuery('#'+id+"paypal_totalform_id_temp").css('width').length-2) : '300';
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_class+"*:*w_class*:*";
			form_fields+=w_size+"*:*w_size*:*";
				
			form_fields+="*:*new_field*:*";		
			
			break;
		}
    
    case 'type_stripe':
		{	
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_size+"*:*w_field_size*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_class+"*:*w_class*:*";
				
			form_fields+="*:*new_field*:*";	
			break;
		}
		
		case 'type_star_rating':
		{
			w_star_amount  = document.getElementById(id+"_star_amountform_id_temp").value;
			w_field_label_col  = document.getElementById(id+"_star_colorform_id_temp").value;
			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_field_label_col+"*:*w_field_label_col*:*";
			form_fields+=w_star_amount+"*:*w_star_amount*:*";
			form_fields+=w_required+"*:*w_required*:*";
			form_fields+=w_class+"*:*w_class*:*";
			
			for(j=0; j<w_attr_name.length; j++)
			{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";	
			break;
				
		}
			
		case 'type_scale_rating':
		{
		
			w_mini_labels  =[document.getElementById(id+"_mini_label_worst").innerHTML,document.getElementById(id+"_mini_label_best").innerHTML];	
			
			w_scale_amount = document.getElementById(id+"_scale_amountform_id_temp").value;
				
			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
				
						
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_mini_labels.join('***')+"*:*w_mini_labels*:*";
			form_fields+=w_scale_amount+"*:*w_scale_amount*:*";
			form_fields+=w_required+"*:*w_required*:*";
			form_fields+=w_class+"*:*w_class*:*";
			
			for(j=0; j<w_attr_name.length; j++)
			{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";	
			break;
				
		}
		
		case 'type_spinner':
		{
		
			w_field_min_value  = document.getElementById(id+"_min_valueform_id_temp").value;
			w_field_max_value  = document.getElementById(id+"_max_valueform_id_temp").value;
			w_field_width  = document.getElementById(id+"_spinner_widthform_id_temp").value;
			w_field_step = document.getElementById(id+"_stepform_id_temp").value;
			w_field_value  = document.getElementById(id+"_elementform_id_temp").getAttribute("aria-valuenow");
				
			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
							
									
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_field_width+"*:*w_field_width*:*";
			form_fields+=w_field_min_value+"*:*w_field_min_value*:*";
			form_fields+=w_field_max_value+"*:*w_field_max_value*:*";
			form_fields+=w_field_step+"*:*w_field_step*:*";
			form_fields+=w_field_value+"*:*w_field_value*:*";
			form_fields+=w_required+"*:*w_required*:*";
			form_fields+=w_class+"*:*w_class*:*";
			
			for(j=0; j<w_attr_name.length; j++)
			{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";	
			break;
				
		}
		case 'type_slider':
		{
			
			w_field_min_value  = document.getElementById(id+"_slider_min_valueform_id_temp").value;
			w_field_max_value  = document.getElementById(id+"_slider_max_valueform_id_temp").value;
			w_field_width  = document.getElementById(id+"_slider_widthform_id_temp").value;
			w_field_value  = document.getElementById(id+"_slider_valueform_id_temp").value;
				
			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			
			
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_field_width+"*:*w_field_width*:*";
			form_fields+=w_field_min_value+"*:*w_field_min_value*:*";
			form_fields+=w_field_max_value+"*:*w_field_max_value*:*";
			form_fields+=w_field_value+"*:*w_field_value*:*";
			form_fields+=w_required+"*:*w_required*:*";
			form_fields+=w_class+"*:*w_class*:*";
			
			for(j=0; j<w_attr_name.length; j++)
			{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";	
			break;
				
		}
			
		case 'type_range':
		{
		
				w_field_range_width  = document.getElementById(id+"_range_widthform_id_temp").value;
				w_field_range_step = document.getElementById(id+"_range_stepform_id_temp").value;
				
				w_field_value1  = document.getElementById(id+"_elementform_id_temp0").getAttribute("aria-valuenow");
				w_field_value2  = document.getElementById(id+"_elementform_id_temp1").getAttribute("aria-valuenow");
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				
				w_mini_labels = [document.getElementById(id+"_mini_label_from").innerHTML,document.getElementById(id+"_mini_label_to").innerHTML]; 	 
				
													
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_field_range_width+"*:*w_field_range_width*:*";
			form_fields+=w_field_range_step+"*:*w_field_range_step*:*";
			form_fields+=w_field_value1+"*:*w_field_value1*:*";
			form_fields+=w_field_value2+"*:*w_field_value2*:*";
			form_fields+=w_mini_labels.join('***')+"*:*w_mini_labels*:*";
			form_fields+=w_required+"*:*w_required*:*";
			form_fields+=w_class+"*:*w_class*:*";
			
			for(j=0; j<w_attr_name.length; j++)
			{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";	
			break;
				
		}
		case 'type_grading':
		{
				w_total = document.getElementById(id+"_grading_totalform_id_temp").value;
				w_items=[];
				
				for(k=0;k<100;k++)
					if(document.getElementById(id+"_label_elementform_id_temp"+k))
					{
						
						w_items.push(document.getElementById(id+"_label_elementform_id_temp"+k).innerHTML);
						
					}
				
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
				
		
				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_items.join('***')+"*:*w_items*:*";
				form_fields+=w_total+"*:*w_total*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_class+"*:*w_class*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				
				form_fields+="*:*new_field*:*";	
				break;
		}
		case 'type_matrix':
		{
				w_rows=[];
				w_rows[0]="";
				
				for(k=1;k<100;k++)
					if(document.getElementById(id+"_label_elementform_id_temp"+k+"_0"))
					{
						
						w_rows.push(document.getElementById(id+"_label_elementform_id_temp"+k+"_0").innerHTML);
						
					}
			
			    w_columns=[];
				w_columns[0]="";
				for(k=1;k<100;k++)
					if(document.getElementById(id+"_label_elementform_id_temp0_"+k))
					{
						
						w_columns.push(document.getElementById(id+"_label_elementform_id_temp0_"+k).innerHTML);
						
					}
					
				w_field_input_type = document.getElementById(id+"_input_typeform_id_temp").value;		
				w_textbox_size = document.getElementById(id+"_textbox_sizeform_id_temp") ? document.getElementById(id+"_textbox_sizeform_id_temp").value : '100';	
				atrs=return_attributes(id+'_elementform_id_temp');
				w_attr_name=atrs[0];
				w_attr_value=atrs[1];
			
							
				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_field_input_type+"*:*w_field_input_type*:*";
				form_fields+=w_rows.join('***')+"*:*w_rows*:*";
				form_fields+=w_columns.join('***')+"*:*w_columns*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_class+"*:*w_class*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				form_fields+=w_textbox_size+"*:*w_textbox_size*:*";
				form_fields+="*:*new_field*:*";	
				break;
		}
		case 'type_time':
		{	
			atrs=return_attributes(id+'_hhform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			w_hh=document.getElementById(id+'_hhform_id_temp').value;
			w_mm=document.getElementById(id+'_mmform_id_temp').value;
			if(document.getElementById(id+'_ssform_id_temp'))
			{
				w_ss=document.getElementById(id+'_ssform_id_temp').value;
				w_sec="1";
				w_sec_label=document.getElementById(id+'_mini_label_ss').innerHTML;
			}
			else
			{
				w_ss="";
				w_sec="0";
				w_sec_label='SS';
			}
			if(document.getElementById(id+'_am_pm_select'))
			{
				w_am_pm=document.getElementById(id+'_am_pmform_id_temp').value;
				w_time_type="12";
				w_mini_labels = [document.getElementById(id+'_mini_label_hh').innerHTML, document.getElementById(id+'_mini_label_mm').innerHTML, w_sec_label, document.getElementById(id+'_mini_label_am_pm').innerHTML];
			}
			else
			{
				w_am_pm=0;
				w_time_type="24";
				w_mini_labels = [document.getElementById(id+'_mini_label_hh').innerHTML, document.getElementById(id+'_mini_label_mm').innerHTML, w_sec_label, 'AM/PM'];
				
			}
				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_time_type+"*:*w_time_type*:*";
				form_fields+=w_am_pm+"*:*w_am_pm*:*";
				form_fields+=w_sec+"*:*w_sec*:*";
				form_fields+=w_hh+"*:*w_hh*:*";
				form_fields+=w_mm+"*:*w_mm*:*";
				form_fields+=w_ss+"*:*w_ss*:*";
				form_fields+=w_mini_labels.join('***')+"*:*w_mini_labels*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_class+"*:*w_class*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				form_fields+="*:*new_field*:*";	



			 break;
		}
		case 'type_date':
		{	
			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			w_date=document.getElementById(id+'_elementform_id_temp').value;
			w_format=document.getElementById(id+'_buttonform_id_temp').getAttribute("format");
			w_but_val=document.getElementById(id+'_buttonform_id_temp').value;
			w_disable_past_days = document.getElementById(id+'_dis_past_daysform_id_temp') ? document.getElementById(id+'_dis_past_daysform_id_temp').value : 'no';
			
				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_date+"*:*w_date*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_class+"*:*w_class*:*";
				form_fields+=w_format+"*:*w_format*:*";
				form_fields+=w_but_val+"*:*w_but_val*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				form_fields+=w_disable_past_days+"*:*w_disable_past_days*:*";
				form_fields+="*:*new_field*:*";	
			 break;
		}
		case 'type_date_fields':
		{	
			atrs			=return_attributes(id+'_dayform_id_temp');
			w_attr_name		=atrs[0];
			w_attr_value	=atrs[1];
			w_day			=document.getElementById(id+'_dayform_id_temp').value;
			w_month			=document.getElementById(id+'_monthform_id_temp').value;
			w_year			=document.getElementById(id+'_yearform_id_temp').value;
			w_day_type		=document.getElementById(id+'_dayform_id_temp').tagName;
			w_month_type	=document.getElementById(id+'_monthform_id_temp').tagName;
			w_year_type		=document.getElementById(id+'_yearform_id_temp').tagName;
			w_day_label		=document.getElementById(id+'_day_label').innerHTML;
			w_month_label	=document.getElementById(id+'_month_label').innerHTML;
			w_year_label	=document.getElementById(id+'_year_label').innerHTML;
			
			s				=document.getElementById(id+'_dayform_id_temp').style.width;
			w_day_size		=s.substring(0,s.length-2);
			
			s				=document.getElementById(id+'_monthform_id_temp').style.width;
			w_month_size	=s.substring(0,s.length-2);
			
			s				=document.getElementById(id+'_yearform_id_temp').style.width;
			w_year_size		=s.substring(0,s.length-2);

      w_from			=document.getElementById(id+'_yearform_id_temp').getAttribute('from');
      w_to			=document.getElementById(id+'_yearform_id_temp').getAttribute('to');
			
			w_divider		=document.getElementById(id+'_separator1').innerHTML;

				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_day+"*:*w_day*:*";
				form_fields+=w_month+"*:*w_month*:*";
				form_fields+=w_year+"*:*w_year*:*";
				form_fields+=w_day_type+"*:*w_day_type*:*";
				form_fields+=w_month_type+"*:*w_month_type*:*";
				form_fields+=w_year_type+"*:*w_year_type*:*";
				form_fields+=w_day_label+"*:*w_day_label*:*";
				form_fields+=w_month_label+"*:*w_month_label*:*";
				form_fields+=w_year_label+"*:*w_year_label*:*";
				form_fields+=w_day_size+"*:*w_day_size*:*";
				form_fields+=w_month_size+"*:*w_month_size*:*";
				form_fields+=w_year_size+"*:*w_year_size*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_class+"*:*w_class*:*";
				form_fields+=w_from+"*:*w_from*:*";
				form_fields+=w_to+"*:*w_to*:*";
				form_fields+=w_divider+"*:*w_divider*:*";

				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				form_fields+="*:*new_field*:*";	
				break;


		}
		case 'type_own_select':
		{	
			tt=0;
			jQuery('#'+id+'_elementform_id_temp option').each(function() {
				w_choices[tt]=jQuery(this).html();
				w_choices_value[tt]=jQuery(this).val();
				w_choices_checked[tt]=jQuery(this)[0].selected;
				if(jQuery(this).attr('where'))
					w_choices_params[tt]=jQuery(this).attr('where')+'[where_order_by]'+jQuery(this).attr('order_by')+'[db_info]'+jQuery(this).attr('db_info');
				else
					w_choices_params[tt]='';
					
				if(jQuery(this).val())
					w_choices_disabled[tt]=false;	
				else
					w_choices_disabled[tt]=true;
					
				tt++;		
			});

			w_value_disabled = document.getElementById(id+'_value_disabledform_id_temp').value;
			
			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];


				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_size+"*:*w_size*:*";
				form_fields+=w_choices.join('***')+"*:*w_choices*:*";
				form_fields+=w_choices_checked.join('***')+"*:*w_choices_checked*:*";
				form_fields+=w_choices_disabled.join('***')+"*:*w_choices_disabled*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_value_disabled+"*:*w_value_disabled*:*";
				form_fields+=w_choices_value.join('***')+"*:*w_choices_value*:*";
				form_fields+=w_choices_params.join('***')+"*:*w_choices_params*:*";
				form_fields+=w_class+"*:*w_class*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				form_fields+="*:*new_field*:*";	
				break;


		}
		
		case 'type_paypal_select':
		{	
			tt=0;
			jQuery('#'+id+'_elementform_id_temp option').each(function() {
				w_choices[tt]=jQuery(this).html();
				w_choices_price[tt]=jQuery(this).val();
				w_choices_checked[tt]=jQuery(this)[0].selected;
				if(jQuery(this).attr('where'))
					w_choices_params[tt]=jQuery(this).attr('where')+'[where_order_by]'+jQuery(this).attr('order_by')+'[db_info]'+jQuery(this).attr('db_info');
				else
					w_choices_params[tt]='';
					
				if(jQuery(this)[0].value=="")
					w_choices_disabled[tt]=true;
				else
					w_choices_disabled[tt]=false;
					
				tt++;		
			});
	
			for(k=0;k<100;k++)
			{	
				if(document.getElementById(id+"_propertyform_id_temp"+k))
				{
					w_property.push(document.getElementById(id+"_property_label_form_id_temp"+k).innerHTML);
					
					if(document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length)
					{	
						w_property_values[w_property.length-1]='';	
						for(m=0;m < document.getElementById(id+"_propertyform_id_temp"+k).childNodes.length;m++)
						{				
							w_property_values[w_property.length-1]+='###'+(document.getElementById(id+"_propertyform_id_temp"+k).childNodes[m].value);
						}
					}
					else
					{
						w_property_values.push('');
					}
				}
				
			}
			
			w_quantity="no";
			w_quantity_value=1;
			if(document.getElementById(id+"_element_quantityform_id_temp"))
			{
				w_quantity='yes';
				w_quantity_value=document.getElementById(id+"_element_quantityform_id_temp").value;
			}

			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];

				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_size+"*:*w_size*:*";
				form_fields+=w_choices.join('***')+"*:*w_choices*:*";
				form_fields+=w_choices_price.join('***')+"*:*w_choices_price*:*";
				form_fields+=w_choices_checked.join('***')+"*:*w_choices_checked*:*";
				form_fields+=w_choices_disabled.join('***')+"*:*w_choices_disabled*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_quantity+"*:*w_quantity*:*";
				form_fields+=w_quantity_value+"*:*w_quantity_value*:*";	
				form_fields+=w_choices_params.join('***')+"*:*w_choices_params*:*";
				form_fields+=w_class+"*:*w_class*:*";
				form_fields+=w_property.join('***')+"*:*w_property*:*";
				
				form_fields+=w_property_values.join('***')+"*:*w_property_values*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				form_fields+="*:*new_field*:*";	
				break;



		}
		
		case 'type_country':
		{	
			w_countries=[];

			select_=document.getElementById(id+'_elementform_id_temp');
			k=select_.childNodes.length;
			for(j=0; j<k; j++)
			{
				w_countries.push(select_.childNodes[j].value);
			}

			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];

				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_size+"*:*w_size*:*";
				form_fields+=w_countries.join('***')+"*:*w_countries*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_class+"*:*w_class*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				form_fields+="*:*new_field*:*";	
				break;


		}
		case 'type_file_upload':
		{
			w_destination=document.getElementById(id+"_destination").value.replace("***destinationverj"+id+"***", "").replace("***destinationskizb"+id+"***", "");
			w_extension  =document.getElementById(id+"_extension").value.replace("***extensionverj"+id+"***", "").replace("***extensionskizb"+id+"***", "");
			w_max_size   =document.getElementById(id+"_max_size").value.replace("***max_sizeverj"+id+"***", "").replace("***max_sizeskizb"+id+"***", "");
			w_multiple   =(document.getElementById(id+"_elementform_id_temp").getAttribute('multiple') ? 'yes' : 'no');
			
			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];


				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_destination+"*:*w_destination*:*";
				form_fields+=w_extension+"*:*w_extension*:*";
				form_fields+=w_max_size+"*:*w_max_size*:*";
				form_fields+=w_required+"*:*w_required*:*";
				form_fields+=w_multiple+"*:*w_multiple*:*";
				form_fields+=w_class+"*:*w_class*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				form_fields+="*:*new_field*:*";	
				break;
		}
		case 'type_captcha':
		{
			w_digit=document.getElementById("_wd_captchaform_id_temp").getAttribute("digit");
			atrs=return_attributes('_wd_captchaform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			
			
				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
				form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
				form_fields+=w_digit+"*:*w_digit*:*";
				form_fields+=w_class+"*:*w_class*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				form_fields+="*:*new_field*:*";	
				break;

		}
		case 'type_arithmetic_captcha':
		{
			w_count = document.getElementById("_wd_arithmetic_captchaform_id_temp").getAttribute("operations_count");
			w_operations = document.getElementById("_wd_arithmetic_captchaform_id_temp").getAttribute("operations");
			w_input_size = document.getElementById("_wd_arithmetic_captchaform_id_temp").getAttribute("input_size");
			atrs=return_attributes('_wd_captchaform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_count+"*:*w_count*:*";
			form_fields+=w_operations+"*:*w_operations*:*";
			form_fields+=w_class+"*:*w_class*:*";
			form_fields+=w_input_size+"*:*w_input_size*:*";
			
			for(j=0; j<w_attr_name.length; j++)
			{
			form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";	
			break;

		}
		case 'type_recaptcha':
		{
			w_public  = document.getElementById("wd_recaptchaform_id_temp").getAttribute("public_key");
			w_private  = document.getElementById("wd_recaptchaform_id_temp").getAttribute("private_key");
			w_theme  = document.getElementById("wd_recaptchaform_id_temp").getAttribute("theme");
			
			atrs=return_attributes('wd_recaptchaform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_public+"*:*w_public*:*";
			form_fields+=w_private+"*:*w_private*:*";
			form_fields+=w_theme+"*:*w_theme*:*";
			form_fields+=w_class+"*:*w_class*:*";
			
			for(j=0; j<w_attr_name.length; j++)
			{
			form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";	
			document.getElementById("public_key").value = document.getElementById("wd_recaptchaform_id_temp").getAttribute("public_key");
			document.getElementById("private_key").value= document.getElementById("wd_recaptchaform_id_temp").getAttribute("private_key");

			break;

		}
		case 'type_map':
		{
			w_lat=[];
			w_long=[];
			w_info=[];
			
			w_center_x  = document.getElementById(id+"_elementform_id_temp").getAttribute("center_x");
			w_center_y  = document.getElementById(id+"_elementform_id_temp").getAttribute("center_y");
			w_zoom  = document.getElementById(id+"_elementform_id_temp").getAttribute("zoom");
			w_width = parseInt(document.getElementById(id+"_elementform_id_temp").style.width);
			w_height= parseInt(document.getElementById(id+"_elementform_id_temp").style.height);
			
			
			
			for(j=0; j<=20; j++)
				if( document.getElementById(id+"_elementform_id_temp").getAttribute("lat"+j))
				{
					w_lat.push(document.getElementById(id+"_elementform_id_temp").getAttribute("lat"+j));
					w_long.push(document.getElementById(id+"_elementform_id_temp").getAttribute("long"+j));
					w_info.push(document.getElementById(id+"_elementform_id_temp").getAttribute("info"+j));
				}

			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];


				form_fields+=w_field_label+"*:*w_field_label*:*";
				form_fields+=w_center_x+"*:*w_center_x*:*";
				form_fields+=w_center_y+"*:*w_center_y*:*";
				form_fields+=w_long.join('***')+"*:*w_long*:*";
				form_fields+=w_lat.join('***')+"*:*w_lat*:*";
				form_fields+=w_zoom+"*:*w_zoom*:*";
				form_fields+=w_width+"*:*w_width*:*";
				form_fields+=w_height+"*:*w_height*:*";
				form_fields+=w_info.join('***')+"*:*w_info*:*";
				form_fields+=w_class+"*:*w_class*:*";
				
				for(j=0; j<w_attr_name.length; j++)
				{
				form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
				}
				form_fields+="*:*new_field*:*";	
				break;


		}
		case 'type_mark_map':
		{
			w_info  = document.getElementById(id+"_elementform_id_temp").getAttribute("info0");
			w_long  = document.getElementById(id+"_elementform_id_temp").getAttribute("long0");
			w_lat   = document.getElementById(id+"_elementform_id_temp").getAttribute("lat0");
			w_zoom  = document.getElementById(id+"_elementform_id_temp").getAttribute("zoom");
			w_width = parseInt(document.getElementById(id+"_elementform_id_temp").style.width);
			w_height= parseInt(document.getElementById(id+"_elementform_id_temp").style.height);
			w_center_x  = document.getElementById(id+"_elementform_id_temp").getAttribute("center_x");
			w_center_y  = document.getElementById(id+"_elementform_id_temp").getAttribute("center_y");
			
			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];

			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_field_label_size+"*:*w_field_label_size*:*";
			form_fields+=w_field_label_pos+"*:*w_field_label_pos*:*";
			form_fields+=w_center_x+"*:*w_center_x*:*";
			form_fields+=w_center_y+"*:*w_center_y*:*";
			form_fields+=w_long+"*:*w_long*:*";
			form_fields+=w_lat+"*:*w_lat*:*";
			form_fields+=w_zoom+"*:*w_zoom*:*";
			form_fields+=w_width+"*:*w_width*:*";
			form_fields+=w_height+"*:*w_height*:*";
			form_fields+=w_info+"*:*w_info*:*";
			form_fields+=w_class+"*:*w_class*:*";
			
			for(j=0; j<w_attr_name.length; j++)
			{
			form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";	
			break;
		}
		case 'type_submit_reset':
		{
			atrs=return_attributes(id+'_element_submitform_id_temp');
			w_act=!(document.getElementById(id+"_element_resetform_id_temp").style.display=="none");
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			w_submit_title = document.getElementById(id+"_element_submitform_id_temp").value;
			w_reset_title  = document.getElementById(id+"_element_resetform_id_temp").value;
			
			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_submit_title+"*:*w_submit_title*:*";
			form_fields+=w_reset_title+"*:*w_reset_title*:*";
			form_fields+=w_class+"*:*w_class*:*";
			form_fields+=w_act+"*:*w_act*:*";
			
			for(j=0; j<w_attr_name.length; j++)
			{
			form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";	
			break;
		}

		case 'type_button':
		{
			w_title	=new Array();	
		
			w_func	=new Array();
			tt=0;
			v=0;
			for(k=0;k<100;k++)
				if(document.getElementById(id+"_elementform_id_temp"+k))
				{
					w_title[tt]=document.getElementById(id+"_elementform_id_temp"+k).value;
					w_func[tt]=document.getElementById(id+"_elementform_id_temp"+k).getAttribute("onclick");
					tt++;
					v=k;
				}
			atrs=return_attributes(id+'_elementform_id_temp'+v);
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];

			form_fields+=w_field_label+"*:*w_field_label*:*";
			form_fields+=w_title.join('***')+"*:*w_title*:*";
			form_fields+=w_func.join('***')+"*:*w_func*:*";
			form_fields+=w_class+"*:*w_class*:*";
			
			for(j=0; j<w_attr_name.length; j++)
			{
			form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";	
			break;
		}
		case 'type_hidden':
		{
			w_value  = document.getElementById(id+"_elementform_id_temp").value;
			w_name  = document.getElementById(id+"_elementform_id_temp").name;
			
			atrs=return_attributes(id+'_elementform_id_temp');
			w_attr_name=atrs[0];
			w_attr_value=atrs[1];
			
			form_fields+=w_name+"*:*w_field_label*:*";
			form_fields+=w_name+"*:*w_name*:*";
			form_fields+=w_value+"*:*w_value*:*";
			
			for(j=0; j<w_attr_name.length; j++)
			{
			form_fields+=w_attr_name[j]+"="+w_attr_value[j]+"*:*w_attr_name*:*";
			}
			form_fields+="*:*new_field*:*";	
			break;
		}
	}
}