var p;
var b;
var arrayResult = new Array();
var arrayZipCode = new Array();
var arrayStateCode = new Array();
var arrayParamValues = new Array();
var ResultInnerFrame = "";
var GlobalCity = ""
var Status = 0;
var autoComplete = "txtCity";

var aState = new Array();
var aCity = new Array();
var aName;
var FinishedCityZipCode = 0; //switch to set the City and Zip Code
var FinishedState = 0; //switch to set the City and Zip Code
var onStateFocus = 0;

var outp;
var oldins;
var posi = -1;
var words = new Array();
var input;
var key = 27;
var enabletabpersistence=1; //enable tab persistence via session only cookies, so selected tab is remembered?

var tabcontentIDs=new Object();
var results;
var divValue;
var gblFunction;
var heightWidthUrl;
var URLAddress;
var GuidID;
var LinkAddress;
var UrlAddress  = "";
var UrlName ="";
var holdStateCode = "";
var Beds = new Array(1,2,3,4,5,6,7,8,9,10,11,12);   
var Bath = new Array(1,1.5,2,2.5,3,3.5,4,4.5);   
var Property_Type1 = new Array("Home", "Condo", "Townhome");
var Land = new Array("2 Units", "3 Units", "4 Units", "5+ Units");
var latitiude = '';
var longitude = '';
var checkZIndex = true;

var dragObject = null;
var tx;
var ty;
var dragdropvalue;
var locationsArray = []; 
var globalres = '';
var UserName;
var map = null;
var geocoder = null;
var address = "";
var valpoint = "";   
var htmlHeader = [];
var rateDown = new Array("1.000%","1.125%","1.250%","1.375%","1.500%","1.625%","1.750%","2.000%","2.125%","2.250%","2.500%","2.625%","2.750%","2.875%","3.000%","3.125%","3.250%","3.375%","3.500%","3.625%","3.750%","3.875%","4.000%","4.125%","4.250%","4.375%","4.500%","4.625%","4.750%","4.875%","5.000%","5.125%","5.250%","5.375%","5.500%","5.625%","5.750%","5.875%","6.000%","6.125%","6.250%","6.375%","6.500%","6.625%","6.750%","6.875%","7.000%","7.125%","7.250%","7.375%","7.500%","7.625%","7.750%","7.875%","8.000%","8.125%","8.250%","8.375%","8.500%","8.625%","8.750%","8.875%","9.000%","9.125%","9.250%","9.375%","9.500%","9.625%","9.750%","9.875%","10.000%");    
var MonthlyPayment = "";
var ItemID = -1;
var GlobalTable = "";
var idValue = 0;
var defaultchoice = 1;
var RecTaggedInfo;
var ItemCount;
var fPosY = 3;
var fPosX = 2;
var arrayLocation = "";
var CacheID; 
var StateCode;
var colFormInfo = [];
var claimAgentProfile1 = '';
var defaultYPosition = 60;
var defaultXPosition = 4;
var currentSession = '';
var processSurroundingCity = '';
var processSurrondingRealEstates = '';




var ie5; // = document.all != null && document.getElementsByTagName != null;


//onclick of the State Text box run function {eventMouseOnfocus}
function getEvents(){
	var sCity = document.getElementById("txtCity");
	GetStateList();
	//sCity.onfocus = GetCityInfor;
}
function expandDivOff(value){
	 	var d = document.getElementById(value);
	if(d != null)
		d.className = (d.className == "StateWorkSpaceOff") ? "StateWorkSpaceOnExtra" : "StateWorkSpaceOff"; 
}
function GetChoice(res, divName, Title){
popUpDiv(""+'|'+100+'|'+100+'|'+ divName +'|'+"Top Menu"+'|'+res+'|'+Title);

}

function topMenu(){
var html = [];
    html[html.length] = "<table>";
    html[html.length] = "<tr><td>Enter Link Name</td><td><input id=\"txtTopMenuLinkName\" type=\"text\" /></td>";
    html[html.length] = "<td>Enter Page Name</td><td><input id=\"txtTopMenuLinkPage\" type=\"text\" /></td></tr>";
    html[html.length] ="<tr><td colspan=2 align=center><input id=\"btnSubmitUrl\" type=\"button\" value=\"Submit\" onclick=\"submitURL()\" /></td></tr>" ;   
    html[html.length] = "</table>";
    return html.join("");
}


function createDiv(id, postHTML, objId)
{
var className = "blinkcube";
 var t = document.getElementById(objId);
	divValue = objId;
	dragdropvalue = "shadowDiv";
     document.getElementById("shadowDiv").className == "dialog";
    document.getElementById("shadowDiv").innerHTML = "<div>" +  _createCustomDiv('shadowDiv','Claim Profile',reSubmitURL())+ "</div>";
    runEvents(dragdropvalue);		
	setVisibleDiv('visible');

}
   

function leftMenu(){
var html = [];
    html[html.length] = "<table>";
    html[html.length] = "<tr><td>Left Menu Title</td><td><input id=\"txtLeftMenuTitle\" type=\"text\" /></td></tr>";
    html[html.length] = "<tr><td>Link Name</td><td><input id=\"txtLeftMenuLinkName\" type=\"text\" /></td>";
    html[html.length] = "<td>Page Name</td><td><input id=\"txtLeftMenuLinkPage\" type=\"text\" /></td></tr>";
    html[html.length] ="<tr><td colspan=2 align=center><input id=\"btnSubmitUrl\" type=\"button\" value=\"Submit\" onclick=\"submitURLLeftMenu()\" /></td></tr>" ;   
    html[html.length] = "</table>";
    return html.join("");
}

function mainBody(){
var html = [];
    html[html.length] = "<table>";
    html[html.length] = "<tr><td>Title:</td><td><input id=\"txtBodyTitle\" type=\"text\" /></td></tr>";
    html[html.length] = "<tr><td>Content:</td><td><textarea id=\"txtBodyContent\" rows=\"4\" style=\"width: 350px\"></textarea></td></tr>";
    html[html.length] ="<tr><td colspan=2 align=center><input id=\"btnSubmitUrl\" type=\"button\" value=\"Submit\" onclick=\"submitURL()\" /></td></tr>" ;   
    html[html.length] = "</table>";
    return html.join("");

}

function getURLAddress(){
 window.location.href = document.getElementById("txtCity").value;
}

function relinkPrice(){
    window.location.href = document.getElementById("ddMinPrice").value + "-" + document.getElementById("ddMaxPrice").options[document.getElementById("ddMaxPrice").selectedIndex].text;
}

function reSubmitURL(){
var SiteType = ["REALTOR Site","Real Estate Company Site","FSBO","Online Classifieds","Newspaper","Bank REO","MLS","Foreclosures","Other"];
var AreaCoverage = ["National","Alaska","California","Other"];
var html = [];
    html[html.length] = "<table>";
    html[html.length] = "<tr><td>Main URL:</td><td>Site Title:</td></tr>";
    html[html.length] = "<tr><td><input id=\"txtMainUrl\" type=\"text\" /></td><td><input id=\"txtSiteTitle\" type=\"text\" /></td></tr>";
    
    html[html.length] = "<tr><td>Search Url:</td><td>Site Type:</td></tr>";
    html[html.length] = "<tr><td><input id=\"txtSearchUrl\" type=\"text\" /></td>";
    html[html.length] = "<td><select id=\"ddlSiteType\">";    
    for(var i=0; i<SiteType.length; i++){
        html[html.length] = '<option value=\''+SiteType[i]+  '\'>' + SiteType[i] + '</option>';
    }
    html[html.length] = "</select></td></tr>";
            
    html[html.length] = "<tr><td>select Area Coverage:</td><td>Name:</td></tr>";
    
    html[html.length] = "<tr><td><Select id=\"ddlAreaCoverage\">";    
    for(var i=0; i<AreaCoverage.length; i++){
        html[html.length] = '<option value=\''+AreaCoverage[i]+  '\'>' + AreaCoverage[i] + '</option>';
    }
    html[html.length] = "</select></td>";       
    html[html.length] = "<td><input id=\"txtName\" type=\"text\"/></td></tr>";
    
    html[html.length] = "<tr><td>Day Phone:</td><td>Email:</td></tr>";
    html[html.length] = "<tr><td><input id=\"txtDayPhone\" type=\"text\"  /></td><td><input id=\"txtEmailAddress\" type=\"text\" /></td></tr>";
    
    html[html.length] = "<tr><td>Re-Enter Email:</td><td>Captcha :</td></tr>";
    html[html.length] = "<tr><td><input id=\"txtReEmail\" type=\"text\" /></td><td><input id=\"txtCaptcha\" type=\"text\" /></td></tr>";
    html[html.length] ="<tr><td colspan=2 align=center><input id=\"btnSubmitUrl\" type=\"button\" value=\"Submit\" onclick=\"submitURL()\" />" ;   
    html[html.length] = "</table>";
    return html.join("");

}

function submitURL(){
    alert('This functionality is still under development ');
}
function relinkBeds(){
    window.location.href = document.getElementById("ddBeds").value;
}

function ContactInfo(){
var html = [];
 html[html.length] = "<div class=\"handle\" handlefor=\"displayGeneralInfo\" id=\"ContactUsHeader\"></div>";
    html[html.length] = "<div id=\"ContactUsHeader1\">";
    html[html.length] = "<table>";
    html[html.length] = "<tr><td>First Name:</td><td>Middle Name:</td></tr>";
    html[html.length] = "<tr><td><input id=\"txtFirstName\" type=\"text\" /></td><td><input id=\"txtMiddleName\" type=\"text\" /></td></tr>";
    html[html.length] = "<tr><td>Last Name:</td><td>Nickname:</td></tr>";
    html[html.length] = "<tr><td><input id=\"txtLastName\" type=\"text\" /></td><td><input id=\"txtNickName\" type=\"text\" /></td></tr>";
    
    html[html.length] = "<tr><td>Home Phone:</td><td>Personal Email:</td></tr>";
    html[html.length] = "<tr><td><input id=\"txtHomePhone\" type=\"text\" /></td><td><input id=\"txtPersonalEmail\" type=\"text\" /></td></tr>";
    
    html[html.length] = "<tr><td>Work Phone:</td><td>Work Email:</td></tr>";
    html[html.length] = "<tr><td><input id=\"txtWorkPhone\" type=\"text\"  /></td><td><input id=\"txtWorkEmail\" type=\"text\" /></td></tr>";
    
    html[html.length] = "<tr><td>Other Phone:</td><td>Other Email</td></tr>";
    html[html.length] = "<tr><td><input id=\"txtOtherPhone\" type=\"text\" /></td><td><input id=\"txtOtherEmail\" type=\"text\" /></td></tr>";
    
    html[html.length] = "<tr><td colspan=2>Notes:</td></tr>";
    html[html.length] = "<tr><td colspan=2><textarea id=\"txtNotes\" rows=\"4\" style=\"width: 350px\"></textarea></td></tr>";
    html[html.length] ="<tr><td colspan=2 align=center><input id=\"btnSubmitContact\" type=\"button\" value=\"Submit\" onclick=\"submitContactInfo()\" />" ;   
    html[html.length] = "</table>";
    html[html.length] = "</div>";
    html[html.length] = "<span id=rstContactInfo>";
    
    document.getElementById("displayGeneralInfo").innerHTML = html.join("");
    getContactInfo();

}

function getContactInfo(){
 
 Retrove.DemoMethods.getContactInfor(document.getElementById("lvwLogin_lgnName").innerHTML.replace("Welcome ",""),callback_submitContactInfo);
}


function RefineSearchLink(value,display){
var replaceValue = value.replace(display, "");
window.location.href = replaceValue;
}

function ResultSearchLink(value,display){
    Retrove.DemoMethods.buildRefineLinks(value,display,callback_RefineSearchLink);
}
function callback_RefineSearchLink(res){
 window.location.href = res.value;

}


function submitContactInfo(){
    Retrove.DemoMethods.postContactInfo(ItemID,document.getElementById("lvwLogin_lgnName").innerHTML.replace("Welcome ",""),
                                   document.getElementById("txtFirstName").value,
                                   document.getElementById("txtMiddleName").value, 
                                   document.getElementById("txtLastName").value, 
                                   document.getElementById("txtNickName").value, 
                                   document.getElementById("txtHomePhone").value, 
                                   document.getElementById("txtPersonalEmail").value, 
                                   document.getElementById("txtWorkPhone").value, 
                                   document.getElementById("txtWorkEmail").value, 
                                   document.getElementById("txtOtherPhone").value,
                                   document.getElementById("txtOtherEmail").value,
                                   document.getElementById("txtNotes").value,
                                   callback_submitContactInfo);
}

