function bl(id,m,w,c)
{
	var u = '/p/'+id;
	var r = '';
	if(m) r+='<a href="'+u+'?j=contacts" class="lm">Map & Directions</a>';
	if(w) r+='<a href="/w/'+id+'" class="lw" target="_blank">Open Website</a>';
	if(c) r+='<a href="'+u+'?j=bcform" class="lq">Send an Inquiry</a>';
	if(r)document.write(r)
}
function bMap(u){document.location=u+'#contacts';}
function bContact(u){document.location=u+'#bcform';}
function open_link(i)
{
	var obj = document.getElementById(i);
	var v = obj.value;
	if(!v) 
	{
		alert('The field is empty');
		obj.focus()
		return false;
	}
	if(v.indexOf('http://', v) == -1) v = 'http://' + v;
	if(v) window.open(v);
}

function bookmark(t){t=!t?document.title:t;var u=document.location.href;if(window.sidebar){window.sidebar.addPanel(t,u,"");}else if(document.all&&window.external){window.external.AddFavorite(u,t);}else if(window.opera &&window.print){alert('Opera users - press Ctrl + T to bookmark');}return true;}

function pCat(id,f){openI('/html/popup-select-category.php?f='+f+'&cat_id=' + id, 700,520);regIsExit=true;}
function pBanner(c){openI('/html/popup-html-code.php?c='+c, 700,520);}
function pPlace(id,f){openI('/html/popup-select-place.php?f='+f+'&place_id=' + id, 750,520);}


function fieldFocus(o, req){var c = req ? 'fieldFocus requiredBg' : 'fieldFocus';o.className=c;}
function fieldBlur(o, req){var c = req ? 'field requiredBg' : 'field';o.className=c;}

//--------------
function tooltipShow(elt)
{
	var t = elt.getElementsByTagName('div')[0];
	t.style.display = 'block';
}

function tooltipHide(elt)
{
	var t = elt.getElementsByTagName('div')[0];
	t.style.display = 'none';
}

function contact(mode, id){openP('/popup-contact.php?mode='+mode+'&id='+id,450);}
function review(item_id, id, d){openP('/popup-review.php?item_id='+item_id+'&id='+id+'&delete='+d,570);}
function reviewr(id,r){openP('/popup-review-response.php?id='+id + '&request_removal=' + r,400);}
function taf(u,t)
{
	var t=!t?document.title:t;var u=!u?document.location.href:u;u = u.split('?');u = u[0];
	openP('/popup-taf.php?url='+escape(u)+'&title='+escape(t),380);
}
function updateBusiness(id, url){openP('/popup-update.php?id='+id+'&url='+url,350);}
function reportError(item_id, report_type){openP('/popup-report-error.php?item_id=' + item_id + '&report_type=' + report_type, 400);}

function openP(src, h)
 {
	e = document.getElementById('inp');
 	if(!e) return openI(src, 700, h);
 	e.innerHTML = '';
 	e.style.marginBottom = '15px';
 	
	var i = document.createElement("IFRAME");
	if(window.opera) i.setAttribute("src", src);
	i.setAttribute("frameBorder", 0);
	i.setAttribute("id", 'inpF');
	i.style.width ='737px';
	i.style.height = h + 'px';
	i.style.border = '4px solid #FF8D41';

	e.appendChild(i); 	
	e.style.display='';
	document.getElementById('inpF').src = src;
	return false;
 }

