
var nh=0;
var html_code="";
var msg="";
function step1(){



nh = document.the_form1.qty.options[document.the_form1.qty.selectedIndex].value;
if(document.dothecode.codearea.value != ""){document.dothecode.codearea.value="";}
msg="";


if(nh > 0){
msg += '<form action="#" method="POST" name="the_form">\n';
msg += '<table border=0>\n';
msg += '<tr>\n';
msg += '<td align="right" class="tablecontent">Initial Text : <input type=Text name=starttext Value="-- Select and Go --"></td>\n';
msg += '<td align="right" class="tablecontent">Target Frame : <input type=Text name=target></td>\n';
msg += '</tr>\n';

msg += '<tr>\n';
msg += '<td align="right" class="tablecontent">Menu Name : <input type=Text name=menuname Value="menu"></td>\n';
msg += '<td class="tablecontent">*choose a 1 word name (no spaces)</td>\n';
msg += '</tr>\n';


}
	//nh=nh-0;
document.getElementById("counter").innerHTML = "";
	for (var i=1; i <= nh;i++){
		
msg += "<tr><td class='tablecontent' align='right'>URL "+i+" : <input type=Text name=thelink"+i+" value='http://'></td>\n";

msg += "<td class='tablecontent' align='right'>Link Text "+i+" : <input type=Text name=thetext"+i+" value=''></td>\n";




	}
if(nh > 0){
msg += '<TR>\n';
msg += '<TD class=tablecontent align=middle colSpan=2>Tick Box if you want a GO button <INPUT class=radio type=checkbox  value=go name=whichtype>\n';
msg += '</TD></TR>\n';
msg += '<TR>\n';
msg += '<TD class=tablecontent align=middle colSpan=2><INPUT class=submit type=button  onclick="buildit();" value="Make the Code" name=generate></TD></TR></TBODY></TABLE>\n';


msg+="</form>";


}	
document.getElementById("counter").innerHTML += msg;
}

function buildit(){
var remspaces = "NO";
var themenuname=document.the_form.menuname.value;

var re= / /gi;


if (themenuname.match(re)){remspaces = "YES";}
themenuname = themenuname.replace(re,'_');

if(remspaces == "YES"){
alert("Replacing Spaces with _\n\nOld Name : "+document.the_form.menuname.value+"\n\nNew Name : "+themenuname);
}


document.the_form.menuname.value=themenuname;


html_code="";
html_code+="<form name=\""+themenuname+"\">\n";
the_text = document.the_form.starttext.value;
if(the_text == ""){the_text="--------";}

the_target = document.the_form.target.value;
if(the_target == ""){the_target="_self";}



if(document.the_form.whichtype.checked==true){
html_code +='<select name="list" size=1>\n';
}
else
{
html_code+="<select name='list' size=1  onChange=\"if (document."+themenuname+".list.selectedIndex != 0) window.open(url = document."+themenuname+".list.options[document."+themenuname+".list.selectedIndex].value,'"+the_target+"'); else alert('Please choose from menu.')\">\n";
}


html_code +='<option selected value="">'+the_text+'</option>\n';
for (var i=1; i <= nh;i++){
whatlink = eval("document.the_form.thelink"+i+".value;");
whattext = eval("document.the_form.thetext"+i+".value;");
html_code += "<option value=\""+whatlink+"\">"+whattext+"</option>\n";
}


if(document.the_form.whichtype.checked==true){
html_code += "</select>\n";
html_code +="<input type=\"button\" value=\"OK\" onClick=\"if (document."+themenuname+".list.selectedIndex != 0) window.open(url = document."+themenuname+".list.options[document."+themenuname+".list.selectedIndex].value,'"+the_target+"'); else alert('Please choose from menu.')\">\n";
html_code +="</form>\n";
}
else
{
html_code += "</select>\n";
html_code += "</form>\n";
}




var finaltext="<!-- start click  code -->\n"+html_code+"\n<!-- http://www.webdevtips.com/webdevtips/codegen/clickgo.shtml -->\n<!-- end click code -->\n";
document.dothecode.codearea.value=finaltext;
return false;
}
function preview() {
if(document.dothecode.codearea.value==""){alert("Sorry, there is nothing to preview.\n\nPlease make sure you fill in all the fields then click on the Make the Code button\n\nThank You");return false;}

	msg=open("","","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=400,height=200");
msg.document.write('<html><head><title>test page</title><style type=text/css>body,TD{font : 8pt verdana, sans-serif;}</style></head><body bgcolor=white><b>This is how your menu will appear in a browser.</b><hr><table bgcolor="#fffff5" border="1" width="95%" align="center"><tr><td align="center" valign="middle">'+html_code+'</td></tr></table><hr>');
msg.document.write('</body></html>');
	return false;}