function callback_submitContactInfo(res){

    if(res != null && res.value != null && res.value.Tables != 0 && res.value.Tables.length == 1) {
    GlobalTable = res;
        var html = [];
        html[html.length] = "<table>";
        html[html.length] ="<tr><td>Contact</td></tr>";
        html[html.length] = "<tr><td><hr style=\"border-bottom: 1px dotted #A5AEC5; background-color: #FFFFFF; color: white;\"/></td></tr>";
        for(var i=0; i<res.value.Tables[0].Rows.length; i++){
            html[html.length] ="<tr>";
		    html[html.length] = '<td><strong><a href="javascript:void(0);" onclick="EditContactInfo('+i+ ');return false;">' + res.value.Tables[0].Rows[i].FirstName + " " + res.value.Tables[0].Rows[i].MiddleName +  " " + res.value.Tables[0].Rows[i].LastName   + '</a></strong></td>';
            html[html.length] ="</tr>";           
        }
        html[html.length] = "</table>";
        document.getElementById("rstContactInfo").innerHTML = html.join("");
    }       
}


function EditContactInfo(value)
{
        ItemID = GlobalTable.value.Tables[0].Rows[value].ItemID;
        document.getElementById("txtFirstName").value = GlobalTable.value.Tables[0].Rows[value].FirstName;
        document.getElementById("txtMiddleName").value = GlobalTable.value.Tables[0].Rows[value].MiddleName;
        document.getElementById("txtLastName").value = GlobalTable.value.Tables[0].Rows[value].LastName;
        document.getElementById("txtNickName").value = GlobalTable.value.Tables[0].Rows[value].NickName;
        document.getElementById("txtHomePhone").value = GlobalTable.value.Tables[0].Rows[value].HomePhone;
        document.getElementById("txtPersonalEmail").value = GlobalTable.value.Tables[0].Rows[value].PersonalEmail;
        document.getElementById("txtWorkPhone").value = GlobalTable.value.Tables[0].Rows[value].WorkPhone;
        document.getElementById("txtWorkEmail").value = GlobalTable.value.Tables[0].Rows[value].WorkEmail;
        document.getElementById("txtOtherPhone").value = GlobalTable.value.Tables[0].Rows[value].OtherPhone;
        document.getElementById("txtOtherEmail").value = GlobalTable.value.Tables[0].Rows[value].OtherEmail;
        document.getElementById("txtNotes").value = GlobalTable.value.Tables[0].Rows[value].Note;

}

function EditTaggedInfo(value){
       TaggedInfo();
        ItemCount = value;
        ItemID = RecTaggedInfo.value.Tables[0].Rows[value].TagID;
        document.getElementById("txtStreetAddress").value = RecTaggedInfo.value.Tables[0].Rows[value].StreetAddress;
        document.getElementById("txtCity1").value = RecTaggedInfo.value.Tables[0].Rows[value].City;
        document.getElementById("txtState").value = RecTaggedInfo.value.Tables[0].Rows[value].State;
        document.getElementById("txtPrice1").value = RecTaggedInfo.value.Tables[0].Rows[value].Price;       
}


function TaggedInfo(){
var html = [];
 html[html.length] = "<div class=\"handle\" handlefor=\"displayTaggedInfo\" id=\"TaggedUsHeader\"></div>";
    html[html.length] = "<div id=\"TaggedUsHeader1\">";
    html[html.length] = "<table>";
    html[html.length] = "<tr><td>Address:</td><td>City:</td><td>State:</td><td>Price:</td></tr>";
    html[html.length] = "<tr><td><input id=\"txtStreetAddress\" type=\"text\" /></td><td><input id=\"txtCity1\" type=\"text\" /></td><td><input id=\"txtState\" type=\"text\" /></td><td><input id=\"txtPrice1\" type=\"text\" /></td><td colspan=2 align=center><input id=\"btnSubmitContact\" type=\"button\" value=\"Submit\" onclick=\"UpdateTaggedInfo()\" /></td></tr>";
    html[html.length] = "</table>";
    html[html.length] = "</div>";
    html[html.length] = "<span id=rstTaggedInfo>";
    document.getElementById("displayTaggedInfo").innerHTML = html.join("");
}

 

function UpdateTaggedInfo() {
    try{
  Retrove.DemoMethods.getAddressVerify(document.getElementById("lvwLogin_lgnName").innerHTML.replace("Welcome ",""),
                                   RecTaggedInfo.value.Tables[0].Rows[ItemCount].Title,
                                   RecTaggedInfo.value.Tables[0].Rows[ItemCount].Notes,
                                   document.getElementById("txtStreetAddress").value,
                                   document.getElementById("txtCity1").value,
                                   document.getElementById("txtState").value,
                                   RecTaggedInfo.value.Tables[0].Rows[ItemCount].Bed,
                                   RecTaggedInfo.value.Tables[0].Rows[ItemCount].PropertyType,
                                   RecTaggedInfo.value.Tables[0].Rows[ItemCount].Land,
                                   RecTaggedInfo.value.Tables[0].Rows[ItemCount].Bath,
                                   RecTaggedInfo.value.Tables[0].Rows[ItemCount].ZipCode,
                                   document.getElementById("txtPrice1").value,
                                   RecTaggedInfo.value.Tables[0].Rows[ItemCount].Realtor,
                                   RecTaggedInfo.value.Tables[0].Rows[ItemCount].UrlAddress,ItemID,processAddress);
     } catch(exception) {
         alert('Only registered users can use this feature');
     }

}



function StateAccordian(value){
	//document.getElementById("divSaveShare").className = "StateWorkSpaceOff";
	document.getElementById("divSiteType").className = "StateWorkSpaceOff";
	document.getElementById("divNearByCities").className = "StateWorkSpaceOff";
	document.getElementById("divPrice").className = "StateWorkSpaceOff";	
	document.getElementById("divBedRoom").className = "StateWorkSpaceOff";	
	document.getElementById("divProtype").className = "StateWorkSpaceOff";	
	document.getElementById("divBathRoom").className = "StateWorkSpaceOff";
	document.getElementById("divRealEstate").className = "StateWorkSpaceOff";
			
	try{
		document.getElementById("divgoogleBase").className = "StateWorkSpaceOff";
		}catch(exception){}
		
			try{
	document.getElementById("divZipCode").className = "StateWorkSpaceOff";
		}catch(exception){}

	document.getElementById("divAllCities").className = "StateWorkSpaceOff";
		
	if(value == "divZipCode" || value == "divgoogleBase")
	   document.getElementById(value).className = "StateWorkSpaceOnExtra";
	else
       document.getElementById(value).className = "StateWorkSpaceOn";
}

function LocalInfoAccordian(value){
   var divArray = ["divSchools","divCity","divCrime","divCensus","divGovernment","divPark","divMaps","divWeather","divJobs"];
     for(var i=0; i<divArray.length; i++){
        document.getElementById(divArray[i]).className = "PersonalWorkSpaceOff";
     }
	
	 	var d = document.getElementById(value);
	if(d != null)
		d.className = (d.className == "PersonalWorkSpaceOff") ? "PersonalWorkSpaceOnExpand" : "PersonalWorkSpaceOff"; 


}

function validateAutoComplete(){

  if(typeof(document.getElementById("lstStateInfo").value) != "undefined"){
		//alert(document.getElementById("lstStateInfo").value);
	 GetCityInfor(0);
	}
}

 function load() {
      if (GBrowserIsCompatible()) {
      map = new GMap2(document.getElementById("map"));
      map.addControl(new GSmallMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(37.4419, -122.1419), 12);
      // Creates a marker at the given point with the given number label
      function createMarker(point, number , description ) {  
      	var marker = new GMarker(point);  
      	GEvent.addListener(marker, "click", function() {    marker.openInfoWindowHtml("<br><b>" + number + "</b>" + description);  });  
      	return marker;
      }
      	for (var i = 0; i < globalres.value.Tables[0].Rows.length; i++) {  
      	  var point = new GLatLng(parseFloat(globalres.value.Tables[0].Rows[i].Latitude), parseFloat(globalres.value.Tables[0].Rows[i].Longitude));  
      	  address = globalres.value.Tables[0].Rows[i].StreetAddress + " ," + globalres.value.Tables[0].Rows[i].City + " ," + globalres.value.Tables[0].Rows[i].State + " ," + globalres.value.Tables[0].Rows[i].ZipCode;    
      	  var Notes = "<br><div id=\"notes\" style=\"width: 300px; float:left; border: 0px solid black;\">" + globalres.value.Tables[0].Rows[i].Notes + "</div>";
      	  map.addOverlay(createMarker(point, address, Notes));
      	  
      	  }    
      	  map.setCenter(point, 12);
      	  
     }
   }
   
   

 
function getGoogleBaseHousing(){

 try
   {
    var link = "http://" + window.location.host + "/images/Loading.gif";
    var value = "<b>Searching....</b>";
    document.getElementById('CitySearch').innerHTML = '<img src="' + link + '">' + value + '</>'; 
    Retrove.DemoMethods.getData(callback_location);
         } catch(exception) {
         //alert('Only registered users can use this feature');       
     }

}
function openRss(){
    window.open("http://" + window.location.host + "/getrss.aspx?User=" + document.getElementById("lvwLogin_lgnName").innerHTML.replace("Welcome ",""));
}

function drivingDirections() {
    window.open("http://" + window.location.host + "/directions.aspx?User=" + document.getElementById("lvwLogin_lgnName").innerHTML.replace("Welcome ",""));

}

function callback_location(res){
        var arrayLocate = [];

    if(res != null && res.value != null && res.value.Tables != 0 && res.value.Tables.length == 1 && res.value.Tables[0].Rows.length > 0) {
                for(var i=0; i<res.value.Tables[0].Rows.length; i++){
                    //var splitlocation = res.value.Tables[0].Rows[i].location.split(',');
                        //for (j=0; j<splitlocation.length; j++){
                            //if (validate(splitlocation[j]) == true)
                              //if(arrayCity.indexOf(splitlocation[j]) ==null)
                              if(res.value.Tables[0].Rows[i].Total != 0)
                                arrayLocate[arrayLocate.length] = "<a href=http://www.retrove.com/" +res.value.Tables[0].Rows[i].StateCode + "/"+ replaceSpace(res.value.Tables[0].Rows[i].CityName) + ">" + res.value.Tables[0].Rows[i].CityName + " (Results " + res.value.Tables[0].Rows[i].Total +")</a><br />";
                         //}
                }
            document.getElementById('CitySearch').innerHTML = "";                
            document.getElementById('location').innerHTML = arrayLocate.join("");
    }
    else
        {
            document.getElementById('CitySearch').innerHTML = "";                
            document.getElementById('location').innerHTML = "No results";
        }

}




function callback_getGoogleBaseHousing(res){
    if(res != null && res.value != null && res.value.Tables != 0 && res.value.Tables.length == 1 && res.value.Tables[0].Rows.length > 0) {
        var html = [];
        html[html.length] = "<div class=\"handle\" handlefor=\"GooglebaseInfo\" id=\"googleHeader\"><a href=\"javascript:void(0);\" onclick=\"StateAccordian(\'divgoogleBase\')\"> <b>Google Base Real Estate Results :- " + res.value.Tables[0].Rows.length +  " </b></a></div>";
        html[html.length] = "<hr style=\"border-bottom: 1px dotted #A5AEC5; background-color: #FFFFFF; color: white;\"/>";
        html[html.length] = "<div id=\"divgoogleBase\" class=\"StateWorkSpaceOff\">";
            for(var i=0; i<res.value.Tables[0].Rows.length; i++){
                var splitLink = res.value.Tables[0].Rows[i].Links.split('|');
		        html[html.length] = '<strong><a href="javascript:void(0);" onclick="AppendLink(\''+splitLink[0] +'\',\''+res.value.Tables[0].Rows[i].agent+ '\');return false;">' + validateforDollarSign(res.value.Tables[0].Rows[i].Title ,  res.value.Tables[0].Rows[i].price)   + " | Agent - " + res.value.Tables[0].Rows[i].agent + '</a></span></span></strong><br />';
                html[html.length] = res.value.Tables[0].Rows[i].Content + "<br />";
                html[html.length] = "<b>Bed Rooms -</b>  " + res.value.Tables[0].Rows[i].bedrooms + ", <b>Bath -</b> " +  res.value.Tables[0].Rows[i].bathrooms + " <b>Property Type - </b>" +  res.value.Tables[0].Rows[i].property_type + "<br/>";
                html[html.length] = "<b>MLS -</b>  " + res.value.Tables[0].Rows[i].mls_listing_id + " <b>School district -</b>  " + res.value.Tables[0].Rows[i].school_district + ", <b>area -</b> " +  res.value.Tables[0].Rows[i].area + " <b>location - </b>" +  res.value.Tables[0].Rows[i].location +  " <b>Price - </b>" +  res.value.Tables[0].Rows[i].price +  " <b>Publish Date - </b>" +  res.value.Tables[0].Rows[i].publish_date + "<br/>"; 
            }
        html[html.length] = "</div>";
		//document.getElementById("GooglebaseInfo").innerHTML = html.join("");
    }
        document.getElementById('SearchLoading').innerHTML = "";
        dragdropvalue = "GooglebaseInfo";
        runEvents(dragdropvalue);
}
function validateforDollarSign(myTitle, myprice){
   try
   {
		if( myTitle.indexOf("$") != -1)
			return myTitle;
		else
		    return myprice + " " + myTitle;

     } catch(exception) {
         //alert('Only registered users can use this feature');       
     }
		
}


