quote='"';
popup='popup';
empty='';
wopts = 'location=no,toolbar=no,status=no,menubar=no,resizable=yes,width=260,left=200,top=200,scrollbars=yes,height=';
wopts2 = 'location=no,toolbar=no,status=no,menubar=no,resizable=yes,width=500,left=100,top=100,scrollbars=yes,height=';
ropts = 'location=no,toolbar=no,status=no,menubar=no,resizable=yes,width=260,left=200,top=200,scrollbars=no,height=';
purl = '/prop.htm?t';

if( !window.XMLHttpRequest ) XMLHttpRequest = function(){
	try{ return new ActiveXObject("MSXML3.XMLHTTP") }catch(e){}
	try{ return new ActiveXObject("MSXML2.XMLHTTP.3.0") }catch(e){}
	try{ return new ActiveXObject("Msxml2.XMLHTTP") }catch(e){}
	try{ return new ActiveXObject("Microsoft.XMLHTTP") }catch(e){}
	alert('Your browser does not support XMLHTTP');
	return null;
}

function cancelEvent(e) {
	if (e && e.stopPropagation) e.stopPropagation(); else event.cancelBubble=true;
}

function newcpt() {
	window.open(empty,popup,wopts+360).focus();
}

function edit(e,id) {
	if (id)	{
		window.open('/prop.aspx?'+id,popup,wopts+360).focus();
		cancelEvent(e);
	}
}

function imgchg(id) {window.open('/images.aspx?i='+id,popup,wopts2+400).focus();}

function do_http(url) {
	var xmlHttp = new XMLHttpRequest();
	if (xmlHttp!=null) {
		xmlHttp.open('GET', url,false);
		xmlHttp.send(null);
		if (xmlHttp.reponseText!=null) alert(xmlHttp.responseText); else return true;
	}
}

function del(bt,pk,id) {
	if (confirm('Are you sure?')) {
		if (do_http('/del.aspx?table='+bt+'&'+pk+'='+id)) {
			if ((window.location.pathname+'?').indexOf('/'+id+'?')>-1 && document.referrer) window.location.replace(document.referrer);
			else window.location.replace(window.location.href);
		}
	}
}

function rate(me,id,r) {
	if (do_http('/rate.aspx?ID='+id+'&Rating='+r)) me.parentNode.style.backgroundImage='url(/Images/'+r+'star.gif)';
}

function rate2(me,id,r) {
	if (do_http('/rate.aspx?ID='+id+'&Rating='+r)) me.parentNode.className='StarRating'+r;
}

function approve(me,id) {
	do_http('/approve.aspx?ID='+id+'&Approved='+(me.checked?1:0));
}

var voted = '';
function vote(id) {
	if (do_http('/vote.aspx?ID='+id+voted)) window.location.replace(window.location.href);
}

function len(t,n) {
	if (n<0) n=100000;
	if (t.value.length>n) t.value=t.value.substr(0,n); //Maximum length is n
}

function key(e) {
	return (e.which||e.keyCode) != 60; //Don't allow <
}

function ifont(me) {
	me = me.parentNode.currentStyle;
	return me.fontStyle + ' ' + me.fontWeight + ' ' + me.fontSize + ' ' + me.fontFamily;
}

function checkForm(me) {
	var f;
	if (me.TandCs && !me.TandCs.checked) {alert('You must accept the Terms & Conditions'); return false;}
	for (var i=0; f=me[i]; i++) if (f.title.substr(0,1)=='*' && (f.value==null || f.value=='')) {alert('Please complete '+f.title.substr(1)); return false;}
}

var dragObject,dragHeader,xStart,dropLast;

