/****************************************************************************
file:			prc-nav-java-v02.js
author:			Bryan Carrington
description:	JavaScript for ForRent.com
changes:		2007.12.3 - bryan.carrington@de.com - Bryan Carringto -- Initial code
******************************************************************************/

/* moved from search.tile */
function getCityList(val, refresh){	
	if (!val) return;
	
	// get list of cities from database / cache
	new Ajax.Request('/ajax/geoGetList.php?state='+escape(val),
  {
    method:'get',
    onSuccess: function(transport){
      var response=transport.responseText;
      if (response){
       	 myList=response.split(',');
       	 if (!refr){
       	 	refr=actb(document.getElementById('search_city'),myList);
       	 }else{       	 
       	 	refr.actb_keywords=myList;       	 	       	 
       	 }
       	 if (refresh) {       	 
       	 	$('search_city').value='';
       	 	checkMetro();
       	 }
      }     
    }   
  });
}

function checkMetro(){
	if ($F('search_city').length > 0){
		$('CA').disabled=1;
		$('super_city').disabled=1;
	}else {
		$('CA').disabled=0;
		$('super_city').disabled=0;
	}
}

//  Flash check
var MM_contentVersion=7;
var plugin=(navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
	var words=navigator.plugins["Shockwave Flash"].description.split(" ");
	for (var i=0; i < words.length; ++i) {
		if (isNaN(parseInt(words[i])))
		continue;
		var MM_PluginVersion=words[i];
	}
	var MM_FlashCanPlay=MM_PluginVersion >=MM_contentVersion;
	FlashMode=0;
	if (navigator.plugins && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash"]) {
			var plugin_version=0;
			var words=navigator.plugins["Shockwave Flash"].description.split(" ");
			for (var i=0; i < words.length; ++i) {
				if (isNaN(parseInt(words[i])))
				continue;
				plugin_version=words[i];
			}
			if (plugin_version >=8) {
				var plugin=navigator.plugins["Shockwave Flash"];
				var numTypes=plugin.length;
				for (j=0; j < numTypes; j++) {
					mimetype=plugin[j];
					if (mimetype) {
						if (mimetype.enabledPlugin && (mimetype.suffixes.indexOf("swf") !=-1)) // Mac wierdness
						FlashMode=1;
						if (navigator.mimeTypes["application/x-shockwave-flash"]==null)
						FlashMode=0;
					}
				}
			}
		}
	}
	var MM_FlashCanPlay=(FlashMode==1) ? true : false
	
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") !=-1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay=( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}