function getURLLink(){
        if (validate(document.getElementById("txtCity").value) == true){
			if(document.getElementById("txtCity").value != "" && document.getElementById("txtCity").value != "Enter City or Zip"){
            var link = "http://" + window.location.host + "/images/Loading.gif";
            var value = "<b>Searching Real Estate....</b>";
            document.getElementById('SearchLoading').innerHTML = '<img src="' + link + '">' + value + '</>'; 
			    window.location.href = "http://" + window.location.host + "/" + document.getElementById("lstStateInfo").value + "/" + replaceSpace(document.getElementById("txtCity").value); 
			}else{
			    alert('Enter a City or Zipcode')
			}
        }else{
            alert("Enter a valid City");
        } 
}

function replaceSpace(urlLink){
var bindUnderScore;
    try
    {
        var splitValue = urlLink.split(' '); 
        for(var i=0; i<splitValue.length; i++)
        {
            bindUnderScore +=splitValue[i] + "_";     
        }
        bindUnderScore = bindUnderScore.replace("undefined", "");       
        return bindUnderScore.substring(0,bindUnderScore.length -1);
    } catch(exception) 
     {
      return  urlLink;
     }   

}
function FilterLink(state,city,zipCode){
    window.location.href = "http://" + window.location.host + "/" + state + "/" + city.ToString.replace(' ','_')+ "/" + zipCode; 
}

function saveLink(Title,URLAddress, Realtor,Description){
    try
    {
        Retrove.DemoMethods.SavePersonalLink(document.getElementById("lvwLogin_lgnName").innerHTML.replace("Welcome ",""),Title,URLAddress, Realtor,Description,callback_saveLink);
    } catch(exception) {
        alert('Only registered users can use this feature');       
    }
 
 }

function callback_saveLink(res){
    if(res != null && res.value != null && res.value.Tables != 0 && res.value.Tables.length == 1) {
        alert(res.value.Tables[0].Rows[0].Success);
        getSavedLinks();
    }
}





		
function addToSite(idTag,UrlAddress, Realtor)
{
popUpDiv(UrlAddress+'|'+500+'|'+400+'|'+idTag+'|'+Realtor+'|'+"localArea"+'|'+"Retrove this link");
}	
function GetStateList(){
	 	//initializetabcontent("maintab");
    arrayResult = new Array();
    autoComplete = "txtState";
    Retrove.DemoMethods.GetState(callback_GetStateList);
    document.getElementById("txtCity").value = 'Enter City or Zip';
    
}


function GetStateList1(){
    Retrove.DemoMethods.GetState(callback_GetStateList);
    //cachLinksToDatabase();
}

function cachLinksToDatabase(){
    var stateCode = ""; 
    if(document.getElementById("StateCode").value == ""){
        for(i=0; i< arrayStateCode.length; i++){
            stateCode = arrayStateCode[i].split('|');
            Retrove.DemoMethods.GetStateCache(stateCode[1]);
        }
    }else{
    Retrove.DemoMethods.GetStateCache(document.getElementById("StateCode").value);
    }
}

function callback_GetStateList(res){
    if(res != null && res.value != null && res.value.Tables != 0 && res.value.Tables.length == 1) {
	    var html = [];
	    	    html[html.length] = '<select id=\"lstStateInfo\" onchange=GetCityInfor(1)>';
		        for(var i=0; i<res.value.Tables[0].Rows.length; i++){
      					html[html.length] = '<option value=\''+res.value.Tables[0].Rows[i].statecode+  '\'>' + res.value.Tables[0].Rows[i].STATE + '</option>';
  	        }
	          html[html.length] = '</select></td>';
	          document.getElementById("selSate").innerHTML = html.join("");
 		}
				var urlName = "divValue" + i;
					document.getElementById("lstStateInfo").selectedIndex = -1;
				//document.getElementById("searchResultsList").innerHTML += buildListing(res.value.Tables[0].Rows[i].URL, res.value.Tables[0].Rows[i].Name, urlName);
}

function mbMouseDownListener() {
    alert('here');
}

function PageInit(){
    //document.getElementById("lstState").selectedIndex = -1;
}



function AddArray(){
    var paraName = document.getElementById("txtParaName").value;
    var paraValue = document.getElementById("txtParaValue").value;  
    arrayParamValues[arrayParamValues.length]= '<li><a href="javascript:void(0);" onclick="RemovefromList(\''+ paraValue+ '\');return false;">' +paraName + '=' + paraValue + '</a></li>';
    document.getElementById("ParaResult").innerHTML = arrayParamValues.join("");
}
 
function RemovefromList(res){
    arrayParamValues = RemoveArrayIndex(arrayParamValues,res);
    document.getElementById("ParaResult").innerHTML = arrayParamValues;
}
function RemoveArrayIndex (arr,keyword) { 
  var r = new Array (); 
  var l = 0; 
  for (var i = 0; i < arr.length; i++) { 
   if (arr[i].indexOf(keyword) != -1){   
   } else{
      r[l++] = arr[i];
   }
  } 
return r;
} 


function popUpProperty(mylist){
    var heightWidthUrl = mylist.split('|');
    divValue = heightWidthUrl[3];//assign value to be made visible
    AddMiscInfo();
    setVisibleDiv('visible'); //set's id to visible
} 
function popUpDiv(hrefID){
	heightWidthUrl = hrefID.split('|');
	divValue = heightWidthUrl[3];
	_createWindow("shadowDiv",heightWidthUrl[6]);
	setVisibleDiv('visible');
}
function performLocalCall()
{	
	if(heightWidthUrl[5] == "localArea") { 
			return localArea(heightWidthUrl[0],heightWidthUrl[4]);
	}
	if(heightWidthUrl[5] == "localProperty") { 
			return AddMiscInfo();
	}
	
	if(heightWidthUrl[5] == "addToRetrove"){
	 
	}
	if(heightWidthUrl[5] == "ReportLink") { 
			return buildReportLink();
	}
	
	if(heightWidthUrl[5] == "formClaimAgentProfile") { 	
			return formClaimAgentProfile();
	}
	
	
	if(heightWidthUrl[5] == "reSubmitLink") { 
			return reSubmitURL();
	}
	if(heightWidthUrl[5] == "topMenu") { 
			return topMenu();
	}
	
	if(heightWidthUrl[5] == "leftMenu") { 
			return leftMenu();
	}
	if(heightWidthUrl[5] == "mainBody") { 
			return mainBody();
	}
	
	
}

function addToRetrove(){
    popUpDiv(URLAddress+'|'+500+'|'+600+'|'+'addToRetrove|'+LinkAddress+'|'+"localArea"+'|'+"Retrove this link")
      
}


function logIn(_id){
claimAgentProfile1 = _id;
    Retrove.DemoMethods.RequestResponse("<LogInFormRequest><type><FormRequest><LogInFormRequestProcess></LogInFormRequestProcess></FormRequest></type></LogInFormRequest>",callback_registerUser);

}

function callback_logIn(res){

defaultYPosition = -150;// - for down + for up
defaultXPosition = -700; // - left + right,

var className = "blinkcube";
	divValue = claimAgentProfile1;
	dragdropvalue = "shadowDiv";
     document.getElementById("shadowDiv").className == "dialog";
    document.getElementById("shadowDiv").innerHTML = "<div>" +  _createCustomDiv('shadowDiv','Log  In',res.value)+ "</div>";
    runEvents(dragdropvalue);		
	setVisibleDiv('visible');

}




function addNewOfficeListing(_officeListingID){
claimAgentProfile1 = _officeListingID;
    Retrove.DemoMethods.RequestResponse("<AddNewOfficeFormRequest><type><FormRequest><AddNewOfficeFormRequestProcess></AddNewOfficeFormRequestProcess></FormRequest></type></AddNewOfficeFormRequest>",callback_addNewOfficeListing);

}

function callback_addNewOfficeListing(res){
    defaultYPosition = 60;
    defaultXPosition = 4;
    buildDisplayForm("Add New Office Profile" ,res.value);
}


function addNewAgentListing(_agentListingID){
claimAgentProfile1 = _agentListingID;
    Retrove.DemoMethods.RequestResponse("<AddNewAgentFormRequest><type><FormRequest><AddNewAgentFormRequestProcess></AddNewAgentFormRequestProcess></FormRequest></type></AddNewAgentFormRequest>",callback_addNewAgentListing);

}

function callback_addNewAgentListing(res){
    defaultYPosition = 60;
    defaultXPosition = 4;

    buildDisplayForm("Add New Agent Profile", res.value);
}


function emailThisLink(_emailThisLink,_emailAddress, _realtorName){
claimAgentProfile1 = _emailThisLink;
    var xmlAdd = '<EmailAddress><![CDATA[' + _emailThisLink + ']]></EmailAddress>';
    xmlAdd = xmlAdd + '<RealtorName><![CDATA[' + _realtorName + ']]></RealtorName>'; 
    Retrove.DemoMethods.RequestResponse("<EmailThisLinkRequest><type><FormRequest><EmailThisLinkRequestProcess>" + xmlAdd +"</EmailThisLinkRequestProcess></FormRequest></type></EmailThisLinkRequest>",callback_EmailThisLink);

}

function getGoogleInfo(){
   
   var _stateCode = document.getElementById("idStateCode").value;
   var _city = document.getElementById("idCity").value;
    var xmlAdd = '<StateCode><![CDATA[' + _stateCode + ']]></StateCode>';
    xmlAdd = xmlAdd + '<City><![CDATA[' + _city + ']]></City>'; 
    Retrove.DemoMethods.googleDataFeed("<GoogleFeedRequest><type><FormRequest><GoogleFeedRequestProcess>" + xmlAdd +"</GoogleFeedRequestProcess></FormRequest></type></GoogleFeedRequest>",callback_googleRequestFeed);

}

function googleRequestFeed(_stateCode, _city){
    var xmlAdd = '<StateCode><![CDATA[' + _stateCode + ']]></StateCode>';
    xmlAdd = xmlAdd + '<City><![CDATA[' + _city + ']]></City>'; 
    Retrove.DemoMethods.googleDataFeed("<GoogleFeedRequest><type><FormRequest><GoogleFeedRequestProcess>" + xmlAdd +"</GoogleFeedRequestProcess></FormRequest></type></GoogleFeedRequest>",callback_googleRequestFeed);
}

function callback_googleRequestFeed(res)
{
document.getElementById("tcontent7").innerHTML = res.value;
//document.getElementById("googleStore").innerHTML = "this is a test";
}

function callback_EmailThisLink(res){
    defaultYPosition = 60;
    defaultXPosition = 4;

    buildDisplayForm("Email This Link", res.value);
}


function submitValidateloginInfor(_activeSession,_tableId){
    var xml = "";
    var xmlAdd = '<Param Name=\'' + _activeSession  + '\'><![CDATA[' + document.getElementById(_activeSession).value + ']]></Param>';
    xml = getRegistrationInfo(_tableId);
    Retrove.DemoMethods.RequestResponse("<LogInFormProcess><type><FormRequest><LogInFormRequestProcess>" + xmlAdd + xml + "</LogInFormRequestProcess></FormRequest></type></LogInFormProcess>",callback_submitRegistrationForm);
}

function callback_LogInForm(res) {
    buildDisplayForm("Log in Status", res.value);
}



function  buildDisplayForm(_formName, _res){

var className = "blinkcube";
	divValue = claimAgentProfile1;
	dragdropvalue = "shadowDiv";
     document.getElementById("shadowDiv").className == "dialog";
    document.getElementById("shadowDiv").innerHTML = "<div>" +  _createCustomDiv('shadowDiv',_formName,_res)+ "</div>";
    runEvents(dragdropvalue);		
	setVisibleDiv('visible');

}
function registerUser(_registerUser,_activeSession){
claimAgentProfile1 = _registerUser;

    Retrove.DemoMethods.RequestResponse("<RegisterFormRequest><type><FormRequest><RegisterFormRequestProcess></RegisterFormRequestProcess></FormRequest></type></RegisterFormRequest>",callback_registerUser);
}

