function pageInURL(URL)
{
	var URLlength	= URL.length;
	for (var i=URLlength; i>1; i=i-1) {
		tmpURL			= URL.substring(i, URL);
		tmpURLlength	= tmpURL.length;
		if(tmpURL.substring(tmpURLlength-1,tmpURLlength)=="/") {
			var URLstart = URL.substring(tmpURLlength,URLlength);
			break; 
			}
	}
	var URLend		= URLstart.indexOf(".");
	var pageURL		= URLstart.substring(0,URLend);
	return pageURL;
}

function getObject(arg, formObj) {
    var myObj = null;
    if (formObj != null) {
    	myObj = formObj.elements[arg];
    } else if (typeof arg == 'string') {
        myObj = document.getElementById(arg);
    } else if (typeof arg == 'object') {
        myObj = arg;
    }

    return myObj;
}


function swapImage(obj, src)
{
	if(obj){
		obj.src = src;
	}
}

function genRandAd(channel,tile,x,y) {
	var lbound = 1000;
	var ubound = 9999;
	var rnd = Math.floor(Math.random() * (ubound - lbound)) + lbound;
	var size = x + 'x' + y;
	var url = 'http://ad.doubleclick.net/adi/cablevision.news12/' + channel + ';sz=' + size + ';tile=' + tile + ';ord=' + rnd;
	contents =  '<ifr' + 'ame src=' + url + '? name=frame1 width=' + x + ' height=' + y + ' frameborder=no border=0 marginwidth=0 marginheight=0 scrolling=no>';
	contents += '<scr' + 'ipt language=JavaScript1.1 src=' + url + '></scr' + 'ipt>';
	contents += '<nosc'+'ript>';
	contents += '<a href=' + url + '? target=\"_blank\"><img src=' + url + '? border=0 height=' + y + ' width=' + x + ' vspace=0 hspace=0></a>';
	contents += '</nosc'+'ript>';
	contents += '</ifr'+'ame>';
	document.write(contents);
}

var CntPage		= pageInURL(document.location.href);
var SubPage		= CntPage.split("_");
if(SubPage.length-1 > 0)
{
	CntPage	= SubPage[0];
	SubPage	= SubPage[1];
}

var isFromN12 = (getCookie("oh_from_n12") != null) && (getCookie("oh_from_n12").split("|")[0] == "true");
if (isFromN12) {
	var regionN12 = getCookie("oh_from_n12").split("|")[1];
	document.write('<div style="position:relative; left:-110px;"><IFRAME SRC="http://www.news12.com/includes/home_header.jsp?optimum=1" WIDTH="998" HEIGHT="130" FRAMEBORDER="0" scrolling="No" style="margin-left:10px;"></IFRAME></div>');
}