function dinit(root) {
	if (root==null) {
		root=document;
		document.onmousedown=drag;
		document.onselectstart=function(e) {return !dragObject;};
		document.ondragstart=function(e) {return !dragObject;};
		document.onmouseup=dstop;
//		document.body.style.cursor='default';
	}
	var divs = root.getElementsByTagName('div'), tds=root.getElementsByTagName('td');
	for (var i=0; n=divs[i]; i++) if (n.id && n.className.substr(0,9)=='Item Move') {
		n.onmousemove=function(e) {dropon(e,this); return false;};
		if (document.images.sizer && n.title.indexOf('Styler')<0) n.onmouseover=function(e) {if (!dragObject) this.appendChild(document.images.sizer); cancelEvent(e);}
	}
	for (var i=0; n=tds[i]; i++) if (n.id) n.onmousemove=function(e) {dropon(e,this);};

	var tas = root.getElementsByTagName('textarea');
	for (var i=0;i<tas.length;i++) resize(tas[i]); // loop through all textareas sizing them
}

function dstop(e) {
	xStart = null;
	document.onmousemove = null;
	if (dragObject) {
		dragObject.className=dragObject.className.replace(' drag','');
		dragObject=null;
		dropLast=null;
		document.body.style.cursor='default';
	}
}

function drag(e) {
	var target = e ? e.target : window.event.srcElement;
	if (target==document.images.sizer) {xStart = (e ? e.clientX : window.event.clientX)-target.parentNode.offsetWidth; document.onmousemove = sizerMove;}
	if (target.nodeName=='IMG' || target.nodeName=='SPAN') target=target.parentNode;
	if (target.className.substr(0,9)!='Item Move') return true;
    dragObject = target;
	dragHeader = document.getElementById(target.id+'h');
	target.className += ' drag';
	document.body.style.cursor=xStart ? 'w-resize' : 'move';
	return false;
}

function dropon(e,me) {
	if (xStart) return;
	if (!dragObject || dragObject==me || dropLast==me) {cancelEvent(e); return;}
	if (me.parentNode.title.split(':')[0]==dragObject.parentNode.title.split(':')[0]) {
		dropLast=me;
		if (me.previousSibling==dragObject) me.parentNode.insertBefore(dragObject,me.nextSibling);
		else me.parentNode.insertBefore(dragObject,me);
		var myHeader = document.getElementById(me.id+'h');
		if (me.nodeName=='TD' && myHeader && dragHeader) {
			if (myHeader.previousSibling==dragHeader) myHeader.parentNode.insertBefore(dragHeader,myHeader.nextSibling);
			else myHeader.parentNode.insertBefore(dragHeader,myHeader);
		}
		cancelEvent(e);
	}
	else if (dragObject!=me.lastChild && me.title.split(':')[0]==dragObject.parentNode.title.split(':')[0]) {
		dropLast=me;
		me.appendChild(dragObject);
		cancelEvent(e);
	}
}

var clipboardCpt,clipboardType;

function delcpt(me) {
	clipboardType = me.parentNode.title.split(':')[0];
	var hider = document.getElementById('x0');
	hider.appendChild(me);
	clipboardCpt = me;
	var myHeader = document.getElementById(me.id+'h');
	if (myHeader) hider.appendChild(myHeader);
}

function resize(me) {
	me.style.height='10px';
	me.style.height=me.scrollHeight+'px';
}

function sizerMove(e) {
	if (!dragObject || !xStart) return true;
	e = e ? e : window.event;
	var d = (e.clientX-xStart)*100 / dragObject.parentNode.clientWidth;
	if (d>=100) {
		dragObject.style.width = '';
		if (typeof dragObject.style.styleFloat != 'undefined') dragObject.style.styleFloat=''; else dragObject.style.cssFloat='';
		dragObject.style.clear='';
	} else {
		dragObject.style.width = d.toFixed(3) + '%';
		if (typeof dragObject.style.styleFloat != 'undefined') dragObject.style.styleFloat='left'; else dragObject.style.cssFloat='left';
		dragObject.style.clear='none';
	}
	return false;
}