function subscribeToAlert(_subscribeToAlert,_city,_stateCode,_county){
claimAgentProfile1 = _subscribeToAlert;
     var xmlAdd = '<Param Name=\'1\'><![CDATA[' + _city + ']]></Param>';
     xmlAdd = xmlAdd +  '<Param Name=\'2\'><![CDATA[' + _stateCode+ ']]></Param>';
     xmlAdd = xmlAdd +  '<Param Name=\'3\'><![CDATA[' + _county+ ']]></Param>';
     xmlAdd = xmlAdd +  '<Param Name=\'4\'><![CDATA[' + document.getElementById("txtSessionid").value+ ']]></Param>';
    Retrove.DemoMethods.RequestResponse("<SubscribeFormRequest><type><FormRequest><SubscribeFormRequestProcess>" + xmlAdd+" </SubscribeFormRequestProcess></FormRequest></type></SubscribeFormRequest>",callback_subscribeToAlert);
}


function getTheCurentSession(){
 Retrove.DemoMethods.getCurrentSession(callback_getTheCurentSession);
 }
 
 
 function callback_getTheCurentSession(res){
    currentSession = res.value;
 }

function callback_subscribeToAlert(res){

defaultYPosition = -150;// - for down + for up
defaultXPosition = -700; // - left + right,

var className = "blinkcube";
	divValue = claimAgentProfile1;
	dragdropvalue = "shadowDiv";
     document.getElementById("shadowDiv").className == "dialog";
    document.getElementById("shadowDiv").innerHTML = "<div>" +  _createCustomDiv('shadowDiv','Subcribe To an Alert',res.value)+ "</div>";
    runEvents(dragdropvalue);		
	setVisibleDiv('visible');

}-







function callback_registerUser(res){

defaultYPosition = -150;// - for down + for up
defaultXPosition = -700; // - left + right,

var className = "blinkcube";
	divValue = claimAgentProfile1;
	dragdropvalue = "shadowDiv";
     document.getElementById("shadowDiv").className == "dialog";
    document.getElementById("shadowDiv").innerHTML = "<div>" +  _createCustomDiv('shadowDiv','Registration Form',res.value)+ "</div>";
    runEvents(dragdropvalue);		
	setVisibleDiv('visible');

}



function submitRegistrationForm(_activesession){ 
    var xml = "";
    var xmlAdd = '<Param Name=\'' + _activesession  + '\'><![CDATA[' + document.getElementById(_activesession).value + ']]></Param>';
    xml = getRegistrationInfo('tblRegistrationForm');
    Retrove.DemoMethods.RequestResponse("<RegisterFormProcess><type><FormRequest><RegisterFormRequestProcess>" + xmlAdd + xml + "</RegisterFormRequestProcess></FormRequest></type></RegisterFormProcess>",callback_submitRegistrationForm);
}



function subcriberAutoGenerateEmail(){
    var xml = getRegistrationInfo('tblInitialSubscriber');
    Retrove.DemoMethods.RequestResponse("<SubscribeEmailRequest><type><FormRequest><SubscribeEmailRequestProcess>" + xml + "</SubscribeEmailRequestProcess></FormRequest></type></SubscribeEmailRequest>",callback_subscribeEmailRequestForm);
}


function callback_subscribeEmailRequestForm(res){
}



function processSubcriberAlert(_id, _urlAddress,_realtorName,_city,_stateCode,_county){
var t = document.getElementById(_id);
    if(t.value.length <= 0)
        alert("Provide a valid email address");
    else{
         var xmlAdd = '<Param Name=\'Email_Address\'><![CDATA[' + t.value + ']]></Param>';
         xmlAdd = xmlAdd +  '<Param Name=\'LinkAddress\'><![CDATA[' + _urlAddress+ ']]></Param>';
         xmlAdd = xmlAdd +  '<Param Name=\'Realtor\'><![CDATA[' + _realtorName+ ']]></Param>';
         xmlAdd = xmlAdd +  '<Param Name=\'City\'><![CDATA[' + _city+ ']]></Param>';
         xmlAdd = xmlAdd +  '<Param Name=\'StateCode\'><![CDATA[' + _stateCode+ ']]></Param>';
         xmlAdd = xmlAdd +  '<Param Name=\'County\'><![CDATA[' + _county+ ']]></Param>';
        Retrove.DemoMethods.RequestResponse("<ProcessSubcriberAlertRequest><type><FormRequest><ProcessSubcriberAlertRequestProcess>"+ xmlAdd +"</ProcessSubcriberAlertRequestProcess></FormRequest></type></ProcessSubcriberAlertRequest>",callback_processSubcriberAlert);
    }
}

function callback_processSubcriberAlert(res) { 
    document.getElementById("divSubcribedContent").innerHTML = res.value;
}
function callback_submitRegistrationForm(res){

var className = "blinkcube";
	divValue = claimAgentProfile1;
	dragdropvalue = "shadowDiv";
     document.getElementById("shadowDiv").className == "dialog";
    document.getElementById("shadowDiv").innerHTML = "<div>" +  _createCustomDiv('shadowDiv','Registration Form',res.value)+ "</div>";
    runEvents(dragdropvalue);		
	setVisibleDiv('visible');
}

function processUnSubscriberAlert(_emailAddress, _urlAddress,_realtorName){
         var xmlAdd = '<Param Name=\'Email_Address\'><![CDATA[' + _emailAddress + ']]></Param>';
         xmlAdd = xmlAdd +  '<Param Name=\'LinkAddress\'><![CDATA[' + _urlAddress+ ']]></Param>';
         xmlAdd = xmlAdd +  '<Param Name=\'Realtor\'><![CDATA[' + _realtorName+ ']]></Param>';
         Retrove.DemoMethods.RequestResponse("<UnSubscribeFormRequest><type><FormRequest><UnSubscribeFormRequestProcess>" + xmlAdd+" </UnSubscribeFormRequestProcess></FormRequest></type></UnSubscribeFormRequest>",callback_processSubcriberAlert);
}

function submitSubcriptionInfo(_subscribeToAlert,_emailAddress) {
claimAgentProfile1 = _subscribeToAlert;
    if(echeck(document.getElementById(_emailAddress).value)){
        var t = document.getElementById(_emailAddress);
            if(t.value.length <= 0)
                alert("Provide a valid email address");
            else{
                 var xmlAdd = '<Param Name=\'Email_Address\'><![CDATA[' + t.value + ']]></Param>';
                 xmlAdd = xmlAdd +  '<Param Name=\'sessionInfo\'><![CDATA[' + document.getElementById("txtSessionid").value + ']]></Param>';
                Retrove.DemoMethods.RequestResponse("<InitialSubscriberRequest><type><FormRequest><InitialSubscriberProcess>"+ xmlAdd +"</InitialSubscriberProcess></FormRequest></type></InitialSubscriberRequest>",callback_InitialSubscriberRequest);
                }
    }

}



function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.frmSample.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }




function callback_InitialSubscriberRequest(res){

defaultYPosition = -150;// - for down + for up
defaultXPosition = -700; // - left + right,

var className = "blinkcube";
	divValue = claimAgentProfile1;
	dragdropvalue = "shadowDiv";
     document.getElementById("shadowDiv").className == "dialog";
    document.getElementById("shadowDiv").innerHTML = "<div>" +  _createCustomDiv('shadowDiv','Confirmation message',res.value)+ "</div>";
    runEvents(dragdropvalue);		
	setVisibleDiv('visible');
	
	subcriberAutoGenerateEmail();

}




function claimAgentProfileProcess(profileID,_stateCode, _claimAgentProfile){
    defaultYPosition = 60;
    defaultXPosition = 4;
    claimAgentProfile1 = _claimAgentProfile;
    var rtnValue = claimOffficeRequestFormProcess("AgentID",profileID,_stateCode);
    closeWindow();
    Retrove.DemoMethods.RequestResponse(rtnValue,callback_claimAgentProfileProcess);
}

function callback_claimAgentProfileProcess(res){
    var className = "blinkcube";
    //var t = document.getElementById(claimAgentProfile1);
    divValue = claimAgentProfile1;
    dragdropvalue = "shadowDiv";
    document.getElementById("shadowDiv").className == "dialog";
    document.getElementById("shadowDiv").innerHTML = "<div>" +  _createCustomDiv('shadowDiv','Claim Profile',res.value)+ "</div>";
    runEvents(dragdropvalue);		
    setVisibleDiv('visible');
}  



function claimAgentProfile(profileID,_stateCode, _claimAgentProfile){
        defaultYPosition = 60;
        defaultXPosition = 4;
        claimAgentProfile1 = _claimAgentProfile;
        var rtnValue = claimOffficeRequestForm("AgentID",profileID,_stateCode);
        Retrove.DemoMethods.RequestResponse(rtnValue,callback_claimAgentProfile);
  }
function callback_claimAgentProfile(res){

var className = "blinkcube";
 //var t = document.getElementById(claimAgentProfile1);
	divValue = claimAgentProfile1;
	dragdropvalue = "shadowDiv";
     document.getElementById("shadowDiv").className == "dialog";
    document.getElementById("shadowDiv").innerHTML = "<div>" +  _createCustomDiv('shadowDiv','Claim Profile',res.value)+ "</div>";
    runEvents(dragdropvalue);		
	setVisibleDiv('visible');
}  


function submitSubscribeFormRequest(){

}



function closeWindow(){
	setVisibleDiv('hidden');
}
  // Creates HTML window code
function _createWindow (id, title) {
    var className = "blinkcube";
    var win = "";
    var content;
    
    var closeDiv = "<div class='"+ className +"_close' id='"+ id +"_close' onclick='Windows.close(\""+ id +"\", event)'></div>";
    var minDiv = "<div class='"+ className + "_minimize' id='"+ id +"_minimize' onclick='Windows.minimize(\""+ id +"\", event)'> </div>";
    var maxDiv = "<div class='"+ className + "_maximize' id='"+ id +"_maximize' onclick='Windows.maximize(\""+ id +"\", event)'> </div>";
    var seAttributes = "class='" + className + "_sizer' id='" + id + "_sizer'";
    
    win = closeDiv + minDiv + maxDiv + "<div class=\"handle\" handlefor=\"shadowDiv\"  id=\"divtags\">\
      <table id='"+ id +"_row1' class=\"top table_window\">\
        <tr>\
          <td class='"+ className +"_nw'>&nbsp;</td>\
          <td class='"+ className +"_n'><div id='"+ id +"_top' class='"+ className +"_title title_window'>"+ title + "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;    " +'<a href="javascript:void(0);" onclick="closeWindow();return false;">' + 'Close Window' + "</a></div></td>\
          <td class='"+ className +"_ne'>&nbsp;</td>\
        </tr>\
      </table></div>\
      <table id='"+ id +"_row2' class=\"mid table_window\">\
        <tr>\
          <td class='"+ className +"_w'></td>\
            <td id='"+ id +"_table_content' class='"+ className +"_content' valign='top'>" + performLocalCall() + "</td>\
          <td class='"+ className +"_e'></td>\
        </tr>\
      </table>\
        <table id='"+ id +"_row3' class=\"bot table_window\">\
        <tr>\
          <td class='"+ className +"_sw'>&nbsp;</td>\
            <td class='"+ className +"_s'><div id='"+ id +"_bottom' class='status_bar'>&nbsp;</div></td>\
            <td " + seAttributes + ">&nbsp;</td>\
        </tr>\
      </table>\
      ";
      //content ="<div id=\"" + id + "\" class=\"" +className + "_content\">" + win + "</div>";
    //win
    dragdropvalue = "shadowDiv";
     document.getElementById("shadowDiv").className == "dialog";
    document.getElementById("shadowDiv").innerHTML = win;
    runEvents(dragdropvalue);
    //return win;
  }
  
  
  
  
    // Creates HTML window code
