
  var SlideoutActive = 0;
  var SlideoutNew = null;
  var SlideoutShown = null;
  var Carpics = new Array("a","b","c","d","e");
  var List1 = new Array();
  var List2 = new Array();
  var List3 = new Array();
  var List4 = new Array();
  var Flag_search = false;
  var sflag = 0;
  var xflag = 0;
  var rollflag = 0;
  var browser;
  var expireAt = new Date;
  var pass1 = 0;
  var pass2 = "empty"; 
  var pass3 = 0;
  var pass4="empty";
  var pass_list;
  var domainname ="bhauto.bluedomino.com";
  var at = "@";
  var username = "sales";
  var Picdiv = new Array("pic1","pic2","pic3","pic4","pic5","pic6");
  var Menu = new Array("button2","button7");
  var Menu1 = new Array("button2a","button7a");
  var Menu2 = new Array("row1a","row1b","row1c","row1d","row1e");
  var Menu3 = new Array("row1a1","row1b1","row1c1","row1d1","row1e1");
  var year = new Array();
  var make = new Array();
  var model = new Array();
  var price = new Array();
  var miles = new Array();
  var type = new Array();
  var taken = new Array();
  var edit = new Array();
  var upload = new Array();
  var entered = new Array();
  var sold = new Array();
  var stock = new Array();
  var yr = new Array();
  var vin = new Array();
  var pkg = new Array();
  var opthold = new Array("First","Second");
  var ccMenu = new Array("Look for First","Year","Make","Model","Price","Miles","Type");
  var c2Menu = new Array("Then Look for","Year","Make","Model","Price","Miles","Type");
  var ccOpt = new Array(0,1,2,3,4,5,6);
  var c2Opt = new Array(0,1,2,3,4,5,6);
  var cc1enu = new Array("Category Options");
  var cc2enu = new Array("Category Options");
  var maxlength = ccMenu.length;
  var truelength = ccMenu.length;
  var lst = cc1enu.length;
  var lst1 = cc2enu.length;
  var day = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
  var mnth = new Array("January","February","March","April","May","June","July","August","September","October","November","December");   
  function drop1() {
    drop1off();
    document.getElementById("subbar1").style.visibility="visible";
  }
  
  function drop1off() {
    if(document.getElementById("subbar1").style.visibility == "visible") document.getElementById("subbar1").style.visibility = "hidden";
	if(document.getElementById("search1").style.visibility == "visible") document.getElementById("search1").style.visibility = "hidden";
  }
  
  function init() {
    SlideoutActive = 0;
	SlideoutShown = "picbig1";
	document.getElementById(SlideoutShown).style.left = 0;
    SlideoutNew = "none";
	
  }
  
  function slideout(which) {
    if(!SlideoutActive && SlideoutShown != which) {
	  SlideoutActive = 1;
	  SlideoutNew = which;
	  document.getElementById(which).style.left = -600;
	  slideoutLeft();
    }
  }
  
  function slideoutLeft() {
    if(parseInt(document.getElementById(SlideoutShown).style.left) > -600) {
	   document.getElementById(SlideoutShown).style.left = parseInt(document.getElementById(SlideoutShown).style.left) - 15 + "px";
	   setTimeout("slideoutLeft()",30);
	}
	else {
	   hide(SlideoutShown);
	   show(SlideoutNew);
	   setTimeout("slideoutRight()",30);
	}
  }
  
  function slideoutRight() {
    if(parseInt(document.getElementById(SlideoutNew).style.left) < 0) {
	   document.getElementById(SlideoutNew).style.left = parseInt(document.getElementById(SlideoutNew).style.left) + 15 + "px";
	   setTimeout("slideoutRight()",30);
	}
	else {
	   SlideoutShown = SlideoutNew;
	   SlideoutActive = 0;
	}
  }
  
  function show(showobj) {
    document.getElementById(showobj).style.visibility = "visible";
  }
  
  function hide(hideobj) {
    document.getElementById(hideobj).style.visibility = "hidden";
  }

  function SearchWrite(){
  with (document) {
     writeln("<form name='lookfor' method='POST' action='http://blackhillsautosales.com/search.php?'>");
     writeln("<table border='0' cellspacing='2' cellpadding='2' align='center' border='0'><tr>");
	 writeln("<td align='center'><font size='4'><b>SEARCH</b></font></td></tr><tr>");
	 writeln("<td valign='center' align='center'><select name='look1st' id='look1st' onChange='Change1st(this.form)'>");
	 tox = ccMenu.length;
	 for(i=0;i<tox;i++) {
	    writeln("<option value="+ccOpt[i]+">"+ccMenu[i]+"</option>");
	 }
	 writeln("</select></td></tr>");
	 lookfor.look1st.options[0].selected = true;
	 writeln("<tr><td valign='center' align='center'><select name='opt1st' id='opt1st'>");
	 for(i=0;i<cc1enu.length;i++) {
	    writeln("<option value="+cc1enu[i]+">"+cc1enu[i]+"</option>");
	 }
	 writeln("</select></td></tr>");
	 writeln("<tr><td align='center'><hr align='center' width='70%' size='3'></td></tr>");
	 writeln("<tr><td valign='center' align='center'><select name='look2nd' onChange='Change2nd(this.form)'>")
	 for(i=0;i<c2Menu.length;i++) {
	    writeln("<option value="+c2Opt[i]+">"+c2Menu[i]+"</option>");
	 }
	 lookfor.look2nd.options[0].selected = true;
	 writeln("</select></td></tr><tr><td valign='center' align='center'><select name='opt2nd'>");
	 for(i=0;i<cc2enu.length;i++) {
	    writeln("<option value="+i+">"+cc2enu[i]+"</option>");
	 }
	 lookfor.opt2nd.options[0].selected = true;
	 writeln("</select></td></tr>");
	 writeln("<tr><td align='center'><hr align='center' width='70%' size='2'></td></tr>");
	 writeln("<tr><td align='center'><font color='#000000'><font size='3'><b> Or Search For</b></font>&nbsp;&nbsp;<br><input type='text' name='bigsearch' size='15'></td></tr><tr><td align='center' valign='bottom'><input type='submit' value='GO'>&nbsp;&nbsp;<input type='reset'></td>");
	 writeln("</tr></table></form><br>")
  }
}	 

