var orderarray=new order(100);	//	Number of lines in order.
var count=0
var pWord=" "
var pName=" "
var uType=" "
var uLog=" "

var newwindow;
function popterm(url)
{
	newwindow=window.open(url,'name','height=500,width=640,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
	if (window.focus) {newwindow.focus()}
}



// Sets cookie values. Expiration date is optional
//
function setCookie(name, value, expire) {
document.cookie = name + "=" + escape(value)
+ ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}

function getCookie(Name) {
//alert("In get Cookie")
var search = Name + "="
if (document.cookie.length > 0) { // if there are any cookies
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset)
// set index of end of cookie value
if (end == -1)
end = document.cookie.length
return unescape(document.cookie.substring(offset, end))
}
}
}

function register(name,fname) {
var today = new Date()
var expires = new Date()
expires.setTime(today.getTime() + 1000*60*60*24*365)
setCookie(fname, name, expires)
}

function Write_Login(){
	var tStr=""
	tStr=pName+","
	tStr+=pWord+","
	tStr+=uType+","
	tStr+=uLog
	register(tStr,"pLog")
}

function Write_User_Type(usType){
	var tStr=""
	tStr=pName+","
	tStr+=pWord+","
	tStr+=usType+","
	tStr+=uLog
	register(tStr,"pLog")
}



function Read_Login(){
	oLog = new String(getCookie("pLog"))
	if (oLog.length >0){
		pattern = /,/
		oLdets = oLog.split (pattern)
		pName = oLdets[0]
		pWord = oLdets[1]
		uType = oLdets[2]
		uLog = oLdets[3]
	}
}



function Read_Order(){
	oItems = new String(getCookie("pSize"))
	if (oItems.length >10){
		pattern = /,/
		oList = oItems.split (pattern)
		count = oList[0]
		if (count>0){
			var offseta=0;
			for (var i0=0;i0<count;i0++) {
				var pHtm=oList[1+offseta];
				var pName=oList[2+offseta];
				var pImg=oList[3+offseta];
				var pItem=oList[4+offseta];
				var pQty=oList[5+offseta];
				var pVal=oList[6+offseta];
				orderarray[i0]=new orderline(pHtm,pName,pImg,pItem,pQty,pVal);
				offseta=offseta+6
			}
		}
	}
}

function PrintOrder(){
	document.write("Var Count = "+count+"<BR>")
	var offseta=0
	if (count>0){
		for (var i0=0;i0<count;i0++) {
			document.write("<BR>i0 = "+i0+"<BR>")
			//for (var i1=0;i1<6;i1++){
			//orderarray[i1]=oList[i1+offseta];
			document.write("   "+orderarray[i0].htm+"   "+orderarray[i0].name+"   "+orderarray[i0].img+"   "+orderarray[i0].item+"   "+orderarray[i0].qty+"   "+orderarray[i0].val);
			//}
		offseta=offseta+6
		//alert(offseta)
		}
	}
}