function _createCustomDiv (id, title, htmlfile) {
    var className = "blinkcube";
    var win = "";
    var content;
    
    var closeDiv = "<div class='"+ className +"_close' id='"+ id +"_close' onclick='Windows.close(\""+ id +"\", event)'></div>";
    var minDiv = "<div class='"+ className + "_minimize' id='"+ id +"_minimize' onclick='Windows.minimize(\""+ id +"\", event)'> </div>";
    var maxDiv = "<div class='"+ className + "_maximize' id='"+ id +"_maximize' onclick='Windows.maximize(\""+ id +"\", event)'> </div>";
    var seAttributes = "class='" + className + "_sizer' id='" + id + "_sizer'";
    
    win = closeDiv + minDiv + maxDiv + "<div class=\"handle\" handlefor=\"shadowDiv\"  id=\"divtags\">\
      <table id='"+ id +"_row1' class=\"top table_window\">\
        <tr>\
          <td class='"+ className +"_nw'>&nbsp;</td>\
          <td class='"+ className +"_n'><div id='"+ id +"_top' class='"+ className +"_title title_window'>"+ title + "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;    " +'<a href="javascript:void(0);" onclick="closeWindow();return false;">' + 'Close Window' + "</a></div></td>\
          <td class='"+ className +"_ne'>&nbsp;</td>\
        </tr>\
      </table></div>\
      <table id='"+ id +"_row2' class=\"mid table_window\">\
        <tr>\
          <td class='"+ className +"_w'></td>\
            <td id='"+ id +"_table_content' class='"+ className +"_content' valign='top'>" + htmlfile + "</td>\
          <td class='"+ className +"_e'></td>\
        </tr>\
      </table>\
        <table id='"+ id +"_row3' class=\"bot table_window\">\
        <tr>\
          <td class='"+ className +"_sw'>&nbsp;</td>\
            <td class='"+ className +"_s'><div id='"+ id +"_bottom' class='status_bar'>&nbsp;</div></td>\
            <td " + seAttributes + ">&nbsp;</td>\
        </tr>\
      </table>\
      ";
      //content ="<div id=\"" + id + "\" class=\"" +className + "_content\">" + win + "</div>";
    //win
    //dragdropvalue = "shadowDiv";
     //document.getElementById("shadowDiv").className == "dialog";
    //document.getElementById("shadowDiv").innerHTML = win;
    //runEvents(dragdropvalue);
    return win;
  }
  
 function GetStateCode()
 {
     Retrove.DemoMethods.GetState(callback_GetStateCode);
 }
 
 function process10MileRadius(_id,_div10MileRadius,_city,_stateCode,_county){
    
    if(document.getElementById(_id).checked){
        var xmlAdd = '<Param Name=\'stateCode\'><![CDATA[' + _stateCode+ ']]></Param>';
        xmlAdd = xmlAdd +  '<Param Name=\'city\'><![CDATA[' + _city+ ']]></Param>';
        if(processSurroundingCity == '')
            Retrove.DemoMethods.RequestResponse("<SurroundingCityRequest><type><FormRequest><SurroundingCityRequestProcess>"+ xmlAdd +"</SurroundingCityRequestProcess></FormRequest></type></SurroundingCityRequest>",callback_processSurroundingCity);
        else {
            document.getElementById("div10MileRadius").style.display="block";
            document.getElementById("div10MileRadius").innerHTML = processSurroundingCity;
        }
              
    }
    else
     document.getElementById(_div10MileRadius).style.display="none";
}


function addResources(_id,_divAddRealEstateSource,_city,_stateCode,_county){
    
    if(document.getElementById(_id).checked){
        var xmlAdd = '<Param Name=\'stateCode\'><![CDATA[' + _stateCode+ ']]></Param>';
        xmlAdd = xmlAdd +  '<Param Name=\'city\'><![CDATA[' + _city+ ']]></Param>';
        if(processSurrondingRealEstates == '')
            Retrove.DemoMethods.RequestResponse("<RealEstateRequest><type><FormRequest><RealEstateRequestProcess>"+ xmlAdd +"</RealEstateRequestProcess></FormRequest></type></RealEstateRequest>",callback_addResources);
        else {
            document.getElementById("divAddRealEstateSource").style.display="block";
            document.getElementById("divAddRealEstateSource").innerHTML = processSurrondingRealEstates;
        }
              
    }
    else
     document.getElementById(_divAddRealEstateSource).style.display="none";
}
 
 
 function callback_addResources(res){
    processSurrondingRealEstates = res.value;
    document.getElementById("divAddRealEstateSource").style.display="block";
    document.getElementById("divAddRealEstateSource").innerHTML = processSurrondingRealEstates;
}

function callback_processSurroundingCity(res){
    processSurroundingCity = res.value;
    document.getElementById("div10MileRadius").style.display="block";
    document.getElementById("div10MileRadius").innerHTML = processSurroundingCity;
}

function processCurrentCityMonitored(_divCurrentlyMonitored,_emailAddess){
    if(document.getElementById(_divCurrentlyMonitored).checked){
        var xmlAdd = '<Param Name=\'stateCode\'><![CDATA[' + _emailAddess+ ']]></Param>';
        Retrove.DemoMethods.RequestResponse("<CurrentCityMonitoredRequest><type><FormRequest><CurrentCityMonitoredProcess>"+ xmlAdd +"</CurrentCityMonitoredProcess></FormRequest></type></CurrentCityMonitoredRequest>",callback_processCurrentCityMonitored);
    }
    else
        document.getElementById("divCurrentlyMonitored").style.display="none";
     
}
function callback_processCurrentCityMonitored(res){
    document.getElementById("divCurrentlyMonitored").style.display="block";
    document.getElementById("divCurrentlyMonitored").innerHTML  = res.value;
}    


 function callback_GetStateCode(res){
   if(res != null && res.value != null && res.value.Tables != 0 && res.value.Tables.length == 1) {
    var html = [];
	    html[html.length] = '<select id=\"lstStateCode\">';
        for(var i=0; i<res.value.Tables[0].Rows.length; i++){
				html[html.length] = '<option value=\''+res.value.Tables[0].Rows[i].statecode+  '\'>' + res.value.Tables[0].Rows[i].statecode + '</option>';
        }
       html[html.length] = '</select></td>';
       document.getElementById("holdStateCode").innerHTML =  html.join("");
 	}
	html.length = 0;		
    html[html.length] = '<select id=\"lslBeds\">';
        for(var i=0; i<Beds.length; i++){
            html[html.length] = '<option value=\''+Beds[i]+  '\'>' + Beds[i] + '</option>';
        }
    html[html.length] = '</select></td>';
    document.getElementById("holdBed").innerHTML =  html.join("");
	html.length = 0;		
    html[html.length] = '<select id=\"lslProperty_Type\">';
        for(var i=0; i<Property_Type1.length; i++){
            html[html.length] = '<option value=\''+Property_Type1[i]+  '\'>' + Property_Type1[i] + '</option>';
        }
    html[html.length] = '</select></td>';
    document.getElementById("holdProperty_Type").innerHTML =  html.join("");
	html.length = 0;		
    html[html.length] = '<select id=\"lslLand\">';
        for(var i=0; i<Land.length; i++){
            html[html.length] = '<option value=\''+Land[i]+  '\'>' + Land[i] + '</option>';
        }
    html[html.length] = '</select></td>';
    document.getElementById("holdLand").innerHTML =  html.join("");
	html.length = 0;		
    html[html.length] = '<select id=\"lslBath\">';
        for(var i=0; i<Bath.length; i++){
            html[html.length] = '<option value=\''+Land[i]+  '\'>' + Bath[i] + '</option>';
        }
    html[html.length] = '</select></td>';
    document.getElementById("holdBath").innerHTML =  html.join("");
		
}


function localArea(urlLink, urlName){
var win = "";
win = "<table width=\"100%\">"
win +="<tr>";
win +="<td colspan=\"5\">";
win +="<span style=\"font-size: 10pt; font-family: Arial\">Tag links. Insert addresses and we will map them for you.</span></td>";
win +="</tr>";
win +="<tr>";
    win +="<td>Title</td>";
    win +="<td>";
    win +="Ranks";
    win +="</td>";
win +="</tr>";
win +="<tr>";
    win +="<td colspan=\"5\"><div>Notes</div><div><textarea id=\"txtNotes\" rows=\"2\" style=\"width: 550px\">" + document.getElementById("CachedLinks").innerHTML + "</textarea></div></td>";
win +="</tr>";
win +="<tr>";
    win +="<td><div>Street Address</div><div><input id=\"txtStreetAddress\" type=\"text\" /></div></td>";
    win +="<td><div>City</div><div><input id=\"txtCity1\" type=\"text\" /></div></td>";
    win +="<td><div>State</div><div><span id=\"holdStateCode\"></span></div></td>";
    win +="<td><div>ZipCode</div><div><input id=\"txtZipCode\" type=\"text\" style=\"width: 40px\" /></div></td>";
    win +="</td>";
win +="</tr>";
win +="<tr>";
    win +="<td><div>Price</div><div><input id=\"txtPrice\" type=\"text\" style=\"width: 90px\" /></div></td>";
    win +="<td><div>Bed</div><div><span id=\"holdBed\"></span></div></td>";
    win +="<td><div>Property Type</div><div><span id=\"holdProperty_Type\"></span></div></td>";
    win +="<td><div>Land</div><div><span id=\"holdLand\"></span></div></td>";
    win +="<td><div>Bath</div><div><span id=\"holdBath\"></span></div></td>";
win +="</tr>";
win +="<tr>";
    win +="<td colspan=\"5\"><div>Tags</div><div><textarea id=\"txtTags\" rows=\"2\" style=\"width: 550px\"></textarea></div></td>";
win +="</tr>";
win +="<tr>";
    win +="<td align=\"center\" colspan=\"4\">";;
    win +="<input id=\"Button1\" type=\"button\" value=\"Submit\" onclick=\"postAddTag()\" />" ;   
    win +="</td>";
win +="</tr>";
win +="</table>";
GetStateCode();
return win;
}

function postAddTag(){
geocode();                                                 
}

function geocode() {
    try{
  Retrove.DemoMethods.getAddressVerify(document.getElementById("lvwLogin_lgnName").innerHTML.replace("Welcome ",""),
                                   document.getElementById("txtTags").value,
                                   document.getElementById("txtNotes").value, 
                                   document.getElementById("txtStreetAddress").value,
                                   document.getElementById("txtCity1").value,
                                   document.getElementById("lstStateCode").value,
                                   document.getElementById("lslBeds").value,
                                   document.getElementById("lslProperty_Type").value,
                                   document.getElementById("lslLand").value,
                                   document.getElementById("lslBath").value,
                                   document.getElementById("txtZipCode").value,
                                   document.getElementById("txtPrice").value,
      							   LinkAddress, 
                                   URLAddress,"",processAddress);
     } catch(exception) {
         alert('Only registered users can use this feature');
     }

}

function processAddress(response) {
    if(response != null && response.value != null && response.value.Tables != 0 && response.value.Tables.length == 1) 
      					alert(response.value.Tables[0].Rows[0].Success);
     if(response.value.Tables[0].Rows[0].Success.indexOf("valid") != -1){
      }else{   					
     document.getElementById("displayTaggedInfo").innerHTML = "";
     getTaggedInfo();
     }
}



function loadUser(){
 Retrove.DemoMethods.loadUser(callback_loadUser);
}

function callback_loadUser(res){
//alert("User Name " + res.value);
    UserName = res.value;
    getTaggedGoogleinfo();
}

function getTaggedGoogleinfo(){
    try{
        Retrove.DemoMethods.getTaggedInfo(UserName,callback_getTaggedGoogleinfo);
    } catch(exception) {
         //alert('Only registered users can use this feature');
    }
}
function callback_getTaggedGoogleinfo(res){
globalres = res;
    for(var i=0; i<res.value.Tables[0].Rows.length; i++){
            locationsArray[locationsArray.length] = "{StreetAddress : " +  res.value.Tables[0].Rows[i].StreetAddress + ", City : " + res.value.Tables[0].Rows[i].City + ", State : " +  res.value.Tables[0].Rows[i].State + ", ZipCode : " +  res.value.Tables[0].Rows[i].ZipCode + " , Bed : " + res.value.Tables[0].Rows[i].Bed +  ", PropertyType : " + res.value.Tables[0].Rows[i].PropertyType + ", Latitude : " + res.value.Tables[0].Rows[i].Latitude + " , Longitude : " + res.value.Tables[0].Rows[i].Longitude + "}";
    }
    load();
}