function setInfo() {
	var info='', sep=String.fromCharCode(1), nl=String.fromCharCode(2);
	var divs = document.getElementsByTagName('div'), tds=document.getElementsByTagName('td');
	var bid = document.body.id;
	if (bid) info+=bid.substr(1)+sep+parentsId(document.getElementById('s'+bid.substr(1)))+sep+document.body.style.cssText.toLowerCase()+nl;
	for (var i=0; c=divs[i]; i++) if (c.id && c.className.substr(0,4)=='Item') {
		info+=c.id.substr(1)+sep+parentsId(c)+sep+c.style.cssText.toLowerCase();
		if (c.className.substr(0,9)=='Item Move') info+=sep+c.className.substr(10)+nl; else info+=nl;
	}
	for (var i=0; c=tds[i]; i++) if (c.id && c.className.substr(0,4)=='Item') {
		info+=c.id.substr(1)+sep+parentsId(c)+sep+c.style.cssText.toLowerCase();
		if (c.className.substr(0,9)=='Item Move') info+=sep+c.className.substr(10)+nl; else info+=nl;
	}
	document.getElementById('design_id').value = info;
}

function parentsId(n) {
	if (n) while (n=n.parentNode) if (n.id) return n.id.substr(1);
}

var tickers;
function setTickers() {
	tickers = document.getElementsByTagName('tt');
	if (tickers[0]) setInterval('tick()',300);
}

function tick() {
	var ticker;
	for(var i=0; ticker=tickers[i]; i++) {
		var x = ticker.offsetLeft;
		if (x+ticker.offsetWidth<0) x = ticker.parentNode.offsetWidth;
		ticker.style.left = (x-20)+'px';
	}
}

function clear_back() {document.cookie='_back=';}
function set_back() {document.cookie='_back='+escape(location.href);}

function setback() {
	var els = document.getElementsByTagName('a');
	for(var i=0; el=els[i]; i++) if (el.className=='setback') el.onclick=set_back;
}

function replaceCite(){
	var els = document.getElementsByTagName('cite');
	for(var i=0; el=els[i]; i++) replaceElement(el);
}

function replaceElement(el){
	var c = el.style.color || document.defaultView ? document.defaultView.getComputedStyle(el, null).color : el.currentStyle ? el.currentStyle.color : '#000001';
	if(c.indexOf('rgb') > -1) c = '#'+eval(c);
	else if(c.length == 4) c = '#'+c.charAt(1)+c.charAt(1)+c.charAt(2)+c.charAt(2)+c.charAt(3)+c.charAt(3);
	var sVars = 'txt='+escape(el.innerHTML).replace(/%B4/g,'%27')+'&amp;textcolor='+c+'&amp;w='+el.offsetWidth+'&amp;h='+el.offsetHeight;
	temp = el.innerHTML = '<object type="application/x-shockwave-flash" data="/flash/kinship.swf" style="width:'+el.offsetWidth+'px;height:'+el.offsetHeight+'px"><param name="movie" value="/flash/kinship.swf"/><param name="flashvars" value="'+sVars+'"/><param name="wmode" value="transparent"/>'+el.innerHTML+'</object>';
}

function Hex2(d){
	var d = parseInt(d);
	if (isNaN(d)) return '00'; else return '0123456789abcdef'.charAt(d>>4) + '0123456789abcdef'.charAt(d&15);
}

function rgb(r,g,b){
	return Hex2(r)+Hex2(g)+Hex2(b);
}

var tfixclose='';
function tfix(){
	if (tfixclose=='') {document.write('<table class="main">'); tfixclose='</table>';}
}

function tdfix(){
	if (tfixclose=='') {document.write('<table class="Item Move main">'); tfixclose='</table>';}
}

function flashfix(){
	var obj,objs = document.getElementsByTagName('object');
	for(var i=0;obj=objs[i];i++) obj.parentNode.innerHTML = obj.parentNode.innerHTML;
}

