var csprod;
function winopen(csprod){
  if (csprod==2)  {
var cswindow=open("","cswin","width=300,height=230,status=no,toolbar=no,menubar=no,scrollbars=yes")

   cswindow.document.write("<html><head><title>quote</title>\n")
   cswindow.document.write("<style type=text/css>\n")
   cswindow.document.write("td {font-family:verdana;font-size:12px;background-color:#C9DBED}\n")
   cswindow.document.write("th {font-family:verdana;font-size:12px;background-color:#336699;color:#ffffff}\n")
   cswindow.document.write("</style>\n")
   cswindow.document.write("</head>")   
   cswindow.document.write("<body bgcolor=#689acc >\n")  
   cswindow.document.write("<form method=post action='asp/add.asp' name=frmprod onsubmit='return(window.opener.inputvalidation(this))' \n>")
   cswindow.document.write("<table border=0 cellspacing=1 bgcolor=#ffffff>\n")   
   cswindow.document.write("<tr ><th colspan=2>Frame and Flat Heaters</th></tr>\n")
   cswindow.document.write("<tr><td>Heater Type</td><td><select name=elmselect><option>Mica</option><option>Ceramic</option><option>Mineral Insulated</option></td></tr>\n")
   cswindow.document.write("<tr><td>Length (mm)</td><td><input type=text name=elmtxt size=4 maxlength=10></td></tr>\n")
   cswindow.document.write("<tr><td>Width (mm)</td><td><input type=text name=elmtxt size=4 maxlength=10></td></tr>\n")
   
   cswindow.document.write("<tr><td>Wattage (W)</td><td><input type=text name=elmtxt size=4 maxlength=10></td></tr>\n")
   cswindow.document.write("<tr><td>Voltage (V)</td><td><input type=text name=elmtxt size=4 maxlength=10></td></tr>\n")
   cswindow.document.write("<tr><td>Maximum Temperature (<sup>.</sup>C)</td><td><input type=text name=elmtxt size=4 maxlength=10></td></tr>\n")   
   
   cswindow.document.write("<tr><td>Quantity Required</td><td><input type=text name=elmtxt size=4 maxlength=10></td></tr>\n")
   cswindow.document.write("<tr ><td colspan=2>* Send drawing where special type of holes or cutout required</td></tr>")
   cswindow.document.write("<tr><td>Additional Info</td><td><textarea name=elmtxtarea cols=10 rows=3 onKeyDown='window.opener.textCounter(this.form.elmtxtarea,125);'></textarea></td></tr>\n")
   cswindow.document.write("<input type=hidden name=prodid value=" + csprod + ">\n" )
   cswindow.document.write("<tr><td><input align=center type=submit value=Submit name=elmsubmit ></td><td align=right><input type=reset name=elmreset ></td></tr>\n")
   cswindow.document.write("</table>\n")
  
   cswindow.document.write("</form>\n")   
   cswindow.document.write("</body></html>\n")
       }
    }




function inputvalidation(csobj){
  
   

decallowed = 2;  // how many decimals are allowed?
  for(i=0;i<=csobj.elmtxt.length-1;i++){

           

if (i==0 || i==1 || i==3 || i==5){
			if (isNaN(csobj.elmtxt[i].value) || csobj.elmtxt[i].value == "") {
					alert("Please enter a valid number.");
						csobj.elmtxt[i].focus();
							return false;
												}  //end if
			
						if (i !=5){
if (csobj.elmtxt[i].value.indexOf('.') == -1) csobj.elmtxt[i].value += ".0";
dectext = csobj.elmtxt[i].value.substring(csobj.elmtxt[i].value.indexOf('.')+1, csobj.elmtxt[i].value.length);

if (dectext.length > decallowed )
{
alert ("Please enter a number with up to 2 decimal places.");
csobj.elmtxt[i].focus();
return false;
      }
		}//end if i not 6	
									
									} //end if
   
   
   if (i==2 || i==4 ){
          if (csobj.elmtxt[i].value != ""){
			if (isNaN(csobj.elmtxt[i].value)) {
					alert("Please enter a valid number.");
						csobj.elmtxt[i].focus();
							return false;
												}  //end if
			
						
if (csobj.elmtxt[i].value.indexOf('.') == -1) csobj.elmtxt[i].value += ".0";
dectext = csobj.elmtxt[i].value.substring(csobj.elmtxt[i].value.indexOf('.')+1, csobj.elmtxt[i].value.length);

if (dectext.length > decallowed ){
alert ("Please enter a number with up to 2 decimal places.");
csobj.elmtxt[i].focus();
return false;
      }
		
   }
   }   
   
   
   




}

textCounter(csobj.elmtxtarea, 125)
}
 

function textCounter(field, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
}
