// Author: Tim Johnson - tim@johnsons-web.com
var kbconfig_js = 1; // "register" this file with calling code
var curYear = 2011;
function InitForm1(){
  var now = new Date();
  var domain = document.domain;
  // As new documents are added, will need to add the names
  if(strFind(document.location.pathname,'advance.html')){
	var cookie = document.cookie;
	if(cookie){
	  info_pairs = DocSetup('advance_html_state')
      InitLists(info_pairs);
	} else InitLists();
  }
  else{
		try{InitLists();}
		catch(e){
		} // Depends on whether GeoData.js has been loaded
  }
    if (domain == 'www.rgud.com')
    	 copyRight = "&nbsp;&#169;&nbsp;" + curYear + " RGud Properties&#153;, All Rights Reserved.";
  copyRight = "&nbsp;&#169;&nbsp;&nbsp;" + curYear;
  IDprint('copyrightyear',copyRight);
}
function InitForm(){
  try{InitLists();}
  catch(e){}
  //InitLists();
  var domain = document.domain;
  if (domain == 'www.rgud.com'){
	 IDprint('copyrightyear',"&nbsp;&#169;&nbsp;" + curYear);
  }
  else if (domain == 'www.wabo.biz' || domain == 'bart.johnson.com' || domain == 'www.alaskamls.com'
		   || domain == 'localhost' || domain == 'alaskamls.com'){
   	 copyRight = "<table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" " +
	             "width=\"100%\" bgcolor=\"#0000ff\" style=\"border-top: 1px solid rgb(0,255,0)\">" +
	             "<tr><td><table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" " +
				 "width=\"100%\" bgcolor=\"#1505a5\"><tr><td bgcolor=\"#FFFFFF\" width=\"4%\">" +
	             "<center><a href=\"http://www.alaskamls.com/FairHousingAct.shtml\" target=\"_blank\">" +
	             "<img src=\"http://www.alaskamls.com/logos/eh.gif\" alt=\"HUD Fair Housing Act\"" +
	             " border=\"0\"></a></center></td><td width=\"46%\">" +
	             "<font color=\"#ffffff\" size=\"2\" align=\"left\">&nbsp;&#169;&nbsp; " + curYear +
	   //	             " AlaskaMLS.com, all rights reserved.</font></td><td width=\"46%\" align=\"right\">" +
	             " Property, Inc. all rights reserved.</font></td><td width=\"46%\" align=\"right\">" +
	             "<a href=\"http://www.alaskamls.com\" target=\"_top\">" +
	             "<font color=\"#ffffff\" size=\"2\">Home</a>&nbsp;|&nbsp;</font>" +
	             "<a href=\"http://www.alaskamls.com/Privacy_Policy.shtml\" target=\"_top\">" +
	             "<font color=\"#ffffff\" size=\"2\">Privacy Policy</a>&nbsp;|&nbsp;</font>" +
	             "<a href=\"http://www.alaskamls.com/Terms_of_Use.shtml\" target=\"_top\">" + 
                 "<font color=\"#ffffff\" size=\"2\">Terms of Use</a>&nbsp;|&nbsp;</font>" + 
                 "<a href=\"http://www.alaskamls.com/Contact.shtml\" target=\"_top\">" + 
                 "<font color=\"#ffffff\" size=\"2\">Contact Us</font></a>&nbsp;&nbsp;</td>" + 
                 "<td bgcolor=\"#FFFFFF\" width=\"4%\"><center>" + 
                 "<a href=\"http://www.alaskamls.com/FairHousingAct.shtml\" target=\"_blank\">" + 
                 "<img src=\"http://www.alaskamls.com/logos/eh.gif\" alt=\"HUD Fair Housing Act\" border=\"0\">" + 
                 "</a></center></td></tr></table></td></tr></table>";
	 IDprint('copyrightyear',copyRight);
  }
  else if (domain == 'www.rgud.biz'){
   	 copyRight = "&nbsp;&#169;&nbsp;" + curYear + " RGud Properties&#153;, All Rights Reserved.";
	 IDprint('copyrightyear',copyRight);
  }
}
function InitContent(){
  IDprint('copyrightyear',"&nbsp;&#169;&nbsp;" + curYear)
}
// ==============================================================
function DocSetup(name){
  var cookie_info = readCookie('advance_html_state');
  return ParseCookieValue(cookie_info);
}
// ==============================================================
function dbg(obj,label){
  var debug = "Examining: " + label + "\n";
  for (var i in obj){
		debug += i + " -> " + obj[i] + "\n";
		}
  alert(debug);
	}