function getTickEmails(bAll) {
	var i, e='mailto:', tes=document.getElementsByName('tickEmail');
	for(i=0; i<50 && (te=tes[i]); i++) if (bAll || te.checked) e+=te.value+',';
	if (tes[i]) alert('Too many email addresses: only using first 50')
	return e;
}

function digits_only(e) {
	var c=e.which||e.keyCode;
	return c==8 || c==127 || (c>=48 && c<=57); //Only allow BS, DEL and digits
}

function chars_only(e) {
	var c=e.which||e.keyCode;
	return c==8 || c==127 || (c>=48 && c<=57) || (c>=97 && c<=122) || (c==45) || (c==46); //Only allow BS, DEL, digits and domain chars
}

function file_only(e) {
	var c=e.which||e.keyCode;
	return c==8 || c==127 || (c>=48 && c<=57) || (c>=97 && c<=122) || (c==45) || (c==95); //Only allow BS, DEL, digits and file chars
}

function domcheck(me) {
	var i = me.getElementsByTagName('img')[0];
	i.src = 'http://'+document.getElementsByName('DomainName')[0].value+'/Images/tick.gif';
}

function init() {
	if (window.location.search.indexOf('&_design=')>-1) dinit(); else {setback();NewlinkWeb();linkWeb(); replaceCite(); addtickercontent();IBMaddtickercontent();womOn();}
	if (location.search.indexOf("_loginfail")>-1) alert("Username or Password not recognised");
}

function linkWeb() {
	//loop through div elements looking for ones with Item Description or Item About
	var div_list=document.getElementsByTagName('div');
	for(var i=0; check_div=div_list[i]; i++) if (check_div.className=='Item Description' || check_div.className=='Item About'){
		if (check_div.innerHTML.indexOf('<textarea')==-1) check_div.innerHTML=check_div.innerHTML.replace(/(http:\/\/\S+)/g, '<a href="$1">$1</a>').replace(/>(http:\/\/\S+)<\/a> \[([^\]]+)\]/g, '>$2</a>');			
		}

	var td_list=document.getElementsByTagName('td');
	for(var i=0; check_td=td_list[i]; i++) if (check_td.className=='Item Description' || check_td.className=='Item About'){
		if (check_td.innerHTML.indexOf('<textarea')==-1) check_td.innerHTML=check_td.innerHTML.replace(/(http:\/\/\S+)/g, '<a href="$1">$1</a>').replace(/>(http:\/\/\S+)<\/a> \[([^\]]+)\]/g, '>$2</a>');			
		}
}

function set_select(n,v,d) {
	var s = document.getElementsByName(n)[0];
	if (s) s.innerHTML=('<option>'+v.replace(/,/g,'</option><option>')+'</option>').replace('<option>'+d+'</option>','<option selected>'+d+'</option>');
}

function setImage(n) {
	var el=document.getElementsByName('Image')[0];
	if (!el) el=document.getElementsByName('Main_image')[0];
	if (el) {el.value=n; document.images['img_'+el.name].src=n;}
}

function shrinkImages() {
		var els=document.getElementsByTagName('img');
		for(var i=0; el=els[i]; i++) if ((p=el.parentNode).className.substr(0,11)=='Item Shrink' || (p=p.parentNode).className.substr(0,11)=='Item Shrink') {
			var n=100;
			while (n && p.scrollHeight>p.clientHeight) el.style.width=(n=n-2)+'%';
		}
}

function opts(a,c,n) {
document.write('<option value="">-</option>');
var add=true;
var cl=c.toLowerCase().replace(/,\s/g,',');
for (i in a) {
	var v = a[i].split('=');
	if (v.length<2) v[1]=v[0];
	if (v[1].toLowerCase()==cl) {document.write('<option value="'+v[1]+'"'+(n?' style="'+n+v[1]+'"':'')+' selected>'+v[0]+'</option>'); add=false;}
	else document.write('<option value="'+v[1]+'"'+(n?' style="'+n+v[1]+'"':'')+'>'+v[0]+'</option>');
	}
if (add && c) document.write('<option'+(n?' style="'+n+c+'"':'')+' selected>'+c+'</option>');
}