document.write("<table width=\"780\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
document.write("<tr><td align=\"left\"><a href=\"re_home.jsp\" title=\"Find real estate to buy or rent in New York, New Jersey and Connecticut with Optimum Homes.\"><img src=\"homes/interface/oh_logo_web_header.jpg\" width=\"218\" height=\"63\" alt=\"Find real estate to buy or rent in New York, New Jersey and Connecticut with Optimum Homes.\" border=\"0\"></a></td>");
if (isFromN12) {
	document.write("<td valign=\"middle\" align=\"right\">Sponsored<br> by:</td><td align=\"right\" style=\"padding-right:35px; width:98px;\"><script language=javascript>genRandAd('HomesSponsor',1,88,31);</script></td></tr></table>");
} else {
	document.write("<td align=\"right\" style=\"padding-right:35px;\"><a href=\"http://www.optimum.com/io/what/enhanced_tv.jsp\" title=\"Experience Optimum Homes on TV!\"><img src=\"homes/interface/oh_iO_606_web_header.jpg\" width=\"144\" height=\"43\" alt=\"Experience Optimum Homes on TV!\" border=\"0\"></a></td></tr></table>");
}
document.write("<table id=\"oh_top_nav\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");


if(SubPage == "home")
{
document.write("<tr><td><a href=\"re_home.jsp\"><img src=\"homes/interface/oh_head_home_on.jpg\" width=\"127\" height=\"25\" name=\"home\" alt=\"\" border=\"0\"></a></td>");
}
else
{
document.write("<tr><td><a onMouseOver=\"swapImage(document.home,'homes/interface/oh_head_home_roll-over.jpg')\" onMouseOut=\"swapImage(document.home,'homes/interface/oh_head_home_off.jpg')\" onMouseDown=\"swapImage(document.home,'homes/interface/oh_head_home_click.jpg')\" href=\"re_home.jsp\"><img src=\"homes/interface/oh_head_home_off.jpg\" width=\"127\" height=\"25\" name=\"home\" alt=\"\" border=\"0\"></a></td>");
}

if(SubPage == "buying") 
{
document.write("<td><a href=\"re_buying_home.jsp\"><img src=\"homes/interface/oh_head_buy_on.jpg\" width=\"127\" height=\"25\" name=\"buying\" alt=\"\" border=\"0\"></a></td>");
}
else
{
document.write("<td><a onMouseOver=\"swapImage(document.buying,'homes/interface/oh_head_buy_roll-over.jpg')\" onMouseOut=\"swapImage(document.buying,'homes/interface/oh_head_buy_off.jpg')\" onMouseDown=\"swapImage(document.buying,'homes/interface/oh_head_buy_click.jpg')\" href=\"re_buying_home.jsp\"><img src=\"homes/interface/oh_head_buy_off.jpg\" width=\"127\" height=\"25\" name=\"buying\" alt=\"\" border=\"0\"></a></td>");
}

if(SubPage == "renting") 
{
document.write("<td><a href=\"re_renting_home.jsp\"><img src=\"homes/interface/oh_head_rent_on.jpg\" width=\"127\" height=\"25\" name=\"renting\" alt=\"\" border=\"0\"></a></td>");
}
else
{
document.write("<td><a onMouseOver=\"swapImage(document.renting,'homes/interface/oh_head_rent_roll-over.jpg')\" onMouseOut=\"swapImage(document.renting,'homes/interface/oh_head_rent_off.jpg')\" onMouseDown=\"swapImage(document.renting,'homes/interface/oh_head_rent_click.jpg')\" href=\"re_renting_home.jsp\"><img src=\"homes/interface/oh_head_rent_off.jpg\" width=\"127\" height=\"25\" name=\"renting\" alt=\"\" border=\"0\"></a></td>");
}

if(SubPage == "realtor") 
{
document.write("<td><a href=\"re_realtor_home.jsp\"><img src=\"homes/interface/oh_head_find_on.jpg\" width=\"127\" height=\"25\" name=\"realtors\" alt=\"\" border=\"0\"></a></td>");
}
else
{
document.write("<td><a onMouseOver=\"swapImage(document.realtors,'homes/interface/oh_head_find_roll-over.jpg')\" onMouseOut=\"swapImage(document.realtors,'homes/interface/oh_head_find_off.jpg')\" onMouseDown=\"swapImage(document.realtors,'homes/interface/oh_head_find_click.jpg')\" href=\"re_realtor_home.jsp\"><img src=\"homes/interface/oh_head_find_off.jpg\" width=\"127\" height=\"25\" name=\"realtors\" alt=\"\" border=\"0\"></a></td>");
}

if(SubPage == "gallery") 
{
document.write("<td><a href=\"video_gallery.jsp\"><img src=\"homes/interface/oh_head_videos_on.jpg\" width=\"127\" height=\"25\" name=\"gallery\" alt=\"\" border=\"0\"></a></td>");
}
else
{
document.write("<td><a onMouseOver=\"swapImage(document.gallery,'homes/interface/oh_head_videos_roll-over.jpg')\" onMouseOut=\"swapImage(document.gallery,'homes/interface/oh_head_videos_off.jpg')\" onMouseDown=\"swapImage(document.gallery,'homes/interface/oh_head_videos_click.jpg')\" href=\"video_gallery.jsp\"><img src=\"homes/interface/oh_head_videos_off.jpg\" width=\"127\" height=\"25\" name=\"gallery\" alt=\"\" border=\"0\"></a></td>");
}

if(SubPage == "neighborhood") 
{
document.write("<td><a href=\"re_neighborhood_search.jsp\"><img src=\"homes/interface/oh_head_neighbor_on.jpg\" width=\"127\" height=\"25\" name=\"neighborhoods\" alt=\"\" border=\"0\"></a></td></tr></table>");
}
else
{
document.write("<td><a onMouseOver=\"swapImage(document.neighborhoods,'homes/interface/oh_head_neighbor_roll-over.jpg')\" onMouseOut=\"swapImage(document.neighborhoods,'homes/interface/oh_head_neighbor_off.jpg')\" onMouseDown=\"swapImage(document.neighborhoods,'homes/interface/oh_head_neighbor_click.jpg')\" href=\"re_neighborhood_search.jsp\"><img src=\"homes/interface/oh_head_neighbor_off.jpg\" width=\"127\" height=\"25\" name=\"neighborhoods\" alt=\"\" border=\"0\"></a></td></tr></table>");
}
