function CountrySearch(frm,srch) {

openWin();

var cntry = frm.srchval.value;

fnd = new Array(); total=0;

for (i = 0; i<item.length; i++){

if (cntry.toUpperCase() == item[i][srch].toUpperCase()){

fnd[i] = "true";}

else {fnd[i] ="false";}}

sendFnd(fnd)}



function validateZIP(frm) {

var valid = "0123456789-";

var hyphencount = 0;

var ZIP = frm.srchval.value;

if (ZIP.length!=5) {

alert("Please enter your 5 digit zip code.");

return false;}

for (var i=0; i < ZIP.length; i++) {

temp = "" + ZIP.substring(i, i+1);

if (valid.indexOf(temp) == "-1") {

alert("Invalid characters in your zip code.  Please try again.");

return false;}}

search(ZIP);}



function openWin(){

page=	"<html><head><title>J P S  L A B S -- Dealer Search Results     </title><link rel=stylesheet href=JS/DFcss.css type=text/css></head>";

page+="<body><table class=DTable border=0 width=100%><tr><td><table class=DBody bgcolor=#e6e6fa width=100%>";

win = window.open("","DF","width=900,height=500,scrollbars");

win.document.write(page);

win.focus();

}



function sendFnd(fnd) {

var total=0;

if (fnd.length){

win.document.write("<div class=Header>For experienced advice please contact...</div>");

for (c = 0; c < fnd.length; c++) {

	if (fnd[c] == "true") {

		show(c,win);

		total++}}}

if (total == 0){

	win.document.write("<tr><td>Sorry, there were no Dealers serving your Area.</td></tr>");

	win.document.write("<tr><td>Please <a href=http://www.jpslabs.com/contactus.shtml target=_blank  >click here</a>");

	win.document.write(" to contact us for your closest dealer.</td></tr>");}

//Write out the footer

win.document.write("<tr><td class=Footer>Thank you for Choosing <b>JPS LABS!</b></td></tr>");

win.document.write("</table></tr></td></table><div align =center class=footer><br>Total found: "+total+"<br>");

win.document.write("<a href = 'javascript:window.close()'>Close Window</a></div></body></html>");

win.document.close();

}





function search(ZIP) {

openWin();

fnd = new Array(); total=0;

for (i = 0; i < item.length; i++)  {

for (m = 9; m < item[i].length; m++){

var the_Zips=item[i][m].split("-");

var hi = parseInt(the_Zips[1]);

var lo = parseInt(the_Zips[0]);

if (ZIP <= hi) { 

if (ZIP >= lo) {fnd[i] = "true";}}

else { fnd[i] ="false";}}}

sendFnd(fnd)}





function show(which,wind,total) {

link = item[which][1]; 

line = "<tr><td><img src =_logo/"+item[which][8]+"></td></tr><tr><td>"+item[which][2]+"<br>";

line += item[which][3]+", "+item[which][4]+"<br>";

line += "TEL (" + item[which][5] +") " + item[which][6] + "<br>";

line += "Email <a href='mailto:"+item[which][7] + "'>"+item[which][7] +"</a><br>";

line += "Web <a href='"+link+"' target =_blank>"+link+"</a><br><hr></td></tr>";

wind.document.write(line);

return 1;

}



function ClassNew(obj, new_style) {

  obj.className=new_style;

}


