var City;var State;var ZipCode;var CityZipColumnModel;var CityZipListingGrid;var pag_ZipSearch;var pag_ConSearch;Ext.onReady(function(){var H;var K;var I;var O;var M=1;Ext.QuickTips.init();var J=Ext.get("btnSearch");pag_ConSearch=new Ext.data.Store({id:"pag_ConSearch",proxy:new Ext.data.HttpProxy({url:"GSIDataFetch.aspx",method:"POST"}),baseParams:{methodName:"GSI"},reader:new Ext.data.JsonReader({root:"GSIDealer",totalProperty:"total",id:"id"},[{name:"DealerId"},{name:"DealerName"},{name:"Distance"},{name:"City"},{name:"State"},{name:"address1"},{name:"address2"},{name:"phone"},{name:"fax"},{name:"email"},{name:"zip"},{name:"websiteaddress"},{name:"sitestatus"}]),remoteSort:false,autoExpandColumn:"DealerName"});function L(B){B=B.replace(/</g,"*abc*");B=B.replace(/&#/g,"*bcd*");return B}function N(B){return L(document.getElementById(B).value)}function G(B){return document.getElementById(B).checked}J.on("click",function(){if(N("ddTypeOfOperation")==0){Ext.MessageBox.show({title:"Information",msg:"Please select Type of Operation!",width:325,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.INFO})}else{if(N("ddProductCategory")==0){Ext.MessageBox.show({title:"Information",msg:"Please select Product Category!",width:325,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.INFO})}else{if(N("ddProductType")==0&&N("ddProductCategory")!=1){Ext.MessageBox.show({title:"Information",msg:"Please select Product Type!",width:325,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.INFO})}else{if(N("txt_City")==""&&N("txt_Zip")==""){Ext.MessageBox.show({title:"Information",msg:"Please enter either City or Zip/Postal Code!",width:325,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.INFO})}else{City=N("txt_City");State=N("ddState");ZipCode=N("txt_Zip");Ext.MessageBox.show({msg:"Validating City, State  & Zip/Postal Code, please wait...",progressText:"Validating...",width:400,wait:true,waitConfig:{interval:200},icon:"ext-mb-download",animEl:"btn_Search"});pag_ZipSearch=new Ext.data.Store({id:"pag_ZipSearch",proxy:new Ext.data.HttpProxy({url:"GSIDataFetch.aspx",method:"POST"}),baseParams:{methodName:"GSI_ZipSearch"},reader:new Ext.data.JsonReader({root:"GSIDealer",totalProperty:"total",id:"id"},[{name:"zip"},{name:"city"},{name:"state"}]),sortInfo:{field:"city",direction:"ASC"},remoteSort:false});var B=new Ext.grid.CheckboxSelectionModel({header:"",width:20});CityZipColumnModel=new Ext.grid.ColumnModel([B,{id:"zip",header:"Zip/Postal Code",dataIndex:"zip",sortable:true,width:150},{id:"city",header:"City",dataIndex:"city",sortable:true,width:200},{id:"state",header:"State",dataIndex:"state",sortable:true,width:50}]);CityZipColumnModel.defaultSortable=true;CityZipListingGrid=new Ext.grid.GridPanel({id:"CityZipListingGrid",title:"",store:pag_ZipSearch,cm:CityZipColumnModel,enableColLock:false,width:400,height:380,loadMask:true,autoExpandColumn:"city",viewConfig:{forceFit:true},selModel:new Ext.grid.RowSelectionModel({singleSelect:true})});pag_ZipSearch.load({params:{start:0,limit:15,p1_City:N("txt_City"),p2_State:N("ddState"),p3_Zip:N("txt_Zip")}});K=new Ext.Window({title:"Dealer Locator : City, State and Zip/Postal Code List",modal:true,height:450,width:415,items:[new Ext.Panel({items:[CityZipListingGrid]})],buttons:[{text:"OK",handler:function(){D()}}]});CityZipListingGrid.on("rowdblclick",D,CityZipListingGrid);pag_ZipSearch.on("load",P,CityZipListingGrid)}}}}});function P(){Ext.MessageBox.hide();if(CityZipListingGrid.store.getTotalCount()==1){document.getElementById("txt_Zip").value=pag_ZipSearch.data.items[0].data.zip;document.getElementById("txt_City").value=pag_ZipSearch.data.items[0].data.city;document.getElementById("ddState").value=pag_ZipSearch.data.items[0].data.state;E()}else{if(CityZipListingGrid.store.getTotalCount()==0){Ext.MessageBox.show({title:"Information",msg:"No Dealers Matched!",width:325,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.INFO})}else{K.show()}}}function E(){Ext.MessageBox.show({msg:"Searching Dealer, please wait...",progressText:"Searching...",width:300,wait:true,waitConfig:{interval:200},icon:"ext-mb-download",animEl:"btn_Search"});pag_ConSearch.load({params:{start:0,limit:15,p1_City:N("txt_City"),p2_State:N("ddState"),p3_Zip:N("txt_Zip"),p1_TypeOfOperation:N("ddTypeOfOperation"),p_ProductType:N("ddProductType"),p_ProductCategory:N("ddProductCategory")}});var F=new Ext.grid.CheckboxSelectionModel({header:"",width:20});DealerListColumnModel=new Ext.grid.ColumnModel([{id:"DealerName",header:"Dealer Information",dataIndex:"DealerName",renderer:B,sortable:true,width:500},{id:"Distance",header:"Distance(in miles)",dataIndex:"Distance",sortable:true,width:200}]);DealerListColumnModel.defaultSortable=false;DealerListingGrid=new Ext.grid.GridPanel({id:"DealerListingGrid",title:"",store:pag_ConSearch,cm:DealerListColumnModel,enableColLock:false,width:700,height:380,loadMask:true,autoExpandColumn:"DealerName",viewConfig:{forceFit:true},selModel:new Ext.grid.RowSelectionModel({singleSelect:true})});function B(S,T,Q){var R=Q.data.websiteaddress.replace("http://","");if(R!=""){R="http://"+R}if(Q.data.sitestatus=="2"){S='<a href="../dealers/'+Q.data.DealerId+"/"+S.replace(/ /g,"").replace(/\./g,"")+'.html" target="_blank">'+S+"</a>"}return String.format('<b>{0}</b></br>{1}</br>{2}, {3} - {4}</br><b>Phone:</b>{5}</br><b>Fax:</b>{6}</br><b>Email:</b>{7}</br><b>Website:</b><a href="{8}" target="_blank">{8}</a>',S,Q.data.address1,Q.data.City,Q.data.State,Q.data.zip,Q.data.phone,Q.data.fax,Q.data.email,R)}I=new Ext.Window({title:"Dealer Locator : Search Results",modal:true,height:450,width:715,items:[new Ext.Panel({items:DealerListingGrid})],buttons:[{text:"Print",handler:function(){C()}}]});Ext.MessageBox.hide();I.show()}function D(){var B=CityZipListingGrid.getSelections();if(B.length>0){document.getElementById("txt_Zip").value=B[0].get("zip");document.getElementById("txt_City").value=B[0].get("city");document.getElementById("ddState").value=B[0].get("state");K.hide();E()}else{Ext.MessageBox.show({title:"Information",msg:'Select a City, State or Zip from grid before you click on "Ok" button',width:350,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.INFO})}}function C(){var F=pag_ConSearch.data.items.length;var B;B='<html><head><title>Dealer Information List</title><style type="text/css">body{font-family:Calibri,Verdana, Tahoma,Arial;font-size:0.8px;margin:0px 0px 0px 0px;}table{border:solid 1px #000;}th{background-color:#333;color:#fff}td{background-color:#f1f1f1;}</style></head>';B+='<body onload="window.print();"><table cellpadding="3" cellspacing="0" border="0"><tr><th style="width:300px">Dealer Information</th><th style="width:200px">Distance(in miles)</th></tr>';for(i=0;i<F;i++){B+="<tr><td><b>"+pag_ConSearch.data.item(i).data.DealerName;B+="</br>"+pag_ConSearch.data.item(i).data.address1+" "+pag_ConSearch.data.item(i).data.address2;B+="</br>"+pag_ConSearch.data.item(i).data.City+","+pag_ConSearch.data.item(i).data.State+"-"+pag_ConSearch.data.item(i).data.zip;B+="</br><b>Phone:</b>"+pag_ConSearch.data.item(i).data.phone;B+="</br><b>Email:</b>"+pag_ConSearch.data.item(i).data.email;B+="</br><b>Fax:</b>"+pag_ConSearch.data.item(i).data.fax;B+="</br><b>Website:</b>"+pag_ConSearch.data.item(i).data.websiteaddress;B+="</td><td>"+pag_ConSearch.data.item(i).data.Distance+"</td></tr>"}B+="</table></body></html>";pwin=window.open();newdocument=pwin.document;newdocument.write(B)}function A(B){B.focus();B.print()}});function prodChange(A,B){cleardd("ddProductType");addItem("ddProductType","Select Product Type",0);document.getElementById("ddProductType").disabled=false;if(A==0){document.getElementById("ddProductType").disabled=true}else{if(A==1){if(B==1){document.getElementById("ddProductType").disabled=true}if(B==2){addItem("ddProductType","Farm",1);addItem("ddProductType","Farm Commercial",2);addItem("ddProductType","Bulk Feed Tanks",3);addItem("ddProductType","Parts",4)}else{if(B==3){addItem("ddProductType","Fans & Heaters",1);addItem("ddProductType","Portable Dryers",2);addItem("ddProductType","Top Dry",3);addItem("ddProductType","Parts",4)}else{if(B==4){addItem("ddProductType","Air Systems",1);addItem("ddProductType","Chain Loops",2);addItem("ddProductType","Bucket Elevators (<10,000 bph)",3);addItem("ddProductType","Conveyors (<10,000 bph)",5);addItem("ddProductType","Parts",7)}}}}else{if(A==2||A==3||A==4){if(B==1){document.getElementById("ddProductType").disabled=true}if(B==2){addItem("ddProductType","Farm",1);addItem("ddProductType","Farm Commercial",2);addItem("ddProductType","Bulk Feed Tanks",3);addItem("ddProductType","Commercial",4);addItem("ddProductType","Parts",4)}else{if(B==3){addItem("ddProductType","Fans & Heaters",1);addItem("ddProductType","Portable Dryers",2);addItem("ddProductType","Top Dry",3);addItem("ddProductType","Tower Dryer",4);addItem("ddProductType","Parts",5)}else{if(B==4){addItem("ddProductType","Air Systems",1);addItem("ddProductType","Chain Loops",2);addItem("ddProductType","Bucket Elevators (<10,000 bph)",3);addItem("ddProductType","Bucket Elevators (>10,000 bph)",4);addItem("ddProductType","Conveyors (<10,000 bph)",5);addItem("ddProductType","Conveyors (>10,000 bph)",6);addItem("ddProductType","Parts",7)}}}}}}}function addItem(C,B,E){var D;var A=document.getElementById(C);D=document.createElement("Option");D.text=B;D.value=E;A.options.add(D)}function cleardd(C){var B=document.getElementById(C);var A=B.options.length;for(i=0;i<A;i++){B.remove(0)}};