function isNull(val){return(val==null);}

function hiBlock(sBlock)
{
	var sTmp = left(sBlock, sBlock.length - 1)
	document.getElementById(sTmp + 'a').className = "linkHi fancy"
	document.getElementById(sTmp + 'b').style.fontWeight = "bold"
}

function loBlock(sBlock)
{
	var sTmp = left(sBlock, sBlock.length - 1)
	document.getElementById(sTmp + 'a').className = "linkLo fancy"
	document.getElementById(sTmp + 'b').style.fontWeight = "normal"
}

function left(str, n)
{
	if (n <= 0)
	{
		return "";
	}
	else if (n > String(str).length)
	{
		return str;
	}
	else
	{
		return String(str).substring(0, n);
	}
}

function correctPNG()
{
	if (document.all)
	{
		for(var i=0; i<document.images.length; i++)
		{
			var img = document.images[i]
			var imgName = img.src.toUpperCase()
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
			{
				img.style.display = "block"
				var imgID = (img.id) ? "id='" + img.id + "' " : ""
				var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				var imgStyle = "visibility: visible; display:inline-block;" + img.style.cssText 
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
				var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
				img.outerHTML = strNewHTML
				i = i - 1
			}
		}
	}
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function addEvent(elm, evType, fn, useCapture)
{
  if (elm.addEventListener){
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent){
    var r = elm.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Please upgrade your browser to use full functionality on this page");
  }
}

function showProperties()
{
	var iBeds = document.getElementById("hbeds").value
	var iBedDesc = document.getElementById("hbeddesc").value
	if (iBedDesc == "") {iBedDesc = "1"}
	//var sLoc = document.getElementById("hloc").value
	//var sArea = document.getElementById("harea").value
	//var sType = document.getElementById("hbeds").value

	if (document.getElementById("hpets").checked) {sPets = "Y"} else {sPets = ""}
	if (document.getElementById("hsmoking").checked) {sNonSmoking = "Y"} else {sNonSmoking = ""}
	if (document.getElementById("hlinens").checked) {sLinens = "Y"} else {sLinens = ""}
	if (document.getElementById("hpool").checked) {sPool = "Y"} else {sPool = ""}
	if (document.getElementById("hhottub").checked) {sHotTub = "Y"} else {sHotTub = ""}
	if (document.getElementById("helevator").checked) {sElevator = "Y"} else {sElevator = ""}
	if (document.getElementById("hinternet").checked) {sInternet = "Y"} else {sInternet = ""}

	var sSort = document.getElementById("hsort").value
	document.location.href = "http://www.oakislandpets.com/VacationRentals.asp?beds=" + iBeds + "&bedDesc=" + iBedDesc + "&pets=" + sPets + "&nonsmoking=" + sNonSmoking + "&linens=" + sLinens + "&pool=" + sPool + "&hottub=" + sHotTub + "&elevator=" + sElevator + "&internet=" + sInternet + "&sort=" + sSort
}

var popupHandle;
function closePopup()
{
	if(popupHandle != null && !popupHandle.closed) popupHandle.close();
}

function displayPopup(url,name,height,width)
{
	var properties = "location=0, scrollbars,resizable, menubar=0, status=0, titlebar=0, toolbar=0, height = " + height;
	properties = properties + ", width=" + width;
	var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		screenY = document.body.offsetHeight;
		screenX = window.screen.availWidth;
	}
	else
	{
		screenY = window.outerHeight
		screenX = window.outerWidth
	}
	leftvar = (screenX - width) / 2;
	rightvar = (screenY - height) / 2;
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		leftprop = leftvar;
		topprop = rightvar;
	}
	else
	{
		leftprop = (leftvar - pageXOffset);
		topprop = (rightvar - pageYOffset);
	}
	properties = properties + ", left = " + leftprop;
	properties = properties + ", top = " + topprop;
	closePopup();
	popupHandle = open(url,name,properties);
}

function NewWindow(mypage, myname, w, h, scroll, url, menubar)
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;

	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
	if (menubar == 'yes') {winprops = winprops + ',menubar=yes'}
	if (url == '')
	{
		win = window.open(mypage, myname, winprops)
	}
	else
	{
		win = window.open(mypage + '&page=' + url, myname, winprops)
		if (!win.opener)
		{
			win.opener = self
		}
	}
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