function getTaggedInfo(){
    try{
        Retrove.DemoMethods.getTaggedInfo(document.getElementById("lvwLogin_lgnName").innerHTML.replace("Welcome ",""),callback_getTaggedInfo);
    } catch(exception) {
         //alert('Only registered users can use this feature');
    }

}
function callback_getTaggedInfo(res){
    if(res != null && res.value != null && res.value.Tables != 0 && res.value.Tables.length == 1) {
        var html = []
        var strMonthly = "";
        RecTaggedInfo = res;
        html[html.length] = "<div id=divTaggedInfo class=PersonalWorkSpaceOnExpand>";
        html[html.length] = "<table>";
        html[html.length] = "<tr><td>Address</td><td>location</td><td>Bed</td><td>Bath</td><td>Property Type</td><td>Price</td><td>Monthly Payment</td><tr>";
    for(var i=0; i<res.value.Tables[0].Rows.length; i++){
            html[html.length] ="<tr>";
		    html[html.length] = '<td><strong><a href="javascript:void(0);" onclick="EditTaggedInfo('+i+ ');return false;">' + res.value.Tables[0].Rows[i].StreetAddress + '</a></strong></td>';
            html[html.length] ="<td>" +res.value.Tables[0].Rows[i].City +  " , " + res.value.Tables[0].Rows[i].State + "</td>";
            html[html.length] ="<td>" + res.value.Tables[0].Rows[i].Bed + "</td>";
            html[html.length] ="<td>" + res.value.Tables[0].Rows[i].Bath + "</td>";
            html[html.length] ="<td>" + res.value.Tables[0].Rows[i].PropertyType + "</td>";
            html[html.length] ="<td>" + res.value.Tables[0].Rows[i].Price + "</td>";
            if(res.value.Tables[0].Rows[i].Price != ""){
            html[html.length] =  "<td><span id=MonthlyPayment" + i+"></span></td>"; 

             rtnMonthlyPayment(res.value.Tables[0].Rows[i].Price, i); 
            }else{
            html[html.length] =  "<td></td>"; 
            }
            html[html.length] ="</tr>";
    }
           html[html.length] = "</table>";
            html[html.length] = "</div>";
        document.getElementById("tagggedInfo").innerHTML = html.join("");
        GUnload();
        loadUser();
        //Googlelink("http://" + window.location.host + "/pageflakes.aspx","googlemaps");
        document.getElementById("headerinfo").innerHTML = htmlHeader.join("");

        
        //document.getElementById("jsonResponse").innerHTML = html[html.length] = " Json Request <div style=\"border : solid 1px #ff0000; padding : 4px; width : 400px; height : 200px; overflow : auto; \">locationsArray :[" + locationsArray.join(",") + "]</div>";
    }
   
             
}

function rtnMonthlyPayment(price, value){
        Retrove.DemoMethods.BasicMortgageCalculator(document.getElementById("ddlDownPayment").value, document.getElementById("ddInterestRate").value, document.getElementById("ddLoan1Term").value, price.replace("$", ""),value, defaultchoice,callback_monthlyPayment);
        idValue = value;

}

function callback_monthlyPayment(res){
   var value = res.value.split('|');
    var id = "MonthlyPayment" + value[0];
    document.getElementById(id).innerHTML = value[1];
}

function CalculatePayment(){
    if (document.getElementById("chkInterestOnly").checked)
       defaultchoice = 2;
    else 
       defaultchoice = 1;
   
getTaggedInfo();
}
   
 function toggleWorkSpace(value, linksvalue){
 
 
 	var d = document.getElementById(value);
	if(d != null)
		d.className = (d.className == "PersonalWorkSpaceOff") ? "PersonalWorkSpaceOnExpand" : "PersonalWorkSpaceOff"; 
 }

function getSavedLinks(){
    try{
        Retrove.DemoMethods.getSavedLinks(document.getElementById("lvwLogin_lgnName").innerHTML.replace("Welcome ",""),callback_getSavedLinks);
    } catch(exception) {
         //alert('Only registered users can use this feature');
    }

}
function callback_getSavedLinks(res){
   if(res != null && res.value != null && res.value.Tables != 0 && res.value.Tables.length == 1) {
        var html = [];        
        html[html.length] = "<div id=divSavedPersonalLink class=PersonalWorkSpaceOff>";
        for(var i=0; i<res.value.Tables[0].Rows.length; i++){
                html[html.length] = "<hr style=\"font-size: 10pt; font-family: Arial\"/>";
		        html[html.length] = '<strong><a href="javascript:void(0);" onclick="AppendLink(\''+res.value.Tables[0].Rows[i].SavedSearch+'\',\''+res.value.Tables[0].Rows[i].RealtorName+ '\');return false;">' +res.value.Tables[0].Rows[i].SavedLinks + '</a></span></span></strong><br />';
		        html[html.length] = res.value.Tables[0].Rows[i].Description + "<br />";
                html[html.length] = '<strong><a href="javascript:void(0);" onclick="deleteSavedLinks(\''+res.value.Tables[0].Rows[i].PersonalID+'\',\''+"savedLinks"+ '\');return false;">[Delete Saved Link]</a></span></span></strong><br />';
                }
                html[html.length] = "</div>";
             document.getElementById("savedPersonalLinks").innerHTML = html.join("");
        }

}

function getSearchHistory(){
    try{
        Retrove.DemoMethods.getSearchHistory(document.getElementById("lvwLogin_lgnName").innerHTML.replace("Welcome ",""),callback_getSearchHistory);
    } catch(exception) {
         //alert('Only registered users can use this feature');
    }

}
function callback_getSearchHistory(res){
   if(res != null && res.value != null && res.value.Tables != 0 && res.value.Tables.length == 1) {
        var html = [];
        html[html.length] = "Search History";
        html[html.length] = "<div id=divSearchHistory class=PersonalWorkSpaceOn>";
    for(var i=0; i<res.value.Tables[0].Rows.length; i++){
            html[html.length] = "<hr style=\"font-size: 10pt; font-family: Arial\"/>";
		    html[html.length] = '<strong><a href="javascript:void(0);" onclick="AppendLink(\''+res.value.Tables[0].Rows[i].SavedLink+'\');return false;">' +res.value.Tables[0].Rows[i].LinkName + '</a></span></span></strong>&nbsp;';
            html[html.length] = '<strong><a href="javascript:void(0);" onclick="deleteSavedLinks(\''+res.value.Tables[0].Rows[i].LinkID+'\',\''+"searchHistory"+ '\');return false;">[Delete Link]</a></span></span></strong><br />';
            }
            html[html.length] = "</div>";
         document.getElementById("SaveHistoryInfo").innerHTML = html.join("");
    }

}

function deleteSavedLinks(delValue, recordName){
    try{
       if (recordName =="savedLinks"){
          if(confirm("Sure you want to delete this record")){
            Retrove.DemoMethods.deleteSavedLink(document.getElementById("lvwLogin_lgnName").innerHTML.replace("Welcome ",""),delValue,callback_deleteSavedLink);
          }
        }
       if(recordName == "savedTags"){
          if(confirm("Sure you want to delete this record")){      
            Retrove.DemoMethods.deleteTaggedLinks(document.getElementById("lvwLogin_lgnName").innerHTML.replace("Welcome ",""),delValue,callback_delete_taginfo);       
           }
        }
       if(recordName == "searchHistory"){
          if(confirm("Sure you want to delete this record")){      
            Retrove.DemoMethods.deleteSearchHistory(document.getElementById("lvwLogin_lgnName").innerHTML.replace("Welcome ",""),delValue,callback_deleteSearchHistory);       
           }
        }
    } catch(exception) {
         alert('An error occured while trying delete a record. Please try back later!!');
    }

}

function callback_deleteSearchHistory(res){
getSearchHistory();
}
function callback_deleteSavedLink(res){
getSavedLinks();

}

function callback_delete_taginfo(res){
getTaggedInfo();
}

 //@para [visi] -- Takes a "hidden" or "visible"
	function setVisibleDiv(visi){
		var x = document.getElementById("shadowDiv");
		x.className = "dialog";
		var t = document.getElementById(divValue);
		x.style.position = 'absolute';
		// Sets the Y of the control
		x.style.top =  (findPosY(t)-defaultYPosition)+"px";
		// Sets the Z of the control
		x.style.left = (findPosX(t)+defaultXPosition)+"px";
		x.style.visibility = visi;
	}

function Pop(URL) {
	var heightWidthUrl = URL.split('|');
    day = new Date;
    id = day.getTime();
    results = eval("page" + id + " = window.open(heightWidthUrl[0], \" + id + \", 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + heightWidthUrl[1] + ",height=" + heightWidthUrl[2] + "');");

   
}


function ValidateState (arr,keyword) { 
  var r = new Array (); 
  var strStateCode = '';
  var l = 0; 
  for (var i = 0; i < arr.length; i++) { 
   if (arr[i].indexOf(keyword) != -1){   	   
	   	strStateCode = arr[i].split('|');
	 } 
   	//break;   
  } 
  return strStateCode[1]; 
 
} 

function toggle(id) 
{
	var d = document.getElementById(id);
	if(d != null)
		d.className = (d.className == "h") ? "s" : "h"; 
} 

function showdiv(){
    toggle(document.getElementById("advancedSearch").id);
}

var IFrameObj; // our IFrame object
function callToServer() {
MyStrURL= document.getElementById("lstDiscoveryInfo").value.split('|');
  if (!document.createElement) {return true};
  var IFrameDoc;
  document.getElementById("RealEstateTitle").innerHTML = MyStrURL[1];
  var URL = MyStrURL[0];
  IFrameObj ="";
  document.getElementById("testbody").innerHTML = "";
  if (!IFrameObj && document.createElement) {
    // create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time 
    // callToServer() is called
   try {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','RSIFrame');
      tempIFrame.style.border='10';
      tempIFrame.style.width='100%';
      tempIFrame.style.height='800px';
      IFrameObj = document.getElementById("testbody").appendChild(tempIFrame);
      
      if (document.frames) {
        // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj = document.frames['RSIFrame'];
      }
    } catch(exception) {
      // This is for IE5 PC, which does not allow dynamic creation
      // and manipulation of an iframe object. Instead, we'll fake
      // it up by creating our own objects.
      iframeHTML = "";
      iframeHTML='\<iframe id="RSIFrame" style="';
      iframeHTML+='border:10 padding:30;';
      iframeHTML+='width:100%;';
      iframeHTML+='height:800px;';
      iframeHTML+='"><\/iframe>';
      //document.body.innerHTML+=iframeHTML;
      document.getElementById("testbody")+=iframeHTML;
      IFrameObj = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
      IFrameObj.document.location.replace = function(location) {
        this.iframe.src = location;
      }
    }
  }
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('callToServer()',10);
    return false;
  }
  
  if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 

  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }
  AddurlToCachingLink(URL);
  IFrameDoc.location.replace(URL);
  expandtab("maintab", 1);
  retrieveCacheInfo(URL,LinkName)
  return false;
}


function AppendLink(LinkValue, LinkName) {
MyStrURL= LinkValue;
  if (!document.createElement) {return true};
  var IFrameDoc;
  var URL = MyStrURL;
  IFrameObj ="";
  document.getElementById("testbody").innerHTML = "";
  if (!IFrameObj && document.createElement) {
    // create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time 
    // callToServer() is called
   try {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','RSIFrame');
      tempIFrame.style.border='0px';
      tempIFrame.style.width='100%';
      tempIFrame.style.height='800px';
      IFrameObj = document.getElementById("testbody").appendChild(tempIFrame);
      
      if (document.frames) {
        // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj = document.frames['RSIFrame'];
      }
    } catch(exception) {
      // This is for IE5 PC, which does not allow dynamic creation
      // and manipulation of an iframe object. Instead, we'll fake
      // it up by creating our own objects.
      iframeHTML = "";
      iframeHTML='\<iframe id="RSIFrame" style="';
      iframeHTML+='border:0px;';
      iframeHTML+='width:100%;';
      iframeHTML+='height:800px;';
      iframeHTML+='"><\/iframe>';
      //document.body.innerHTML+=iframeHTML;
      document.getElementById("testbody")+=iframeHTML;
      IFrameObj = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
      IFrameObj.document.location.replace = function(location) {
        this.iframe.src = location;
      }
    }
  }
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('callToServer()',10);
    return false;
  }
  
  if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }
  
  if(validateLogin(URL)){
    IFrameDoc.location.replace(URL);
    AddurlToCachingLink(URL);
    URLAddress = URL;
    LinkAddress = LinkName;  
    expandtab("maintab", 1);
     document.getElementById("RealEstateTitle").innerHTML = LinkName;
    return false;
  }else{
    window.open(URL);
    }
}



function Googlelink(LinkValue, LinkName) {
MyStrURL= LinkValue;
  if (!document.createElement) {return true};
  var IFrameDoc;
  //document.getElementById("RealEstateTitle").innerHTML = LinkName;
  var URL = MyStrURL;
  IFrameObj ="";
  document.getElementById("googlebody").innerHTML = "";
  if (!IFrameObj && document.createElement) {
    // create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time 
    // callToServer() is called
   try {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','RSIFrame1');
      tempIFrame.style.width='800px';
      tempIFrame.style.height='540px';
      tempIFrame.style.border ='0';
      tempIFrame.style.frameborder ='0';
      IFrameObj = document.getElementById("googlebody").appendChild(tempIFrame);
      
      if (document.frames) {
        // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj = document.frames['RSIFrame1'];
      }
    } catch(exception) {
      // This is for IE5 PC, which does not allow dynamic creation
      // and manipulation of an iframe object. Instead, we'll fake
      // it up by creating our own objects.
      iframeHTML = "";
      iframeHTML='\<iframe id="RSIFrame1" style="';
      iframeHTML+='width:800px;';
      iframeHTML+='height:540px;';
      iframeHTML+='border:0;';
      iframeHTML+='frameborder:0;';
      iframeHTML+='"><\/iframe>';
      //document.body.innerHTML+=iframeHTML;
      document.getElementById("googlebody")+=iframeHTML;
      IFrameObj = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById('RSIFrame1');
      IFrameObj.document.location.replace = function(location) {
       this.iframe.src = location;
 
      }
    }
  }
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('callToServer()',10);
    return false;
  }
  
  if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }
