
var newwindow;
function showPop(url,w,h)
//use: onclick="showPop('pop_titletips.asp',540,370)"
{
	if(w < 100) w = 540;
	if(h < 100) h = 500;
	if(w == 0) w = 540;
	url = "http://www.locallocator.com/" + url;
	newwindow=window.open(url,'locallocator','width='+w+',height='+h+',left=100,top=100,resizable=yes,scrollbars=auto,toolbar=no,status=no,location=0,menubar=0');
	if (window.focus) {newwindow.focus()}
}


//validate product search
function validateSearch(fn,f1,f2){
			//document.getbiz.business.value
			
			var v1 = eval('document.'+fn+'.'+f1);
			var v2 = eval('document.'+fn+'.'+f2);
			
			v1 = v1.value;
			v2 = v2.value;
			if(fn == "getbiz") {
				if (v2 == "") {
				 alert("Please fill in your search location.");
					return false;
				}
			} else if (fn == "getdir") {
				if (v1 == "" || v2 == "") {
					alert("Please fill in both starting and ending address.");
					return false;
				}	
			} else if (fn == "getproduct") {
				if ( v1 == "") {
					alert("Please fill in your search term.");
					return false;
				}	
				var addressdef = /Zip Code/;
				if ( v2.match(addressdef)) {
					alert("Please fill in your search location.");
					return false;
				}	
			}
			return true;
		}
		
function setFormValue(f,i,v) 
{
	var f = eval('document.'+f+'.'+i);
	f.value = v;
}

function defaultField(f,text){
	if(f.value == "")
		f.value=text;
}

function changeBG(id,color){
	var a = id.split(',');
	for(i=0;i<a.length;i++){
		document.getElementById(a[i]).style.backgroundColor = color;
	}
	
}

function changeBGClear(id,color,list,color2){
	var b = id.split(',');
	for(i=0;i<b.length;i++){
		document.getElementById(b[i]).style.backgroundColor = color;
	}

	var a = list.split(',');
	for(i=0;i<a.length;i++){
		document.getElementById(a[i]).style.backgroundColor = color2;
	}
}

function checklocationready(loc,zipboxname,zipboxid,url){
	
	if(loc != 'Zip Code or City,State' && loc != '') {
		window.location = url;
	} else {	
		document.getElementById(zipboxid).style.backgroundColor="#FAC8C8";
		alert('You need to enter your Zip Code or City,State and hit Enter');
		//document.vaddress.location.focus();
		zipboxname.focus();
	}
}
	
function saveValue(f,i,v) 
{
	var f = eval('document.'+f+'.'+i);
	f.value = v;
}

function saveValue3(f,i,v,o) 
{
	var f = eval('document.'+f+'.'+i);
	f.value = v;
	if (o) f.disabled = false;
	else f.disabled = true;
}

function saveValue2(f,i,v,t) 
{
	var f = eval('document.'+f+'.'+i);
	if(t=='make_' && v == "") f.value="";
	else {
		
		var L = f.value.split(",");
		var N;
		var onlythis = "";
		var M = 1;
		var c = 0;
		var newval = new Array();
		for(k=0;k<L.length;k++) {
			if(L[k].indexOf(t) >= 0) {
				newval[newval.length] = v;
				M = 0;
				if(t == 'make_' || t == 'bedrooms_') {
					onlythis = v;
				}
			} else {
				newval[newval.length] = L[k];
			}
		}
		
		if(onlythis != ""){
			
			f.value = onlythis;
		} else {
			if (M) newval[newval.length] = v;
			N = newval.join(',');
			f.value = N;
		}
	}
}

function clearField(f)
//use with onFocus
{
	f.value = "";
}

function focusField(f)
{
	f.focus();
}

function writeField(f,showvalue)
{
	if(f.value == "") f.value = showvalue;
}

function getQueryVariable(variable) 
{ 
	var query = window.location.search.substring(1); 
	var vars = query.split("&"); 
	for (var i=0;i<vars.length;i++) 
	{ 
		var pair = vars[i].split("="); 
		if (pair[0] == variable) 
		{ 
			return pair[1]; 
		} 
	} 
}

var newwindow;
function showVideo(url)
//use: onclick="showPop('pop_titletips.asp',540,370)"
{
	var w = 422;
	var h = 340;
	url = "http://dev.locallocator.com/player/player.html?file=http://dev.locallocator.com/dir/" + url;
	newwindow=window.open(url,'popwin','width='+w+',height='+h+',left=0,top=0,resizable=no,scrollbars=no,toolbar=no,status=no');
	if (window.focus) {newwindow.focus()}
}