function Paginate(Total_items,PageSize,Start_item) {
	if (isNaN(Total_items) || isNaN(PageSize)) return;
	if (isNaN(Start_item)) Start_item=0;
	var end_item = Start_item + PageSize;
	if (end_item > Total_items) end_item = Total_items;
	var qs=window.location.search;
	if (qs=='') qs='?&_from='; else qs=qs.replace(/&_from=[0-9]*/,'')+'&_from=';
	document.write('Displaying '+(Start_item+1)+' to '+end_item +' of '+Total_items+' items ');

//create a back link
	if (Start_item>=PageSize) document.write('&lt;Back'.link(qs+(Start_item-PageSize))+' ');

//------------Added Section----------
var NumberOfPagesToDisplay=10
var ListSize =0;
var LastPage = Math.ceil(Total_items/PageSize)
var CurrentPage=0;

for (var i=1;i<=Math.ceil(Total_items/PageSize);i++ )//calculate current page, traverse through the pages until pagesize*currentpage=start item
{
	if ((i-1)*PageSize==Start_item) 
	{CurrentPage=i;}
}

//ListSize is the largest page number displayed on the screen
if (LastPage-CurrentPage>NumberOfPagesToDisplay-1) ListSize=CurrentPage+NumberOfPagesToDisplay-1;
else {ListSize=LastPage;}

//------------Added Section----------
//Also modified section below

//List pages
//Total_items/pageSize = total number of pages
	for (var i=CurrentPage; i<=ListSize; i++)
		if ((i-1)*PageSize==Start_item) document.write((i+' ').bold())
        else document.write(String(i).link(qs+(i-1)*PageSize)+' ');

//Create a next link, if the user is looking at the last page no next link should appear
	var LastPageStart = LastPage*PageSize-PageSize;
	if (Start_item<LastPageStart) document.write('Next&gt;'.link(qs+(Start_item+PageSize)));
}


function findSearchDiv(){
var divs = document.getElementsByTagName('div');
for (var i=0; n=divs[i]; i++) if (n.className.substr(0,16)=='Item searchOuter') n.onmousedown=displayFilters;

}

function displayFilters(){
var divs = document.getElementsByTagName('div');
for (var i=0; n=divs[i]; i++) if (n.className.substr(0,16)=='Item searchOuter')  n.style.height=105+'px';
for (var i=0; n=divs[i]; i++) if (n.className.substr(0,16)=='Item searchInner') {

n.style.display='block';
n.style.position='absolute';
n.style.top=0+'px'; 
n.style.left=0+'px';
n.style.backgroundImage='url(/Images/1811/header_search_dropdown_lower_portion.jpg)';
n.style.backgroundRepeat='no-repeat';
n.style.height=105+'px';
n.style.width=720+'px';
}

}