function Change1st() {
 tot = cc1enu.length;
 cc1enu.length = 0;
 xemp = new Array;
 menuNum = document.lookfor.look1st.selectedIndex;
 if(menuNum == null) return;
 if(menuNum == 1) {
   cc1enu = new Array;
   cctemp = new Array
   cctemp.length = 0;
   cctemp[0] = year[0];
   j=0;
   for(i=1;i<year.length;i++) {
      tflag=0;
      for(k=0;k<=j;k++) {
	    if(cctemp[k] == year[i])tflag = 1;
	  }
	  if(tflag == 0) {
	    j = j +1;
		cctemp[j] = year[i];
	  }
   }
   for(i=0;i<cctemp.length;i++) {
       for(j=i;j<cctemp.length;j++) {
	      if(cctemp[i] > cctemp[j]) {
		    temp = cctemp[i];
			cctemp[i] = cctemp[j];
			cctemp[j] = temp;
		  }
	   }
   } 
   for(i=0;i<cctemp.length;i++) cc1enu[i] = new Option(cctemp[i]);
 }
 if(menuNum == 2) {
   cc1enu = new Array;
   cctemp = new Array;
   cctemp.length = 0;
   cctemp[0] = make[0];
   j=0;
   for(i=1;i<make.length;i++) {
      tflag=0;
      for(k=0;k<=j;k++) {
	    if(cctemp[k] == make[i])tflag = 1;
	  }
	  if(tflag == 0) {
	    j = j +1;
		cctemp[j] = make[i];
	  }
   }
   for(i=0;i<cctemp.length;i++) {
       for(j=i;j<cctemp.length;j++) {
	      if(cctemp[i] > cctemp[j]) {
		    temp = cctemp[i];
			cctemp[i] = cctemp[j];
			cctemp[j] = temp;
		  }
	   }
   }
   for(i=0;i<cctemp.length;i++) cc1enu[i] = new Option(cctemp[i]);
 }
 if(menuNum == 3) {
   cc1enu = new Array;
   cctemp = new Array;
   cctemp.length = 0;
   cctemp[0] = model[0];
   j=0;
   for(i=1;i<model.length;i++) {
      tflag=0;
      for(k=0;k<=j;k++) {
	    if(cctemp[k] == model[i])tflag = 1;
	  }
	  if(tflag == 0) {
	    j = j +1;
		cctemp[j] = model[i];
	  }
   }
   for(i=0;i<cctemp.length;i++) {
       for(j=i;j<cctemp.length;j++) {
	      if(cctemp[i] > cctemp[j]) {
		    temp = cctemp[i];
			cctemp[i] = cctemp[j];
			cctemp[j] = temp;
		  }
	   }
   }
   for(i=0;i<cctemp.length;i++) cc1enu[i] = new Option(cctemp[i]);
 }
 if(menuNum == 4) {
   cc1enu = new Array;
   cc1enu[0] = new Option("Under $5000");
   cc1enu[1] = new Option("$5,000 to $7,000");
   cc1enu[2] = new Option("$7,000 to $10,000");
   cc1enu[3] = new Option("$10,000 to $15,000");
   cc1enu[4] = new Option("$15,000 to $20,000");
   cc1enu[5] = new Option("Over $20,000");
 }
 if(menuNum == 5) {
   cc1enu = new Array;
   cc1enu[0] = new Option("Under 25,000 Miles");
   cc1enu[1] = new Option("25,000 to 50,000");
   cc1enu[2] = new Option("50,000 to 75,000");
   cc1enu[3] = new Option("75,000 to 100,000");
   cc1enu[4] = new Option("100,000 to 150,000");
   cc1enu[5] = new Option("Over 150,000 Miles");
 }
 if(menuNum == 6) {
   cc1enu = new Array;
   cctemp = new Array;
   cctemp.length = 0;
   xtemp = new Array;
   cctemp[0] = type[0];
   j=0;
   for(i=1;i<type.length;i++) {
      tflag=0;
      for(k=0;k<=j;k++) {
	    if(cctemp[k] == type[i])tflag = 1;
	  }
	  if(tflag == 0) {
	    j = j +1;
		cctemp[j] = type[i];
	  }
   }
   for(i=0;i<cctemp.length;i++) {
       for(j=i;j<cctemp.length;j++) {
	      if(cctemp[i] > cctemp[j]) {
		    temp = cctemp[i];
			cctemp[i] = cctemp[j];
			cctemp[j] = temp;
		  }
	   }
   }
   xtemp[0] = "Vehicle Type";
   xtemp[1] = "Sedan";
   xtemp[2] = "Coupe";
   xtemp[3] = "Regular Cab Pickup";
   xtemp[4] = "Regular Cab Longobox Pickup";
   xtemp[5] = "SUV";
   xtemp[6] = "MiniVan";
   xtemp[7] = "15 Pass Van";
   xtemp[8] = "Cargo Van";
   xtemp[9] = "Convertable";
   xtemp[10] = "Conversion Van";
   xtemp[11] = "Ext.Cab Pickup";
   xtemp[12] = "Crewcab Pickup";
   xtemp[13] = "Ext Cab Longbox Pickup";
   xtemp[14] = "Crewcab Longbox Pickup";
   xtemp[15] = "Green Car / Hybrid";
   xtemp[16] = "Crossover";
		
   for(i=0;i<cctemp.length;i++) {
      cc1enu[i] = new Option(xtemp[cctemp[i]]);
   }
   
   
 }
 tot = cc1enu.length;
 for(i=lst;i>0;i--) {
   document.lookfor.opt1st.options[i] = null;
 }
 for(i=0;i<tot;i++) {
   document.lookfor.opt1st.options[i] = cc1enu[i];
 }
 document.lookfor.opt1st.options[0].selected = true;
 lst = cc1enu.length;
 
}  