function playListingVideo(url)
//use: onclick="showPop('pop_titletips.asp',540,370)"
{
	var w = 422;
	var h = 340;
	url = "http://dev.locallocator.com/player/player.html?file=http://dev.locallocator.com" + url;
	newwindow=window.open(url,'popwin','width='+w+',height='+h+',left=0,top=0,resizable=no,scrollbars=no,toolbar=no,status=no');
	if (window.focus) {newwindow.focus()}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

//MM_changeProp('test1','','innerHTML','testeafdafa','DIV')
function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Example: showHideLayers(Layer1,'','show',Layer2,'','hide');
function showHideLayers()

{ 

  var i, visStr, obj, args = showHideLayers.arguments;

  for (i=0; i<(args.length-2); i+=3)

  {

    if ((obj = MM_findObj(args[i])) != null)

    {

      visStr = args[i+2];

      if (obj.style)

      {

        obj = obj.style;

        if(visStr == 'show') visStr = 'visible';

        else if(visStr == 'hide') visStr = 'hidden';

      }

      obj.visibility = visStr;

    }

  }

}

// get mouse location

function Pointxy(x,y) {  this.x = x; this.y = y; }

mLoc = new Pointxy(-500,-500);

function getMouseLoc(e)

{

  if(!document.all)  //NS

  {

    mLoc.x = e.pageX;

    mLoc.y = e.pageY;

  }

  else               //IE

  {

    mLoc.x = event.x + document.body.scrollLeft;

    mLoc.y = event.y + document.body.scrollTop;

  }

  return true;

}

//NS init:

if(document.layers){ document.captureEvents(Event.MOUSEMOVE); document.onMouseMove = getMouseLoc; }

function moveLayerToMouseLoc(theLayer, offsetH, offsetV)

{

  var obj;

  if ((MM_findObj(theLayer))!=null)

  {

    if (document.layers)  //NS

    {

      document.onMouseMove = getMouseLoc;

      obj = document.layers[theLayer];

      obj.left = mLoc.x +offsetH;

      obj.top  = mLoc.y +offsetV;

    }

    else if (document.all)//IE

    {

      getMouseLoc();

      obj = document.all[theLayer].style;

      obj.pixelLeft = mLoc.x +offsetH;

      obj.pixelTop  = mLoc.y +offsetV;

    }

    showHideLayers(theLayer,'','show');

  }

}



//write to div/layer
//use: WriteLayer(divID,null,text)
function WriteLayer(ID,parentID,text) {
if (document.layers) {
var oLayer;
if(parentID){
oLayer = eval('document.' + parentID + '.document.' + ID + '.document');
}else{
oLayer = document.layers[ID].document;
}
oLayer.open();
oLayer.write(text);
oLayer.close();
}
else if (parseInt(navigator.appVersion)>=5&&navigator.
appName=="Netscape") {
document.getElementById(ID).innerHTML = text;
}
else if (document.all) document.all[ID].innerHTML = text;
}

function goto(URL){
	window.location.href = URL;
}


function checkAll(formObj) {
	if(formObj.check.checked) {
		selectAll(formObj, 0);
		formObj.check.checked = true;
	} else {
		selectAll(formObj, 1);
		formObj.check.checked = false;
	}

}

function selectAll(formObj, isInverse) 
{
   for (var i=0;i < formObj.length;i++) 
   {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox')
      { 
         if(isInverse)
            fldObj.checked = (fldObj.checked) ? false : true;
         else fldObj.checked = true; 
       }
   }
}

//Form Manipulations
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

//textarea characters limiter
var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}


function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename;
var rlimit;
rlimit = thelimit - theform.value.length;
var limit_text='<b><span id="'+theform.toString()+'">'+rlimit+'</span></b> characters remaining on your input limit'

if (document.all||ns6)
document.write(limit_text);
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}

}
//end textarea limiter

//confirm deletion popup
function deletethis(msg,gotourl){
	var answer = confirm (msg);
	if (answer) {
		location.href = gotourl;
	} else
		return false;
		
	return;	
}


function showSpan(id) {
	document.getElementById(id).style.display = 'block';
}

function hideSpan(id) {
	document.getElementById(id).style.display = 'none';
}



function showhideSpan(id) {
	if (document.getElementById(id).style.display == 'none')
		showSpan(id);
	else
		hideSpan(id);
}

function objectExists(Id, Tag)
{
  var o = document.getElementById(Id);
  if (o)
  {
    if (Tag)
    {
      if (o.tagName.toLowerCase() == Tag.toLowerCase())
      {
        return o;
      }
    }
    else
    {
      return o;
    }
  }
  return null;
}
