// ----------------------------------------------
// LSHALLMAN - Base User Interface Tools
//
// Date: Apr 25, 2006
// Devl: Derek Alldritt
// Revision: 1.0
// ----------------------------------------------

function quickSearch() {
	if (document.quickSearchForm.q.value > "") {
		document.quickSearchForm.submit();
	} else {
		alert("Please input a search term to continue");
	}
}

function openFeed(myURL) {
	prompt('Copy the URL below into your RSS reader to read headlines:',myURL);
}


// ----------------------------------------------
// STYLE SWITCHING
// ===============
// - Humm....switches the font size only for now.
// ----------------------------------------------
var prefsLoaded = false;
var currentFontSize = 12;

function revertStyles(){
	currentFontSize = 12;
	changeFontSize(0);
}
function changeFontSize(sizeDifference){
	currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference);

		if(currentFontSize > 16){
			currentFontSize = 16;
		}else if(currentFontSize < 8){
			currentFontSize = 8;
		}
	setFontSize(currentFontSize);
};
function setFontSize(fontSize){
	var stObj = (document.getElementById) ? document.getElementById('CenterNav') : document.all('CenterNav');
	stObj.style.fontSize = fontSize + 'px';

// THIS IS TO BE USED EVENTUALLY...FOR NOW, NOT ALL PAGES HAVE A RIGHTNAV, SO WE'LL CONSIDER IT.
//  -- NOTE: THAT FOR PAGES WITHOUT A RIGHTNAV, THIS WILL GENERATE A JS ERROR!!!!!
//----------------------------------------------------------------------------------------------	
	if ( document.getElementById != "undefined" ) {
		var stObj = (document.getElementById) ? document.getElementById('RightNav') : document.all('RightNav');
		stObj.style.fontSize = fontSize + 'px';
	}

//----------------------------------------------------------------------------------------------
};

window.onload = setUserOptions;

function setUserOptions(){
	if(!prefsLoaded){
		cookie = readCookie("fontSize");
		currentFontSize = cookie ? cookie : 12;
		setFontSize(currentFontSize);
		prefsLoaded = true;
	}
}

window.onunload = saveSettings;

function saveSettings()
{
  createCookie("fontSize", currentFontSize, 365);
}


// ----------------------------------------------
// Cookie functions
// ================
// - Pretty self explanitory, I hope.
// ----------------------------------------------

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = ";expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+";domain=.realogy.quarry.com;path=/;";
}
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}


// ----------------------------------------------
// HyperLink functions
// ===================
// - Rolls one graphic to another in say, a menu.
// ----------------------------------------------

function roll(file, tag) {
	document.images[tag].src = file;
}


// EOF