function order(elem) {
	this.length=elem;
	for (var nL=1;nL<=elem;nL++) {
		this[nL]=0;
	}
	return this
}
function ordertable() {
	alert("in order table");
	var total=0;
	var items=0;
	var str_total="";
	var temp_str="";
	var text="<center><table border=1 cellpadding=5 cellspacing=0 borderColor=#CC9900>";
	text+="<tr align=center bgcolor=#F5F5D1><td width=120><FONT COLOR='000000'>Order Code</td><td width= 250><FONT  COLOR='000000'>Description</td><td width=40><FONT COLOR='000000'>Qty</td><td width=70><FONT COLOR='000000'>Unit Price</td><td width=60><FONT COLOR='000000'>Value</td></tr>"
	for (var i0=0;i0<count;i0++) {
		if (orderarray[i0].qty>0){
			items+=orderarray[i0].qty
			var linetotal=orderarray[i0].val*orderarray[i0].qty;
			total+=linetotal;
	
			text+="<tr align=center>";
			temp_str=orderarray[i0].img;
			str_total=temp_str.substr(temp_str.length-8,8)
			text+="<td align=left><FONT COLOR='0000FF'><A href='"+orderarray[i0].htm+".htm#"+orderarray[i0].name+"'>"+orderarray[i0].img+"</A></TD>";
			text+="<td align=left><FONT COLOR='000000'>"+orderarray[i0].item+"</td>";
			text+="<td><FONT COLOR='000000'>"+orderarray[i0].qty+"</td>";
			temp_str="£"+orderarray[i0].val
			str_total=temp_str.substring(0,temp_str.length-2)+"."+temp_str.substring(temp_str.length-2,temp_str.length)
			text+="<td align=right><FONT COLOR='000000'>"+str_total+"</td>";
			linetotal="£"+linetotal
			str_total=linetotal.substring(0,linetotal.length-2)+"."+linetotal.substring(linetotal.length-2,linetotal.length)
			text+="<td align=right><FONT COLOR='000000'>"+str_total+"</td>";
			text+="</tr>"
		}
	}
	total="£"+total
	str_total=total.substring(0,total.length-2)+"."+total.substring(total.length-2,total.length)
	text+="<tr><td colspan=4 align=right><FONT COLOR='000000'>Total:  </TD><TD align=right><FONT COLOR='000000'>"+str_total+"</TD></TR>"
	text+="</table></center>"
	return text;
}
function FillOrder() {
	var total=0;
	var items=0;
	var text="";
	for (var i0=0;i0<count;i0++) {
		items+=orderarray[i0].qty
		var linetotal=orderarray[i0].val*orderarray[i0].qty;
		total+=linetotal;

		text+="Item: "+orderarray[i0].img;
		text+=", ";
		text+="Qty: "+orderarray[i0].qty;
		text+=", ";
		text+="Retail: "+orderarray[i0].val;
		text+=", ";
	}
	return text;
}

function orderline(pHtm,pName,pImg,pItem,pQty,pVal) {
	//alert("in orderline");
	//alert("Alll the p's = "+pHtm+pName+pImg+pItem+pQty+pVal);
	this.length=6;				//	number of properties in collection
	this.htm=pHtm;				//	even newer property 1
	//alert("this.htm "+this.htm);
	this.name=pName;
	this.img=pImg;				// new property 1
	this.item=pItem;			//	property1		'item'
	this.qty=parseInt(pQty,10);	//	property2		'qty'
	this.val=parseFloat(pVal);	//	property3		'cost'
							//	this collection could be extended so that each line of the order also holds a thumbnail filename
}

function WriteCookie() {
	var cookie_txt=count+","
	for (var i0=0;i0<count;i0++) {
		cookie_txt+=orderarray[i0].htm+",";	
		cookie_txt+=orderarray[i0].name+",";	
		cookie_txt+=orderarray[i0].img+",";	
		cookie_txt+=orderarray[i0].item+",";	
		cookie_txt+=orderarray[i0].qty+",";	
		cookie_txt+=orderarray[i0].val+",";	
	}	
	register(cookie_txt,"pSize")
	
}

function AddToOrder(pHtm,pName,pImg,pItem,pQty,pVal) {
	//alert("in add to order");
	//var count=getCookie("pSize");
	//alert("Count = "+count);
	var temp_str="";
	var str_total="";
	var textline="";
	//temp_str=pHtm+","+pName+","+pImg+","+pItem+","+pQty+","+pVal;
	//register(temp_str);
	//alert(temp_str);
	if (parseInt(pQty,10)>=0) {
		var found=0;
		//alert("pQty = "+pQty)
		//tink this looks to see if item in array already......
		for (var i0=0;i0<count;i0++) {
			//alert("Array 0 = "+orderarray[0].item)
			if (pItem.toUpperCase()==orderarray[i0].item.toUpperCase()) {
				//alert(orderarray[i0].qty)
				orderarray[i0].qty=parseInt(pQty,10);
				found=1;
			}
		}
		if (found==0) orderarray[count++]=new orderline(pHtm,pName,pImg,pItem,pQty,pVal);

		var total=0;
		var items=0;
		for (var i0=0;i0<count;i0++) {
			items+=orderarray[i0].qty;
			total+=orderarray[i0].val*orderarray[i0].qty;
		}
		//alert(count);
		//alert("orderarray length = "+orderarray.length);
		WriteCookie()
		textline="Basket Contents ";
		textline+=count;
		textline+=" Product Line(s) & ";
		textline+=items;
		textline+=" Items, Value = ";
		temp_str="£"+total;
		str_total=temp_str.substring(0,temp_str.length-2)+"."+temp_str.substring(temp_str.length-2,temp_str.length)
		textline+=str_total;
		//alert(textline);
		document.temp.tline.value=textline
		}
}

