function createpreview() {
	
	pollradiobuttons_class_div = "div_pollradiobuttons";
	pollradiobuttons_class = "pollradiobuttons";
	
	document.getElementById("pollquestion").innerHTML = document.CreatePoll_Form["poll_question"].value;
	
	answers_disp = "";
	
	if (document.getElementById("poll_multiplechoice[]").value == "No")
		strInputType = '<input type="radio" class="' + pollradiobuttons_class + '" name="grouppreview" id="grouppreview">';
	
	if (document.getElementById("poll_multiplechoice[]").value == "Yes")
		strInputType = '<input type="checkbox" class="' + pollradiobuttons_class + '" >';
	
	answerscounter = 0;
	
	for (i=1; i<=document.CreatePoll_Form["answers_disp"].value; i++) {
		if (document.getElementById("poll_answers_" + i))
				if (trim(document.CreatePoll_Form["poll_answers_" + i].value) != "") {
					answers_disp += "<div class=\"divpollanswerlines\"><div class=" + pollradiobuttons_class_div + " id='pollradiobuttons_class_div_" + i + "'>" + strInputType + "</div> <div class='div_pollvote'>" + document.CreatePoll_Form["poll_answers_" + i].value + "</div></div>";
					answerscounter ++;
				}
	}
	
	document.getElementById("pollanswers").innerHTML = answers_disp;
	
	if (trim(document.CreatePoll_Form["poll_question"].value) == "" && answerscounter == 0)
		document.getElementById("container_poll").innerHTML = divContents;
		
	if (answerscounter == 0) {
		for (i=1; i<=4; i++) {
			if (document.getElementById("pollradiobuttons_class_div_" + i))
				document.getElementById("pollradiobuttons_class_div_" + i).innerHTML = strInputType;
		}
	}
	
	if (document.getElementById("poll_bordersize[]").options[0].text == '0px')
	{
		document.getElementById("poll_bordersize[]").options[0].text = 'No Border';
	}
	
	document.getElementById("container_poll").style.fontFamily = document.getElementById("poll_fontstyle[]").value;
	document.getElementById("container_poll").style.fontSize = document.getElementById("poll_fontsize[]").value;
	document.getElementById("container_poll").style.borderWidth = document.getElementById("poll_bordersize[]").value;

	document.getElementById("poll_btnvote").style.borderWidth = document.getElementById("poll_buttonstyle_bordersize[]").value;
	document.getElementById("poll_btnvote").style.fontFamily = document.getElementById("poll_buttonstyle_fontstyle[]").value;
	
	document.getElementById("poll_btnresults").style.borderWidth = document.getElementById("poll_buttonstyle_bordersize[]").value;
	document.getElementById("poll_btnresults").style.fontFamily = document.getElementById("poll_buttonstyle_fontstyle[]").value;

	if (document.getElementById("poll_answerdisplaytype[]").value == "Vertically")
		changecss('.divpollanswerlines','display','block');
	else
		changecss('.divpollanswerlines','display','inline');
	
	changecolor();	

}

function applyCorners() {
	
	if (document.getElementById("poll_typeofcorners[]").value == 'Round')
	{
			strRoundBegin = '<div style="width:100%;">' + 
				'<b class="pmb1_b" id="pmb1_b_t">' +
				'<b class="pmb1_1" id="pmb1_1_t" style="color: inherit;"></b>' +
				'<b class="pmb1_2" id="pmb1_2_t" style="color: inherit;"></b>' +
				'<b class="pmb1_3" id="pmb1_3_t" style="color: inherit;"></b>' +
				'<b class="pmb1_4" id="pmb1_4_t" style="color: inherit;"></b>' +
				'</b>' +
				'<div class="pmb1_c" id="pmb1_c_t" style="color: inherit;">' +
				'<b class="pmb1_s" id="pmb1_s_t"></b>';

			strRoundEnd = 	'<b class="pmb1_s" id="pmb1_s_b"></b>' +
 							'</div>' +
 							'<b class="pmb1_b" id="pmb1_b_b">' +
  							'<b class="pmb1_4" id="pmb1_4_b" style="color: inherit;"></b>' +
  							'<b class="pmb1_3" id="pmb1_3_b" style="color: inherit;"></b>' +
  							'<b class="pmb1_2" id="pmb1_2_b" style="color: inherit;"></b>' +
  							'<b class="pmb1_1" id="pmb1_1_b" style="color: inherit;"></b>' +
 							'</b>' +
							'</div>';

			document.getElementById("previewcontainer").innerHTML = strRoundBegin + strPreviewContainer + strRoundEnd;
	}
	
	if (document.getElementById("poll_typeofcorners[]").value == 'Rectangle Shadow')
	{
			strRoundBegin = '<div style="width: 100%; background: #333333">' +
 							'<div id="pmb3_1_div" class="pmb3_1" style="color: inherit;">' +
  							'<div class="pmb3_2">' +
   							'<b class="pmb3_s"></b>';

			strRoundEnd = '<b class="pmb3_s"></b>' +
  						  '</div>' +
 						  '</div>' +
						  '</div>';

			document.getElementById("previewcontainer").innerHTML = strRoundBegin + strPreviewContainer + strRoundEnd;
	}
	
	if (document.getElementById("poll_typeofcorners[]").value == 'Rectangle')
	{
			document.getElementById("previewcontainer").innerHTML = strPreviewContainer;
	}
	
}