function Change2nd() {
 if(document.lookfor.look1st.selectedIndex == document.lookfor.look2nd.selectedIndex) {
   alert("You have chosen the same Search Category. Please Choose a different Category");
   document.lookfor.look2nd.options[0].selected = true;
   return;
 }
 tot1 = cc2enu.length;
 cc2enu = new Array;
 cctemp = new Array;
 ccxemp = new Array;
 xtemp = new Array;
 cc2enu.length = 0;
 cctemp.length = 0;
 ccxemp.length = 0;
 yemp = new Array;
 yemp[0] = "Vehicle Type";
 yemp[1] = "Sedan";
 yemp[2] = "Coupe";
 yemp[3] = "Regular Cab Pickup";
 yemp[4] = "Regular Cab Longbox Pickup";
 yemp[5] = "SUV";
 yemp[6] = "MiniVan";
 yemp[7] = "15 Pass Van";
 yemp[8] = "Cargo Van";
 yemp[9] = "Convertable";
 yemp[10] = "Conversion Van";
 yemp[11] = "Ext.Cab Pickup";
 yemp[12] = "Crewcab Pickup";
 yemp[13] = "Ext Cab Longbox Pickup";
 yemp[14] = "Crewcab Longbox Pickup";
 yemp[15] = "Green Car / Hybrid";
 yemp[16] = "Crossover";
 menuDum = document.lookfor.look2nd.selectedIndex;
 menu1st = document.lookfor.look1st.selectedIndex;
 optfor = document.lookfor.opt1st.selectedIndex; 
 if(menuDum == null) return;
 if(menu1st == 1) {
   cctemp = new Array
   cctemp.length = 0;
   cctemp[0] = year[0];
   j=0;
   for(i=1;i<year.length;i++) {
      tflag=0;
      for(k=0;k<=j;k++) {
	    if(cctemp[k] == year[i])tflag = 1;
	  }
	  if(tflag == 0) {
	    j = j +1;
		cctemp[j] = year[i];
	  }
   }
   for(i=0;i<cctemp.length;i++) {
       for(j=i;j<cctemp.length;j++) {
	      if(cctemp[i] > cctemp[j]) {
		    temp = cctemp[i];
			cctemp[i] = cctemp[j];
			cctemp[j] = temp;
		  }
	   }
   }
   optlook = cctemp[optfor];
 }
 if(menu1st == 2) {
   cctemp = new Array;
   cctemp.length = 0;
   cctemp[0] = make[0];
   j=0;
   for(i=1;i<make.length;i++) {
      tflag=0;
      for(k=0;k<=j;k++) {
	    if(cctemp[k] == make[i])tflag = 1;
	  }
	  if(tflag == 0) {
	    j = j +1;
		cctemp[j] = make[i];
	  }
   }
   for(i=0;i<cctemp.length;i++) {
       for(j=i;j<cctemp.length;j++) {
	      if(cctemp[i] > cctemp[j]) {
		    temp = cctemp[i];
			cctemp[i] = cctemp[j];
			cctemp[j] = temp;
		  }
	   }
   }
   optlook = cctemp[optfor];
 }
 if(menu1st == 3) {
   cctemp = new Array;
   cctemp.length = 0;
   cctemp[0] = model[0];
   j=0;
   for(i=1;i<model.length;i++) {
      tflag=0;
      for(k=0;k<=j;k++) {
	    if(cctemp[k] == model[i])tflag = 1;
	  }
	  if(tflag == 0) {
	    j = j +1;
		cctemp[j] = model[i];
	  }
   }
   for(i=0;i<cctemp.length;i++) {
       for(j=i;j<cctemp.length;j++) {
	      if(cctemp[i] > cctemp[j]) {
		    temp = cctemp[i];
			cctemp[i] = cctemp[j];
			cctemp[j] = temp;
		  }
	   }
   }
   optlook = cctemp[optfor];
 }
 if(menu1st == 6) {
	   cctemp = new Array;
   cctemp.length = 0;
   xtemp = new Array;
   cctemp[0] = type[0];
   j=0;
   for(i=1;i<type.length;i++) {
      tflag=0;
      for(k=0;k<=j;k++) {
	    if(cctemp[k] == type[i])tflag = 1;
	  }
	  if(tflag == 0) {
	    j = j +1;
		cctemp[j] = type[i];
	  }
   }
   for(i=0;i<cctemp.length;i++) {
       for(j=i;j<cctemp.length;j++) {
	      if(cctemp[i] > cctemp[j]) {
		    temp = cctemp[i];
			cctemp[i] = cctemp[j];
			cctemp[j] = temp;
		  }
	   }
   }
   optlook = yemp[cctemp[optfor]];
 }
 cctemp = new Array;
 cctemp.length = 0;
 if(menuDum == 1) {
   if(menu1st == 2) {
     j=0;
     for(i=0;i<make.length;i++) {
	    if(optlook == make[i]) {
		  ccxemp[j] = year[i];
		  j++;
		}
	 }
   }
   if(menu1st == 3) {
     j=0;
	 for(i=0;i<model.length;i++) {
	    if(optlook == model[i]) {
		  ccxemp[j] = year[i];
		  j++;
		}
	 }
   }
   if(menu1st == 6) {
     for(i=0;i<yemp.length;i++) {
	    if(optlook == yemp[i]) type_flag=i;
	 }
     j=0;
	 for(i=0;i<type.length;i++) {
	    if(type_flag == type[i]) {
		  ccxemp[j] = year[i];
		  j++;
		}
	 }
   }
   if(menu1st == 4 || menu1st == 5) {
      for(i=0;i<year.length;i++) {
	     ccxemp[i] = year[i];
	  } 	
   }
   cctemp[0] = ccxemp[0];
   j=0;
   for(i=1;i<ccxemp.length;i++) {
      tflag=0;
      for(k=0;k<=j;k++) {
	    if(cctemp[k] == ccxemp[i])tflag = 1;
	  }
	  if(tflag == 0) {
	    j = j +1;
		cctemp[j] = ccxemp[i];
	  }
   }
   for(i=0;i<cctemp.length;i++) {
       for(j=i;j<cctemp.length;j++) {
	      if(cctemp[i] > cctemp[j]) {
		    temp = cctemp[i];
			cctemp[i] = cctemp[j];
			cctemp[j] = temp;
		  }
	   }
   }
   for(i=0;i<cctemp.length;i++) cc2enu[i] = new Option(cctemp[i]);
 }
 if(menuDum == 2) {
   cc2enu = new Array;
   if(menu1st == 1) {
     j=0;
	 for(i=0;i<year.length;i++) {
	    if(optlook == year[i]){
		  ccxemp[j] = make[i];
		  j++;
		}
	 }
	 
   }
   if(menu1st == 3) {
     j=0;
     for(i=0;i<model.length;i++) {
	    if(optlook == model[i]) {
		  ccxemp[j] = make[i];
		  j++;
		}
	 }
   }
   if(menu1st == 6) {
     j=0;
	 for(i=0;i<yemp.length;i++) {
	    if(optlook == yemp[i]) type_flag=i;
	 }
	 for(i=0;i<type.length;i++) {
	    if(type_flag == type[i]){
		   ccxemp[j] = make[i];
		   j++;
		}
	 }
   }
   if(menu1st == 4 || menu1st == 5) {
     for(i=0;i<make.length;i++) {
	   ccxemp[i] = make[i];
	 }
   }
   cctemp[0] = ccxemp[0];
   j=0;
   for(i=1;i<ccxemp.length;i++) {
      tflag=0;
      for(k=0;k<=j;k++) {
	    if(cctemp[k] == ccxemp[i])tflag = 1;
	  }
	  if(tflag == 0) {
	    j = j +1;
		cctemp[j] = ccxemp[i];
	  }
   }
   for(i=0;i<cctemp.length;i++) {
       for(j=i;j<cctemp.length;j++) {
	      if(cctemp[i] > cctemp[j]) {
		    temp = cctemp[i];
			cctemp[i] = cctemp[j];
			cctemp[j] = temp;
		  }
	   }
   }
   for(i=0;i<cctemp.length;i++) cc2enu[i] = new Option(cctemp[i]);	    
 }
 if(menuDum == 3) {
   cc2enu = new Array;
   cc2enu.length = 0;
   cctemp= new Array;
   cctemp.length = 0;
   ccxemp = new Array;
   ccxemp.length=0;
   if(menu1st == 1) {
     j=0;
     for(i=0;i<year.length;i++) {
	    if(optlook == year[i]) {
		   ccxemp[j] = model[j];
		   j++;
		}
	 }
   }
   if(menu1st == 2) {
     j=0;
     for(i=0;i<make.length;i++) {
	    if(optlook == make[i]) {
		   ccxemp[j] = model[i];
		   j++;
		}
     }
   }	 
   if(menu1st == 6) {
     for(i=0;i<yemp.length;i++) {
	    if(optlook == yemp[i]) type_flag=i;
	 }
     j=0;
	 for(i=0;i<type.length;i++) {
	    if(type_flag == type[i]) {
		  ccxemp[j] = model[i];
		  j++;
	    }
	 }
   }
   if(menu1st == 4 || menu1st == 5) {
     for(i=0;i<model.length;i++) {
	    ccxemp[i] = model[i];
	 }
   }
   cctemp[0] = ccxemp[0];
   j=0;
   for(i=1;i<ccxemp.length;i++) {
      tflag=0;
      for(k=0;k<=j;k++) {
	    if(cctemp[k] == ccxemp[i])tflag = 1;
	  }
	  if(tflag == 0) {
	    j = j +1;
		cctemp[j] = ccxemp[i];
	  }
   }
   for(i=0;i<cctemp.length;i++) {
       for(j=i;j<cctemp.length;j++) {
	      if(cctemp[i] > cctemp[j]) {
		    temp = cctemp[i];
			cctemp[i] = cctemp[j];
			cctemp[j] = temp;
		  }
	   }
   }
   for(i=0;i<cctemp.length;i++) cc2enu[i] = new Option(cctemp[i]);		
 }
 if(menuDum == 4) {
   cc2enu = new Array;
   cc2enu[0] = new Option("Under $5000");
   cc2enu[1] = new Option("$5,000 to $7,000");
   cc2enu[2] = new Option("$7,000 to $10,000");
   cc2enu[3] = new Option("$10,000 to $15,000");
   cc2enu[4] = new Option("$15,000 to $20,000");
   cc2enu[5] = new Option("Over $20,000");
 }
 if(menuDum == 5) {
   cc2enu = new Array;
   cc2enu[0] = new Option("Under 25,000 Miles");
   cc2enu[1] = new Option("25,000 to 50,000");
   cc2enu[2] = new Option("50,000 to 75,000");
   cc2enu[3] = new Option("75,000 to 100,000");
   cc2enu[4] = new Option("100,000 to 150,000");
   cc2enu[5] = new Option("Over 150,000 Miles");
 }
 if(menuDum == 6) {
   cc2enu = new Array;
   if(menu1st == 1) {
     j=0;
	 for(i=0;i<year.length;i++) {
        if(optlook == year[i]) {
	      ccxemp[j] = type[i];
	      j++;
	    }
     }
   }
   if(menu1st == 2) {
     j=0;
	 for(i=0;i<make.length;i++) {
	    if(optlook == make[i]) {
		  ccxemp[j] = type[i];
		  j++;
		}
	 }
   }
   if(menu1st == 3) {
     j=0;
	 for(i=0;i<model.length;i++) {
	    if(optlook == model[i]) {
		  ccxemp[j] = type[i];
		  j++;
		}
	 }
   }
   cctemp[0] = ccxemp[0];
   j=0;
   for(i=1;i<ccxemp.length;i++) {
      tflag=0;
      for(k=0;k<=j;k++) {
	    if(cctemp[k] == ccxemp[i])tflag = 1;
	  }
	  if(tflag == 0) {
	    j = j +1;
		cctemp[j] = ccxemp[i];
	  }
   }
   for(i=0;i<cctemp.length;i++) {
       for(j=i;j<cctemp.length;j++) {
	      if(cctemp[i] > cctemp[j]) {
		    temp = cctemp[i];
			cctemp[i] = cctemp[j];
			cctemp[j] = temp;
		  }
	   }
   }
   xtemp[0] = "Vehicle Type";
   xtemp[1] = "Sedan";
   xtemp[2] = "Coupe";
   xtemp[3] = "Regular Cab Pickup";
   xtemp[4] = "Regular Cab Longbox Pickup";
   xtemp[5] = "SUV";
   xtemp[6] = "MiniVan";
   xtemp[7] = "15 Pass Van";
   xtemp[8] = "Cargo Van";
   xtemp[9] = "Convertable";
   xtemp[10] = "Conversion Van";
   xtemp[11] = "Ext.Cab Pickup";
   xtemp[12] = "Crewcab Pickup";
   xtemp[13] = "Ext Cab Longbox Pickup";
   xtemp[14] = "Crewcab Longbox Pickup";
   xtemp[15] = "Green Car / Hybrid";
   xtemp[16] = "Crossover";
   for(i=0;i<cctemp.length;i++) {
      cc2enu[i] = new Option(xtemp[cctemp[i]]);
   }
 }
 tot = cc2enu.length;
 for(i=lst1;i>0;i--) {
   document.lookfor.opt2nd.options[i] = null;
 }
 for(i=0;i<tot;i++) {
   document.lookfor.opt2nd.options[i] = cc2enu[i];
 }
 document.lookfor.opt2nd.options[0].selected = true;
 lst1 = cc2enu.length;
 
}

