// This file is Copyright (C) 2006-2010 Daniel James
// All rights reserved.

window._error=false;
function showerror(message) {
	if(window._error==false){
		window._error=new Object();
		var obj=window._error;
		obj.error=document.createElement("div");
		obj.error.id='error';
		obj.w=document.createElement("div");
		obj.w.id="errorwindow";
		obj.text=document.createElement('div');
		obj.text.id='errortext';
		obj.w.appendChild(obj.text);
		obj.error.appendChild(obj.w);
		var form=document.createElement('form');
		form.onsubmit=function() {
			return false;
		}
		var ele=document.createElement('div');
		ele.className="right";
		var c=document.createElement('input');
		c.type="button";
		c.value="Ok";
		c.onclick=function(){
			obj.error.style.display="none";
			return false;
		}
		ele.appendChild(c);
		form.appendChild(ele);
		obj.w.appendChild(form);
		document.body.appendChild(obj.error);
	}
	var obj=window._error;
	obj.text.innerHTML=message.replace(/\n/g,'<br />');
	obj.error.style.display="block";
}
window._loading=false;
function loading(message){
	if(window._loading==false){
		window._loading=new Object();
		var obj=window._loading;
		obj.loading=document.createElement("div");
		obj.loading.id='loading';
		obj.w=document.createElement("div");
		obj.w.id="loadwindow";
		obj.loading.appendChild(obj.w);
		document.body.appendChild(obj.loading);
	}
	var obj=window._loading;
	if(typeof(message)=='string'){
		obj.w.innerHTML=message;
		obj.loading.style.display="block";
	}else{
		obj.loading.style.display='none';
	}
}
function gm(){
	if(google.setOnLoadCallback) {
		var obj=this;
		this.m={};
		google.setOnLoadCallback(function(){
			obj.loadgmaps();
		});
		google.load("maps","2.123",{"other_params":"sensor=false"});
		this.showdiv=false;
		this.tooltipdiv=false;
		this.layout=document.getElementById('layout');
		this.httpreq=false;
	}
}
gm.prototype={
inithttpreq:function(){
	try { return new XMLHttpRequest(); } catch(e){ }
  try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch(e){ }
	try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch(e){ }
	try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e){ }
	try { return ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ }
	return false;
},show:function(id,ll){
	var obj=this,ele,a;
	if(this.showdiv == false){
		ele=document.createElement("div");
		ele.id="sitepreload";
		document.body.appendChild(ele);
		ele=document.createElement("div");
		ele.id="emailpreload";
		document.body.appendChild(ele);
		this.dim=document.createElement("div");
		this.dim.id='dim';
		document.body.appendChild(this.dim);
		this.showdiv=document.createElement("div");
		this.showdiv.id='sitecard';
		this.showdiv.style.top='20px';
		this.showdiv.style.position='absolute';
		this.showdiv.style.display='none';
		this.showdiv.style.zIndex='5';
		this.headdiv=document.createElement('div');
		this.headdiv.id='buttons';
		a=document.createElement('a');
		a.className="close";
		ele=document.createElement('span');
		a.href='#';
		a.onclick=function(){
			return obj.closewindow();
		}
		ele.appendChild(document.createTextNode('X Close Sitecard'));
		a.appendChild(ele);
		this.headdiv.appendChild(a);
		/*this.emaila=document.createElement('a');
		this.emaila.className="email";
		ele=document.createElement('span');
		this.emaila.href='#';
		this.emaila.onclick=function(){
			return sendviaemail(this.sitenumber);
		}
		ele.appendChild(document.createTextNode('Send Via Email'));
		this.emaila.appendChild(ele);
		this.headdiv.appendChild(this.emaila);*/
		this.contacta=document.createElement('a');
		this.contacta.className="email";
		ele=document.createElement('span');
		this.contacta.href='#';
		this.contacta.onclick=function(){
			return contactus(this.sitenumber,this.title);
		}
		ele.appendChild(document.createTextNode('Contact Us'));
		this.contacta.appendChild(ele);
		this.headdiv.appendChild(this.contacta);
		this.showdiv.appendChild(this.headdiv);
		var ele=document.createElement('div');
		ele.id='image';
		this.image=document.createElement('div');
		ele.appendChild(this.image);
		this.showdiv.appendChild(ele);
		this.maps=document.createElement('div');
		this.maps.id='maps';
		this.map1=document.createElement('a');
		this.map1.href='#';
		this.map1.onclick=function(){
			obj.closewindow();
			obj.map.setCenter(new google.maps.LatLng(this.la,this.ln),11);
			return false;
		}
		this.maps.appendChild(this.map1);
		this.map2=document.createElement('a');
		this.map2.href='#';
		this.map2.onclick=function(){
			obj.closewindow();
			obj.map.setCenter(new google.maps.LatLng(this.la,this.ln),7);
			return false;
		}
		this.maps.appendChild(this.map2);
		this.showdiv.appendChild(this.maps);
		this.foot=document.createElement('div');
		this.foot.id='foot';
		this.showdiv.appendChild(this.foot);
		document.body.appendChild(this.showdiv);
	}
	var height=window.innerHeight && window.scrollMaxY?window.innerHeight+window.scrollMaxY:(document.body.scrollHeight>document.body.offsetHeight?document.body.scrollHeight:document.body.offsetHeight);
	var width=window.innerWidth && window.scrollMaxX?window.innerWidth+window.scrollMaxX:(document.body.scrollWidth>document.body.offsetWidth?document.body.scrollWidth:document.body.offsetWidth);
	//this.emaila.sitenumber=id;
	this.contacta.sitenumber=id;
	this.map.disableScrollWheelZoom();
	this.dim.style.width=width+'px';
	this.dim.style.height=height+'px';
	this.dim.style.display="block";
	loading("Loading Sitecard...");
	this.showdiv.style.left=(width>812?((width-812)/2):10)+'px';
	this.curimg=new Image();
	var map1=new Image();
	var map2=new Image();
	var ln,la=ll.split(',');
	ln=la[1];
	la=la[0];
	this.map1.la=la;
	this.map2.la=la;
	this.map1.ln=ln;
	this.map2.ln=ln;
	if(this.image.childNodes[0]){
		this.image.replaceChild(this.curimg,this.image.childNodes[0]);
		this.map1.replaceChild(map1,this.map1.childNodes[0]);
		this.map2.replaceChild(map2,this.map2.childNodes[0]);
	} else {
		this.image.appendChild(this.curimg);
		this.map1.appendChild(map1);
		this.map2.appendChild(map2);
	}
	this.parts=4;
	function hookup(img){
		if(typeof(img.complete)!='undefined'){
			img.onload=function(){
				obj.showsitecard();
			}
			img.onerror=function(){
				obj.showsitecard();
			}
		} else {
			obj.showsitecard();
		}
	}
	hookup(map1);
	hookup(map2);
	hookup(this.curimg);
	this.curimg.src="/card.nb?nb%5Bop%5D=image&nb%5Bid%5D="+id+"&nb%5Bsize%5D=1";
	map1.src='http://maps.google.com/staticmap?markers='+ll+',midblue&zoom=11&size=192x196&maptype=roadmap&key='+gk+'&sensor=false';
	map2.src='http://maps.google.com/staticmap?markers='+ll+',midblue&zoom=7&size=192x196&maptype=roadmap&key='+gk+'&sensor=false';

	if(this.httpreq===false){
		this.httpreq=this.inithttpreq();
	}else if(this.httpreq){
		this.httpreq.abort();
	}
	if(this.httpreq){
		var obj=this;
		this.httpreq.open('GET','card.nb?data=1&id='+id,true);
		this.httpreq.onreadystatechange=function(){
			if(obj.httpreq.readyState==4){
				if(obj.httpreq.status==200){
					var dat=eval('('+obj.httpreq.responseText+')');
					if(dat){
						obj.contacta.title=dat.detail.rtitle;
						obj.foot.innerHTML="<h1>"+dat.detail.title+"</h1><dl><dt>Size:</dt><dd>"+dat.detail.size+"</dd><dt>Illumination:</dt><dd>"+(dat.detail.light?'Yes':'No')+"</dd><dt>Direction:</dt><dd>"+dat.detail.dir+"</dd><dt>Traffic Flow:</dt><dd>"+dat.detail.flow+" Per Day</dd><dt>Location:</dt><dd>"+dat.detail.loc+"</dd></dl>";
						obj.showsitecard();
					}else{
						obj.closewindow();
						showerror("Sorry, Sitecard is not available for this billboard.");
					}
				} else {
					obj.closewindow();
					showerror("Sorry, an error occured while loading the sitecard. Please try again.");
				}
			}
		}
		this.httpreq.send(null);
	}
	return false;
},findandshow:function(id,lat,lng){
	var obj=this;
	id=id.replace('/','')
	this.map.setCenter(new google.maps.LatLng(lat,lng),17);
	if(this.m[id]){
		setTimeout(function(){
			google.maps.Event.trigger(obj.m[id],'click');
		},1000);
	}
	this.show(id,lat+","+lng);
},showsitecard:function(){
	this.parts --;
	if(!this.parts){
		loading();
		this.showdiv.style.display='block';
	}
},closewindow:function(){
	this.showdiv.style.display='none';
	loading();
	this.dim.style.display='none';
	this.map.enableScrollWheelZoom();
	return false;
},showtooltip:function(){
	//'this'=marker
	var obj=gmi;
	var point=obj.map.fromLatLngToContainerPixel(this.getLatLng());
	if(!obj.tooltipdiv){
		obj.tooltipdiv=document.createElement('div');
		obj.tooltipdiv.className='tooltipdiv';
		obj.layout.appendChild(obj.tooltipdiv);
		obj.tooltipreset=true;
		obj.tooltipresettimer=false;
	}
	obj.tooltipdiv.style.left=(point.x+50)+'px';
	obj.tooltipdiv.style.top=(point.y+20)+'px';
	if(obj.tooltiptimer){
		clearTimeout(obj.tooltiptimer);
	}
	obj.tooltipdiv.innerHTML=this.nb_tooltip;
	if(obj.tooltipreset){
		obj.tooltiptimer=setTimeout(function(){
			obj.tooltiptimer=false;
			obj.tooltiptimeout();
		},500)
	} else {
		if(obj.tooltipresettimer){
			clearTimeout(obj.tooltipresettimer);
			obj.tooltipresettimer=false;
		}
		obj.tooltiptimeout();
	}
},tooltiptimeout:function(obj){
	this.tooltipdiv.style.display="block";
	this.tooltipreset=false;
},hidetooltip:function(){
	var obj=gmi;
	if(obj.tooltiptimer){
		clearTimeout(obj.tooltiptimer);
		obj.tooltiptimer=false;
	}
	if(obj.tooltipresettimer){
		clearTimeout(obj.tooltipresettimer);
	}
	obj.tooltipresettimer=setTimeout(function(){
		obj.tooltipresettimeout();
	},100);
	obj.tooltipdiv.style.display="none";
},tooltipresettimeout:function(){
	this.tooltipresettimer=false;
	this.tooltipreset=true;
},zoomtogroup:function(){
	gmi.map.setCenter(this.getPoint());
	if(gmi.map.getZoom() == this.nb_zf){
		gmi.map.zoomIn();
	} else {
		gmi.map.setZoom(this.nb_zf+1);
	}
},loadgmaps:function(){
	var mapele=document.getElementById('map');
	this.map=new google.maps.Map2(mapele,{logoPassive:true});

	var bm=new google.maps.Icon(G_DEFAULT_ICON);
	bm.image="/paradise/style/images/bmarker.png";

	this.map.addControl(new google.maps.LargeMapControl());
	this.map.addControl(new google.maps.MapTypeControl());
	this.map.setCenter(new google.maps.LatLng(-27,136),1,G_NORMAL_MAP);

	var man=new google.maps.MarkerManager(this.map,{borderPadding:100});

	this.map.addMapType(G_PHYSICAL_MAP);

	this.map.enableContinuousZoom();
	this.map.enableScrollWheelZoom();

	var markers=new Array(),x,lat=0,lng=0,ct=s.length,nm=0,m,h,l,y,tt;
	for (x=0; x < ct; x ++){
		if(typeof(s[x]) == 'number'){
			man.addMarkers(markers,s[x]);
			markers=new Array();
		} else {
			nm++; lat += s[x][0]; lng += s[x][1]; l=s[x][2].split(',');

			h='<div>Click on '+(l.length==1?'the':'an')+' image below to view a larger version</div><table border="0" cellpadding="0" cellspacing="0" class="gmgal"><tr>';
			z=0;
			for (y=0; y < l.length; y++){
				z ++;
				if(z == 5){ z=1; h += '</tr><tr>'; }
				h += '<td><a href="" onclick="return gmi.show(\''+l[y]+'\',\''+s[x][0]+','+s[x][1]+'\')"><img src="/billboard_locations.nb?nb%5Bop%5D=image&nb%5Bid%5D='+l[y]+'&nb%5Bsize%5D=2" width="120" height="90" /></a></td>';
			}
			if(y > 3){
				while (z < 4){ h+= '<td></td>'; z ++; }
			}
			h += '</tr></table>';
			tt=l[0];
			last=tt.substr(tt.length - 1,1);
			if((last == 'E') || (last == 'W') || (last='N') || (last='S')){
				tt=tt.substr(0,tt.length - 1);
			}
			m=new GMarker(new google.maps.LatLng(s[x][0],s[x][1]),{clickable:true,icon:bm});
			m.nb_tooltip=tt;
			m.bindInfoWindowHtml(h);
			for (y=0; y < l.length; y++){
				this.m[l[y]]=m;
			}
			google.maps.Event.addListener(m,"mouseover",gmi.showtooltip);
			google.maps.Event.addListener(m,"mouseout",gmi.hidetooltip);
			markers[markers.length]=m;
		}
	}
	ct=g.length;
	for (x=0; x < ct; x ++){
		if(typeof(g[x]) == 'number'){
			var yct;
			for (y=0,yct=markers.length; y<yct; y++){
				markers[y].nb_zf=g[x+1];
			}
			man.addMarkers(markers,g[x],g[x+1]);
			x++;
			markers=new Array();
		} else {
			m=new GMarker(new google.maps.LatLng(g[x][0],g[x][1]),{clickable:true,icon:G_DEFAULT_ICON});
			m.nb_tooltip=g[x][2]+" billboards at this location";
			google.maps.Event.addListener(m,"click",gmi.zoomtogroup);
			google.maps.Event.addListener(m,"mouseover",gmi.showtooltip);
			google.maps.Event.addListener(m,"mouseout",gmi.hidetooltip);
			markers[markers.length]=m;
		}
	}
	man.refresh();
	lat /= nm;
	lng /= nm;
	if(ll){
		ll=ll.split(',');
		lat=ll[0];
		lng=ll[1];
	}
	this.map.setCenter(new google.maps.LatLng(lat,lng),zo,G_NORMAL_MAP);
	setTimeout(function(){
		mapele.parentNode.style.backgroundImage='none';
	},2000);
}
}
if(typeof(google)!='undefined'){
	window.gmi=new gm();
}
window._senddialog=false;
function sendviaemail(n){
	function createdialog(){
		window._senddialog=new Object();
		var obj=window._senddialog;
		obj.bg=document.createElement('div');
		obj.bg.id='emailbg';
		document.body.appendChild(obj.bg);
		obj.w=document.createElement('div');
		obj.w.id='emailouter';
		obj.d=document.createElement('div');
		obj.d.id='emaildialog';
		var ele=document.createElement('h1');
		ele.appendChild(document.createTextNode('Send Sitecard Via Email'));
		obj.d.appendChild(ele);
		var form=document.createElement('form');
		obj.httpreq=false;
		form.onsubmit=function(){
			if(!obj.r.value){
				showerror("Please enter the Recipient's Name.");
				obj.r.focus();
			}else if(obj.i.value){
				if(/^([-a-zA-Z0-9_.+]+@[-a-zA-Z0-9_]+(\.[-a-zA-Z0-9_]+)+)$/.test(obj.i.value)){
					if(obj.httpreq===false){
						if(window.gmi){
							if(window.gmi.httpreq===false){
								window.gmi.httpreq=window.gmi.inithttpreq();
							}
							obj.httpreq=window.gmi.httpreq;
						}else{
							obj.httpreq=gm.prototype.inithttpreq();
						}
					}else if(obj.httpreq){
						obj.httpreq.abort();
					}
					if(obj.httpreq){
						obj.httpreq.open("GET", '/card.nb?op=httpreq&to='+escape(obj.i.value)+'&card='+obj.n.value+'&detail='+escape(obj.a.value)+'&name='+escape(obj.r.value),true);
						obj.httpreq.onreadystatechange=function(){
							if(obj.httpreq.readyState==4){
								loading();
								showerror(obj.httpreq.responseText);
							}
						}
						obj.w.style.display="none";
						obj.bg.style.display="none";
						loading("Sending Sitecard...");
						obj.httpreq.send(null);
					}else{
						window.location.href='/card.nb?op=send&to='+escape(obj.i.value)+'&card='+obj.n.value+'&detail='+escape(obj.a.value)+'&name='+escape(obj.r.value);
					}
				}else{
					showerror("Sorry. The email address you entered was not valid, please try again.");
					obj.i.focus();
				}
			}else{
				showerror("Please enter the email address you wish to send this card to.");
				obj.i.focus();
			}
			return false;
		}
		ele=document.createElement('div');
		var c=document.createElement('span');
		c.appendChild(document.createTextNode('Recipient Name: '));
		ele.appendChild(c);
		obj.r=document.createElement('input');
		obj.r.type="text";
		obj.r.name="name";
		obj.r.className="ti";
		ele.appendChild(obj.r);
		c=document.createElement('div');
		c.className='fix';
		ele.appendChild(c);
		form.appendChild(ele);
		ele=document.createElement('div');
		c=document.createElement('span');
		c.appendChild(document.createTextNode('Recipient Email: '));
		ele.appendChild(c);
		obj.i=document.createElement('input');
		obj.i.type="text";
		obj.i.name="to";
		obj.i.className="ti";
		ele.appendChild(obj.i);
		c=document.createElement('div');
		c.className='fix';
		ele.appendChild(c);
		form.appendChild(ele);
		ele=document.createElement('div');
		ele.appendChild(document.createTextNode('Extra Detail (optional):'));
		obj.a=document.createElement('textarea');
		obj.a.name="detail";
		obj.a.maxLength=900;
		ele.appendChild(obj.a);
		form.appendChild(ele);
		ele=document.createElement('div');
		ele.className="right";
		c=document.createElement('input');
		c.type="submit";
		c.value="Send";
		ele.appendChild(c);
		c=document.createElement('input');
		c.type="button";
		c.value="Cancel";
		c.onclick=function(){
			if(((obj.i.value=='')&&(obj.r.value=='')&&(obj.a.value==''))||confirm("Are you sure you want to cancel sending this email?")){
				obj.bg.style.display="none";
				obj.w.style.display="none";
			}
			return false;
		}
		ele.appendChild(c);
		form.appendChild(ele);
		obj.n=document.createElement('input');
		obj.n.type="hidden";
		form.appendChild(obj.n);
		obj.d.appendChild(form);
		obj.w.appendChild(obj.d);
		document.body.appendChild(obj.w);
	}
	if(window._senddialog==false){
		createdialog();
	}
	var obj=window._senddialog;
	var height=window.innerHeight && window.scrollMaxY?window.innerHeight+window.scrollMaxY:(document.body.scrollHeight>document.body.offsetHeight?document.body.scrollHeight:document.body.offsetHeight);
	var width=window.innerWidth && window.scrollMaxX?window.innerWidth+window.scrollMaxX:(document.body.scrollWidth>document.body.offsetWidth?document.body.scrollWidth:document.body.offsetWidth);
	obj.r.value='';
	obj.i.value='';
	obj.a.value='';
	obj.n.value=n;
	obj.bg.style.width=width+'px';
	obj.bg.style.height=height+'px';
	obj.bg.style.display="block";
	obj.w.style.display="block";
	obj.r.focus();
	return false;
}
window._contactdialog=false;
function contactus(n,s){
	function createField(lab,nam) {
		var ele=document.createElement('div');
		var c=document.createElement('span');
		c.appendChild(document.createTextNode(lab+': '));
		ele.appendChild(c);
		var input;
		try {
			input=document.createElement('<input type="text" name="'+nam+'"/>');
		} catch(e) {
			input=document.createElement('input');
			input.type="text";
			input.name=nam;
		}
		input.className="ti";
		ele.appendChild(input);
		c=document.createElement('div');
		c.className='fix';
		ele.appendChild(c);
		return ele;
	}
	function createdialog(){
		window._contactdialog=new Object();
		var obj=window._contactdialog;
		obj.bg=document.createElement('div');
		obj.bg.id='contactbg';
		document.body.appendChild(obj.bg);
		obj.w=document.createElement('div');
		obj.w.id='contactouter';
		obj.d=document.createElement('div');
		obj.d.id='contactdialog';
		var ele=document.createElement('h1');
		ele.appendChild(document.createTextNode('Contact Us'));
		ele.style.marginBottom="5px";
		obj.d.appendChild(ele);
		ele=document.createElement('div');
		ele.appendChild(document.createTextNode('Feel free to call us on 07 4758 4613 or fill in the form below to contact us.'));
		ele.style.marginBottom="5px";
		obj.d.appendChild(ele);
		ele=document.createElement('div');
		ele.appendChild(document.createTextNode('All fields are mandatory. Please enter N/A for fields that are not applicable / non-existent.'));
		obj.d.appendChild(ele);
		var form=document.createElement('form');
		form.method="post";
		form.action="card.nb";
		obj.form=form;
		obj.httpreq=false;
		form.onsubmit=function(){
			var c=[['givenname',/./,'Please enter your First Name'],
			['surname',/./,'Please enter your Surname'],
			['position',/./,'Please enter your Position'],
			['from',/./,'Please enter your Email Address'],
			['from',/^([-a-zA-Z0-9_.+]+@[-a-zA-Z0-9_]+(\.[-a-zA-Z0-9_]+)+)?$/,'Your email address was not valid, please try again'],
			['company',/./,'Please enter your Company Name'],
			['address',/./,'Please enter your Address'],
			['suburb',/./,'Please enter your Suburb/City'],
			['postcode',/./,'Please enter your Postcode'],
			['phone',/./,'Please enter your Phone Number'],
			['phone',/^[- +0-9()]*$/,'Your phone number was not valid, please try again'],
			['fax',/./,'Please enter your Fax Number'],
			['mobile',/./,'Please enter your Mobile Number'],
			['mobile',/^[- +0-9()]*$/,'Your mobile number was not valid, please try again'],
			['detail',/./,'Please enter a Message']];
			var x,err,foc=false,ct=0;
			for(x=c.length-1;x>=0;x--){
				if(!c[x][1].test(this[c[x][0]].value)){
					if(ct){
						err=c[x][2]+"\n"+err;
					}else{
						err=c[x][2];
					}
					foc=c[x][0];
					ct++;
				}
			}
			if(ct){
				if(ct==1){
					showerror(err);
				}else{
					showerror("Sorry, there were problems with the information you provided:\n"+err);
				}
				this[foc].focus();
				return false;
			}
			if(obj.httpreq===false){
				if(window.gmi){
					if(window.gmi.httpreq===false){
						window.gmi.httpreq=window.gmi.inithttpreq();
					}
					obj.httpreq=window.gmi.httpreq;
				}else{
					obj.httpreq=gm.prototype.inithttpreq();
				}
			}else if(obj.httpreq){
				obj.httpreq.abort();
			}
			if(obj.httpreq){
				obj.httpreq.open("POST", '/card.nb', true);
				obj.httpreq.onreadystatechange=function(){
					if(obj.httpreq.readyState==4){
						loading();
						showerror(obj.httpreq.responseText);
					}
				}
				obj.w.style.display="none";
				obj.bg.style.display="none";
				loading("Sending Message...");
				var x,ct,params='op=httpcontact';
				ct=obj.form.elements.length;
				for(x=0;x<ct;x++) {
					params+='&'+obj.form.elements[x].name+'='+escape(obj.form.elements[x].value);
				}
				obj.httpreq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				obj.httpreq.setRequestHeader("Content-length", params.length);
				obj.httpreq.setRequestHeader("Connection", "close");
				obj.httpreq.send(params);
			}else{
				var i;
				try {
					i = document.createElement('<input type="hidden" name="op"/>');
				} catch(e) {
					i = document.createElement('input');
					i.type="hidden";
					i.name="op";
				}
				i.value="contact";
				obj.form.appendChild(i);
				return true;
			}
			return false;
		}
		form.appendChild(createField('First Name', 'givenname'));
		form.appendChild(createField('Surname', 'surname'));
		form.appendChild(createField('Position', 'position'));
		form.appendChild(createField('Your Email', 'from'));
		form.appendChild(createField('Company Name', 'company'));
		form.appendChild(createField('Address', 'address'));
		form.appendChild(createField('Suburb/City', 'suburb'));
		ele = document.createElement('div');
		c=document.createElement('span');
		c.appendChild(document.createTextNode('State: '));
		ele.appendChild(c);
		try {
			c=document.createElement('<select name="state" size="1"/>');
		} catch(e) {
			c=document.createElement('select');
			c.name='state';
			c.size='1';
		}
		var ss=['ACT','NSW','NT','QLD','SA','TAS','VIC','WA'];
		for(x=0; x<8; x++) {
			var no=new Option(ss[x],ss[x]);
			c.options[x]=no;
		}
		c.className='si';
		ele.appendChild(c);
		c=document.createElement('div');
		c.className='fix';
		ele.appendChild(c);
		form.appendChild(ele);
		form.appendChild(createField('Postcode', 'postcode'));
		form.appendChild(createField('Phone', 'phone'));
		form.appendChild(createField('Fax', 'fax'));
		form.appendChild(createField('Mobile', 'mobile'));
		ele=document.createElement('div');
		ele.appendChild(document.createTextNode('Enter a Message:'));
		try {
			obj.a=document.createElement('<textarea name="detail"/>');
		} catch(e) {
			obj.a=document.createElement('textarea');
			obj.a.name="detail";
		}
		ele.appendChild(obj.a);
		form.appendChild(ele);
		ele=document.createElement('div');
		ele.className="right";
		c=document.createElement('input');
		c.type="submit";
		c.value="Send";
		ele.appendChild(c);
		c=document.createElement('input');
		c.type="button";
		c.value="Cancel";
		c.onclick=function(){
			if (confirm("Are you sure you want to cancel sending this message?")) {
				obj.bg.style.display="none";
				obj.w.style.display="none";
			}
			return false;
		}
		ele.appendChild(c);
		form.appendChild(ele);
		try {
			obj.n=document.createElement('<input type="hidden" name="card"/>');
		} catch(e) {
			obj.n=document.createElement('input');
			obj.n.type="hidden";
			obj.n.name="card";
		}
		form.appendChild(obj.n);
		obj.d.appendChild(form);
		obj.w.appendChild(obj.d);
		document.body.appendChild(obj.w);
	}
	if(window._contactdialog==false){
		createdialog();
	}
	var obj=window._contactdialog;
	var height=window.innerHeight && window.scrollMaxY?window.innerHeight+window.scrollMaxY:(document.body.scrollHeight>document.body.offsetHeight?document.body.scrollHeight:document.body.offsetHeight);
	var width=window.innerWidth && window.scrollMaxX?window.innerWidth+window.scrollMaxX:(document.body.scrollWidth>document.body.offsetWidth?document.body.scrollWidth:document.body.offsetWidth);
	obj.form['givenname'].value='';
	obj.form['surname'].value='';
	obj.form['position'].value='';
	obj.form['from'].value='';
	obj.form['company'].value='';
	obj.form['address'].value='';
	obj.form['suburb'].value='';
	obj.form['postcode'].value='';
	obj.form['phone'].value='';
	obj.form['fax'].value='';
	obj.form['mobile'].value='';
	obj.form['detail'].value='';
	obj.form['card'].value=n;
	obj.bg.style.width=width+'px';
	obj.bg.style.height=height+'px';
	obj.bg.style.display="block";
	obj.w.style.display="block";
	obj.form['givenname'].focus();
	return false;
}