function validate()
{
var obj_e1= document.getElementById('email1');
var obj_p1= document.getElementById('password1');
var obj_pc1= document.getElementById('passwordconfirm1');
var obj_tc1= document.getElementById('TandC');
var obj_rcb13=0;
var age13allow=1;
var obj_rcbUK=0;
var LocUKallow=1;
if (document.getElementById('RegisterCB_Age13')){
	obj_rcb13= document.getElementById('RegisterCB_Age13');
}
if (document.getElementById('RegisterCB_LocUK')){
	obj_rcbUK= document.getElementById('RegisterCB_LocUK');
}
var obj_recaptcha_response= document.getElementById('recaptcha_response_field');
var e1= obj_e1.value;
var p1= obj_p1.value.toLowerCase();
var pc1= obj_pc1.value.toLowerCase();
var recaptcha_response= obj_recaptcha_response.value
var rd1=document.getElementById('Register1div');
var registerHTML="<ul>Your details could not be sent because of the following reasons:";
obj_e1.className=obj_p1.className=obj_pc1.className=obj_recaptcha_response.className='';

	if ((e1.length!=0) && (p1.length>=7) && (pc1 == p1) && (recaptcha_response.length!=0) && (obj_tc1.checked)){ //these are the fields that are mandatory for all our registration forms

		if (obj_rcb13){if (!obj_rcb13.checked){age13allow=0}}
		if (obj_rcbUK){if (!obj_rcbUK.checked){LocUKallow=0}}

		if (age13allow && LocUKallow){
			return true;
		}

	}
	if (e1.length==0)
	{
	registerHTML += "<li>A valid email address was not entered</li>";
	obj_e1.className='setcolor'
	}
	if (p1.length==0)
	{
	registerHTML += "<li>A password was not entered</li>"; 
	obj_p1.className='setcolor'
	}
	if ((p1.length>0) && (p1.length<7))
	{
	registerHTML += "<li>The password entered had less than 7 characters</li>"; 
	obj_p1.className='setcolor'
	}
	if (pc1!=p1)
	{
	registerHTML += "<li>Password and Password confirmation do not match</li>";
	obj_pc1.className='setcolor'
	}
	if (recaptcha_response.length==0)
	{
	registerHTML += "<li>A reCAPTCHA response was not entered</li>";  
	obj_recaptcha_response.className+=' setcolor'
	}
	if (!obj_tc1.checked)
	{
	registerHTML += "<li>The terms and conditions were not accepted</li>";  
	obj_tc1.className+=' setcolor'
	}
	if (obj_rcb13){
		if (!obj_rcb13.checked)
		{
		registerHTML += "<li>You have not confirmed that you are over thirteen. Those under age thirteen are not permitted to register on this site.</li>";
		obj_rcb13.className+=' setcolor'
		}
	}
	if (obj_rcbUK){
		if (!obj_rcbUK.checked)
		{
		registerHTML += "<li>You have not confirmed that you are a resident of the UK.</li>";
		obj_rcbUK.className+=' setcolor'
		}
	}

registerHTML += "</ul>"
rd1.className='registerMessagediv'
rd1.innerHTML=registerHTML;
return false;
}

function query_string(obj)
{
var q1=window.location.search.substring(1)

var q2=q1.split("&");
var q3,variableName;
for (i=0;i<q2.length ;i++ )
	{
	q3 = q2[i].split("=")
	variableName = q3[0];
	obj[variableName] = q3[1];
	}
}

function addtickercontent() {

var container=document.getElementById("ticker1");

if (container)
{
	var xmlHttp = new XMLHttpRequest();
	xmlHttp["onreadystatechange"]=function()
    {
    if(xmlHttp.readyState==4)
      {
		if(xmlHttp.responseText!=""){container.innerHTML=xmlHttp.responseText;setTickers();}
	  }
     }
   
  UrlString= location.protocol + "//" + location.hostname  + "/problem/ticker.htm";
  xmlHttp.open("GET",UrlString,true);
  xmlHttp.send(null);
}

}

function IBMaddtickercontent() {
var container=document.getElementById("ticker2");

if (container)
{
	var xmlHttp = new XMLHttpRequest();
	xmlHttp["onreadystatechange"]=function()
    {
    if(xmlHttp.readyState==4)
      {
		if(xmlHttp.responseText!=""){container.innerHTML=xmlHttp.responseText;setTickers();}
	  }
     }
   
  UrlString= location.hostname + "/question/ticker.htm";
  xmlHttp.open("GET",UrlString,true);
  xmlHttp.send(null);
}

}