// Flash Navigation
function flashNav() {
	
	var img_path=(location.protocol=='https:') ? 'https://secure.forrent.com/imgs/fr/siteFiles/site/flash/' : 'http://images.forrent.com/imgs/fr/siteFiles/site/flash/';
	var which_swf='nav.swf';
	var flashParams='?searchURL=' +  flashPath + '/search.php&relocationURL=' +  flashPath + '/relocation.php&rentURL=' + flashPath + '/privatePartySignup.php?step=0&managersURL=' + flashPath + '/admin.php&aboutURL=' + flashPath + '/aboutus.php';
	document.write('<object type="application/x-shockwave-flash" data="' + img_path + which_swf + flashParams + '"  width="705" height="30">');
	document.write('<param name="movie" value="' + img_path + which_swf + flashParams + '" />');
	document.write('<param name="menu" VALUE="false" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('</object>');
}

// Flash navigation alternate
function flashAlt(urlPath,imgPath) {
	document.write('<div id="navMenuLead"></div>');
	document.write('<div id="navMenu">');
	document.write('<ul>');
	document.write('<li><a id="searchBtn" href="' + urlPath + '/search.php"><img src="' + imgPath + 'btn-search.gif" width="75" height="30" border="0" alt="Search ForRent.com" /></a></li>');
	document.write('<li><a id="reloBtn" href="' + urlPath + '/relocation.php"><img src="' + imgPath + 'btn-relocationcenter.gif" width="148" height="30" border="0" alt="Relocation Center" /></a></li>');
	document.write('<li><a id="rentpropBtn" href="' + urlPath + '/privatePartySignup.php?step=0"><img src="' + imgPath + 'btn-rentyourproperty.gif" width="152" height="30" border="0" alt="Rent Your Property" /></a></li>');
	document.write('<li><a id="managersBtn" href="' + urlPath + '/admin.php"><img src="' + imgPath + 'btn-managersandowners.gif" width="158" height="30" border="0" alt="Managers and Owners" /></a></li>');
	document.write('<li><a id="aboutBtn" href="' + urlPath + '/aboutus.php"><img src="' + imgPath + 'btn-aboutus.gif" width="76" height="30" border="0" alt="About ForRent.com" /></a></li>');
	document.write('</ul>');
	document.write('</div>');
}

// Hide and Show Divs 
function showDiv(linkId,divId,defaultState) {
    var txt;
    // The switch stament lists the links that trigger this function and their text changes
    switch (linkId) {
    	case 'homeSearchCriteriaLink': 
    		txt=(defaultState=='1') ? 'Hide Optional Search Criteria' : 'Show Optional Search Criteria';
    		break;
    }
    // Map and email a friend divs on the profile page uses a hide show div function but is specialized. These functions can be found in profilePage.js
	document.getElementById(linkId).innerHTML=txt;
	var stateNow=(defaultState=='1') ? 'block' : 'none';
	var newState=(defaultState=='1') ? '0' : '1'; 
	document.getElementById(linkId).href="javascript:showDiv('"+linkId+"','"+divId+"','"+newState+"');"
	document.getElementById(divId).style.display=stateNow	
}

/* ----------------- geoCoding.js functions -------------------------- 
@author : shashi,myadam
@email :shashikanth.myadam@traderonline.com
comments : This js file is used for dynamically populating the dropdowns
on the home page and all the search pages.

This functions populates a dropdown {Dropdown} of an
area of type {type CA or SC or CT}  with id {id} and
default_text is the text which you want to display on first value of the dropdown
like "select a state" */
function getArea(type,id,Dropdown,default_text,optional,page,dt_is_value,state,active) {
	if (typeof optional=="undefined") {optional="";}
	if (typeof page=="undefined") {page="search";}
	if (typeof dt_is_value=="undefined") {dt_is_value=0;}
	if (typeof state=="undefined") {state="";}
	if(id.substr(0,6) !="Select" && trim(id) !="")
	{
		var response;
	    var url=(state !='') ? "/ajax/geoCoding.ajax.php?type="+type+"&id="+id+"&state="+state : "/ajax/geoCoding.ajax.php?type="+type+"&id="+id+"&active="+active
		new Ajax.Request(url,{method:'get',onComplete:function(response)
		{
        	clear(Dropdown);
        	if(page=="search") //Does this even work anymore, seems to cause more problems than solutions. -bryan
			{ //a lot of pages ive seen don't define the page so it defaults to search and ends up messing up. -bryan
				if(type=='CA')
				{
					clear($('super_city'));
					$('super_city').options[0]=new Option("Select a City Area","");
					clear($('city'));
					$('city').options[0]=new Option("Select a City","");
					clear($('neighborhood'));
					$('neighborhood').options[0]=new Option("Select a Neighborhood","");
				}
				if(type=='SC')
				{
					clear($('city'));
					$('city').options[0]=new Option("Select a City","");
					clear($('neighborhood'));
					$('neighborhood').options[0]=new Option("Select a Neighborhood","");
				}
				if(type=='CT')
				{
					clear($('neighborhood'));
					$('neighborhood').options[0]=new Option("Select a Neighborhood","");
				}
			}
			else
			{
				if(type=='CA')
				{
					// clear($('super_city'));
					//$('super_city').options[0]=new Option("Select a City Area","");
				}
			}
			if (dt_is_value==0) {
				Dropdown.options[0]=new Option(default_text,"");
			}
			var temp=new Array();
			var temp1=new Array();
			var i=0;
			temp=response.responseText.split('|');
			for(i=0;i<temp.length;i++)
			{
				//populate dropdown
				temp1=temp[i].split(':');
				if(temp1.length==2)
				{
					if(temp1[1].length > 0 && temp1[0].length>0)
					{
						if(optional==temp1[0])
						{
							Dropdown.options[i+1]=new Option(temp1[1],temp1[0],true,true);
						}
						else
						{
							if (dt_is_value==1 && temp1[0]==default_text) {
								Dropdown.options[i+1]=new Option(temp1[1],temp1[0], true);
							} else {
								Dropdown.options[i+1]=new Option(temp1[1],temp1[0]);
							}
						}

					}
				}
			}

		}
		});
	} else {
		clear(Dropdown);
		if(page=="search") //Does this even work anymore, seems to cause more problems than solutions. -bryan
		{ //a lot of pages ive seen don't define the page so it defaults to search and ends up messing up. -bryan
			if(type=='CA')
			{
				clear($('super_city'));
				$('super_city').options[0]=new Option("Select a City Area","");
				clear($('city'));
				$('city').options[0]=new Option("Select a City","");
				clear($('neighborhood'));
				$('neighborhood').options[0]=new Option("Select a Neighborhood","");
			}
			if(type=='SC')
			{
				clear($('city'));
				$('city').options[0]=new Option("Select a City","");
				clear($('neighborhood'));
				$('neighborhood').options[0]=new Option("Select a Neighborhood","");
			}
			if(type=='CT')
			{
				clear($('neighborhood'));
				$('neighborhood').options[0]=new Option("Select a Neighborhood","");
			}
		} else {
			if(type=='CA')
			{
				// clear($('super_city'));
				//$('super_city').options[0]=new Option("Select a City Area","");
			}
		}
		Dropdown.options[0]=new Option(default_text,"");
	}
}

function getcollege(state,Dropdown,optional) {
	if (typeof optional=="undefined") {optional="";}
	var response;
	var url="/ajax/geoCoding.ajax.php?type=college&state="+state;
	new Ajax.Request (url,{method:'get',onComplete:function(response)
	{
		clear(Dropdown);
		Dropdown.options[0]=new Option("Select a College","");
		var temp=new Array();
		var temp1=new Array();
		var i=0;
		temp=response.responseText.split('|');
		for(i=0;i<temp.length;i++)
		{
			//populate dropdown
			temp1=temp[i].split(':');
			if(temp1.length==2)
			{
				if(temp1[1].length > 0 && temp1[0].length>0)
				{
					if(optional==temp1[0])
					{
						Dropdown.options[i+1]=new Option(temp1[1],temp1[1],true,true);
					} else {
						Dropdown.options[i+1]=new Option(temp1[1],temp1[1]);
					}
				}
			}
		}
	}
	});
}

function getmilitary(branch,Dropdown,optional) {
	if (typeof optional=="undefined") {optional="";}
	//This checks to see they have not selected the default text
	if(branch.substr(0,6) !="Select" && trim(branch) !="")
	{
		var response;
		var url="/ajax/geoCoding.ajax.php?type=military&branch="+branch;
		new Ajax.Request (url,{method:'get',onComplete:function(response) {
			clear(Dropdown);
			Dropdown.options[0]=new Option("Select a Military Base","");
			var temp=new Array();
			var temp1=new Array();
			var i=0;
			temp=response.responseText.split('|');
			for(i=0;i<temp.length;i++) {
				//populate dropdown
				temp1=temp[i].split(':');
				if(temp1.length==2) {
					if(temp1[1].length > 0 && temp1[0].length>0) {
						if(optional==temp1[0]) {
							Dropdown.options[i+1]=new Option(temp1[1],temp1[1],true,true);
						} else {
							Dropdown.options[i+1]=new Option(temp1[1],temp1[1]);
						}	
					}
				}
			}
		
		}
		});
	}
}

// Function to see if the returned id is numeric
function IsNumeric(strString) {
	//  check for valid numeric strings
	var strValidChars="0123456789.-";
	var strChar;
	var blnResult=true;
	if (strString.length==0) return false;
	//  test strString consists of valid characters listed above
	for (i=0; i < strString.length && blnResult==true; i++)	{
		strChar=strString.charAt(i);
		if (strValidChars.indexOf(strChar)==-1) blnResult=false;
	}
	return blnResult;
}

// function to get counts
function get_Area_Count() {
	if (parseInt($F('neighborhood')) >0) {
		getCount("NH",$F('neighborhood'),$F('states'));
		return;
	} else if(parseInt($F('city')) >0) {
		getCount("CT",$F('city'),$F('states'))  ;
		return;
	} else if(parseInt($F('super_city')) >0) {
		getCount("SC",$F('super_city'),$F('states'))  ;
		return;
	} else if(parseInt($F('CA')) >0) {
		getCount("CA",$F('CA'),$F('states'))  ;
		return;
	}
}

// function to get count
function getCount(type,id,state) {
	//setting bet,baths,pricelow,pricehigh values
	baths=document.search.baths.value;
	beds=document.search.beds.value;
	price_low=document.search.price_low.value;
	price_high=document.search.price_high.value;
	var response;
	var url="/ajax/geoCoding.ajax.php?count=true&type="+type+"&id="+id+"&state="+state+"&beds="+beds+"&baths="+baths+"&price_low="+price_low+"&price_high="+price_high;
	new Ajax.Request(url,{method:'get',onComplete:function(response){
		count=response.responseText;
		$('searchAptCount').style.display="";
		$('searchAptCount').innerHTML="<p class=\"aptCount\" id=\"aptCount\">"+ count + " Apartments Found</p>";
	} });
}

// clears any form element
function clear(objSelect) {
	for (var i=(objSelect.options.length-1); i >=0; i--){
		objSelect.options[i]=null;
	}
}

// ajax function which gets custom area check boxs in the broad search
var NH_state_code='';
function get_CAs(id) {
	var response;
	var text;
	var url="/ajax/geoCoding.ajax.php?type=CA&id="+id;
	NH_state_code=id;
	new Ajax.Request(url,{method:'get',onComplete:function(response){
		var temp=new Array();
		var temp1=new Array();
		var i=0;
		var nextid;
		temp=response.responseText.split('|');
		//this is for setting the title
		text='<strong>* Select a Metro</strong> <br/>  <a class="mainLinkTextSm" href="javascript:void(\'0\');" onclick="document.getElementById(\'testOn\').style.display=\'none\'; document.getElementById(\'mapWrap\').style.display=\'block\';">Back to Map</a> <br /> <input type="hidden" name="search_type" id="search_type" value="CA">'
		for(i=0;i<temp.length;i++) {
			temp1=temp[i].split(':');
			if(temp1.length==2) {
				if(temp1[1].length > 0 && temp1[0].length>0) {
					if(i%3==0) {
						text=text + '<br class="clear" />';
					}
					text=text + " <div style=\"float:left; width:280px;\" name=\"cadiv\" id=\"cadiv\"><input class=\"checkbox\" type=\"checkbox\" name=\"CA\" id=\"CA\" value=\"" + temp1[0] + "\" onclick=\"edit_elemets(this)\"> " + temp1[1] + "</div>";
				}
			}
		}
		text=text + "<br class=\"clear\" /><br /><div align=\"center\"><input type=\"button\" name=\"refine\" id=\"refine\" value=\"Refine Search\" onclick=\"get_SC_CT_NH('SC','Select a Super City')\"></div>";
		//alert(text);
		$('testOn').innerHTML=text;
	}
	});
}

// ajax function which gets super cities,cities and Neighborhood check boxs in the broad search
function get_SC_CT_NH(type,header) {
	var response;
	var text;
	if(no_areas_checked() > 1) {
		alert("Please select only one area to refine");
		return;
	}
	var id=get_checkedvalues();
	if(typeof id =="undefined" || id=="deleted") {
		alert("Please select an area to refine");
		return;
	}
	if (type=='NH') {
		var url="/ajax/geoCoding.ajax.php?type="+ type +"&id="+id+"&state="+NH_state_code;
	} else {
		var url="/ajax/geoCoding.ajax.php?type="+ type +"&id="+id;
	}	
	new Ajax.Request(url,{method:'get',onComplete:function(response){
		var temp=new Array();
		var temp1=new Array();
		var i=0;
		var nextid;
		temp=response.responseText.split('|');
		//this is for setting the title
		text=header + '<br/><a class="mainLinkTextSm" href="javascript:void(\'0\');" onclick="document.getElementById(\'testOn\').style.display=\'none\'; document.getElementById(\'mapWrap\').style.display=\'block\';">Back to Map</a> <br /><input type="hidden" name="search_type" id="search_type" value="' + type +'">'
		for(i=0;i<temp.length;i++) {
			temp1=temp[i].split(':');
			if(temp1.length==2) {
				if(temp1[1].length > 0 && temp1[0].length>0) {
					if(i%3==0) {
						text=text + '<br class="clear" />';
					}
					//text=text + " <input type=\"checkbox\" name=\"" + temp1[0] + "\" id=\"" + temp1[0] + "\" value=\""+type+"[]\">" + temp1[1];
					text=text + " <div style=\"float:left; width:280px;\" name=\"cadiv\" id=\"cadiv\"><input class=\"checkbox\" type=\"checkbox\" name=\"" + type + "[]\" id=\"" + type + "[]\" value=\""+temp1[0]+"\">" + temp1[1] + "</div>";

				}
			}
		}
      if(temp.length > 1) {
		if(type=='SC') {
			text=text + "<br class=\"clear\" /><br /><div align=\"center\"> <input type=\"button\" name=\"refine\" id=\"refine\" value=\"refine\" onclick=\"get_SC_CT_NH('CT','Select a City')\"></div>";
		}
		if(type=='CT') {
			text=text + "<br class=\"clear\" /><br /><div align=\"center\"> <input type=\"button\" name=\"refine\" id=\"refine\" value=\"refine\" onclick=\"get_SC_CT_NH('NH','Select a Neighborhood')\"></div>";
		}
		$('testOn').innerHTML=text;
      } else {
         $('testOn').innerHTML="This area cannot be refined.Please hit search.<br/>" + $('testOn').innerHTML ;
         $('refine').style.display="none";
      }
	}
	});
}

// un checks the previous custom area so that only one custom area is checked
function edit_elemets(element) {
	for(i=0;i<$('testOn').childNodes.length;i++) {
		if($('testOn').childNodes[i].id=="cadiv") {
			if($('testOn').childNodes[i].childNodes[0].nodeType==1 && $('testOn').childNodes[i].childNodes[0].checked==true && $('testOn').childNodes[i].childNodes[0].value!=element.value) {
				$('testOn').childNodes[i].childNodes[0].checked=false;
			}
		}
	}
}

// gets the area id which was checked
function get_checkedvalues() {
	var id=0;
	for(i=0;i<$('testOn').childNodes.length;i++) {
		if($('testOn').childNodes[i].id=="cadiv")	{
			if($('testOn').childNodes[i].childNodes[0].nodeType==1 && $('testOn').childNodes[i].childNodes[0].checked==true) {
				id=$('testOn').childNodes[i].childNodes[0].value;
				return id;
			}
		}
	}
}

function trim(s) {
	// Remove leading spaces and carriage returns
	while ((s.substring(0,1)==' ') || (s.substring(0,1)=='\n') || (s.substring(0,1)=='\r') || (s.substring(0,1)=='\t'))
	{ s=s.substring(1,s.length); }
	// Remove trailing spaces and carriage returns
	while ((s.substring(s.length-1,s.length)==' ') || (s.substring(s.length-1,s.length)=='\t') || (s.substring(s.length-1,s.length)=='\n') || (s.substring(s.length-1,s.length)=='\r'))
	{ s=s.substring(0,s.length-1); }
	return s;
}

// gets number of areas checked 
function no_areas_checked() {
	var count=0;
	for(i=0;i<$('testOn').childNodes.length;i++) {
		if($('testOn').childNodes[i].id=="cadiv") {
			if($('testOn').childNodes[i].childNodes[0].checked==true) {
				count=count +1;
			}
		}
	}
	return count;
}
/* ----------------- flash.js functions -------------------------- */
if(location.protocol=='https:') {serverName='secure';}
else{serverName='not secure';}
// Flash media center for the detail page
function mediaCenter(domain,siteID,designName,access,backURL) {
	var which_swf='http://'+domain+'/flash/mediacenter/mediacenterSM.swf';
	backURL=backURL+'&initialBtn='+readCookie('playFirst'); 
	drawMediaCenter(domain,siteID,designName,access,backURL,which_swf,'727','315');
}
// Flash media center for the FPI detail page
function mediaCenterFPI(domain,siteID,designName,access,backURL) {
	var which_swf='http://'+domain+'/flash/mediacenter/fpi/mediacenterSM.swf';
	drawMediaCenter(domain,siteID,designName,access,backURL,which_swf,'727','315');
}

// Large Flash media center for the detail page
function mediaCenterLg(domain,siteID,designName,access,backURL,which_swf) {
	//var which_swf='http://'+domain+'/flash/mediacenter/mediacenterLG.swf';
	backURL=backURL+'&initialBtn='+readCookie('playFirst')+'&videoSize='+readCookie('videoSize');
	drawMediaCenter(domain,siteID,designName,access,backURL,which_swf,'968','378')
	createCookie('playFirst','theater',1); // reset the cookie back to theater default
}
function drawMediaCenter(domain,siteID,designName,access,backURL,which_swf,w,h) {
	var flashParams='?domain=' + domain + '&siteID=' + siteID + '&designName=' + designName + '&toppick=favorites?site=' +siteID + '%26action=add&email=guestcard/' + siteID + '&print=profilePrint/' + siteID + '&back='+backURL+'&elementID='+readCookie('test_element_id');
    document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+w+'" height="'+h+'" id="media-center" align="middle">'+
	 '<param name="allowScriptAccess" value="' + access +'" />'+
	 '<param name="movie" value="' + which_swf + flashParams +'" />'+
	 '<param name="quality" value="high" />'+
	 '<param name="bgcolor" value="#FFFFFF" />'+
	 '<embed src="' + which_swf + flashParams +'" quality="high" bgcolor="#FFFFFF" width="'+w+'" height="'+h+'" name="media-center" align="middle" allowScriptAccess="' + access +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
	 '</object>');
}
// Flash Browse Map
function browsemap() {
	var img_path='http://images.forrent.com/imgs/fr/siteFiles/site/flash/';
	var which_swf='us_map.swf?&main=2f6291&select=4796de&bg=ffffff&letters=ffffff&bordercolor=006649&stroke=999999';
	var flashParams='?&url1=' + flashPath + '/browse/&url2'
	document.write('<object type="application/x-shockwave-flash" data="' + img_path + which_swf + flashParams + '"  width="500" height="400"> '+
	 '<param name="movie" value="' + img_path + which_swf + flashParams + '" />'+
	 '<param name="menu" VALUE="false" />'+
	 '<param name="wmode" value="transparent" />'+
	 '</object>');
}
// Flash Search Menu
function searchNav() {
	var img_path='http://images.forrent.com/imgs/fr/siteFiles/site/flash/';
	var which_swf='searchnav1.swf';
	var flashParams='?cityURL=' +  flashPath + '/search-apartments-by-city.php&zipURL=' + flashPath + '/search-apartments-by-zip.php&nameURL=' +  flashPath + '/search-apartments-by-name.php&militaryURL=' + flashPath + '/search-apartments-near-military-bases.php&collegeURL=' + flashPath + '/search-apartments-near-colleges.php&espanolURL=http://www.pararentar.com';
	document.write('<object type="application/x-shockwave-flash" data="' + img_path + which_swf + flashParams + '"  width="104" height="144"> '+
	 '<param name="movie" value="' + img_path + which_swf + flashParams + '" />'+
	 '<param name="menu" VALUE="false" />'+
	 '<param name="wmode" value="transparent" />'+
	 '</object>');
}
// Search menu alternate
function searchAlt(urlPath,imgPath) {
	document.write('<div><img src="' + imgPath + 'searchtype-top.gif" width="104" height="7" border="0" alt="" /></div>'+
	 '<ul>'+
	 '<li><a id="homeAreaBtn" href="' + urlPath + '"><img src="' + imgPath + 'btn-searchtype-area.gif" width="104" height="22" border="0" alt="" /></a><br /></li>'+
	 '<li><a id="homeCityBtn" href="' + urlPath + '/search-apartments-by-city.php"><img src="' + imgPath + 'btn-searchtype-city.gif" width="104" height="22" border="0" alt="" /></a><br /></li>'+
	 '<li><a id="homeZipBtn" href="' + urlPath + '/search-apartments-by-zip.php"><img src="' + imgPath + 'btn-searchtype-zip.gif" width="104" height="22" border="0" alt="" /></a><br /></li>'+
	 '<li><a id="homeNameBtn" href="' + urlPath + '/search-apartments-by-name.php"><img src="' + imgPath + 'btn-searchtype-name.gif" width="104" height="22" border="0" alt="" /></a><br /></li>'+
	 '<li><a id="homeMilitaryBtn" href="' + urlPath + '/search-apartments-near-military-bases.php"><img src="' + imgPath + 'btn-searchtype-military.gif" width="104" height="22" border="0" alt="" /></a><br /></li>'+
	 '<li><a id="homeCollegeBtn" href="' + urlPath + '/search-apartments-near-colleges.php"><img src="' + imgPath + 'btn-searchtype-college.gif" width="104" height="22" border="0" alt="" /></a><br /></li>'+
	 '<li><a id="homeSpanishBtn" href="http://www.pararentar.com" target="_blank"><img src="' + imgPath + 'btn-searchtype-enespanol.gif" width="104" height="22" border="0" alt="" /></a><br /></li>'+
	 '</ul>'+
	 '<div><img src="' + imgPath + 'searchtype-bottom.gif" width="104" height="5" border="0" alt="" /></div>');
}
// Flash Roomplanner
function roomPlanner(domain,siteID,floorID) {
	var which_swf='http://' + domain + '/rmplanner/roomplanner.swf';
	var flashParams='?domain=' + domain +'&siteid=' + siteID + '&floorplanid=' + floorID + '&';
	document.write('<object type="application/x-shockwave-flash" data="' + which_swf + flashParams + '" width="720" height="560"> '+
	 '<param name="movie" value="' + which_swf + flashParams + '" />'+
	 '<param name="menu" VALUE="false" />'+
	 '<param name="wmode" value="transparent" />'+
	 '</object>');
}
//  Interactive Media Kit
function mediakit() {
	var img_path='http://images.forrent.com/imgs/fr/siteFiles/site/flash/';
	var which_swf='forrent.swf';
	var flashParams='';
	document.write('<object type="application/x-shockwave-flash" data="' + img_path + which_swf + flashParams + '" width="720" height="520"> '+
	 '<param name="movie" value="' + img_path + which_swf + flashParams + '" />'+
	 '<param name="menu" VALUE="false" />'+
	 '<param name="wmode" value="transparent" /> '+
	 '</object>');
}
//	Image Approval Tool Virtual Tour Editor Object
function load_virtual_tour(path,domain,tourID) {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="545" height="280" id="media-center" align="middle">'+
	 '<param name="allowScriptAccess" value="always" />'+
	 '<param name="movie" value="' + path + '/flash/mediacenter/virtual-tour-sa.swf?domain=' + domain + '&tourID=' + tourID + '" />'+
	 '<param name="quality" value="high" />'+
	 '<param name="bgcolor" value="#fff" />'+
	 '<embed src="' + path + '/flash/mediacenter/virtual-tour-sa.swf?domain=' + domain + '&tourID=' + tourID + '" quality="high" bgcolor="#fff" width="545" height="280" name="media-center" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
	 '</object>');
}
function communitytheaterIcon(siteID){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="45px" height="45px" id="communitytheater" align="middle">'+
	 '<param name="allowScriptAccess" value="always" />'+
	 '<param name="movie" value="http://images.forrent.com/imgs/fr/siteFiles/site/flash/communityTheaterIcon.swf?siteID='+siteID+'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />	<embed src="http://images.forrent.com/imgs/fr/siteFiles/site/flash/communityTheaterIcon.swf?siteID='+siteID+'" quality="high" bgcolor="#ffffff" width="45px" height="45px" name="communitytheater" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashVars="?siteID='+siteID+'" />'+
	 '</object>');
}
function communitytheaterIconClick(siteId){
	write_event('55',siteId,'site');
	createCookie('playFirst','theater',1);
	window.location="http://"+document.domain+"/apartment-community-profile/"+siteId+".php";
}

