
function gr(id){return getRef(id);}
function gs(id){return getSty(id);}
function gsh(id){gs(id).display='none';}
function gsw(id)
{
	if( id=='div_qm_pp' || id=='div_qm_lh')
	{
		gs(id).display=(isIE)?'block':'table-row';
	}
	else
	{
		gs(id).display='block';
	}
	
}
function gswi(id){gs(id).display='inline';}
function gsd(id){return gs(id).display;}
function gsb(id){return gs(id).backgroundColor;}
function gri(id,h){gr(id).innerHTML=h;} //
function grv(id){return gr(id).value;} 

function alert1(m){gr('drep').innerHTML+=m+"<br>";}

function calc_class()
{
	this.get_price = false;
	this.is_total = false;
	this.is_qn=false;
	this.is_start = true;
	this.tid = null;
	this.bob = null;
	this.n_box=2;
	this.vht = 1/61023.744094732;//inch
	this.wht = 1;//lbs
	this.vlm_act = false;
	this.e = Array('srv','ocnt','ocity','dcnt','dcity','cmd','vlm_s');
	this.def_price = "USD 0";

	this.opt = Array();
	this.opt1 = Array();
	this.lh_pr = 0;
	
	this.liftgate = false;

	this.sl = function()
	{
		gs('calc_ldr').width = gs('calc_block').width = gr('calc_table').offsetWidth;
		gs('calc_ldr').height = gs('calc_block').height = gr('calc_table').offsetHeight;
	}
	this.lock = function(e)
	{
		this.sl();
		this.lk();
		if(e == 'ocnt')gsh("tab_dcnt");
		if(e == 'ocity')gri("td_dcity",'');
		if(e == 'dcnt')gsw("tab_vw");
		if(e)
		{
			if(e != 'cmd')gsh("tab_vw"); 
			gri('total_sum',this.def_price);
			this.is_total = false;
		}
	}
	this.lk = function(){gsw('tC_block');}
	this.unlock = function(){gsh('tC_block');}
	this.req = function(name)
	{
		r="";
		for(i=0;i<this.e.length;i++)
		{
//			r+=this.e[i]+'='+( (this.e[i]=='ocity') ? grv('real_ocity') : grv(this.e[i]) );
			r+=this.e[i]+'='+( (this.e[i]=='ocity') ? grv('real_ocity') + '&lh_city=' + grv('ocity') : grv(this.e[i]) );
			if(name==this.e[i])break;
			r+='&';
		}
		return r;
	}
	this.act_qt = function()
	{
		gs("ocnt_s").background = "url(imgs/calc/gs.gif) no-repeat center";
		gs("dcnt_s").background = "url(imgs/calc/gs.gif) no-repeat center";

		if(grv('ocity').substr(grv('ocity').length-1)=='*')
		{
//			gri('q_lh_city1',grv('ocity'));
			gsw('ocity_txt');
			gsh('tab_zip_lh');
			gsw('bl_tab1');
			gs('td_dwlm_s').display = (isIE)?'block':'table-cell';
//			gsh('send1');
		}
		this.lock('dcity');
		ReqOnSer(this.req('dcity'));
	}
	this.act = function(o)
	{
		name = o.name;
		this.sbl2();
		if(o.options[0].value == 0) o.remove(0);
		this.vlm_act = (name == 'cmd') ? true : false;
		if(name == 'ocnt' || name == 'dcnt')gs(name+"_s").background = "url(imgs/calc/gs.gif) no-repeat center";
		if(name == 'ocity')
		{
			if(grv('ocity').substr(grv('ocity').length-1)=='*')
			{
//				gri('q_lh_city1',grv('ocity'));
				gsw('ocity_txt');
				gsh('tab_zip_lh');
				gsw('bl_tab1');
				gs('td_dwlm_s').display = (isIE)?'block':'table-cell';
//				gsh('send1');
			}
			else if(gr("pickup_type").selectedIndex==0)
			{
				gsh('ocity_txt');
				gswi('tab_zip_lh');
				gsh('bl_tab1');
				gsh('td_dwlm_s');
//				gsw('send1');
			}
			//gr('real_ocity').value = this.opt1[gr('ocity').selectedIndex];
			gr('real_ocity').value = this.s_lh(grv('ocity'));
			if(gr('ocnt').value != 'USA')gr('real_ocity').value = grv('ocity');
			this.mode_zip();
		}
		if(name == 'ocnt')gr('real_ocity').value = '';
		if(name != 'dcity') this.reset_price();
		if(name != 'cmd') gsh('ddett');
		this.lock(name);
		ReqOnSer(this.req(name));
	}
	this.act1 = function(name)
	{
		if(name == 'ocnt')gs(name+"_s").background = "url(imgs/calc/gs.gif) no-repeat center";
		this.lk();
		ReqOnSer(this.req(name));
	}
	this.act2 = function()
	{
		this.bl('ocnt');
	}
	this.act3 = function()
	{
		this.sbl2();
		this.vlm_act = true;
		this.lock('cmd');
		ReqOnSer(this.req('cmd'));
	}
	this.s_lh = function(city)
	{
		for(i=1;i<this.opt.length;i++)
			if(this.opt[i]==city)
			{
				//alert1("--"+this.opt[i]+" = "+this.opt1[i-1]);
				return this.opt1[i-1];
			}
	}
	this.set_option = function(name,opt,opt1,pr,adr)
	{
//		alert1(adr);
		switch(name)
		{
			case 'ocnt': t='1';break;
			case 'ocity':t='2'; this.opt1=opt1; this.opt=opt; break;
			case 'dcnt': t='3';break;
			case 'dcity':t='4';break;
			case 'cmd':  t='5';break;
		}
		sel = "<select tabindex="+t+" id="+name+" name="+name+" onChange='c.act(this)'>";
		sel += "<option value=0>"+opt[0]+"</option>";
		for( i=1; i<opt.length; i++ )
			sel += "<option title=\""+opt[i]+"\" value=\""+opt[i]+"\">"+opt[i]+"</option>";
		sel += "</select>";
		
		if(name=='ocity' && grv('ocnt')=='USA')
		{
			st = '';
			sel2 = "<select id=sel_state onchange=\"sst(this)\" ><option>Filter by State</option>";
			for( i=1; i<opt.length; i++ )
			{
				v = opt[i];
				state = (v.substr(v.length-1)=='*') ? v.substr(v.length-3,2) : v.substr(v.length-2);
				if(st.indexOf(state)==-1) st += " "+state;
			}
			mst = st.split(" ");
			mst.sort();
			for( i=1; i<mst.length; i++ )
			{
				sel2 += "<option value=\""+mst[i]+"\">"+mst[i]+"</option>";
			}
			sel2 += "</select>";
			sel = sel2+sel;
		}
		gri('td_'+name,sel);
		this.lh_pr = pr;
		gri('lh_adr',adr);
		gr('qlh_adr').value = adr;
		
		gs(name).backgroundColor = "#9dcb8f";//"yellow";
		if(name=='dcnt')gsw("tab_dcnt");
		this.bl(name);
	}
	this.set_cmd = function(opt)
	{
//		alert1("m1");
		sel = "<select id=cmd name=cmd tabindex=5 onChange='c.act(this)'>";
		for(i=0;i<opt.length;i++)
			sel += "<option value=\""+opt[i]+"\""+ ( ( opt[i] == "Commercial / Industrial Goods" ) ? " selected " : "" ) +">"+opt[i]+"</option>";
		sel += "</select>";
		gri('td_cmd',sel);
		gsw("tab_vw");
		this.act(gr('cmd'));
	}	
	this.set_input = function(name,opt)
	{
//		alert1('set_input('+name+')');
		gri('td_'+name,"<span class=tC_inp>"+opt[0]+"</span><input type=hidden id="+name+" name="+name+" value=\""+opt[0]+"\" readonly=1 />");
		if(name=='ocity')gr('real_ocity').value = opt[0];
		this.lock(name);
		if(name=='dcnt')gsw("tab_"+name);
		if(name=='cmd'){this.act3();return;}
		ReqOnSer(this.req(name));
	}
//---
	this.get_tab_info = function(m1,m2)
	{
		str = "<table class=clc_line border=0 cellspacing=0 cellpadding=0>";
		for(i=0;i<m1.length;i++)
			str += "<tr><td width=160>"+m1[i]+"</td><td align=right><strong>"+m2[i]+"</strong></td></tr>";
		str += "</table>";
		return str;
	}
//---
	this.cmd = function(tab1,tab2,tab3,h_ocity,tr_time,sid,cfs_adr)
	{
		gs("ocnt_s").background = gs("dcnt_s").background = "url(imgs/calc/gs.gif) no-repeat center";
		gr('real_ocity').value = h_ocity;
		gr('warn_cfs').innerHTML = h_ocity;
		gr('ttime').value = tr_time;
		if(tr_time !== '')
		{
			gri('dett',tr_time);
			gsw('ddett');
		}
		gr('sid').value = sid;
//		gr('sid1').value = sid;
//new quote		gri('q_lh_city2',h_ocity);
		gri('cfs_adr',cfs_adr);
		gr('qcfs_adr').value = cfs_adr;
		
//		gri('q_real_city1',h_ocity);
//		gri('q_real_city2',h_ocity);
		gri('dim_ocity',h_ocity);
//		gri('q_lh_city1',grv('ocity'));
		gri('rate_det',this.get_tab_info(tab1,tab2));
		//alert(this.get_tab_info(tab1,tab2));
		gri('rate_com',tab3);
		gsw('rate_com');
		gsw('tab_vw');
		if(this.get_price){this.get_price=false; this.price();}
		//this.vlm();
	}
	this.is_num = function(v)
	{
		re = /,/gi;
		n = new Number(v.replace(re, "."));
		if(!isNaN(n)) return n;
		alert("Enter number only!"); 
		return false;
	}
	this.rd = function(n){n=parseFloat(n);if(!isNaN(n)){ n*=Math.pow(10, 2); n=Math.round(n); n/=Math.pow(10, 2);} else {return "NaN";} return n;}
	this.sinf=function(){ gri( 'td_hhg', grv('vlm_s') + " cbm, " + grv('wlm_s') + " lbs, " + grv('cmd') ); }
	this.vlm = function()
	{
		if(!this.vlm_act){alert("Please, Enter Full Origin and Destination Information Before!");return false;}
		if(grv('vlm_s')=='0' || grv('wlm_s')=='0'){return;}
		s = gr('vlm_s');
		this.sinf();
		this.wlm();
	}
	this.wlm = function()
	{
		if(!this.vlm_act){alert("Please, Enter Full Origin and Destination Information Before!");return;}
		if(grv('vlm_s')=='0' || grv('wlm_s')=='0'){return;}
		s = gr('wlm_s');
		this.sinf();
		this.sl();
		this.lk();
		s = "&vlm_s="+grv('vlm_s');
		ReqOnSer("cmd_info=1&"+this.req('cmd')+s);
	}
	this.reset_price = function()
	{
		gsw('pr_start');
		gsh('div_quote');
		gsh('tab_route');
		gsh('lrt');
		gsh('hh2');
		//---
		gsh('div_bf');
//		gsw('asend1');gsw('asend2');gsw('asend3');
	}
	this.change_zip = function()
	{
		//gr('').focus();gr('').select();
		this.reset_price();
		if(gr('pickup_type').selectedIndex==0 && grv('ocity').substr(grv('ocity').length-1)!='*')
		{
			gswi('tab_zip_lh');
			gsh('bl_tab1');
			gsh('td_dwlm_s');
//			gsw('send1');
		}
		if(gr('pickup_type').selectedIndex!=0)
		{
			gsh('tab_zip_lh');
			gsw('bl_tab1');
			gs('td_dwlm_s').display =  (isIE)?'block':'table-cell';
			//gr('zip_code').focus();
			if((gr('pickup_type').selectedIndex==2 || gr('pickup_type').selectedIndex==3) && this.liftgate)
				gsw('lift');
			else
				gsh('lift');
		}
		this.mode_zip();
	}
	this.mode_zip = function()
	{
		if(gr("pickup_type").selectedIndex!=0)
		{
			gsw('div_qm_pp');
			gsw('s_zip');
		}
		else
		{
			gsh('div_qm_pp');
			gsh('s_zip');
		}
		
		if( grv('ocity').substr(grv('ocity').length-1)=='*' )
			gsw('div_qm_lh');
		else
			gsh('div_qm_lh');
		//if( grv('zip_code').length >4 )this.zip_city();
	}
	this.zip_city = function()
	{
		if( grv('zip_code').length <5 ){alert("Please enter the Zip/Postal code where your goods are located"); return;} 
		this.lk();
		ReqOnSer("ocnt="+grv('ocnt')+"&zip="+grv('zip_code'));
	}
	this.set_zip_city = function(zcity)
	{
		gri('q_zip_city1',zcity);
	}
//---
	this.price = function()
	{
		if(grv('vlm_s')=='0' || grv('wlm_s')=='0'){alert('Please enter dimensions and weight first!');return;}
		this.mode_zip(); 
//		alert1('before vlm');
		this.vlm();
	}
	this.total = function(sum)
	{
//		alert1('run total');
		gri('ocf',"$"+sum);
		gr('sfr_pr').value = sum;
		gr('of_rate').value = sum;
		sum = Number(sum);
		ds = (sum+89)*0.0379 > 25 ? (sum+89)*0.0379 : 25;
		gri('dsf',"$"+Math.floor(ds));
		getRef('tpr').value = it = new String( Math.floor( Number(sum)+Number(89)+Number(ds) ) );
		gri('total_sum',"US$ " + it);
		gri('td_ror',grv('real_ocity')+", "+grv('ocnt'));
		
		if( grv('wlm_s') < 1000 )
			this.lh_pr = this.lh_pr;
		else if( grv('wlm_s') < 3000)
			this.lh_pr = (this.lh_pr/1.2)*1.1;
		else
			this.lh_pr = (this.lh_pr/1.2);
			
		lhpr = Math.ceil( this.lh_pr * grv('wlm_s') * 1.0379 );
		if( lhpr < 223 && lhpr!=0 ) lhpr =Math.ceil( 223 * 1.0379); 
		gr('lhprs').value = lhpr;
		
		lhpr1 = Math.ceil( this.lh_pr * grv('wlm_s') );
		if( lhpr1 < 223 && lhpr1!=0 ) lhpr1 = 223; 
		gr('lh_rate').value = lhpr1;

		lht =  Math.ceil(it) + lhpr;
		gri( 'total_sum_lh', "US$ " + lht );//grv('lhprs') );

		//big button send1 gri('td_ror_b',grv('real_ocity'));
		gri('td_rds',grv('dcity')+", "+grv('dcnt'));
		this.sinf();
		this.is_total = true;
		if( getSty('hh2').display == 'none' )getSty('lrt').display = 'block';
		gsw('tab_route');
		gsh('pr_start');
		gsw('div_quote');
		this.mode_zip();
		gsw('tab_notes');
		document.location="#obp";
//		document.location="#obf";
	}
//---
	this.add_box = function()
	{
		i = this.n_box;
		var r = gr('bl_tab').tBodies[0].insertRow(-1);
		var c0 = r.insertCell(0);
		c0.innerHTML = "<input type=image src=/imgs/calc/reset1.gif onclick='c.del_box(this)' />";
		var c1 = r.insertCell(-1);
		c1.innerHTML = "<select name='tp"+i+"' style='width:57px; margin:1px;'><option value='box'>Box</option><option value='crate'>Crate</option><option value='pallet'>Pallet</option></select>";
		var c2 = r.insertCell(-1);
		c2.innerHTML = "<input type=text id=vn"+i+" name=vn"+i+" class=ii3 onBlur='c.tv();c.tw();' value=1 />";
		var c3 = r.insertCell(-1);
		c3.innerHTML = "<input type=text id=vl"+i+" name=vl"+i+" class=ii3 onBlur='c.tv()' />";
		var c4 = r.insertCell(-1);
		c4.innerHTML = "<input type=text id=vw"+i+" name=vw"+i+" class=ii3 onBlur='c.tv()' />";
		var c5 = r.insertCell(-1);
		c5.innerHTML = "<input type=text id=vh"+i+" name=vh"+i+" class=ii3 onBlur='c.tv()' />";
		var c6 = r.insertCell(-1);
		c6.innerHTML = "<input type=text name=wp"+i+" id=wp"+i+" class=ii3 onBlur='c.tw()' />";
		var c7 = r.insertCell(-1);
		c7.innerHTML = "<input type=text id=vt"+i+" name=vt"+i+" class=ii4 readonly=1 tabindex='-1' value='0' />";
		var c8 = r.insertCell(-1);
		c8.innerHTML = "<input type=text name=wt"+i+" id=wt"+i+" class=ii4 readonly=1 tabindex='-1' value='0' />";

		r = gr('bl_tab1').tBodies[0].insertRow(-1);
		var c9 = r.insertCell(0);
		c9.innerHTML = "<input type=hidden name=dw"+i+" id=dw"+i+" /><div id=dtw"+i+">&ndash;</div>";
		var c10 = r.insertCell(-1);
		c10.innerHTML = "<input type=hidden name=dfr"+i+" id=dfr"+i+" /><div id=df"+i+">&ndash;</div>";
		var c11 = r.insertCell(-1);
		c11.innerHTML = "<input type=hidden name=cfc"+i+" id=cfc"+i+" /><div id=fc"+i+">&ndash;</div>";
		var c12 = r.insertCell(-1);
		c12.innerHTML = "<select id='fcu"+i+"' name='fcu"+i+"' class=ss><option value='-'>-</option><option value='50'>50</option><option value='55'>55</option><option value='60'>60</option><option value='65'>65</option><option value='80'>80</option><option value='85'>85</option><option value='88.5'>88.5</option><option value='92.5'>92.5</option><option value='100'>100</option><option value='110'>110</option><option value='125'>125</option><option value='150'>150</option><option value='175'>175</option><option value='200'>200</option><option value='250'>250</option><option value='300'>300</option><option value='400'>400</option><option value='500'>500</option></select>";
		this.n_box++;
	}
	this.del_box = function(obj)
	{
		var num_tr=obj.parentNode.parentNode.sectionRowIndex;
		gr('bl_tab').tBodies[0].deleteRow(num_tr); 
		gr('bl_tab1').tBodies[0].deleteRow(num_tr); 
		this.tw();this.tv();
	}
	this.tv = function()
	{
		sum = 0;
		sum_vn = 0;
		sum1 = 0;
		for( i=1; i<this.n_box; i++ )
		{
			if(!gr('vn'+i))continue;
			t = 0;
			vn = this.is_num(grv('vn'+i));
			sum_vn += vn;
			l = this.is_num(grv('vl'+i));
			w = this.is_num(grv('vw'+i));
			h = this.is_num(grv('vh'+i));
			if(l && w && h && vn)
			{
//				alert1(i+' row = '+vn*l*w*h*this.vht);
				al = vn*l*w*h*this.vht;
				if(al>0 && al<0.01) al=0.01;
				sum += gr('vt'+i).value = this.rd(al);
				sum1 +=Math.ceil( this.calc_fc(i));
			}
		}
		sum = this.rd(sum);
		this.set_dd('vlm_s', sum,   'cbm');
		this.set_dd('dwlm_s',sum1,  'lbs');
		this.set_dd('unit_s',sum_vn,'pieces');
		this.reset_price();
	}
	this.set_dd = function(n,v,dim)
	{
		gr(n).value = v;
		gri('td_'+n,v);//+' '+dim
	}
	this.tw = function()
	{
		this.liftgate=false;
		sum = 0;
		sum1=0;
		for(i=1;i<this.n_box;i++)
		{
//			alert1("tw "+this.n_box+" i="+i);
			if(!gr('vn'+i))continue;
			nn = this.is_num(grv('vn'+i));
			vv = this.is_num(grv('wp'+i));
			if(vv && nn)
			{
				al = vv*nn*this.wht;
				if(al>0 && al<1) al=1;
				if(al>=100)this.liftgate=true; 
				sum+= gr('wt'+i).value = this.rd(al);
				sum1 += Math.ceil(this.calc_fc(i));
			}
		}
		sum = this.rd(sum);
		this.set_dd('wlm_s',sum,'cbm');
		this.set_dd('dwlm_s',sum1,'lbs');
		this.change_zip();
		this.reset_price();
	}
	this.calc_fc = function(i)
	{
		vn = this.is_num(grv('vn'+i));
		wi = this.is_num(grv('wp'+i));
		l = this.is_num(grv('vl'+i));
		w = this.is_num(grv('vw'+i));
		h = this.is_num(grv('vh'+i));
		vi = l*h*w*this.vht;
		if(vi>0 && wi>0)
		{
			//alert('ok');
			wi=wi*this.wht;
			vw = this.rd(wi/(vi*35.3146667));
			gri('df'+i,vw);
			gr('dfr'+i).value=vw;
			cl = 0;
			m1 = Array(1000,50,35,30,22.5,15,13.5,12,10.5,9,8,7,6,5,4,3,2,1,0);
			m2 = Array(50,50,55,60,65,80,85,88.5,92.5,100,110,125,150,175,200,250,300,400,500);
			while( m1.pop() < vw ) cl = m2.pop();
			gri('fc'+i,cl);
			gr('cfc'+i).value = cl;
			gr('fcu'+i).value = cl;
			
			t_dtw = Math.ceil( (vn*l*w*h*this.vht*61023.744094732)/194 );//this.rd(vn*l*w*h*this.vht*61023.744094732/194);
			t_wi = Math.ceil( wi*vn );
			if(t_dtw < t_wi)t_dtw = t_wi;
			gri('dtw'+i,t_dtw);
			gr('dw'+i).value = t_dtw;
			return t_dtw;
		}
		return 0;
	}
	this.qcl = function()
	{
		gsh('q_atr');
		gsw('bsq');
	}
	this.send_quote = function()
	{
		gsh('div_bf');
		//alert1('send_quote('+n1+')');
		if(!this.is_total){alert("Please complete previous steps first.\nSelect ORIGIN & DESTINATION and enter estimated VOLUME & WEIGHT.");return;}
		gsh('bsq');
		gsw('q_atr');
	}
	this.quote = function()
	{
		if(gr('q_email').value == 'Enter your e-mail' || gr('q_email').value == ''){alert('Please enter a valid email');return;}
		gr('quote').value='1';
		gr('calc').submit();
	}
	this.o_brf = function(){gsw('div_bf');document.location="#obf";}
	this.open_brf = function(t)
	{
		//alert1("tpr = "+grv('tpr'));
		gr('booking_type').value=t;
		gr('quote').value = 0;
		if(!this.is_total){alert("Please complete previous steps first.\nSelect ORIGIN & DESTINATION and enter estimated VOLUME & WEIGHT.");return;}
		this.o_brf();
		gsh('but_qcfs'); gsh('but_qlh'); this.qcl(); gsh('bsq'); gsh('tab_notes');
	}
	this.close_brf = function()
	{
		gsh('div_bf');
		gr('quote').value = 1;
		gsw('but_qcfs'); gsw('but_qlh'); gsw('bsq'); gsw('tab_notes');
		document.location = "#obf_s";
	}
	this.ch_vd = function()
	{
		switch(grv('d_vd'))
		{
			case 'cm': this.vht = 0.000001;break;
			case 'meter': this.vht = 1;break;
			case 'inch': this.vht = 1/61023.744094732;break;
			case 'feet': this.vht = 1/35.314666721;break;
		}
//		alert1('vht = ' + this.vht);
		this.tv();
	}
	this.ch_wd = function()
	{
		switch(grv('d_wd'))
		{
			case 'lbs': this.wht = 1;break;
			case 'kg': this.wht = 2.2;break;
		}
		this.tw();
	}
	this.bl = function(o){this.tid = setInterval("gbl( )", 500);this.bob = o;}
	this.gbl = function(){getSty(this.bob).backgroundColor = getSty(this.bob).backgroundColor=='white' ? '#9dcb8f':'white';}
	this.sbl = function(o){if(o!= this.bob)return;this.sbl2();}
	this.sbl2 = function(){if(this.bob==null)return;clearInterval(this.tid);getSty(this.bob).backgroundColor = "white";this.bob = null;}
	this.show_help = function(ur){help_win = window.open("help_file_p.php#"+ur,"subWind","height=400,width=300,scrollbars,location,resizable");help_win.focus();}
}
function gbl(){c.gbl();}
//---