//LinkWeb which looks for Item livelink as the first class
function NewlinkWeb() {
	//loop through div elements looking for ones with Item Description or Item About
	var div_list=document.getElementsByTagName('div');
	for(var i=0; check_div=div_list[i]; i++) if (check_div.className.indexOf('livelink')!=-1){
		if (check_div.innerHTML.indexOf('<textarea')==-1) check_div.innerHTML=check_div.innerHTML.replace(/(http:\/\/\S+)/g, '<a target="_blank" href="$1">$1</a>').replace(/>(http:\/\/\S+)<\/a> \[([^\]]+)\]/g, '>$2</a>');			
		}

	var td_list=document.getElementsByTagName('td');
	for(var i=0; check_td=td_list[i]; i++) if (check_td.className.indexOf('livelink')!=-1){
		if (check_td.innerHTML.indexOf('<textarea')==-1) check_td.innerHTML=check_td.innerHTML.replace(/(http:\/\/\S+)/g, '<a target="_blank" href="$1">$1</a>').replace(/>(http:\/\/\S+)<\/a> \[([^\]]+)\]/g, '>$2</a>');			
		}
}

function ShowPopUp(e,popupID)
{
//Ensure the popup exists
if (document.getElementById(popupID))
	{
	if (!e) e = window.event;
	var spdiv = document.getElementById(popupID);
	if(e.pageY) 
		{
		spdiv.style.position ="absolute";
		spdiv.style.left = e.pageX+10 + "px";
		spdiv.style.top = e.pageY-10 + "px";
		spdiv.style.zIndex =10;
		spdiv.style.visibility = "visible";
		//spdiv.x="100px";
		//spdiv.y="200px";
		//spdiv.width="500px";
		//spdiv.height="500px";
		}
	else 
		{
		spdiv.style.position ="absolute";
		spdiv.style.left = e.clientX+10 + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px";
		spdiv.style.top = e.clientY-10 + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px";
		spdiv.style.zIndex =10;
		spdiv.style.visibility = "visible";
		//spdiv.x="100px";
		//spdiv.y="200px";
		//spdiv.width="500px";
		//spdiv.height="500px";
		}


	//top and left must be set after determining if the pop-up is outside the screen
	//See calendarpopup.js for example of how this can be done
	//must check that the available widht and height are enough to display the popup. if not move the popup
	//if (screen.availHeight)	{	alert("screen.availHeight:"+screen.availHeight) } //supported across browsers
	//if (screen.availWidth)	{alert("screen.availWidth:"+screen.availWidth)	} //supported across browsers
	//if (spdiv.height)	{alert("spdiv.height:"+spdiv.height)	} //the below are user defined properties set for the object which do not affect the position
	//if (spdiv.width)	{alert("spdiv.width:"+spdiv.width)	} //these must be set so we can calculate if the popup will move out of the visible screen
	//if (spdiv.x) {alert("spdiv.x:"+spdiv.x) }
	//if (spdiv.y) { alert("spdiv.y:"+spdiv.y) }


		spdiv.className="show_this";
		document.body.appendChild(spdiv);//necessary so that div is not hidden behind other elements. 

		ShowGreyBackground();
	}
}

function ShowPopUpCentre(popupID)
{
//Ensure the popup exists
if (document.getElementById(popupID))
	{
	var spdiv = document.getElementById(popupID);

		spdiv.style.position ="absolute";
		spdiv.style.left = 300 + "px";
		spdiv.style.top =  200 + "px";
		spdiv.style.zIndex =10;
		spdiv.style.visibility = "visible";

		spdiv.className="show_this";
		document.body.appendChild(spdiv);//necessary so that div is not hidden behind other elements. 

    	ShowGreyBackground();
	}

}

function ShowGreyBackground()
{
if (document.getElementById("GreyBackground1"))
	{
	var gbdiv = document.getElementById("GreyBackground1");

		gbdiv.style.position ="absolute";
		gbdiv.style.left = 0 + "px";
		gbdiv.style.top =  0 + "px";
		if(document.body.clientWidth){
			gbdiv.style.width = (document.body.clientWidth) + "px";
		}
		if(window.innerHeight){
			gbdiv.style.height =  (window.innerHeight )+ "px";
		}
		if(document.documentElement.clientHeight){
			gbdiv.style.height =  (document.documentElement.clientHeight )+ "px";
		}		
		gbdiv.style.zIndex =9;
		gbdiv.style.visibility = "visible";

		gbdiv.className="show_this_grey";
		document.body.appendChild(gbdiv);//necessary so that div is not hidden behind other elements. 
	}
}