//--------------
 function openI(src, w, h)
 {
 	if(!document.getElementById('iframePopup'))
 	{
		var e = document.createElement('div');
		e.setAttribute('id', 'iframePopup');
 	}
 	else
 	{
 		e = document.getElementById('iframePopup');
 	}
	e.style.zIndex = 10000;
 	e.innerHTML = '';
 	
	var i = document.createElement("IFRAME");
	if(window.opera) i.setAttribute("src", src);
	i.setAttribute("frameBorder", 0);
	i.setAttribute("id", 'iframePopupF');
	i.style.position="absolute";
	i.style.zIndex = 10000;

	
	var v = getViewportDimensions();
	var t = document.body.scrollTop || document.documentElement.scrollTop || 0;
	var l = document.body.scrollLeft || document.documentElement.scrollLeft || 0;
	i.style.left =((v.width - w) / 2 + l) + 'px';
	i.style.top =((v.height - h) / 2 + t) + 'px';
	i.style.width =w + 'px';
	i.style.height = h + 'px';
	i.style.border = '4px solid #FF8D41';

	e.appendChild(i); 	
	e.style.display='';
	document.body.appendChild(e)
	document.getElementById('iframePopupF').src = src;
	
	return false;
 }

 function getViewportDimensions() {
    var intH = 0, intW = 0;
    
    if(self.innerHeight) {
       intH = window.innerHeight;
       intW = window.innerWidth;
    } 
    else {
        if(document.documentElement && document.documentElement.clientHeight) {
            intH = document.documentElement.clientHeight;
            intW = document.documentElement.clientWidth;
        }
        else {
            if(document.body) {
                intH = document.body.clientHeight;
                intW = document.body.clientWidth;
            }
        }
    }

    return {
        height: parseInt(intH, 10),
        width: parseInt(intW, 10)
    };
}

function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

function tooltips()
{
 	if(!document.getElementById('tooltipPopup'))
 	{
		var e = document.createElement('div');
		e.setAttribute('id', 'tooltipPopup');
 	}
 	else
 	{
 		e = document.getElementById('tooltipPopup');
 	}
 	e.innerHTML = '';
 	
	e.style.position="absolute";
	e.style.padding = '10px';
	e.style.border = '1px solid #000000';
	e.style.backgroundColor = '#FFFFCC';
	e.innerHTML = '';
	e.style.display='none';
	document.body.appendChild(e)


var z=document.getElementsByTagName("span"); 
for(var y=0;y<z.length;y++) 
{
	if(z[y].className != 'tooltip' && z[y].className != 'tooltipNI') continue;
	if(z[y].title == 'undefined' || z[y].title == '') continue;
	z[y].onmouseover=function()
	{
		var  e = document.getElementById('tooltipPopup');
		e.innerHTML = this.title;
		this.tooltip = this.title;
		this.title = '';
		var w = this.getAttribute('tooltipWidth');
		if(w && w!='undefined') e.style.width = w + 'px';
		e.style.left=findPosX(this) + 'px';
		e.style.top=findPosY(this) +18 + 'px';
		e.style.display = '';
	}
	z[y].onmouseout=function()
	{
		e.innerHTML = '';
		e.style.display = 'none';
		this.title = this.tooltip;
	}

} 
	return false;
}

function fieldsHL()
{
	var z=document.getElementsByTagName("input"); 
	for(var y=0;y<z.length;y++) 
	{
		if(z[y].type.toLowerCase() != 'text') continue;
		if(!/^field/.test(z[y].className)) continue;
		z[y].onfocus=function(){this.className = 'fieldFocus';}
		z[y].onblur=function(){this.className = 'field';}
	} 

	var z=document.getElementsByTagName("textarea"); 
	for(var y=0;y<z.length;y++) 
	{
		if(!/^field/.test(z[y].className)) continue;
		z[y].onfocus=function(){this.className = 'fieldFocus';}
		z[y].onblur=function(){this.className = 'field';}
	}
}

function loadEvents()
{
	//tooltips();
	//fieldsHL();
}

//window.onload=loadEvents;




addEvent(window,"load",shadowInit);
addEvent(window,"load",tooltips);
addEvent(window,"load",fieldsHL);

function shadowInit() {
    if (!document.createElement) return;
	var els = document.all ? document.all : document.getElementsByTagName("*");
    for (i=0;i<els.length;i++) if ((' '+els[i].className+' ').indexOf(' shadow ') != -1) shadow(els[i]);
}

function shadow(e) {
  if (typeof(e) != 'object') e = document.getElementById(e);
  var v = e.firstChild.nodeValue;
  e.style.position = 'relative';
  e.style.zIndex = 1;
  var n = document.createElement('font');
  n.appendChild(document.createTextNode(v));
  n.className = 'shadowed';
  e.appendChild(n);
}

function addEvent(obj, evType, fn) {
	if (obj.addEventListener){obj.addEventListener(evType, fn, false);return true;} 
	else if (obj.attachEvent){var r = obj.attachEvent("on"+evType, fn);return r;} 
	else {return false;}
}


function hide(obj)
{
	if(typeof(obj) != 'object') var obj = document.getElementById(obj);
	if(typeof(obj) != 'object') return false;
	obj.style.display = 'none';
}