if(validateLogin(URL)){
    IFrameDoc.location.replace(URL);
    AddurlToCachingLink(URL);
    URLAddress = URL;
    LinkAddress = LinkName;  
    expandtab("maintab", 1);
    return false;
  }else{
    window.open(URL);
    }
    
}


function validateLogin(URLAddress){
try{
     if (typeof(document.getElementById("lvwLogin_lgnName").value) =="undefined")
        return true; 
    } catch(exception) {
         return false;
    }
 
 }
function AddurlToCachingLink(UrlLink)
{
Retrove.DemoMethods.AddurlToCachingLink1(UrlLink,callback_AddurlToCachingLink);
}

function callback_AddurlToCachingLink(res){
              GuidID = res.value.Tables[1].Rows[0].linksID; 
              retrieveCacheInfo(URLAddress,LinkAddress);
}

function retrieveCacheInfo(URL,LinkName){
    Retrove.DemoMethods.WriteCacheLinksToDataBase(URL,LinkName,GuidID,callback_WriteCacheLinksToDataBase);
}

function callback_WriteCacheLinksToDataBase(res){
    Retrove.DemoMethods.getCacheTable(URLAddress,callback_getCacheTable);
}




function callback_getCacheTable(res){
    document.getElementById("CacheNumber").innerHTML = "";
    document.getElementById("CachedLinks").innerHTML = "";
	    var html = [];
    if(res != null && res.value != null && res.value.Tables != 0 && res.value.Tables.length == 1) {
	        for(var i=0; i<res.value.Tables[0].Rows.length; i++)
	        {
              html[html.length] = res.value.Tables[0].Rows[i].Details.replace('/FindHome/HomeListing.asp', 'http://www.realtor.com/FindHome/HomeListing.asp'); 
            }
             document.getElementById("CachedLinks").innerHTML = html.join("");
             document.getElementById("CacheNumber").innerHTML = "(" + res.value.Tables[0].Rows.length + ")";
     }
}
function TestIframe(){
   //alert(RSIFrame.contentDocument.body.innerHTML);

}
//Makes 2 calls for city and zip code
// arrayResult -- Holds the City Information 
// arrayZipCode --  holds the Zip Code Array
function GetCityInfor(value){
    key = 27;
	autoComplete = "txtCity";
	var strValue = "";
	var strText = "";

   if(value != 0){
    	document.getElementById("txtCity").value = "";
    }
    document.getElementById("testbody").innerHTML = "";
    
    document.getElementById("RealEstateTitle").innerHTML = ""
    try
    {
    strValue = document.getElementById("lstStateInfo").value;
    strText =  document.getElementById("lstStateInfo").options[document.getElementById("lstStateInfo").selectedIndex].text

    }catch(e){
    }
    
   	Retrove.DemoMethods.GetCityZip(strValue,callback_MLS_City);
   	//Retrove.DemoMethods.GetAllZip(strText,callback_MLS_Zip)
   	
 
}
//Return the City from back end transaction 
function callback_MLS_City(res){
	
    arrayResult = new Array();
    if(res != null && res.value != null && res.value.Tables != 0 && res.value.Tables.length == 1) {
        for(var i=0; i<res.value.Tables[0].Rows.length; i++)
        {
         arrayResult[arrayResult.length] = res.value.Tables[0].Rows[i].city; 
        }       
    }
        init();
    FinishedCityZipCode = 1;

              

}
function callback_MLS_Zip(res){
    if(res != null && res.value != null && res.value.Tables != 0 && res.value.Tables.length == 1) {
        for(var i=0; i<res.value.Tables[0].Rows.length; i++){
         arrayZipCode[arrayZipCode.length] = res.value.Tables[0].Rows[i].ZIPCode; 
        }        
    }
    init();
    FinishedCityZipCode = 1;
	
}

function validate(inputField){
    var validStatus = 0;
    var boolStatus = false;
    for (var i = 0; i<arrayResult.length; i++){
		    if (arrayResult[i].toUpperCase() == document.getElementById("txtCity").value.toUpperCase()){
		    document.getElementById("txtCity").value = arrayResult[i];
		     validStatus = 1;
		     boolStatus =  true;
    	    }
    }
    for (var i = 0; i<arrayZipCode.length; i++){
		    if (arrayZipCode[i].toUpperCase() == document.getElementById("txtCity").value.toUpperCase()){
		     validStatus = 1;
		     boolStatus = true;
    	    }
    }
    
     if (validStatus == 0)
 	    return false;
 	 else
 	    return true;
    
}



function onKeyPressBlockNumbers(e)
{
	var key = window.event ? e.keyCode : e.which;
	var keychar = String.fromCharCode(key);
	reg = /\d/;
	if (key == "13" || key == "32")
        	getURLLink();
	  
	
}

function onKeyPressBlockNumbers1(e)
{
	var key = window.event ? e.keyCode : e.which;
	var keychar = String.fromCharCode(key);
	reg = /\d/;
	
	if (key == "13" || key == "32")
        	getURLLink();
	  
	
}

function ReportLinkStatus(CacheID1,URLAddress1,StateCode1){
CacheID = CacheID1
StateCode = StateCode1;
URLAddress = URLAddress1;
var id = "CacheID" + CacheID;
 popUpDiv(URLAddress+'|'+100+'|'+100+'|'+ id +'|'+"LinkAddress"+'|'+"ReportLink"+'|'+"ReportStatus")

}
function SubmitSite(){
window.open("http://" + window.location.host + "/submiturl.aspx");
//fPosY = 0;
//fPosX = 100;
//popUpDiv(""+'|'+100+'|'+100+'|'+ "divWorkSpace" +'|'+"LinkAddress"+'|'+"reSubmitLink"+'|'+"Submit a Url Link")


}

function buildReportLink(){

var status = ["Broken Link", "No Results", "404 Error", "Wrong Location"];
var html = [];
html[html.length] = "<table style='padding: 5px;'>";
html[html.length] = "<tr><td>Link Status :</td>";
html[html.length] = '<td><select id=\"ddlLinkStatus\">';
for(var i=0; i<status.length; i++){
    html[html.length] = '<option value=\''+status[i]+  '\'>' + status[i] + '</option>';
}
    html[html.length] = '</select></td></tr>';
    html[html.length] = "<tr><td>Notes :</td><td><textarea id=\"txtStatusNotes\" rows=\"4\" style=\"width: 350px\"></textarea></td></tr>";
    html[html.length] = "<tr><td>Email :</td><td><input id=\"tbStatusEmail\" type=\"text\" /></td></tr>";
    html[html.length] ="<tr><td colspan=2 align=center><input id=\"btnReportLinkStatus\" type=\"button\" value=\"Submit\" onclick=\"submitReportLink()\" />" ;   
 return html.join("");
}



function  formClaimAgentProfile(){

var html = [];
html[html.length] = "<table style='padding: 5px;'>";
    html[html.length] = "<tr><td>Agent Name :</td><td><input id=\"txtAgentName\" type=\"text\" /></td></tr>";
    html[html.length] = "<tr><td>Company Phone :</td><td><input id=\"txtCompanyPhone\" type=\"text\" /></td></tr>";
    html[html.length] = "<tr><td>Company Information :</td><td><input id=\"txtCompanyInfo\" type=\"text\" /></td></tr>";
    html[html.length] ="<tr><td colspan=2 align=center><input id=\"btnClaimProfile\" type=\"button\" value=\"Submit\" onclick=\"submitReportLink()\" />" ;   
 return html.join("");
}


function submitReportLink(){
Retrove.DemoMethods.ReportLinkStatus(CacheID, StateCode,URLAddress, document.getElementById("ddlLinkStatus").value,document.getElementById("txtStatusNotes").value,document.getElementById("tbStatusEmail").value,callback_submitReportLink);

}

function callback_submitReportLink(res){
    alert(res.value);
}



// @para [visi] -- Takes a "hidden" or "visible"
	function setVisible(visi){
		var x = document.getElementById("shadow");
		var t = document.getElementsByName(autoComplete)[0];
		x.style.position = 'absolute';
		// Sets the Y of the control
		x.style.top =  (findPosY(t)+fPosY)+"px";
		// Sets the Z of the control
		x.style.left = (findPosX(t)+fPosX)+"px";
		x.style.visibility = visi;
	}
 // Init is fired up when the page loads
	function init(){	
	    key = 27;
		outp = document.getElementById("output");
		setVisible("hidden");
		document.onkeydown = keygetter; //needed for Opera...
		document.onkeyup = keyHandler;


	}



	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){
			curtop += obj.offsetHeight;
			while (obj.offsetParent){
				curtop += obj.offsetTop;
				obj = obj.offsetParent;
			}
		}
		else if (obj.y){
			curtop += obj.y;
			curtop += obj.height;
		}
		return curtop;
	}
	
	function lookAt(){
		var ins = document.getElementsByName(autoComplete)[0].value;
		if (oldins == ins) return;
		else if (posi > -1);
		else if (ins.length > 0){
			words = getWord(ins);
			if (words.length > 0){
				clearOutput();
				for (var i=0;i < words.length; ++i) addWord (words[i]);
				setVisible("visible");
				input = document.getElementsByName(autoComplete)[0].value;
			}
			else{
				setVisible("hidden");
				posi = -1;
			}
		}
		else{
			setVisible("hidden");
			posi = -1;
		}
		oldins = ins;
	}
	
	function addWord(word){
		var sp = document.createElement("div");
		sp.appendChild(document.createTextNode(word));
		sp.onmouseover = mouseHandler;
		sp.onmouseout = mouseHandlerOut;
		sp.onclick = mouseClick;
		sp.onkeyenter = mouseClick;	
		sp.onkeypress = mouseClick;	
		outp.appendChild(sp);
	}
	
	function clearOutput(){
		while (outp.hasChildNodes()){
			noten=outp.firstChild;
			outp.removeChild(noten);
		}
		posi = -1;
	}
	
	function getWord(beginning){
		var words = new Array();
		//arrayResult -- looks for the matching city word
		for (var i=0;i < arrayResult.length; ++i){
			var j = -1;
			var correct = 1;
			while (correct == 1 && ++j < beginning.length){
				if (arrayResult[i].charAt(j).toUpperCase() != beginning.charAt(j).toUpperCase()) correct = 0;
			}
			if (correct == 1) words[words.length] = arrayResult[i];
		}
		// arrayZipCode -- looks for the matching zip code
		for (var i=0;i < arrayZipCode.length; ++i){
			var j = -1;
			var correct = 1;
			while (correct == 1 && ++j < beginning.length){
				if (arrayZipCode[i].charAt(j).toUpperCase() != beginning.charAt(j).toUpperCase()) correct = 0;
			}
			if (correct == 1) words[words.length] = arrayZipCode[i];
		}

		return words;
	}
	
	function setColor (_posi, _color, _forg){
		outp.childNodes[_posi].style.background = _color;
		outp.childNodes[_posi].style.color = _forg;
	}
	
	function keygetter(e){
	  if(key == 27)
	     window.setInterval("lookAt()", 100);

	  if (navigator.userAgent.indexOf("MSIE") != -1)
	  {
	    key = event.keyCode;
	  }else{
	   key = e.keyCode;
	   }
	}
		
	function keyHandler(event){
		if (document.getElementById("shadow").style.visibility == "visible"){
		var textfield = document.getElementsByName(autoComplete)[0];
		if (key == 40){ //Key down
			//alert (words);
			if (words.length > 0 && posi < words.length-1){
				if (posi >=0) setColor(posi, "#CCFF99", "black");
				else input = textfield.value;
				setColor(++posi, "blue", "#CCFF99");
				textfield.value = outp.childNodes[posi].firstChild.nodeValue;
			}
		}
		else if (key == 38){ //Key up
			if (words.length > 0 && posi >= 0){
				if (posi >=1){
					setColor(posi, "#CCFF99", "black");
					setColor(--posi, "blue", "#CCFF99");
					textfield.value = outp.childNodes[posi].firstChild.nodeValue;
				}
				else{
					setColor(posi, "blue", "black");
					textfield.value = input;
					textfield.focus();
					posi--;
				}
			}
		}
		else if (key == 27){ // Esc
			textfield.value = input;
			setVisible("hidden");
			posi = -1;
			oldins = input;
		}
		else if (key == 8){ // Backspace
			posi = -1;
			oldins=-1;
		}
		else if(key == 13){
		 document.getElementById("txtCity").focus();
		  getURLLink();
       }
	  }
	}
	
	var mouseHandler=function(){
		for (var i=0; i < words.length; ++i)
			setColor (i, "#CCFF99", "black");
	
		this.style.background = "blue";
		this.style.color= "#CCFF99";
	}
	
	var mouseHandlerOut=function(){
		this.style.background = "#CCFF99";
		this.style.color= "black";
	}
	
	var mouseClick=function(){
		document.getElementsByName(autoComplete)[0].value = this.firstChild.nodeValue;
		setVisible("hidden");
		posi = -1;
		oldins = this.firstChild.nodeValue;
	    //alert(event.Keycode);
		getURLLink();
		
	}
	
	function expandcontent(linkobj){
	var ulid=linkobj.parentNode.parentNode.id //id of UL element
	var divid;
	var ullist=document.getElementById(ulid).getElementsByTagName("li") //get list of LIs corresponding to the tab contents
		for (var i=0; i<ullist.length; i++){
			divid = document.getElementById("maintab").getElementsByTagName("a")[i].getAttribute("rel");
			document.getElementById(divid).style.display="none"
			ullist[i].className=""  //deselect all tabs
				if (typeof tabcontentIDs[ulid][i]!="undefined"){ //if tab content within this array index exists (exception: More tabs than there are tab contents)
					document.getElementById(tabcontentIDs[ulid][i]).style.display="none";
					
				} //hide all tab contents
		}
		//toggle(linkobj.getAttribute("rel"));
	linkobj.parentNode.className="selected";  //highlight currently clicked on tab
	document.getElementById(linkobj.getAttribute("rel")).style.display="block" //expand corresponding tab content
	saveselectedtabcontentid(ulid, linkobj.getAttribute("rel"));
}