function changecolor() {
	
	if (document.getElementById("poll_typeofcorners[]").value == 'Round')
	{
		document.getElementById("container_poll").style.borderWidth = '0px';
		
		document.getElementById("container_poll").style.color = document.CreatePoll_Form["poll_fontcolor"].value;
		document.getElementById("container_poll").style.borderColor = document.CreatePoll_Form["poll_backgroundcolor"].value;
		document.getElementById("container_poll").style.backgroundColor = document.CreatePoll_Form["poll_backgroundcolor"].value;
		
		if (document.CreatePoll_Form["poll_bordersize[]"].value == '0px')
		{
			pollborder = document.CreatePoll_Form["poll_backgroundcolor"].value;
		} else {
			pollborder = document.CreatePoll_Form["poll_bordercolor"].value;
		}
		
		document.getElementById("pmb1_1_t").style.backgroundColor = pollborder;
		document.getElementById("pmb1_1_b").style.backgroundColor = pollborder;
		
		document.getElementById("pmb1_2_t").style.backgroundColor = document.CreatePoll_Form["poll_backgroundcolor"].value;
		document.getElementById("pmb1_2_b").style.backgroundColor = document.CreatePoll_Form["poll_backgroundcolor"].value;
		document.getElementById("pmb1_2_t").style.borderColor = pollborder;
		document.getElementById("pmb1_2_b").style.borderColor = pollborder;
		
		document.getElementById("pmb1_3_t").style.backgroundColor = document.CreatePoll_Form["poll_backgroundcolor"].value;
		document.getElementById("pmb1_3_b").style.backgroundColor = document.CreatePoll_Form["poll_backgroundcolor"].value;
		document.getElementById("pmb1_3_t").style.borderColor = pollborder;
		document.getElementById("pmb1_3_b").style.borderColor = pollborder;
		
		document.getElementById("pmb1_4_t").style.backgroundColor = document.CreatePoll_Form["poll_backgroundcolor"].value;
		document.getElementById("pmb1_4_b").style.backgroundColor = document.CreatePoll_Form["poll_backgroundcolor"].value;
		document.getElementById("pmb1_4_t").style.borderColor = pollborder;
		document.getElementById("pmb1_4_b").style.borderColor = pollborder;
		
		document.getElementById("pmb1_c_t").style.backgroundColor = document.CreatePoll_Form["poll_backgroundcolor"].value;
		document.getElementById("pmb1_c_t").style.borderColor = pollborder;
	}
	
	if (document.getElementById("poll_typeofcorners[]").value == 'Rectangle Shadow')
	{
		document.getElementById("container_poll").style.borderWidth = '0px';
		
		document.getElementById("container_poll").style.color = document.CreatePoll_Form["poll_fontcolor"].value;
		document.getElementById("container_poll").style.borderColor = document.CreatePoll_Form["poll_backgroundcolor"].value;
		document.getElementById("container_poll").style.backgroundColor = document.CreatePoll_Form["poll_backgroundcolor"].value;
		
		changecss('.pmb3_1','background',document.CreatePoll_Form["poll_backgroundcolor"].value);		
		
		document.getElementById("pmb3_1_div").style.backgroundColor = document.CreatePoll_Form["poll_backgroundcolor"].value;
		document.getElementById("pmb3_1_div").style.borderWidth = document.CreatePoll_Form["poll_bordersize[]"].value;
		document.getElementById("pmb3_1_div").style.borderColor = document.CreatePoll_Form["poll_bordercolor"].value;

	}
	
	if (document.getElementById("poll_typeofcorners[]").value == 'Rectangle')
	{
		document.getElementById("container_poll").style.color = document.CreatePoll_Form["poll_fontcolor"].value;
		document.getElementById("container_poll").style.borderColor = document.CreatePoll_Form["poll_bordercolor"].value;
		document.getElementById("container_poll").style.backgroundColor = document.CreatePoll_Form["poll_backgroundcolor"].value;
	}
	
	document.getElementById("poll_btnvote").style.borderColor = document.CreatePoll_Form["poll_buttonstyle_bordercolor"].value;
	document.getElementById("poll_btnvote").style.backgroundColor = document.CreatePoll_Form["poll_buttonstyle_backgroundcolor"].value;
	document.getElementById("poll_btnvote").style.color = document.CreatePoll_Form["poll_buttonstyle_fontcolor"].value;

	document.getElementById("poll_btnresults").style.borderColor = document.CreatePoll_Form["poll_buttonstyle_bordercolor"].value;
	document.getElementById("poll_btnresults").style.backgroundColor = document.CreatePoll_Form["poll_buttonstyle_backgroundcolor"].value;
	document.getElementById("poll_btnresults").style.color = document.CreatePoll_Form["poll_buttonstyle_fontcolor"].value;

}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function changecss(theClass,element,value) {
	//documentation for this script at http://www.shawnolson.net/a/503/
	 var cssRules;
	 if (document.all) {
	  cssRules = 'rules';
	 }
	 else if (document.getElementById) {
	  cssRules = 'cssRules';
	 }
	 for (var S = 0; S < document.styleSheets.length; S++){
	  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
	   if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
	    document.styleSheets[S][cssRules][R].style[element] = value;
	   }
	  }
	 }	
	}