function TellTime() {
  var pagetest = location.href;
  var indextest = pagetest.indexOf("index.php");
  var maintest = pagetest.indexOf("main.php");
  if(indextest < 0 && maintest < 0) return;
  var today = new Date();
  var yr1 = today.getYear();
  if(yr1 < 2000) yr1 = yr1 +1900;
  var date_disp = day[today.getDay()]+" "+ mnth[today.getMonth()]+" "+today.getDate()+" "+yr1;
  var hor = today.getHours();
  var ampm ="AM"
  var Greet;
  if(hor < 1) hor = 12;
  if(hor >= 2 && hor <= 5) Greet ="Early Morning Welcome";
  if(hor >= 6 && hor < 12) Greet = "Good Morning";
  if(hor >= 12 && hor < 17) Greet = "Good Afternoon";
  if(hor >= 17) Greet = "Good Evening";
  if(hor > 12) {
    hor = hor - 12;
	ampm ="PM";
  }
  var mn = today.getMinutes();
  if(mn >= 0 && mn <=9) mn = "0" + mn;
  var time_disp = hor+":"+mn+" "+ampm;
  document.write("<table width='90%' align='center' border='0' cellpadding='2' cellspacing='2'>");
  document.write("<tr><td align='center' class='welc'>"+time_disp+"</td>");
  document.write("<td align='center' class='welc'>"+date_disp+"</td>");
  document.write("<td align='center' class='welc'>"+Greet+"</td>");
  document.write("</tr></table>");
  
}