if (!window.XMLHttpRequest){window.XMLHttpRequest = function(){var types=['Microsoft.XMLHTTP','MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP'];for(var i=0;i<types.length;i++){try{return new ActiveXObject(types[i]);}catch(e){}}return false;}}
var req;
function processReqChange(){if(req.readyState==4){c.unlock();eval(req.responseText);}}
function ReqOnSer(url)
{
	//document.calc.adr.value = "answer3.php?" + url;
	//alert1("answer3.php?" + url);
    req = null;
    req=new XMLHttpRequest();
    if(req){req.onreadystatechange = processReqChange;req.open("GET", "answer4.php?" + url + "&r=" + Math.random(), true);req.send(null);}
}

function sst(o)
{
//	alert1("sst run");
	if(mcity.length == 0)make_m();
	if( $(o).children(":selected").val() )
	{
		v = $(o).children(":selected").val();
		sel = "<option>Select city in "+v+"</option>";
//		sel = "<option>Select city in "+mcity.length+"</option>";
		for( i=0; i<mcity.length; i++ )
			if(mcity[i][0]==v) sel += "<option value=\""+mcity[i][1]+"\">"+mcity[i][2]+"</option>";
		$(o).next().html(sel);
	}
	else
	{
		sel = "";
		for( i=0; i<mcity.length; i++ )
			sel += "<option value=\""+mcity[i][1]+"\">"+mcity[i][2]+"</option>";
		$(o).next().html(sel);
	}
	gsh("tab_dcnt");
	gsh("tab_vw");
	gsh("ddett");
	c.reset_price();
}
mcity = Array();
function make_m()
{
	$("#ocity>option").each(function(){
	if($(this).val())
	{
		v = $(this).text();
		state = (v.substr(v.length-1)=='*') ? v.substr(v.length-3,2) : v.substr(v.length-2);
		mcity.push ( Array( state, $(this).val(), v ) );
	}
  });
}
