// On Mouse events
function isDefined(property)
{
return (typeof property != 'undefined');
}

if (isDefined(window.addEventListener))
{
window.addEventListener("load", RunLoadFunctions, false);
}

else if (isDefined(window.attachEvent))
{
window.attachEvent("onload", RunLoadFunctions);
}

// Targets
function externalLinks()
{

if (!document.getElementsByTagName)
return;

var anchors = document.getElementsByTagName("a");

for (var i=0; i<anchors.length; i++)
{ 
var anchor = anchors[i];

if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") 
{
anchor.target = "_blank"; 
}

}

}

function BlurLinks()
{
lnks	= document.getElementsByTagName("a");

for(i=0;i<lnks.length;i++)
{
	
lnks[i].onfocus	= new Function("this.blur()");
//lnks[i].onclick 	= function() { internalLink = true;}
}

// Input Buttons
inpts	= document.getElementsByName("input");

for(i=0;i<inpts.length;i++)
{
inpts[i].onfocus= new Function("this.blur()");
}

}

function RunLoadFunctions()
{

if (document.getElementById("PropertyTabs"))
{
initializetabcontent("PropertyTabs");
}

if ((document.getElementById("Map")) || (document.getElementById("Map2")))
{
load_map();
expandtab("PropertyTabs", 0);
}

if (document.getElementById("Thumbs"))
{
ThumbNails();
}

if (document.getElementById("QuickSearchForm"))
{
document.getElementById("QuickSearchForm").ListingType.onchange	= new Function("PopulatePrices()");
}

if (document.getElementById("RefineSearchForm"))
{
document.getElementById("RefineSearchForm").ListingType.onchange	= new Function("PopulatePrices()");
}

if (document.getElementById("AdvancedSearchForm"))
{

SelectType	= document.getElementById("AdvancedSearchForm").ListingType.type;

if (SelectType.indexOf("select") >= 0)
{
document.getElementById("AdvancedSearchForm").ListingType.onchange	= new Function("PopulatePrices()");
}

}

if ((document.getElementById("QuickSearchForm")) || (document.getElementById("RefineSearchForm")) || (document.getElementById("AdvancedSearchForm")))
{
PopulatePrices();
}

externalLinks();
BlurLinks();

}

function shortlist(PropertyID)
{
ReturnPage	= window.location.href;
ReturnPage	= ReturnPage.split("/");
ReturnPage	= ReturnPage[0];
ShortList	= 0;

if (getCookie("ShortList"))
{
ShortList	= parseInt(getCookie("ShortList"));
}

ShortList	= ShortList + 1;
CookieName	= "Short" + ShortList;

setCookie("ShortList", ShortList);
setCookie(CookieName, ShortList);

window.location.href	= ReturnPage;
}

function ThumbNails()
{
Thumb	= document.getElementById("Thumbs").getElementsByTagName("a");
Count	= 0;

for(i=0;i<Thumb.length;i++)
{

if (Thumb[i].rel == "Thumb")
{
ThumbImage	= Thumb[i].href;
Thumb[i].href	= "javascript:void('0')";
Thumb[i].onclick	= new Function("ChangeThumbImage('" + ThumbImage + "')");
}

}

}

function ChangeThumbImage(Thumb)
{

if (document.getElementById("MainImage").src != Thumb)
{
document.getElementById("MainImage").src = Thumb;
}

}