function expandtab(tabcontentid, tabnumber){ //interface for selecting a tab (plus expand corresponding content)
	var thetab=document.getElementById(tabcontentid).getElementsByTagName("a")[tabnumber]
		if (thetab.getAttribute("rel")){
				expandcontent(thetab)
		 }
}

function savetabcontentids(ulid, relattribute){// save ids of tab content Divs
	if (typeof tabcontentIDs[ulid]=="undefined"){ //if this array doesn't exist yet
		tabcontentIDs[ulid]=new Array()
		tabcontentIDs[ulid][tabcontentIDs[ulid].length]=relattribute
	}
}

function saveselectedtabcontentid(ulid, selectedtabid){ //set id of clicked on tab as selected tab id & enter into cookie
		if (enabletabpersistence==1){ //if persistence feature turned on
				setCookie(ulid, selectedtabid)
		}
}

function getullistlinkbyId(ulid, tabcontentid){ //returns a tab link based on the ID of the associated tab content
		var ullist=document.getElementById(ulid).getElementsByTagName("li")
			for (var i=0; i<ullist.length; i++){
				if (ullist[i].getElementsByTagName("a")[0].getAttribute("rel")==tabcontentid){
					
					return ullist[i].getElementsByTagName("a")[0]
					break
				}
		}
}

function setCookie(name, value){
document.cookie = name+"="+value; 
}


function initializetabcontent(){
for (var i=0; i<arguments.length; i++){ //loop through passed UL ids
if (enabletabpersistence==0 && getCookie(arguments[i])!="") //clean up cookie if persist=off
setCookie(arguments[i], "")
var clickedontab=getCookie(arguments[i]) //retrieve ID of last clicked on tab from cookie, if any
var ulobj=document.getElementById(arguments[i])
 
var ulist=ulobj.getElementsByTagName("li") //array containing the LI elements within UL
for (var x=0; x<ulist.length; x++){ //loop through each LI element
var ulistlink=ulist[x].getElementsByTagName("a")[0]
if (ulistlink.getAttribute("rel")){
savetabcontentids(arguments[i], ulistlink.getAttribute("rel")) //save id of each tab content as loop runs
ulistlink.onclick=function(){
expandcontent(this)
return false
}
if (ulist[x].className=="selected" && clickedontab=="") //if a tab is set to be selected by default
expandcontent(ulistlink) //auto load currenly selected tab content
}
} //end inner for loop
if (clickedontab!=""){ //if a tab has been previously clicked on per the cookie value
	var culistlink=getullistlinkbyId(arguments[i], clickedontab)
		if (typeof culistlink!="undefined") //if match found between tabcontent id and rel attribute value
				expandcontent(culistlink) //auto load currenly selected tab content
    		else //else if no match found between tabcontent id and rel attribute value (cookie mis-association)
				expandcontent(ulist[0].getElementsByTagName("a")[0]) //just auto load first tab instead
		}
} //end outer for loop
}


function getCookie(Name){ 
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return ""
}
 // Section below is for drag drop functionality.
 
 function getReal(el) {
	temp = el;

	while ((temp != null) && (temp.tagName != "BODY")) {
		if ((temp.className == "moveme") || (temp.className == "handle")){
			el = temp;
			return el;
		}
		temp = temp.parentElement;
	}
	return el;
}


function moveme_onmousedown(e) {
var target;
if (!e) var e = window.event;
	  if (navigator.userAgent.indexOf("MSIE") != -1)
	  {
	    target = e.srcElement;
	  }else{
	   target = e.target;
	   }
	el = getReal(target)
	
	if (el.className == "moveme" || el.className == "handle") {
		if (el.className == "handle") {
			tmp = el.getAttribute("handlefor");
			if (tmp == null) {
				dragObject = null;
				return;
			}
			else
				dragObject = eval(tmp);
		}
		else 
			dragObject = el;
		
		if (checkZIndex) makeOnTop(dragObject);
		
		ty = e.clientY - getTopPos(dragObject);
		tx = e.clientX - getLeftPos(dragObject);
		
		e.returnValue = false;
		e.cancelBubble = true;
	}
	else {
		dragObject = null;
	}
}

function moveme_onmouseup() {
	if(dragObject) {
		dragObject = null;
	}
}

function moveme_onmousemove(e) {
if (!e) var e = window.event;

	if (dragObject) {
		if (e.clientX >= 0 && e.clientY >= 0) {
			dragObject.style.left = e.clientX - tx;
			dragObject.style.top = e.clientY - ty;
		}
		e.returnValue = false;
		e.cancelBubble = true;
	}
}

function getLeftPos(el) {
	if (ie5) {
		if (el.currentStyle.left == "auto")
			return 0;
		else
			return parseInt(el.currentStyle.left);
	}
	else {
		return el.style.pixelLeft;
	}
}

function getTopPos(el) {
	if (ie5) {
		if (el.currentStyle.top == "auto")
			return 0;
		else
			return parseInt(el.currentStyle.top);
	}
	else {
		return el.style.pixelTop;
	}
}

function makeOnTop(el) {
	var daiz;
	var max = 0;
	var da = document.getElementById(dragdropvalue);
	for (var i=0; i<da.length; i++) {
		daiz = da[i].style.zIndex;
		if (daiz != "" && daiz > max)
			max = daiz;
	}
	
	el.style.zIndex = max + 1;
}

function runEvents(idvalue){
		document.getElementById(idvalue).onmousedown = moveme_onmousedown;
		document.getElementById(idvalue).onmouseup = moveme_onmouseup;
		document.getElementById(idvalue).onmousemove = moveme_onmousemove;
}

function socialNetwork(){
    Retrove.DemoMethods.socialNetworking(document.title,location.href,callback_socialNetwork);
}

function callback_socialNetwork(res){
 document.getElementById("social").innerHTML = res.value;
}

function AddDateTime(){
    Retrove.DemoMethods.AddDateTime(document.getElementById("txtGuid").value,
    document.getElementById("ddMonth").options[document.getElementById("ddMonth").selectedIndex].text,
    document.getElementById("ddStartDate").options[document.getElementById("ddStartDate").selectedIndex].text,
    document.getElementById("ddStartTime").options[document.getElementById("ddStartTime").selectedIndex].text,
    document.getElementById("ddEndTime").options[document.getElementById("ddEndTime").selectedIndex].text,
    callback_AddDateTime);          
}

function RemoveFromDateRange(Month, Day, guid){
    Retrove.DemoMethods.RemoveFromDateRange(Month,Day,guid,callback_AddDateTime);          
}
function callback_AddDateTime(res){

    var html = [];
        if(res != null && res.value != null && res.value.Tables != 0 && res.value.Tables.length == 1) {
            html[html.length] = "<table>";
            html[html.length] = "<tr><td>Delete</td><td>Month</td><td>Date</td><td>State Time</td><td>End Time</td></tr>";

            for(var i=0; i<res.value.Tables[0].Rows.length; i++)
            {
                html[html.length] = "<tr>";
                html[html.length] ='<td><a href="javascript:void(0);" onclick="RemoveFromDateRange(\''+res.value.Tables[0].Rows[i].Month +'\',\''+res.value.Tables[0].Rows[i].Date+'\',\''+ res.value.Tables[0].Rows[i].guid + '\' );return false;"> Delete</a></td>';
                html[html.length] = "<td>" + res.value.Tables[0].Rows[i].Month + "</td>";
                html[html.length] = "<td>" + res.value.Tables[0].Rows[i].Date + "</td>";
                html[html.length] = "<td>" + res.value.Tables[0].Rows[i].StartTime + "</td>";
                html[html.length] = "<td>" + res.value.Tables[0].Rows[i].EndTime + "</td>"; 
                html[html.length] = "</tr>";
            }
                html[html.length] = "</table>";
        }

        document.getElementById("AddDateTime").innerHTML = html.join("");
;
}


function openHouse (value){
   var divArray = ["divPage1","divPage2","divPage3"];
     for(var i=0; i<divArray.length; i++){
        document.getElementById(divArray[i]).className = "PersonalWorkSpaceOff";
     }
	
	 	var d = document.getElementById(value);
	if(d != null)
		d.className = (d.className == "PersonalWorkSpaceOff") ? "PersonalWorkSpaceOnExpand" : "PersonalWorkSpaceOff"; 
}

function showMore() {
    toggle('more-tab');
    toggle('more-items');
}


function pview(id) {
    var po = getElt('po-' + id);
    var pc = getElt('pc-' + id);
    var div = getElt('pd-' + id);
    if (div.childNodes.length > 0) {
        var iframe = document.createElement("iframe");
        iframe.setAttribute("id", "pf-" + id);
        iframe.setAttribute("src", po.href);
        iframe.setAttribute("height", 300);
        iframe.setAttribute("width", 800);
        div.innerHTML = "";
        div.appendChild(iframe);
    }
    toggle(div);
    toggle(pc);
    toggle(po);
    return false;
}



function toggle(tog) {
//tog.style.display = (tog.style.display=='none' || tog.style.display=='') ? 'block' : 'none';
    if (!tog.id) {
        tog = getElt(tog);
    }
    tog.style.display = (tog.style.display=='none') ? '' : 'none';
}

function getElt(id) { return document.getElementById(id) }

function claimOffficeRequestForm(id,htmlData,_stateCode)
{

    var xml = "";
                xml='<Param Name=\'' + id + '\'><![CDATA[' + htmlData + ']]></Param>';
                xml= xml +  '<Param Name=\'' + _stateCode + '\'><![CDATA[' + _stateCode + ']]></Param>';

    
    return  "<AddClaimOffice><type><FormRequest><ClaimOfficeRequestForm>" + xml + "</ClaimOfficeRequestForm></FormRequest></type></AddClaimOffice>";
    
    
  }

function claimOffficeRequestFormProcess(id,htmlData,_stateCode)
{
var xml = "";
var  testTable = document.getElementById("AddClaimOfficeForm").getElementsByTagName("INPUT")
   for (var j=0;j < testTable.length;j++) {
               if(testTable[j].id !='')
                xml= xml +  '<Param Name=\'' + testTable[j].id  + '\'><![CDATA[' + testTable[j].value + ']]></Param>';
   }
   
        
    
    return  "<AddClaimOfficeProcess><type><FormRequest><claimOfficeRequestFormProcess>" + xml + "</claimOfficeRequestFormProcess></FormRequest></type></AddClaimOfficeProcess>";
        
  }
  
 
function getRegistrationInfo(tableID){
    var xml = "";
    var  testTable = document.getElementById(tableID).getElementsByTagName("INPUT")
    for (var j=0;j < testTable.length;j++) {
       if(testTable[j].id !='')
       {
         if(testTable[j].type == 'checkbox')
         {
            if(testTable[j].checked)
                xml= xml +  '<Param Name=\'' + testTable[j].id  + '\'><![CDATA[' + testTable[j].value + ']]></Param>';
         }
              else      
                xml= xml +  '<Param Name=\'' + testTable[j].id  + '\'><![CDATA[' + testTable[j].value + ']]></Param>';
       }
    }

    return xml;
}