function ChangeBottom() {
  document.writeln('<h4>Black Hills Auto Sales<br>(605) 716-7878<br>1600 E Hwy 44<br>Rapid City SD 57703</h4>');

} 

function FigPay() {
  var p = 0;
  var r = 0;
  var t = 0;
  var m = 0;
  var w = 0;
  var t1 = 0;
  var d = 0;
  p = Math.round(document.paycalc.price.value);
  r = document.paycalc.rate.value/100;
  t = document.paycalc.lop.selectedIndex;
  m = document.paycalc.lop.options[t].value;
  t1 = Math.round(document.paycalc.trade.value);
  d = Math.round(document.paycalc.down.value);
  var h;
  var h1;
  var temp;
  var py = 0;
  var pymt;
  p = (p + w)*1;
  p = (p - t1)*1;
  p = (p - d)*1;
  py = (p*(r/12)/(1-Math.pow(1+r/12,-m)))
  py = py * 100;
  temp = Math.round(py);
  py = temp / 100;
  pymt = new String(py);
  h = pymt.indexOf(".");
  if(h<0){
    pymt = pymt+".00";
  }
  else {
    if(h+1 == pymt.length){
	   pymt = pymt+"0";
	}   
  }	   	   
  document.paycalc.payment.value = pymt;
} 

