// window.onload = init;

function popup(who, height, width) {
	var win = window.open(who, "_keyb", "toolbar=0, scroallbars=0, height=" + height + ", width=" + width);
	win.focus();
}

function a(pcode) {
	var tmp = pcode.replace(" ", "+");
	var win = window.open("http://www.streetmap.co.uk/streetmap.dll?Postcode2Map?code=" + tmp + "&title=bginfo.co.uk+place+at+" + tmp + "&back=&url=&nolocal=X", "_map", "toolbar=0, height=550, width=650, scrollbars=1"); 
	win.focus();
}

function changes() {
	if (confirm("Are you absolutely sure?")) document.frm.submit();
	}
	
function Pager(how) {
	if (how == 'next') {
	var a = document.frm.pos.options.length; var curr = -1;
	for (ii=0; ii<a; ii++) if (document.frm.pos.options[ii].selected) curr = ii;	
	

	if ((a - curr) > 1) { 
		 document.frm.pos.options[curr+1].selected = true;
		 document.frm.submit();
		 } else {
		 alert("No more pages available!");
		 }
	}
	
	if (how == 'rnd') {
		 document.frm.submit();
}}

function PrintAd(who) {
	var pWin = window.open("/print_ad.html?id=" + who, "_prn", "height=600, width=700, scrollbars=1, toolbars=0");
	pWin.focus();	
	}
	
function setCookie(name, value, days) {
//	if (getCookie(name).indexOf(value) == -1) {	
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else var expires = "";
	
	value = getCookie(name) + "|" + value;
	document.cookie = name+"="+value+expires+"; path=/";
	var wish = window.open("/wishlist.html", "_wish", "height=500, width=400, toolbars=0, scrollbars=1");	
	wish.focus();
//	} else { alert('This advert is already added to your wishlist!'); }
}

function wishlist(who) {
	var wish = window.open("/wishlist.html?id=" + who, "_wish", "height=500, width=350, toolbars=0, scrollbars=1");	
	wish.focus();
	}

function getCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