function InfoLine() {
		var total=0;
		var items=0;
		for (var i0=0;i0<count;i0++) {
			//alert("infoline i0 = "+ i0)
			items+=orderarray[i0].qty;
			total+=orderarray[i0].val*orderarray[i0].qty;
		}
		textline="Basket Contents ";
		textline+=count;
		textline+=" Product Line(s) & ";
		textline+=items;
		textline+=" Items, Value = ";
		temp_str="£"+total;
		str_total=temp_str.substring(0,temp_str.length-2)+"."+temp_str.substring(temp_str.length-2,temp_str.length);
		textline+=str_total;
		//alert(textline);
		document.temp.tline.value=textline;
}

function WTRPageHeader()
{var text="<TABLE width=900 bgColor=#ffffff border=0>";
 	text+="<TR>";
    	text+="<TD width=33>&nbsp;</TD>";
    	text+="<TD width=112 height=107>";
      		text+="<IMG height=90 alt=ms src='images/mbstarGr.jpg' width=124>";
    	text+="</TD>";
    	text+="<TD width=566>";
    		text+="<IMG src='images/tp1.gif' width=40 height=1>";
    		text+="<IMG src='images/logo.jpg' width=460>";
    	text+="</TD>";
    	text+="<TD width=115>";
      		text+="<IMG src='images/tp1.gif' width=20 height=1>";
      		text+="<IMG src='images/tp1.gif' height=90 width=84>";
    	text+="</TD>";
    	text+="<TD width=49>&nbsp;</TD>";
  text+="</TR>";
text+="</TABLE>";
return text;
}

function WTRMenuBar()
{var text="<TABLE width=920 bgColor=#C9CACB border=0>";
	text+="<TR>";
		text+="<TD colspan=99><IMG src='images/tp1.gif' width=890 height=5></TD>";
	text+="</TR>";
	text+="<TR>";
		text+="<TD align='center'><A class=g href='index.htm'><B>Home</A></TD>";
		text+="<TD align='center'><A class=g href='contact.htm'><B>Contact Us</A></TD>";
		text+="<TD align='center'><A class=rg href='viewbook.htm'><B>View/Book<BR>Vehicle</A></TD>";
		text+="<TD align='center'><A class=g href='tiverton.htm'><B>Body Building<BR>& Repair</A></TD>";
		text+="<TD align='center'><A class=g href='profile.htm'><B>Company<BR>Profile</A></TD>";
		text+="<TD align='center'><A class=g href='selfdrivehire.htm'><B>Daily/Short<BR>Term Hire</A></TD>";
		text+="<TD align='center'><A class=g href='longhire.htm'><B>Long Term<BR>Hire</A></TD>";
		text+="<TD align='center'><A class=g href='contract.htm'><B>Contract<BR>Hire</A></TD>";
		text+="<TD align='center'><A class=g href='fleetsales.htm'><B>Sales<BR>Vehicles</A></TD>";
		text+="<TD align='center'><A class=g href='service.htm'><B>Commercial Servicing<BR>& Repair</A></TD>";
	text+="</TR>";
	text+="<TR>";
		text+="<TD colspan=99><IMG src='images/tp1.gif' width=890 height=5></TD>";
	text+="</TR>";
text+="</TABLE>";
return text;
}