function WarUp() {
 var w = document.paycalc.exwar.selectedIndex;
 document.paycalc.warprice.value = document.paycalc.exwar.options[w].value
}

function reset() {
  document.getElementById("name").value="";
  document.getElementById("email").value="";
  document.getElementById("friendmail1").value="";
}

function validate() {
  if(document.tellafriend.friendmail1.value.length == 0) {
     alert("Please enter your friend's email address");
	 return false;
  }
  if(document.tellafriend.email.value.length == 0) {
     alert("Please enter your email address");
	 return false;
  }
  if(document.tellafriend.name.value.length == 0) {
     alert("Please enter your name");
	 return false;
  }
  
  document.tellafriend.submit();
  return true;
  
}

function LoanPay() {
  var p = 0;
  var r = 0;
  var t = 0;
  var m = 0;
  var w = 0;
  var t1 = 0;
  var d = 0;
  var py = document.loancalc.monpay.value;
  alert("py is: "+py);
  r = 0.08;
  m = document.loancalc.lop.value;
  alert("m is: "+m);
  t1 = Math.round(document.loancalc.trade.value);
  d = Math.round(document.loancalc.down.value);
  var h;
  var h1;
  var temp;
  var pymt;
  p = py/((r/12)/(1-Math.pow(1+r/12,-m)))
  alert("P is: "+p);
  p = p * 100;
  temp = Math.round(p);
  p = temp / 100;
  p = p +((t1*1)+(d*1));
  pymt = new String(p);
  h = pymt.indexOf(".");
  if(h<0){
    pymt = pymt+".00";
  }
  else {
    if(h+1 == pymt.length){
	   pymt = pymt+"0";
	}   
  }	   	   
  document.loancalc.loan.value = pymt;
}

function vincheck() {
   for(i=0;i<vin.length;i++) {
      if(document.dataenter.vin.value == vin[i]) {
	     alert("The VIN that you entered has already been entered into the Database");
		 document.dataenter.vin.value = "";
		 return;
	  }
   }
}

function stokcheck() {
   for(i=0;i<stock.length;i++) {
      if(document.dataenter.stocknum.value == stock[i]) {
         alert("The Stock Number Entered has already been used. Please enter new Stock Number");
	     document.dataenter.stocknum.value ="";
	     return;
	  }
   }
}