function show(obj)
{
	if(typeof(obj) != 'object') var obj = document.getElementById(obj);
	if(typeof(obj) != 'object') return false;
	obj.style.display = '';
}

//---------------------
//<a href="javascript:void(0)" id="imgId" title="Test Title" big="/img.jpg" onclick="popupImage('imgId')">Popup</a>
 function popupImage(id)
 {
 	var obj = document.getElementById(id);
 	
 	e = document.getElementById('popupImage');
 	if(!document.getElementById('popupImage'))
 	{
		var e = document.createElement('div');
		e.setAttribute('id', 'popupImage');
 	}
 	e.innerHTML = '';
 	e.style.left=-10000;
 	e.style.top=-10000;
	e.style.zIndex = 10000;
	e.style.position = 'absolute';
	document.body.appendChild(e);
 	e.innerHTML = '<div style="text-align:center;background-color:#fff"><img id="popupImageBig" src="'+obj.getAttribute('big')+'" onload="popupImageCenter()" onclick="popupImageClose()" style="border:2px solid #fff;cursor:pointer" title="Click to close"></div><table style="width:100%;background-color:#fff"><tr><td style="vertical-align:middle;padding:5px 10px;font-size:12px;">'+obj.getAttribute('title')+'</td><td style="text-align:right;vertical-align:middle;padding:5px 10px"><a href="javascript:void(0)" onclick="popupImageClose()" style="color:#666;font-size:14px;text-decoration:none;">close</a></td></tr></table>';
	return false;
 }
 
 function popupImageCenter()
 {
 		var e = document.getElementById('popupImage');
		var v = getViewportDimensions();
		var t = document.body.scrollTop || document.documentElement.scrollTop || 0;
		var l = document.body.scrollLeft || document.documentElement.scrollLeft || 0;
		e.style.width = document.getElementById('popupImageBig').width + 4 + 'px';
 		var w = e.offsetWidth;
 		var h = e.offsetHeight;
		e.style.left =((v.width - w) / 2 + l) + 'px';
		e.style.top =((v.height - h) / 2 + t) + 'px';
		e.style.border = '4px solid #FF8D41';
		e.style.display='';
}

 function popupImageClose()
 {
 		var e = document.getElementById('popupImage');
 		if(!e) return false;
 		e.parentNode.removeChild(e);
}

function quotesFormS(p,c)
{
	var r = '';
	r+='<td style="padding-left:15px;"></td>';
	r+='<td style="width:50%;vertical-align:top;">';
	r+='<div class="boxRnd"><div class="rt1"><div class="rt2"></div></div><div class="rc1"><div class="rc2">';
	r+='<div style="padding:0 5px;height:295px"><form method="get" action="/get-a-quote">';
			
	r+='<div class="qtfH">Get Free Quotes & Price Estimates</div>';
			
	r+='<div class="qtfD">Enter your city / town</div>';
	r+='<div class="qtfE"><input type="text" name="place_name_full" value="'+p+'" style="width:250px"></div>';
			
	r+='<div class="qtfD">Get quotes from <em>(eg: plumbers)</em></div>';
	r+='<div class="qtfE"><input type="text" name="category" value="'+c+'" style="width:250px"></div>';
			
	r+='<div class="qtfD">Enter your email address</div>';
	r+='<div class="qtfE"><input type="text" name="user_email" style="width:250px"></div>';
			
	r+='<div class="qtfD">Quote Details</div>';
	r+='<div class="qtfE"><textarea name="description" style="width:330px;height:60px"></textarea></div>';
			
	r+='<div style="text-align:center;padding-top:5px"><input type="image" src="/css/btn-get-quote.gif" title="Get Free Quotes"></div>';
			
	r+='</form></div>';
			
	r+='</div></div><div class="rb1"><div class="rb2"></div></div></div></td>';
	document.write(r);
}

function textareaExpander(obj, max)
{
	if(typeof(obj) == 'string') obj = document.getElementById(obj);
	if(max && obj.offsetHeight >= max) return false;
	if(obj.offsetHeight < obj.scrollHeight) obj.style.height = (obj.scrollHeight + 20) + 'px';
}

statsImg = new Image() 
statsImg.src = '/stats.php?r=' + Math.random();