function page_footer()
{	var text= "<CENTER>";
	text+="<BR><BR>";
	text+="<HR width=500 size=1 color=#0000FF>";
	text+="<TABLE width=410 border=0>";
	text+="<TR>";
		text+="<TD width=80 align=center><A href='home.htm'><H3>Home</A></TD>";
		text+="<TD><H3>|</TD>";
		text+="<TD width=80 align=center><A href='cd.htm'><H3>CD's</A></TD>";
		text+="<TD><H3>|</TD>";
		text+="<TD width=80 align=center><A href='dvd.htm'><H3>DVD's</A></TD>";
		text+="<TD><H3>|</TD>";
		text+="<TD width=80 align=center><A href='cartridge.htm'><H3>Cartridge's</A></TD>";
		text+="<TD><H3>|</TD>";
		text+="<TD width=80 align=center><A href='hardware.htm'><H3>Hardware</A></TD>";
	text+="</TR>";
	text+="<TR>";
		text+="<TD width=80 align=center><A href='services.htm'><H3>Service's</TD>";
		text+="<TD><H3>|</TD>";
		text+="<TD width=80 align=center><A href='label.htm'><H3>Label's</A></TD>";
		text+="<TD><H3>|</TD>";
		text+="<TD width=80 align=center><A href='cases.htm'><H3>Case's</A></TD>";
		text+="<TD><H3>|</TD>";
		text+="<TD width=80 align=center><A href='contact.htm'><H3>Contact</A></TD>";
		text+="<TD><H3>|</TD>";
		text+="<TD width=80 align=center><A href='home.htm'><H3>Home</A></TD>";
	text+="</TR>";
text+="</TABLE>";
text+="<HR width=500 size=1 color=#0000FF>";
text+="<BR><BR>";
text+="</CENTER>";
return text;
}

function left_menu()
{	var text="<TABLE cellpadding=0 cellspacing=0 width=156 border=1 bgcolor='#FFFFFF' bordercolor='#6995D2'>";
		text+="<TR>";
			text+="<TD>";
				text+="<TABLE cellpadding=0 cellspacing=0 border=0 align='center'>";
					text+="<TR>";
						text+="<TD align='center'><IMG src='images/tp1.gif' height=3></TD>";
					text+="</TR>";
					text+="<TR>";
						text+="<TD align='center'><IMG src='images/main.gif'></TD>";
					text+="</TR>";
					text+="<TR>";
						text+="<TD align='center'><IMG src='images/tp1.gif' height=1></TD>";
					text+="</TR>";
					text+="<TR>";
						text+="<TD>";
							text+="<UL>";
								text+="<LI><A href='index.htm'>Home</A>";
								text+="<LI><A href='contact.htm'>Contact Us</A>";
								text+="<LI><A href='about.htm'>About Us</A>";
							text+="</UL>";
						text+="</TD>";
					text+="</TR>";
					text+="<TR>";
						text+="<TD align='center'><IMG src='images/web.gif'></TD>";
					text+="</TR>";
					text+="<TR>";
						text+="<TD align='center'><IMG src='images/tp1.gif' height=1></TD>";
					text+="</TR>";
					text+="<TR>";
						text+="<TD>";
							text+="<UL>";
								text+="<LI><A href='webd.htm'>Web Design</A>";
								text+="<LI><A href='webp.htm'>Web Site Prices</A>";
								text+="<LI><A href='host.htm'>Hosting</A>";
								text+="<LI><A href='blog.htm'>Blogging</A>";
							text+="</UL>";
						text+="</TD>";
					text+="</TR>";
					text+="<TR>";
						text+="<TD align='center'><IMG src='images/consult.gif'></TD>";
					text+="</TR>";
					text+="<TR>";
						text+="<TD align='center'><IMG src='images/tp1.gif' height=1></TD>";
					text+="</TR>";
					text+="<TR>";
						text+="<TD>";
							text+="<UL>";
								text+="<LI><A href='network.htm'>Networks</A>";
								text+="<LI><A href='hardware.htm'>Hardware/Software</A>";
								text+="<LI><A href='data.htm'>Data Recovery</A>";
							text+="</UL>";
						text+="</TD>";
					text+="</TR>";
					text+="<TR>";
						text+="<TD align='center'><IMG src='images/tp1.gif' height=50 width=1></TD>";
					text+="</TR>";
					text+="<TR>";
						text+="<TD align='center'><IMG src='images/paypal120.gif'></TD>";
					text+="</TR>";
					text+="<TR>";
						text+="<TD align='center'><IMG src='images/tp1.gif' height=110 width=1></TD>";
					text+="</TR>";
				text+="</TABLE>";
			text+="</TD>";
		text+="</TR>";
	text+="</TABLE>";
return text;
}