function HidePopUp(popupID){
		if (document.getElementById(popupID))	document.getElementById(popupID).className="hide_this";
		if (document.getElementById("GreyBackground1"))	document.getElementById("GreyBackground1").className="hide_this";
}

function AddStyleSheet(filename){
	var fileref=document.createElement("link")
	fileref.rel="stylesheet";
	fileref.type="text/css";
	fileref.href=filename;
	if (typeof fileref!="undefined")
	document.getElementsByTagName("head")[0].appendChild(fileref)
 }

function RemoveBox(){
var check_div;
var div_list=document.getElementsByTagName("div");
for(var i=0; check_div=div_list[i]; i++) {    
	if (!check_div.firstChild)  {  
		if (check_div.className=="Item Box" || check_div.className.substr(0,11)=="Item Remove")  check_div.className="removethisdiv";
		}
	}
}

var geocoder;
var map;
var centre=0;
var iconCounter=1;
function initialize() {
	geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(51.52345,-0.077117);
    var myOptions = {
      zoom: 16,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
}

function setLatLong() {
	var address = document.getElementById("Text1id").value;

	geocoder.geocode( { 'address': address}, function(results, status) {

	  if (status == google.maps.GeocoderStatus.OK) {
		//clear the map of all markers
		var container=document.getElementById("LatLongid");
		var LatLongDisplay=document.getElementById("Text5id");
		var LatLongOptions="";
		var marker;
		
		map.setCenter(results[0].geometry.location);
		
		if(LatLongDisplay){LatLongDisplay.value=results[0].geometry.location}
		for(i=0;i<results.length;i++){
			marker = new google.maps.Marker({map: map, position: results[i].geometry.location});
			if (i==0){
			LatLongOptions+="<div class='LatLongOptsClass'><input type='radio' checked='checked' name='LatLongOpts' value='"+results[i].geometry.location+"' onclick='if(document.getElementById(\"Text5id\")){document.getElementById(\"Text5id\").value=this.value;} map.setCenter(new google.maps.LatLng"+results[i].geometry.location+", 13);' />"+results[i].formatted_address+"</div>";       
			} else {
			LatLongOptions+="<div class='LatLongOptsClass'><input type='radio' name='LatLongOpts' value='"+results[i].geometry.location+"' onclick='if(document.getElementById(\"Text5id\")){document.getElementById(\"Text5id\").value=this.value;} map.setCenter(new google.maps.LatLng"+results[i].geometry.location+", 13);' />"+results[i].formatted_address+"</div>";
			}
//var latlng22573=new google.maps.LatLng(51.525602,-0.087588);map.setCenter(latlng22573, 13);
//			alert(results[i].geometry.location);
		}
		if (container){container.innerHTML=LatLongOptions;}
	  } else {
		alert("Geocode was not successful for the following reason: " + status);
	  }

	});
}

/* WOM v1.0  by: Justin Barlow - http://www.netlobo.com/wom.html*/
var woms = new Array();
function womOn(){  window.onload = womGo;}
function womGo(){  for(var i = 0;i < woms.length;i++)    eval(woms[i]);}
function womAdd(func){  woms[woms.length] = func;}

function displayImage(id){
if (document.getElementById(id)){
	var div = document.getElementById(id);

		div.style.position ="absolute";
		div.style.left = 300 + "px";
		div.style.top =  200 + "px";
		div.style.zIndex =10;
		div.style.visibility = "visible";

		div.className="show_this";
		document.body.appendChild(div);//necessary so that div is not hidden behind other elements. 
	}


}

function removeImage(id){
if (document.getElementById(id)){
	var div = document.getElementById(id);

		div.className="hide_this";
	}

}