// ==============================================================
function IDprint(name,text){
  var target = document.getElementById(name);
  if(target)
	target.innerHTML = text;
}
// ==============================================================
function test(){
  alert('hello from kbconfig_js');
}
// ==============================================================
// * = display on internet
// 6 = coming soon  *
// 5 = for rent     *
// 4 = hold        
// 3 = sold         *
// 2 = pending sale *
// 1 = for sale     *
// 0 = default     
// ==============================================================
function DisplaysOnInternet(widget_name,ndx){
  var widget;
  var display = 0;
  var content = 'Yes<input type="hidden" name="displays" value="1">';
  if(TypeOf(ndx) == 'number')
  	ndx = [ndx];
  var chk_node = document.form0[widget_name]
  for(var i = 0;i < chk_node.length; i++){
	widget = chk_node[i];
	if(widget.checked){
	  display = widget.value;
	  break;
	  }
    }
  if(aryFind(ndx,display)){
	content = 'No<input type="hidden" name="displays" value="0">';
	}
  IDprint('DisplaysOnInternet',"Displays on Internet: " + content)
}
function LaunchPreview(MLS){
  var mydomain = document.domain;
  var domain = "www.alaskamls.com";
  if (mydomain == 'www.wabo.biz'){
	domain = mydomain;
  }
  var URL = 'http://' + domain + '/cgi-bin/perl/fsbo_detail_preview.pl?MLS=' + MLS;
  var preview = window.open(URL, "Preview", "height=640,width=850,status=0,scrollbars=1,top=0,left=0");
  //preview.moveTo(0,0);
  return true;
}
function CheckCreateAccount(form){
    if(TextEntered(form["contact_name"],"Contact Name") == false)
        return false;
    if(TextEntered(form["phone"],"Phone #") == false)
        return false;
    if(TextEntered(form["email"],"Email") == false)
        return false;
    if(TextEntered(form["confirm_email"],"Confirm Email") == false)
        return false;
    if(TextEntered(form["password"],"Password") == false)
        return false;
    if(TextEntered(form["confirm_password"],"Confirm Password") == false)
        return false;
    return true;

    } // end validation for Create New Account
// Update Hits
function UpdateHits(mlsNum){
  var domain = document.domain;
  var targets = new Array();
  targets["bart.johnson.com"] = 'http://bart.johnson.com/cgi-bin/baker/AjaxUpdater.py';
  targets["www.alaskamls.com"] = 'http://www.alaskamls.com/cgi-bin/py/AjaxUpdater.py';
  targets["www.wabo.biz"] = 'http://www.wabo.biz/cgi-bin/py/AjaxUpdater.py';
  var target = targets[domain];
  // Retrieve the response text via DOM
  var response = document.forms["AjaxHoldResponseForm"].AjaxCountResponse.value;
  AjaxRequest.get({
    'url':target
    ,'onSuccess':function(req){document.forms['AjaxHoldResponseForm'].AjaxCountResponse.value = req.responseText; }
    ,'onError':function(req){alert("ERROR: " + req.statusText);}
	,'parameters':{'mls_no':mlsNum,'ajax':1,"task":"updatehitcount"}
  });
  //	if(domain == "bart.johnson.com"){
  //		alert('response: ' + response); //debug
  //}
}



