function getNodeValue(obj,tag){return obj.getElementsByTagName(tag)[0].firstChild.nodeValue;}
addL(doFunctions);function doFunctions(){showHover();submitOForm();behaviourForm();Cclick();cal()}
function submitOForm(e){
	if($('orderAddress2').value!=""){
	if($('voucherused').value==""){
	$('orderPrice').innerHTML="";makeActive('orderPrice');
		var status=aR.submit(document.forms[0],{
			"url":"/dd.php",'onSuccess':function(req){
				var prices = req.responseXML.getElementsByTagName('root');totprice=(getNodeValue(prices[0],'price'))*1; hire=(getNodeValue(prices[0],'deposit'))*1;
				$('orderPrice').innerHTML='\u00A3'+totprice;$('nowprice').innerHTML=(totprice+hire)/2;
				$('inputorderPrice').value=totprice+hire;$('inputnowprice').value=(totprice+hire)/2
			makeInactive('orderPrice');
			}
		});}
		
		if(($('voucherused').value!="")&& ($('inputorderPrice').value!="")){
		var stat=aR.submit(document.forms[0],{
			"url":"/voucher.php",'onSuccess':function(requ){
			var root = requ.responseXML.getElementsByTagName('root');
			discountprice=((getNodeValue(root[0],'discount'))*1);
			hire = getNodeValue(root[0],'hiretext');deposit=(getNodeValue(root[0],'deposit'))*1;totprice=((getNodeValue(root[0],'fullprice'))*1)-deposit;
			$('discount').innerHTML="Total after discount ";
			strong1=document.createElement("strong");strong2=document.createElement("strong");span=document.createElement("span");
			$('discount').appendChild(strong1);$('discount').appendChild(span);
			strong1.innerHTML= '\u00A3'+(discountprice.toFixed(2));span.innerHTML=hire;span.appendChild(strong2);strong2.innerHTML='\u00A3'+deposit;
			$('nowprice').innerHTML=((discountprice+deposit)/2).toFixed(2);$('inputnowprice').value=(discountprice+deposit)/2; 
			$('orderPrice').innerHTML='\u00A3'+totprice;$('inputorderPrice').value=totprice+deposit;
			}
		});
		return stat;
	}else{$('discount').innerHTML=""}

		
		return status;
	}
}
function makeActive(o) {$(o).className="loading"; }
function makeInactive(o) {$(o).className=""; }
function changeCal(e){cancelE(e);var status=aR.get({'parameters':{'day':'1', 'monyear':this.attributes.getNamedItem('value').nodeValue},"url":"/cal.php",'onSuccess':function(req){$('calH').innerHTML=req.responseText;doFunctions();showW('a','receptiondatehelp');}});return status;}	
function behaviourForm(){el=$('orderform').elements;for(var i=0;i<el.length;i++){if(el[i].type=='radio'){el[i].onclick=submitOForm}else{$('orderAddress2').onblur=$('postcode').onblur=$('voucherused').onblur=submitOForm};}}
function showHover(){var helpArr=document.getElementsByClassName('helpW');for(var i=0;i<helpArr.length;i++){o=helpArr[i].id;$(o).className="helpW helpBox noshow";var ob=$(o.substr(0,o.length-4));ob.onfocus=bShow;var cl=$('cl'+i);if(cl){cl.onclick=bShow};}}
function bShow(e){t=this;if(t.className!="cl"){showW(t.id,t.id+"help")}else{t=t.parentNode.id;t=t.substr(0,t.length-4);showW(t,t+"help")}}
function showW(p,c){$(c).className=($(c).className=="helpW helpBox noshow")?"helpW helpBox showing" : "helpW helpBox noshow";}
function Cclick(e){tas=$("calendar").getElementsByTagName("button");for(var i=0;i<tas.length;i++){tas[i].onclick=spl}};
function spl(e){cancelE(e);$('receptiondate').value=this.attributes.getNamedItem('value').nodeValue;$('receptiondate').focus();$('receptiondatehelp').className="helpW helpBox noshow";}
function cal(){$('next').onclick=changeCal;$('prev').onclick=changeCal}