function right_menu()
{	var text="<TABLE cellpadding=0 cellspacing=0 width=156 border=1 bgcolor='#FFFFFF' bordercolor='#6995D2'>";
			text+="<TR>";
				text+="<TD>";
					text+="<TABLE cellpadding=0 cellspacing=0 border=0 align='center'>";
						text+="<TR>";
							text+="<TD align='center'><IMG src='images/tp1.gif' height=3></TD>";
						text+="</TR>";
						text+="<TR>";
							text+="<TD align='center'><IMG src='images/blog.gif'></TD>";
						text+="</TR>";
						text+="<TR>";
							text+="<TD align='center'><IMG src='images/tp1.gif' height=10></TD>";
						text+="</TR>";
						text+="<TR>";
							text+="<TD align='left' fontsize=8>";
								text+="<A href='blog.htm'><IMG src='images/3free.gif' align='left' border=0></A>Try our starter Blog for 3 months free. Click <A href='blog.htm'>here</A> to start your Blog";
							text+="</TD>";
						text+="</TR>";
						text+="<TR>";
							text+="<TD align='center'><IMG src='images/tp1.gif' height=30></TD>";
						text+="</TR>";
						text+="<TR>";
							text+="<TD align='center'><IMG src='images/design.gif'></TD>";
						text+="</TR>";
						text+="<TR>";
							text+="<TD align='center'><IMG src='images/tp1.gif' height=10></TD>";
						text+="</TR>";
						text+="<TR>";
							text+="<TD align='left' fontsize=8>";
								text+="<IMG src='images/c4k.gif' align='left'>From new sites to re-designs & upgrades. HTML, XML, ASP, Perl, Javascript, CSS";
							text+="</TD>";
						text+="</TR>";
						text+="<TR>";
							text+="<TD align='center'><IMG src='images/tp1.gif' height=30></TD>";
						text+="</TR>";
						text+="<TR>";
							text+="<TD align='center'><IMG src='images/software.gif'></TD>";
						text+="</TR>";
						text+="<TR>";
							text+="<TD align='center'><IMG src='images/tp1.gif' height=10></TD>";
						text+="</TR>";
						text+="<TR>";
							text+="<TD align='left' fontsize=8>";
								text+="<IMG src='images/hpclogo.gif' align='left'>We specialise in bespoke software and reporting. Over 25 years experience. VB, Java, C, Delphi, Assembler etc..... ";
							text+="</TD>";
						text+="</TR>";
						text+="<TR>";
							text+="<TD align='center'><IMG src='images/tp1.gif' height=30></TD>";
						text+="</TR>";
						text+="<TR>";
							text+="<TD align='center'><IMG src='images/our.jpg'></TD>";
						text+="</TR>";
						text+="<TR>";
							text+="<TD align='center'><IMG src='images/tp1.gif' height=10></TD>";
						text+="</TR>";
						text+="<TR>";
							text+="<TD align='left' fontsize=8>";
								text+="<IMG src='images/hpclogo.gif' align='left'>Currently we have available a range of programs for Data Reporting, Stock Control & Electronic Calculations. <A href='contact.htm'>Contact us for details</A>";
							text+="</TD>";
						text+="</TR>";
						text+="<TR>";
							text+="<TD><IMG src='images/tp1.gif' width=1 height=20 rowspan=99></TD>";
						text+="</TR>";
					text+="</TABLE>";
				text+="</TD>";
			text+="</TR>";
		text+="</TABLE>";
return text;
}

function page_title()
{	return "<TITLE>Western Truck Rental</TITLE>";
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}



function preloadImages() {
	if (document.images) {
		menubar_01_over = newImage("images/menubar_01_over.gif");
		menubar_02_over = newImage("images/menubar_02_over.gif");
		menubar_03_over = newImage("images/menubar_03_over.gif");
		menubar_04_over = newImage("images/menubar_04_over.gif");
		menubar_05_over = newImage("images/menubar_05_over.gif");
		menubar_06_over = newImage("images/menubar_06_over.gif");
		preloadFlag = true;
	}
}

