

function ELG_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	document.ELG_pgW=innerWidth; document.ELG_pgH=innerHeight; onresize=ELG_reloadPage; }}
	else if (innerWidth!=document.ELG_pgW || innerHeight!=document.ELG_pgH) location.reload();
}
ELG_reloadPage(true);

function ELG_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=ELG_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function ELG_showHideLayers() { //v6.0
	var i,p,v,obj,args=ELG_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=ELG_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	obj.visibility=v; }
}

function ELG_preloadImages(a) { //v3.0
	var d=document;	if(d.images) { if(!d.ELG_p) d.ELG_p=new Array();
	var i, j = d.ELG_p.length; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){d.ELG_p[j]=new Image; d.ELG_p[j++].src=a[i];}}
}

function ELG_swapImgRestore() { //v3.0
	var i,x,a=document.ELG_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function ELG_swapImage() { //v3.0
	var i,j=0,x,a=ELG_swapImage.arguments; document.ELG_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=ELG_findObj(a[i]))!=null){document.ELG_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function UpDownIncrement( textBoxId, increment, minValue, maxValue )
{
	var textBoxControl = UpDownGetTextbox( textBoxId );
	if( textBoxControl != null )
	{
		if( textBoxControl.disabled == false )
		{
			var newVal = parseInt( textBoxControl.value ) + increment;
			if( newVal >= minValue && newVal <= maxValue )
				textBoxControl.value = newVal;
		}
	}
}

function UpDownDecrement( textBoxId, increment, minValue, maxValue )
{
	var textBoxControl = UpDownGetTextbox( textBoxId );
	if( textBoxControl != null )
	{
		if( textBoxControl.disabled == false )
		{
			var newVal = parseInt( textBoxControl.value ) - increment;
			if( newVal >= minValue && newVal <= maxValue )
				textBoxControl.value = newVal;
		}
	}
}

function UpDownGetTextbox( textBoxId )
{
	for( var i = 0; i < document.forms.length; i++ )
	{
		var theForm = document.forms[i];
		if( typeof( theForm[textBoxId] ) != "undefined" )
		{
			var textBoxControl = theForm[textBoxId];
			if ( isNaN( parseInt( textBoxControl.value ) ) )
				textBoxControl.value = 0;
			return textBoxControl;
		}
	}
	return null;
}

function TextLengthEvaluateIsValid( val )
{
	var control = document.all[ val.controltovalidate ];

    var text = control.value;
    text = text.replace(/^\s*|\s*$/g,"");
    
	if( text.length < val.minimumlength )
	{
		val.errormessage = val.errormessagetooshort;
		return false;
	}
	else if( text.length > val.maximumlength )
	{
		val.errormessage = val.errormessagetoolong;
		return false;
	}

	return true;
}		

function ToggleAccordian(accordianID) {
	document.getElementById(accordianID).style.display = document.getElementById(accordianID).style.display == "none" ? "" : "none";
}
function SaveClick(bbcomURL, params,propid)
{
    var url = bbcomURL +"/TrackInnClicks.aspx";
    seperator = "?";
    if (params)
    {
        url += seperator + params;
    }
    //send click to google
    var linkprefix;
    var RealPropID =-1;
        try
        {
            if (url.indexOf("PROP=") > 0)
            {
                if (url.indexOf("&") > 0)
                {
                    RealPropID = url.substring(url.indexOf("PROP=") + 5,url.indexOf("&"));
                }
                else
                {
                    RealPropID = url.substring(url.indexOf("PROP=") + 5);
                }
                if (url.indexOf("FLID") > 0)
                    linkprefix = "IOTM";
                else if (url.indexOf("ALTR") > 0)
                    linkprefix = "ALT_LISTING";
                else
                    linkprefix = "LISTING";
            }
            if (url.indexOf("IFS=") > 0)
            {
                if (url.indexOf("&") > 0)
                {
                    RealPropID = url.substring(url.indexOf("IFS=") + 4,url.indexOf("&"));
                }
                else
                {
                    RealPropID = url.substring(url.indexOf("IFS=") + 4);
                }
            }
            else if (propid != 'undefined')
            {
                RealPropID = propid;
                linkprefix = "FPA";
            }
            var track = "/" + linkprefix + "/" + RealPropID;
            if (RealPropID != -1 && typeof(urchinTracker) !='undefined')
            {
                 urchinTracker("/" + linkprefix + "/" + RealPropID);
            }
    }
    catch(e){}

    SendTrackingLink(url);

}

function SendTrackingLink(url)
{
        if (url.indexOf("?") < 0)
            url += "?rnd=" + Math.floor(Math.random()*5000000);
        else
            url += "&rnd=" + Math.floor(Math.random()*5000000);
var atLoadImage = new Image;
   atLoadImage.src = url;
}

		