function openWin( windowURL, windowName, windowFeatures ) {
	return window.open( windowURL, windowName, windowFeatures ) ;
}

/* ----------------- cookie.js functions - cookie code -------------------------- */
function createCookie(name,value,days) {
	if (days) {
		var date=new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires="; expires="+date.toGMTString();
	} else var expires="";
	document.cookie=name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ=name + "=";
	var ca=document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c=ca[i];
		while (c.charAt(0)==' ') c=c.substring(1,c.length);
		if (c.indexOf(nameEQ)==0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

/* ----------------- searchControl.js functions -------------------------- */
var request=null;
try {
 request=new XMLHttpRequest();
} catch (trymicrosoft) {
 try {
   request=new ActiveXObject("Msxml2.XMLHTTP");
 } catch (othermicrosoft) {
   try {
     request=new ActiveXObject("Microsoft.XMLHTTP");
   } catch (failed) {
     request=null;
   }
 }
}

if (request==null)
 alert("Error creating request object!");

function getCAs() {
 var url="AJAX?type=home&state="+ document.MyForm.states.value;
 request.open("GET", url, true);
 request.onreadystatechange=updatePage;
 request.send(null);
}

function updatePage() {
 if (request.readyState==4) {
   /* Get the response from the server */
   var dropdown=request.responseText;
    clear(document.MyForm.CA);
    document.MyForm.CA.options[0]=new Option("Select a Metro","");
    var temp=new Array(); 
    var temp1=new Array(); 
    var i=0;
    temp=dropdown.split('|');
    for(i=0;i<temp.length;i++) {
        temp1=temp[i].split(':');
        if(temp1.length==2)
        {
    	   document.MyForm.CA.options[i+1]=new Option(temp1[1],temp1[0]);
        }
    }
 }
}
function clear(objSelect){
 for (var i=(objSelect.options.length-1); i >=0; i--){
     objSelect.options[i]=null;
 }
}
function replaceText(el, text) {
	if (el !=null) {
		clearText(el);    
		var newNode=document.createTextNode(text);
		el.appendChild(newNode);  
	}
}

function clearText(el) {  
	if (el !=null) {    
		if (el.childNodes) {      
			for (var i=0; i < el.childNodes.length; i++) {        
				var childNode=el.childNodes[i];        
				el.removeChild(childNode);      
			}    
		}
	}
}

function getText(el) {  
	var text=""; 
	 if (el !=null) {   
	 	 if (el.childNodes) {      
	 	 	for (var i=0; i < el.childNodes.length; i++) {        
	 	 		var childNode=el.childNodes[i];       
	 	 		 if (childNode.nodeValue !=null) {        
	 	 		 	  text=text + childNode.nodeValue;  
	 	 		 }
	 	 	}
	 	 }
	  }
	return text;
}

/* ----------------- validation.js functions --------------------------
@author : shashi,myadam
@email :shashikanth.myadam@traderonline.com
comments : This js file is used for validation 
the form on hom page and search page */

function validate_homesearch() {
	if(($F('states')=="" || $F('states')=='--') || (($F('CA')=="Select a State" || $F('CA')=="Select a Metro" || $F('CA')=="Select a Metro Area" || $F('CA')=="") && !$F('search_city'))) {
		alert("You need to either enter a city/state or select a state and metro area before beginning your search");
		return false;
	} else { return true; }
}
function validate_areasearch() {
	if($F('CA')=="Select a State" || $F('CA')=="Select a Metro" || $F('CA')=="") {
		alert("You need to select a state and metro area before beginning your search");
		return false;
	} else { return true; }
}
function  validate_broadsearch() {
	if (document.broadsearch.search_type.value=="state") {
		alert("You need to select a state before beginning your search");
		return false;
	}
	else if(document.broadsearch.search_type.value=="CA") {
		if(typeof get_checkedvalue()=="undefined") {
			alert("You need to select a metro area before beginning your search");
			return false;
		} else { return true; }
	}
	else if(document.broadsearch.search_type.value=="SC") {
		if(typeof get_checkedvalue()=="undefined") {
			alert("You need to select a city area before beginning your search");
			return false;
		} else { return true; }
	}
	else if(document.broadsearch.search_type.value=="CT") {
		if(typeof get_checkedvalue()=="undefined") {
			alert("You need to select a city before beginning your search");
			return false;
		} else { return true; }
	}
	else if(document.broadsearch.search_type.value=="NH") {
		if(typeof get_checkedvalue()=="undefined") {
			alert("You need to select a neighborhood before beginning your search");
			return false;
		} else { return true; }
	}
}
function validate_military() {
	if($F('base')=='Select a Branch' || $F('base')=='' || $F('base')=='Select a Military Base') {
		alert("You need to select a military base before beginning your search");
		return false;
	} 
	else if($F('distance')=="") {
		alert("You need to select a distance before beginning your search");
		return false;
	} else { return true; }
}
function validate_college() {
	if($F('college')=="" || $F('college')=="Select a College" || $F('college')=="Select a State") {
		alert("You need to select a college before beginning your search");
		return false;
	}
	else if($F('distance')=="") {
		alert("You need to select a distance before beginning your search");
		return false;
	} else { return true; }	
}
function validate_name() {
	if(typeof document.search.name.value=="undefined" || document.search.name.value=="") {
		alert("You need to enter a name before beginning your search");
		return false;
	} else { return true; }	
}
function validate_city() {
	if(typeof document.search.states.value=="undefined" || document.search.states.value=="") {
		alert("You need to select state before beginning your search");
		return false;
	}
	if(typeof document.search.search_city.value=="undefined" || document.search.search_city.value=="") {
		alert("You need to enter city before beginning your search");
		return false;
	} else { return true; }	
}
function validate_zip() {
	if(typeof document.search.zip.value=="undefined" || document.search.zip.value=="" || document.search.zip.value.length < 5) {
		alert("You need to enter a 5 digit zip code before beginning your search");
		return false;
	}
	else if(document.search.distance.value=="") {
		alert("You need to select a distance before beginning your search");
		return false;
	} else { return true; }
}

// gets the area id which was checked
function get_checkedvalue() {
 	var id=0;
 	for(i=0;i<$('testOn').childNodes.length;i++) {			 
		if($('testOn').childNodes[i].id=="cadiv") {
			if($('testOn').childNodes[i].childNodes[0].nodeType==1 && $('testOn').childNodes[i].childNodes[0].checked==true) {
					id=$('testOn').childNodes[i].childNodes[0].value;
				    return id;
				}
			}
		}
}

/* ----------------- eventlogging.js functions -------------------------- */
var putItThere=null;
var chasm=screen.availWidth;
var mount=screen.availHeight;
var wd=chasm*.9; // percentage of screen width occupied by pop-up
var ht=mount*.8; // percentage of screen height occupied by pop-up
function write_event(eventid,someid,typecode, newurl, newwindow,el) {
	var href=null;
	// alert("I'm in here!");
	
	if (typeof newurl=="undefined") { newurl=""; }
	if (typeof newwindow=="undefined") { newwindow=0; }
	if(typeof el != "undefined"){
		if(/Safari/.test(navigator.userAgent)){
			href = el.href;
			el.href = null;
		}
	}
	var url="/ajax/eventLogging.ajax.php?eventid="+eventid+"&someid="+someid+"&typecode="+typecode;
	//alert(url);
	new Ajax.Request (url,{method:'get',onComplete:function(response){
		if (newurl !='') {
			if (newwindow==1) {
				deadCenter(newurl);
			} else {
				top.location.href=newurl;
			}
		}
		if(href != null){
			el.href=href;
			window.location=href;
		}
	}
	});	
	/*
alert("I'm in the write_event() function!");
	var url="http://jboisselle-frc.frlabs.com/ajax/eventLogging.ajax.php?eventid="+eventid+"&someid="+someid+"&typecode="+typecode;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		alert("This is where I am setting the XHR object for non IE browsers");
    	http_request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // IE
    	alert("This is where I am setting the XHR object for IE browsers");
    	http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	alert("This is right before the onreadystatechange method declaration");
	http_request.onreadystatechange = safariFix;
	alert("Right after the declaration...and before opening the connection");
    http_request.open('GET', url, true);
	alert("Right after the connection...and before the send");
    http_request.send(null);	
	alert("Right after the send");
*/
}
/*
function safariFix() {
	alert("I'm inside the onreadystatechange method!");
	alert(http_request.status);
		if (http_request.readyState == 4) {
			alert("I'm inside of the first condition...");
        	if (http_request.status == 200) {
              	// do nothing...
				alert("I'm in here! -- the inner most condition");               
			}
			alert(http_request.status);
       }
}
*/
function deadCenter(url) {
	putItThere=window. open(url,'forrent','width='+wd+',height='+ht+',left='+((chasm-wd-10)*.5)+',top='+((mount-ht-25)*.5)+',scrollbars,status,titlebar');
	if (putItThere & !putItThere.closed) putItThere.focus();
}

//Function being called from media center click events
function logEvent(siteId,code){
	write_event(code,siteId,'site')
}

/* ----------------- realmedia.js functions -------------------------- 
*****************************************************************************
file:			realmedia.js
author:			Kevin Strange -- strange@de.com
description:	Real media javaScript for forrent.com
changes:		2006.10.17 - strange@de.com - Kevin Strange -- Initial code
******************************************************************************/
// New mjx delivery method configuration

if(OAS_listpos!="0") {
OAS_url='http://ads.traderonline.com/RealMedia/ads/';
// OAS_sitepage, OAS_listpos, and OAS_query set in nav.templ - KTS
OAS_target='_blank';
// End configuration
OAS_version=10;
OAS_rn= new String (Math.random());
OAS_rns=OAS_rn.substring (2, 11);
function OAS_NORMAL(pos) {
	document.write('<a href="' + OAS_url + 'click_nx.cgi/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + '?' + OAS_query + '" target="' + OAS_target + '">');
	documnet.write('<img src="' + OAS_url + 'click_nx.cgi/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + '?' + OAS_query + '" border="0"></a>');
}
OAS_version=11;
if (( navigator.userAgent.indexOf('Mozilla/3') !=-1) || (navigator.userAgent.indexOf('Mozilla/4.0 WebTV') !=-1))
	OAS_version=10;
if (OAS_version >=11)
	document.write('<scr' + 'ipt language="javascript1.1" src="' + OAS_url + 'adstream_mjx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '?' + OAS_query + '"><\/script>');

document.write('');
function OAS_AD(pos) {
	if (OAS_version <=11)
		OAS_RICH(pos);
	else
		OAS_NORMAL(pos);
}
}

/* ----------------- actb.js -------------------------------------- */
function actb(obj,ca){
	/* ---- Public Variables ---- */
	this.actb_timeOut=-1; // Autocomplete Timeout in ms (-1: autocomplete never time out)
	this.actb_lim=13;    // Number of elements autocomplete can show (-1: no limit)
	this.actb_firstText=true; // should the auto complete be limited to the beginning of keyword?
	this.actb_mouse=true; // Enable Mouse Support
	this.actb_delimiter=new Array(';',',');  // Delimiter for multiple autocomplete. Set it to empty array for single autocomplete
	this.actb_startcheck=1; // Show widget only after this number of characters is typed in.
	/* ---- Public Variables ---- */

	/* --- Styles --- */
	this.actb_bgColor='#013377';
	this.actb_bgStyle='margin-left:218px;';
	this.actb_textColor='#FFFFFF';
	this.actb_textWeight='bold';
	this.actb_hColor='#656565';
	this.actb_fFamily='Verdana';
	this.actb_fSize='11px';
	this.actb_hStyle='font-weight:bold; height:15px; font-family:Verdana, arial, sans-serif; font-size:11px;color:#FFFFFF;z-index:99999;';
	/* --- Styles --- */

	/* ---- Private Variables ---- */
	var actb_delimwords=new Array();
	var actb_cdelimword=0;
	var actb_delimchar=new Array();
	var actb_display=false;
	var actb_pos=0;
	var actb_total=0;
	var actb_curr=null;
	var actb_rangeu=0;
	var actb_ranged=0;
	var actb_bool=new Array();
	var actb_pre=0;
	var actb_toid;
	var actb_tomake=false;
	var actb_getpre="";
	var actb_mouse_on_list=0;
	var actb_kwcount=0;
	var actb_caretmove=false;
	this.actb_keywords=new Array();
	/* ---- Private Variables---- */
	
	this.actb_keywords=ca;
	var actb_self=this;

	actb_curr=obj;
	
	addEvent(actb_curr,"focus",actb_setup);
	function actb_setup(){
		addEvent(document,"keydown",actb_checkkey);
		addEvent(actb_curr,"blur",actb_clear);
		addEvent(document,"keypress",actb_keypress);
	}

	function actb_clear(evt){
		if (!evt) evt=event;
		removeEvent(document,"keydown",actb_checkkey);
		removeEvent(actb_curr,"blur",actb_clear);
		removeEvent(document,"keypress",actb_keypress);
		actb_removedisp();
	}
	function actb_parse(n){
		if (actb_self.actb_delimiter.length > 0){
			var t=actb_delimwords[actb_cdelimword].trim().addslashes();
			var plen=actb_delimwords[actb_cdelimword].trim().length;
		}else{
			var t=actb_curr.value.addslashes();
			var plen=actb_curr.value.length;
		}
		var tobuild='';
		var i;
		if (actb_self.actb_firstText){
			var re=new RegExp("^" + t, "i");
		}else{
			var re=new RegExp(t, "i");
		}
		var p=n.search(re);
				
		for (i=0;i<p;i++){
			tobuild +=n.substr(i,1);
		}
		tobuild +="<font style='"+(actb_self.actb_hStyle)+"'>"
		for (i=p;i<plen+p;i++){
			tobuild +=n.substr(i,1);
		}
		tobuild +="</font>";
			for (i=plen+p;i<n.length;i++){
			tobuild +=n.substr(i,1);
		}
		return tobuild;
	}
	function actb_generate(){
		if (document.getElementById('tat_table')){ actb_display=false;document.body.removeChild(document.getElementById('tat_table')); } 
		if (actb_kwcount==0){
			actb_display=false;
			return;
		}
		a=document.createElement('table');
		a.cellSpacing='2px';
		a.cellPadding='2px';
		a.style.position='absolute';
		a.style.width='160px';
		a.style.minwidth='160px';
		a.style.marginLeft='160px';
		a.style.marginTop='-17px';
		a.style.borderCollapse='collapse';
		a.style.borderWidth='2px';
		a.style.borderStyle='solid';
		a.style.borderColor='#464646';
		a.style.top=eval(curTop(actb_curr) + actb_curr.offsetHeight) + "px";
		a.style.left=curLeft(actb_curr) + "px";
		a.style.backgroundColor=actb_self.actb_bgColor;
		a.id='tat_table';
		document.body.appendChild(a);
		var i;
		var first=true;
		var j=1;
		if (actb_self.actb_mouse){
			a.onmouseout=actb_table_unfocus;
			a.onmouseover=actb_table_focus;
		}
		var counter=0;
		for (i=0;i<actb_self.actb_keywords.length;i++){
			if (actb_bool[i]){
				counter++;
				r=a.insertRow(-1);
				if (first && !actb_tomake){
					r.style.backgroundColor=actb_self.actb_hColor;
					first=false;
					actb_pos=counter;
				}else if(actb_pre==i){
					r.style.backgroundColor=actb_self.actb_hColor;
					first=false;
					actb_pos=counter;
				}else{
					r.style.backgroundColor=actb_self.actb_bgColor;
				}
				r.id='tat_tr'+(j);
				c=r.insertCell(-1);
				c.style.color=actb_self.actb_textColor;
				c.style.fontFamily=actb_self.actb_fFamily;
				c.style.fontSize=actb_self.actb_fSize;
				c.innerHTML=actb_parse(actb_self.actb_keywords[i]);
				c.id='tat_td'+(j);
				c.setAttribute('pos',j);
				if (actb_self.actb_mouse){
					c.style.cursor='pointer';
					c.onclick=actb_mouseclick;
					c.onmouseover=actb_table_highlight;
				}
				j++;
			}
			if (j - 1==actb_self.actb_lim && j < actb_total){
				r=a.insertRow(-1);
				r.style.backgroundColor=actb_self.actb_bgColor;
				c=r.insertCell(-1);
				c.style.color=actb_self.actb_textColor;
				c.style.fontFamily='verdana';
				c.style.fontSize=actb_self.actb_fSize;
				c.align='center';
				replaceHTML(c,'\\/');
				if (actb_self.actb_mouse){
					c.style.cursor='pointer';
					c.onclick=actb_mouse_down;
				}
				break;
			}
		}
		actb_rangeu=1;
		actb_ranged=j-1;
		actb_display=true;
		if (actb_pos <=0) actb_pos=1;
	}
	function actb_remake(){
		document.body.removeChild(document.getElementById('tat_table'));
		a=document.createElement('table');
		a.cellSpacing='2px';
		a.cellPadding='2px';
		a.style.position='absolute';
		a.style.width='160px';
		a.style.minwidth='160px';
		a.style.marginLeft='160px';
		a.style.marginTop='-17px';
		a.style.borderCollapse='collapse';
		a.style.borderWidth='2px';
		a.style.borderStyle='solid';
		a.style.borderColor='#464646';
		a.style.top=eval(curTop(actb_curr) + actb_curr.offsetHeight) + "px";
		a.style.left=curLeft(actb_curr) + "px";
		a.style.backgroundColor=actb_self.actb_bgColor;
		a.id='tat_table';
		if (actb_self.actb_mouse){
			a.onmouseout=actb_table_unfocus;
			a.onmouseover=actb_table_focus;
		}
		document.body.appendChild(a);
		var i;
		var first=true;
		var j=1;
		if (actb_rangeu > 1){
			r=a.insertRow(-1);
			r.style.backgroundColor=actb_self.actb_bgColor;
			c=r.insertCell(-1);
			c.style.color=actb_self.actb_textColor;
			c.style.fontFamily='verdana';
			c.style.fontSize=actb_self.actb_fSize;
			c.align='center';
			replaceHTML(c,'/\\');
			if (actb_self.actb_mouse){
				c.style.cursor='pointer';
				c.onclick=actb_mouse_up;
			}
		}
		for (i=0;i<actb_self.actb_keywords.length;i++){
			if (actb_bool[i]){
				if (j >=actb_rangeu && j <=actb_ranged){
					r=a.insertRow(-1);
					r.style.backgroundColor=actb_self.actb_bgColor;
					r.id='tat_tr'+(j);
					c=r.insertCell(-1);
					c.style.color=actb_self.actb_textColor;
					c.style.fontFamily=actb_self.actb_fFamily;
					c.style.fontSize=actb_self.actb_fSize;
					c.innerHTML=actb_parse(actb_self.actb_keywords[i]);
					c.id='tat_td'+(j);
					c.setAttribute('pos',j);
					if (actb_self.actb_mouse){
						c.style.cursor='pointer';
						c.onclick=actb_mouseclick;
						c.onmouseover=actb_table_highlight;
					}
					j++;
				}else{
					j++;
				}
			}
			if (j > actb_ranged) break;
		}
		if (j-1 < actb_total){
			r=a.insertRow(-1);
			r.style.backgroundColor=actb_self.actb_bgColor;
			c=r.insertCell(-1);
			c.style.color=actb_self.actb_textColor;
			c.style.fontFamily='verdana';
			c.style.fontSize=actb_self.actb_fSize;
			c.align='center';
			replaceHTML(c,'\\/');
			if (actb_self.actb_mouse){
				c.style.cursor='pointer';
				c.onclick=actb_mouse_down;
			}
		}
	}
	function actb_goup(){
		if (!actb_display) return;
		if (actb_pos==1) return;
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor=actb_self.actb_bgColor;
		actb_pos--;
		if (actb_pos < actb_rangeu) actb_moveup();
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor=actb_self.actb_hColor;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid=setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
	}
	function actb_godown(){
		if (!actb_display) return;
		if (actb_pos==actb_total) return;
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor=actb_self.actb_bgColor;
		actb_pos++;
		if (actb_pos > actb_ranged) actb_movedown();
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor=actb_self.actb_hColor;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid=setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
	}
	function actb_movedown(){
		actb_rangeu++;
		actb_ranged++;
		actb_remake();
	}
	function actb_moveup(){
		actb_rangeu--;
		actb_ranged--;
		actb_remake();
	}

	/* Mouse */
	function actb_mouse_down(){
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor=actb_self.actb_bgColor;
		actb_pos++;
		actb_movedown();
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor=actb_self.actb_hColor;
		actb_curr.focus();
		actb_mouse_on_list=0;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid=setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
	}
	function actb_mouse_up(evt){
		if (!evt) evt=event;
		if (evt.stopPropagation){
			evt.stopPropagation();
		}else{
			evt.cancelBubble=true;
		}
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor=actb_self.actb_bgColor;
		actb_pos--;
		actb_moveup();
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor=actb_self.actb_hColor;
		actb_curr.focus();
		actb_mouse_on_list=0;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid=setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
	}
	function actb_mouseclick(evt){
		if (!evt) evt=event;
		if (!actb_display) return;
		actb_mouse_on_list=0;
		actb_pos=this.getAttribute('pos');
		actb_penter();
	}
	function actb_table_focus(){
		actb_mouse_on_list=1;
	}
	function actb_table_unfocus(){
		actb_mouse_on_list=0;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid=setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
	}
	function actb_table_highlight(){
		actb_mouse_on_list=1;
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor=actb_self.actb_bgColor;
		actb_pos=this.getAttribute('pos');
		while (actb_pos < actb_rangeu) actb_moveup();
		while (actb_pos > actb_ranged) actb_movedown();
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor=actb_self.actb_hColor;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid=setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
	}
	/* ---- */

	function actb_insertword(a){
		if (actb_self.actb_delimiter.length > 0){
			str='';
			l=0;
			for (i=0;i<actb_delimwords.length;i++){
				if (actb_cdelimword==i){
					prespace=postspace='';
					gotbreak=false;
					for (j=0;j<actb_delimwords[i].length;++j){
						if (actb_delimwords[i].charAt(j) !=' '){
							gotbreak=true;
							break;
						}
						prespace +=' ';
					}
					for (j=actb_delimwords[i].length-1;j>=0;--j){
						if (actb_delimwords[i].charAt(j) !=' ') break;
						postspace +=' ';
					}
					str +=prespace;
					str +=a;
					l=str.length;
					if (gotbreak) str +=postspace;
				}else{
					str +=actb_delimwords[i];
				}
				if (i !=actb_delimwords.length - 1){
					str +=actb_delimchar[i];
				}
			}
			actb_curr.value=str;
			setCaret(actb_curr,l);
		}else{
			actb_curr.value=a;
		}
		actb_mouse_on_list=0;
		actb_removedisp();
	}
	function actb_penter(){
		if (!actb_display) return;
		actb_display=false;
		var word='';
		var c=0;
		for (var i=0;i<=actb_self.actb_keywords.length;i++){
			if (actb_bool[i]) c++;
			if (c==actb_pos){
				word=actb_self.actb_keywords[i];
				break;
			}
		}
		actb_insertword(word);
		l=getCaretStart(actb_curr);
	}
	function actb_removedisp(){
		if (actb_mouse_on_list==0){
			actb_display=0;
			if (document.getElementById('tat_table')){ document.body.removeChild(document.getElementById('tat_table')); }
			if (actb_toid) clearTimeout(actb_toid);
		}
	}
	function actb_keypress(e){
		if (actb_caretmove) stopEvent(e);
		return !actb_caretmove;
	}
	function actb_checkkey(evt){
		if (!evt) evt=event;
		a=evt.keyCode;
		caret_pos_start=getCaretStart(actb_curr);
		actb_caretmove=0;
		switch (a){
			case 38:
				actb_goup();
				actb_caretmove=1;
				return false;
				break;
			case 40:
				actb_godown();
				actb_caretmove=1;
				return false;
				break;
			case 13: case 9:
				if (actb_display){
					actb_caretmove=1;
					actb_penter();
					return false;
				}else{
					return true;
				}
				break;
			default:
				setTimeout(function(){actb_tocomplete(a)},50);
				break;
		}
	}

	function actb_tocomplete(kc){
		if (kc==38 || kc==40 || kc==13) return;
		var i;
		if (actb_display){ 
			var word=0;
			var c=0;
			for (var i=0;i<=actb_self.actb_keywords.length;i++){
				if (actb_bool[i]) c++;
				if (c==actb_pos){
					word=i;
					break;
				}
			}
			actb_pre=word;
		}else{ actb_pre=-1};
		
		if (actb_curr.value==''){
			actb_mouse_on_list=0;
			actb_removedisp();
			return;
		}
		if (actb_self.actb_delimiter.length > 0){
			caret_pos_start=getCaretStart(actb_curr);
			caret_pos_end=getCaretEnd(actb_curr);
			
			delim_split='';
			for (i=0;i<actb_self.actb_delimiter.length;i++){
				delim_split +=actb_self.actb_delimiter[i];
			}
			delim_split=delim_split.addslashes();
			delim_split_rx=new RegExp("(["+delim_split+"])");
			c=0;
			actb_delimwords=new Array();
			actb_delimwords[0]='';
			for (i=0,j=actb_curr.value.length;i<actb_curr.value.length;i++,j--){
				if (actb_curr.value.substr(i,j).search(delim_split_rx)==0){
					ma=actb_curr.value.substr(i,j).match(delim_split_rx);
					actb_delimchar[c]=ma[1];
					c++;
					actb_delimwords[c]='';
				}else{
					actb_delimwords[c] +=actb_curr.value.charAt(i);
				}
			}

			var l=0;
			actb_cdelimword=-1;
			for (i=0;i<actb_delimwords.length;i++){
				if (caret_pos_end >=l && caret_pos_end <=l + actb_delimwords[i].length){
					actb_cdelimword=i;
				}
				l+=actb_delimwords[i].length + 1;
			}
			var ot=actb_delimwords[actb_cdelimword].trim(); 
			var t=actb_delimwords[actb_cdelimword].addslashes().trim();
		}else{
			var ot=actb_curr.value;
			var t=actb_curr.value.addslashes();
		}
		if (ot.length==0){
			actb_mouse_on_list=0;
			actb_removedisp();
		}
		if (ot.length < actb_self.actb_startcheck) return this;
		if (actb_self.actb_firstText){
			var re=new RegExp("^" + t, "i");
		}else{
			var re=new RegExp(t, "i");
		}

		actb_total=0;
		actb_tomake=false;
		actb_kwcount=0;
		for (i=0;i<actb_self.actb_keywords.length;i++){
			actb_bool[i]=false;
			if (re.test(actb_self.actb_keywords[i])){
				actb_total++;
				actb_bool[i]=true;
				actb_kwcount++;
				if (actb_pre==i) actb_tomake=true;
			}
		}

		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid=setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
		actb_generate();
	}
	return this;
}

/* ----------------- menujs.js functions -------------------------- */
function UL2Menu_ShowHead(){
	var li=this;
	AddClass(li,'active');
	var xy=FindXYWH(li);
	var browserName=navigator.appName;
	if (browserName=="Netscape") {
		var minusy=0;
	}else {
		var minusy=-3;
	}
	if (li.isTop){
		li.sub.style.left=(xy.x+(!li.isHorizontal?xy.w:0))+'px';
		li.sub.style.top=(xy.y+(li.isHorizontal?xy.h:0)-(li.isTop?0:1))+minusy+'px';
	} else {
		li.sub.style.left=li.offsetWidth+'px';
		li.sub.style.top=li.offsetTop+'px';
	}
	li.sub.style.visibility='visible';
}
function UL2Menu_HideHead(){
	var li=this;
	li.sub.style.visibility='hidden';
	KillClass(li,'active');
}
function UL2Menu_ConvertMenu(theid){
	var menu=document.getElementById(theid);
	if (!menu) return;
	var menuIsHorizontal=HasClass(menu,'horizontal');
	var lis=menu.getElementsByTagName('li');
	for (var i=0,len=lis.length;i<len;i++){
		var li=lis[i];
		var uls=li.getElementsByTagName('ul');
		if (!uls || uls.length==0) continue;
		var ul=uls[0];
		li.sub=ul;
		li.onmouseover=UL2Menu_ShowHead;
		li.onmouseout=UL2Menu_HideHead;
		li.isTop=li.parentNode==menu;
		li.isHorizontal=(menuIsHorizontal && li.isTop);

		if (li.addedArrow || li.isTop) continue;
		var arrow=document.createElement('span');
		arrow.innerHTML='&nbsp;&rArr;';
		var a=li.getElementsByTagName('a');
		if (a && a.length>0 && a[0].parentNode==li) a[0].innerHTML+='&nbsp;&rArr;';
		else li.insertBefore(arrow,li.childNodes[1]);
		li.addedArrow=true;
	}
}

AttachEvent(window,'load',UL2Menu_ConvertMenu,true);

//***Generic Library Functions Follow
	function FindXY(obj){
		var x=0,y=0;
		while (obj){
			x+=findPosX(obj) - (obj.scrollLeft || 0);
			y+=findPosY(obj) - (obj.scrollTop || 0);
			obj=null;
		}
		return {x:x,y:y};
	}

	function FindXYWH(obj){
		if (!obj) return { x:0, y:0, w:0, h:0 };
		var objXY=FindXY(obj);
		return { x:objXY.x, y:objXY.y, w:obj.offsetWidth||0, h:obj.offsetHeight||0 };
	}

	function AttachEvent(obj,evt,fnc,useCapture){
		if (obj.addEventListener){
			obj.addEventListener(evt,fnc,useCapture);
			return true;
		} else if (obj.attachEvent) return obj.attachEvent("on"+evt,fnc);
		else obj['on'+evt]=fnc;
		return true;
	}

	function HasClass(obj,cName){ return (!obj || !obj.className)?false:(new RegExp("\\b"+cName+"\\b")).test(obj.className) }
	function AddClass(obj,cName){ if (!obj) return; if (obj.className==null) obj.className=''; return obj.className+=(obj.className.length>0?' ':'')+cName; }
	function KillClass(obj,cName){ if (!obj) return; return obj.className=obj.className.replace(RegExp("^"+cName+"\\b\\s*|\\s*\\b"+cName+"\\b",'g'),''); }
	
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 MenuSelect(selectid, ancid, menuid, inputid) {
	var divcontent=document.getElementById(selectid);
	document.getElementById(inputid).value=ancid;
	divcontent.innerHTML=ancid;
	document.getElementById(menuid).style.visibility='hidden';
}

/* ----------------- browserDetect.js functions -------------------------- */
var BrowserDetect={
	init: function () {
		this.browser=this.searchString(this.dataBrowser) || "An unknown browser";
		this.version=this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS=this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString=data[i].string;
			var dataProp=data[i].prop;
			this.versionSearchString=data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) !=-1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index=dataString.indexOf(this.versionSearchString);
		if (index==-1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

/* ----------------- common.js functions -------------------------- 
Event Functions 
Add an event to the obj given
event_name refers to the event trigger, without the "on", like click or mouseover
func_name refers to the function callback when event is triggered */
function addEvent(obj,event_name,func_name){
	if (obj.attachEvent){
		obj.attachEvent("on"+event_name, func_name);
	}else if(obj.addEventListener){
		obj.addEventListener(event_name,func_name,true);
	}else{
		obj["on"+event_name]=func_name;
	}
}

// Removes an event from the object
function removeEvent(obj,event_name,func_name){
	if (obj.detachEvent){
		obj.detachEvent("on"+event_name,func_name);
	}else if(obj.removeEventListener){
		obj.removeEventListener(event_name,func_name,true);
	}else{
		obj["on"+event_name]=null;
	}
}

// Stop an event from bubbling up the event DOM
function stopEvent(evt){
	evt || window.event;
	if (evt.stopPropagation){
		evt.stopPropagation();
		evt.preventDefault();
	}else if(typeof evt.cancelBubble !="undefined"){
		evt.cancelBubble=true;
		evt.returnValue=false;
	}
	return false;
}

// Get the obj that starts the event
function getElement(evt){
	if (window.event){
		return window.event.srcElement;
	}else{
		return evt.currentTarget;
	}
}
// Get the obj that triggers off the event
function getTargetElement(evt){
	if (window.event){
		return window.event.srcElement;
	}else{
		return evt.target;
	}
}
// For IE only, stops the obj from being selected
function stopSelect(obj){
	if (typeof obj.onselectstart !='undefined'){
		addEvent(obj,"selectstart",function(){ return false;});
	}
}

/*    Caret Functions     */
// Get the end position of the caret in the object. Note that the obj needs to be in focus first
function getCaretEnd(obj){
	if(typeof obj.selectionEnd !="undefined"){
		return obj.selectionEnd;
	}else if(document.selection&&document.selection.createRange){
		var M=document.selection.createRange();
		try{
			var Lp=M.duplicate();
			Lp.moveToElementText(obj);
		}catch(e){
			var Lp=obj.createTextRange();
		}
		Lp.setEndPoint("EndToEnd",M);
		var rb=Lp.text.length;
		if(rb>obj.value.length){
			return -1;
		}
		return rb;
	}
}
// Get the start position of the caret in the object
function getCaretStart(obj){
	if(typeof obj.selectionStart !="undefined"){
		return obj.selectionStart;
	}else if(document.selection&&document.selection.createRange){
		var M=document.selection.createRange();
		try{
			var Lp=M.duplicate();
			Lp.moveToElementText(obj);
		}catch(e){
			var Lp=obj.createTextRange();
		}
		Lp.setEndPoint("EndToStart",M);
		var rb=Lp.text.length;
		if(rb>obj.value.length){
			return -1;
		}
		return rb;
	}
}
// sets the caret position to l in the object
function setCaret(obj,l){
	obj.focus();
	if (obj.setSelectionRange){
		obj.setSelectionRange(l,l);
	}else if(obj.createTextRange){
		m=obj.createTextRange();		
		m.moveStart('character',l);
		m.collapse();
		m.select();
	}
}
// sets the caret selection from s to e in the object
function setSelection(obj,s,e){
	obj.focus();
	if (obj.setSelectionRange){
		obj.setSelectionRange(s,e);
	}else if(obj.createTextRange){
		m=obj.createTextRange();		
		m.moveStart('character',s);
		m.moveEnd('character',e);
		m.select();
	}
}

/*    Escape function   */
String.prototype.addslashes=function(){
	return this.replace(/(["\\\.\|\[\]\^\*\+\?\$\(\)])/g, '\\$1');
}
String.prototype.trim=function () {
    return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};
/* --- Escape --- */

/* Offset position from top of the screen */
function curTop(obj){
	toreturn=0;
	while(obj){
		toreturn +=obj.offsetTop;
		obj=obj.offsetParent;
	}
	return toreturn;
}
function curLeft(obj){
	toreturn=0;
	while(obj){
		toreturn +=obj.offsetLeft;
		obj=obj.offsetParent;
	}
	return toreturn;
}
/* ------ End of Offset function ------- */

/* Types Function */

// is a given input a number?
function isNumber(a) {
    return typeof a=='number' && isFinite(a);
}

/* Object Functions */

function replaceHTML(obj,text){
	while(el=obj.childNodes[0]){
		obj.removeChild(el);
	};
	obj.appendChild(document.createTextNode(text));
}
