function changepage(newpage){
	i=1;
	while(document.getElementById('page'+i)){
		document.getElementById('page'+i).style.display='none';	//block or none
		i++;
	}
	document.getElementById('page'+newpage).style.display='block';
	document.vehicles.cur_page.value=newpage;
	//alert(document.vehicles.cur_page.value);

}

function padDate(thenumber){
	thenumber = thenumber + "";
	if(thenumber.length<2){
		thenumber = "0"+ thenumber;
	}
	return thenumber;
}

//get rid of the yellow background forms that google toolbar creates
  if(window.attachEvent)
    window.attachEvent("onload",setListeners);

  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "")
      event.srcElement.style.backgroundColor = "";
  }//-->




function paddate(num){
	if (num<10)
	{
		return "0"+num;
	}else{
		return num;
	}
}

function display_jat_ad(){
	document.write('<body bgcolor="#ffffff"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="125" height="125" id="jat_ad" align="middle" style="text-align:center;">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="images/flash/jat_ad.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="images/flash/jat_ad.swf" quality="high" bgcolor="#ffffff" width="125" height="125" name="jat_ad" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}

//    **********************************************
//    *       DYNAMICALLY LINKED SELECTBOXES       *
//    **********************************************

function parentChanged(childList, parentValue, selectBoxName, defaultName){
	clearCombo(childList) 
	fillCombobox(childList, parentValue, selectBoxName, defaultName)
}

function clearCombo(oList){
	for (var i = oList.options.length - 1; i >= 0; i--){
    		oList.options[i] = null;
  	}
  	oList.selectedIndex = -1;
  	if (oList.onchange) oList.onchange();
}

function fillCombobox(oList, vValue, selectBoxName, defaultName){
	if (vValue != '') {
    		if (assocArray[selectBoxName + vValue]){
      			oList.options[0] = new Option('Please Select', '');
      			var arrX = assocArray[selectBoxName+vValue];
      			for (var i = 0; i < arrX.length; i = i + 2){
        			if (arrX[i] != 'EOF') {
          			oList.options[oList.options.length] = new Option(arrX[i + 1], arrX[i]);
        			}
      			}
      			if (oList.options.length == 1){
        			oList.options[0] = new Option('None Found', '');
      			} 
			else if (oList.options.length == 2){
        			oList.selectedIndex=1;
      			}
    		} else {
      			oList.options[0] = new Option('None Found', '');
    		}
  	}
    	else 
		oList.options[0] = new Option(defaultName, '')
  	if (oList.onchange) oList.onchange();
}

function setListToValue(oList, vValue){
	if (vValue && vValue != '') {
    		for (var i = 0; i < oList.options.length; i++){
      			if (oList.options[i].value == vValue){//changed from vValue[y]**Feb15
				oList.selectedIndex = i;
				return;
      			}
    		}
  	}
  	oList.selectedIndex = -1;
}

function setMultiToValue(oList, arrValue) {
	if (arrValue != '') {
        	var y =0
		for (var j = 0; j< arrValue.length; j ++){
	   		for (var i = 0; i < oList.length; i++){
				if (oList[i].value == arrValue[j]){
					oList[i].selected=true
				}
      			}
	    	}
	  }
	else
		oList.selectedIndex = -1;
}

//highlight (select) the options that are shown as selected by the database
function parentChangedHighlight(childList, parentValue, assocArrayAtValue){
	
	if (assocArrayAtValue && parentValue !="") {

		//get rid of unnecessary bits of assocArray
		var arrValue 	=assocArrayAtValue + parentValue
		var arrTemp	=assocArray[arrValue]
		var arrX	=new Array

		for (x=0; x<arrTemp.length; x = x + 2) {
			arrX[x/2]	=arrTemp[x]
		}	
		setMultiToValue(childList, arrX)
	}
}

function yahoo_calculate(lang, min_bid){
	//get rid of any non numbers
	maxBid=removeCommas(document.yah_bid.bid_amount.value);
	maxBid = parseInt(maxBid);
	if(maxBid<0 || isNaN(maxBid)){
		maxBid=0;
	}


	var tax=Math.ceil(maxBid*0.05);
	var com=Math.ceil((maxBid+tax)*0.1);
	if(com <2000){
		com = 2000;
	}
	var bidType = document.yah_bid.item_type.value;
	var bidWeight = document.yah_bid.bid_weight.value;
	var bidLoc = document.yah_bid.bid_loc.value;
	var bidTrans=0;

	//////////////////////////////
	// determine transportation //
	//////////////////////////////
	
	if(bidType=="" || bidLoc=="" || bidLoc == "Hokkaido" || bidLoc =="Okinawa" || bidLoc =="Fukuoka" || bidLoc =="Saga" || bidLoc =="Nagasaki" || bidLoc =="Oita" || bidLoc =="Kumamoto" || bidLoc =="Miyazaki" || bidLoc =="Kagoshima"){
		//Must contact for  inland transport
	}else{
			
		// BIKES
		if(bidType=="bike"){
			if(bidLoc == "Aomori" || bidLoc == "Iwate" || bidLoc == "Akita" || bidLoc == "Miyagi" || bidLoc == "Yamagata" || bidLoc == "Fukushima" || bidLoc == "Ibaraki" || bidLoc == "Tochigi" || bidLoc == "Gumma" ){
				bidTrans = 50000;
			}else if(bidLoc == "Chiba" || bidLoc == "Saitama" || bidLoc == "Tokyo" || bidLoc == "Kanagawa" || bidLoc == "Niigata" || bidLoc == "Toyama" || bidLoc == "Ishikawa" || bidLoc == "Nagano"  ){
				bidTrans = 35000;
			}else if(bidLoc == "Gifu" || bidLoc == "Fukui" || bidLoc == "Yamanashi" || bidLoc == "Shizuoka" || bidLoc == "Aichi"  ){
				bidTrans = 35000;
			}else if(bidLoc == "Kyoto"){
				bidTrans = 35000;			
			}else if(bidLoc == "Hyogo" || bidLoc == "Osaka"  ){
				bidTrans = 20000;	
			}else if(bidLoc == "Mie" || bidLoc == "Nara" || bidLoc == "Wakayama"  ){
				bidTrans = 35000;
			}else if(bidLoc == "Shiga" || bidLoc == "Tottori" || bidLoc == "Shimane" || bidLoc == "Okayama"  ){
				bidTrans = 35000;	
			}else if(bidLoc == "Hiroshima" || bidLoc == "Yamaguchi" || bidLoc == "Kagawa" || bidLoc == "Tokushima" || bidLoc == "Ehime" || bidLoc == "Kochi"  ){
				bidTrans = 35000;
			}
		//Jet skis
		}else if(bidType=="jetski"){
			if(bidLoc == "Aomori" || bidLoc == "Iwate" || bidLoc == "Akita" || bidLoc == "Miyagi" || bidLoc == "Yamagata" || bidLoc == "Fukushima" || bidLoc == "Ibaraki" || bidLoc == "Tochigi" || bidLoc == "Gumma" ){
				bidTrans = 37000;
			}else if(bidLoc == "Chiba" || bidLoc == "Saitama" || bidLoc == "Tokyo" || bidLoc == "Kanagawa" || bidLoc == "Niigata" || bidLoc == "Toyama" || bidLoc == "Ishikawa" || bidLoc == "Nagano"  ){
				bidTrans = 37000;
			}else if(bidLoc == "Gifu" || bidLoc == "Fukui" || bidLoc == "Yamanashi" || bidLoc == "Shizuoka" || bidLoc == "Aichi"  ){
				bidTrans = 37000;
			}else if(bidLoc == "Kyoto"){
				bidTrans = 37000;			
			}else if(bidLoc == "Hyogo" || bidLoc == "Osaka"  ){
				bidTrans = 37000;	
			}else if(bidLoc == "Mie" || bidLoc == "Nara" || bidLoc == "Wakayama"  ){
				bidTrans = 37000;
			}else if(bidLoc == "Shiga" || bidLoc == "Tottori" || bidLoc == "Shimane" || bidLoc == "Okayama"  ){
				bidTrans = 37000;	
			}else if(bidLoc == "Hiroshima" || bidLoc == "Yamaguchi" || bidLoc == "Kagawa" || bidLoc == "Tokushima" || bidLoc == "Ehime" || bidLoc == "Kochi"  ){
				bidTrans = 37000;
			}
		}else if(bidType=="forklift"){
			if(bidLoc == "Aomori" || bidLoc == "Iwate" || bidLoc == "Akita" || bidLoc == "Miyagi" || bidLoc == "Yamagata" || bidLoc == "Fukushima" || bidLoc == "Ibaraki" || bidLoc == "Tochigi" || bidLoc == "Gumma" ){
				bidTrans = 500000;
			}else if(bidLoc == "Chiba" || bidLoc == "Saitama" || bidLoc == "Tokyo" || bidLoc == "Kanagawa" || bidLoc == "Niigata" || bidLoc == "Toyama" || bidLoc == "Ishikawa" || bidLoc == "Nagano"  ){
				bidTrans = 150000;
			}else if(bidLoc == "Gifu" || bidLoc == "Fukui" || bidLoc == "Yamanashi" || bidLoc == "Shizuoka" || bidLoc == "Aichi"  ){
				bidTrans = 100000;
			}else if(bidLoc == "Kyoto"){
				bidTrans = 100000;			
			}else if(bidLoc == "Hyogo" || bidLoc == "Osaka"  ){
				bidTrans = 50000;	
			}else if(bidLoc == "Mie" || bidLoc == "Nara" || bidLoc == "Wakayama"  ){
				bidTrans = 100000;
			}else if(bidLoc == "Shiga" || bidLoc == "Tottori" || bidLoc == "Shimane" || bidLoc == "Okayama"  ){
				bidTrans = 100000;	
			}else if(bidLoc == "Hiroshima" || bidLoc == "Yamaguchi" || bidLoc == "Kagawa" || bidLoc == "Tokushima" || bidLoc == "Ehime" || bidLoc == "Kochi"  ){
				bidTrans = 100000;
			}
		}else{
			if(bidLoc == "Aomori" || bidLoc == "Iwate" || bidLoc == "Akita" || bidLoc == "Miyagi" || bidLoc == "Yamagata" || bidLoc == "Fukushima" || bidLoc == "Ibaraki" || bidLoc == "Tochigi" || bidLoc == "Gumma" ){
				bidTrans = 500000;
			}else if(bidLoc == "Chiba" || bidLoc == "Saitama" || bidLoc == "Tokyo" || bidLoc == "Kanagawa" || bidLoc == "Niigata" || bidLoc == "Toyama" || bidLoc == "Ishikawa" || bidLoc == "Nagano"  ){
				bidTrans = 150000;
			}else if(bidLoc == "Gifu" || bidLoc == "Fukui" || bidLoc == "Yamanashi" || bidLoc == "Shizuoka" || bidLoc == "Aichi"  ){
				bidTrans = 100000;
			}else if(bidLoc == "Kyoto"){
				bidTrans = 100000;			
			}else if(bidLoc == "Hyogo" || bidLoc == "Osaka"  ){
				bidTrans = 50000;	
			}else if(bidLoc == "Mie" || bidLoc == "Nara" || bidLoc == "Wakayama"  ){
				bidTrans = 100000;
			}else if(bidLoc == "Shiga" || bidLoc == "Tottori" || bidLoc == "Shimane" || bidLoc == "Okayama"  ){
				bidTrans = 100000;	
			}else if(bidLoc == "Hiroshima" || bidLoc == "Yamaguchi" || bidLoc == "Kagawa" || bidLoc == "Tokushima" || bidLoc == "Ehime" || bidLoc == "Kochi"  ){
				bidTrans = 100000;
			}
		}
	}

	var bidFOB = addCommas(maxBid + tax + com + bidTrans);

	document.yah_bid.bid_amount.value=addCommas(maxBid);
	document.yah_bid.bid_tax.value=addCommas(tax);
	document.yah_bid.bid_com.value=addCommas(com);
	document.yah_bid.bid_tra.value=addCommas(bidTrans);


	if(lang=="en"){
		txt_maxbid="Please Enter max bid";
		txt_itemtype="Enter Item Type";
		txt_foblesst="FOB less Inland Transportation:";
		txt_enterweight="Please Enter Weight";
		txt_contact="Contact for Inland Transportation";
		txt_lowbid="Bid is too low";
	}else if(lang=="ru"){
		txt_maxbid="Ваша макс. ставка";
		txt_itemtype="Предпочетаемый тип товара";
		txt_foblesst="FOB less Inland Transportation:";
		txt_enterweight="Please Enter Weight";
		txt_contact="Свяжитесь с нами по стоимости внутренней доставки.";
		txt_lowbid="Bid is too low";
	}else if (lang="es")
	{
		txt_maxbid="Por favor ponga su maximo bid";
		txt_itemtype="Ingrese el tipo de  artículo";
		txt_foblesst="FOB menos el transporte terrestre:";
		txt_enterweight="Por favor, introduzca el peso";
		txt_contact="Por favor contactar para el transporte  interior";
		txt_lowbid="Bid is too low";
	}

	min_bid = min_bid+0;
	//CHECK BID AMOUNT GREATER THAN MIN BID + MIN_RAISE_BID_AMOUNT
	if(maxBid<min_bid){
		document.getElementById('error_msg').innerHTML =txt_lowbid;
		document.getElementById('error_box').style.display='block';
		document.yah_bid.bid_fob.value='';
	}else{

		//print out any notes necessary
		if(maxBid=="" || maxBid==0){	
			document.getElementById('error_msg').innerHTML =txt_maxbid;
			document.getElementById('error_box').style.display='block';
			document.yah_bid.bid_fob.value='';
		}else if(bidType==""){
			document.getElementById('error_msg').innerHTML =txt_itemtype;
			document.getElementById('error_box').style.display='block';
			document.yah_bid.bid_fob.value='';
		}else if(bidType=="other"){
			document.getElementById('error_msg').innerHTML =txt_foblesst;
			document.getElementById('error_box').style.display='block';
			document.yah_bid.bid_fob.value='';
		}else if(bidWeight==""){
			document.getElementById('error_msg').innerHTML =txt_enterweight;
			document.getElementById('error_box').style.display='block';
			document.yah_bid.bid_fob.value='';
		}else if(bidWeight=="20"){
			document.getElementById('error_msg').innerHTML =txt_contact;
			document.getElementById('error_box').style.display='block';
			document.yah_bid.bid_fob.value='';
		}else{
			document.getElementById('error_box').style.display='none';
			document.yah_bid.bid_notes.value="";
			document.yah_bid.bid_fob.value=bidFOB;
		}
	}
}


function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function removeCommas(nStr)
{
	nStr =nStr.replace(/,/g , "");
	return nStr;
}

function findPosX(obj) {		//not used
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj){			//not used/
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}
