// ----------------------------------------------
// REALOGY - Base User Interface Tools
//
// Date: Apr 25, 2006
// Devl: Derek Alldritt
// Revision: 1.0
// ----------------------------------------------

function quickSearch() {
	if (document.quickSearchForm.qt.value > "") {
		document.quickSearchForm.submit();
	} else {
		alert("Please input a search term to continue");
	}
}

function Search() {
	if (document.getElementById('qt').value > "") {
		document.getElementById('searchForm').submit();
	} else {
		alert("Please input a search term to continue");
	}
}

function quickMediaSearch() {
	if (document.quickMediaSearchForm.qt.value > "") {
		document.quickMediaSearchForm.submit();
	} else {
		alert("Please input a search term to continue");
	}
}

function careerSearch() {
	document.JobSearch_NA.submit();
}

function openFeed(myURL) {
	prompt('Copy the URL below into your RSS reader to read headlines:',myURL);
}

// Function to verify the existance of a variable
function isDefined(item) {
	return (typeof item != 'undefined');
}


// ----------------------------------------------
// 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, 'CenterNav');
	setFontSize(currentFontSize, 'RightNav');
};
function setFontSize(fontSize, ElementID){
	var stObj = (document.getElementById) ? document.getElementById(ElementID) : document.all(ElementID);
	if( stObj ) {
		stObj.style.fontSize = fontSize + 'px';
	}
};

//window.onload = setUserOptions();

function setUserOptions(){
	if(!prefsLoaded){
		cookie = readCookie("fontSize");
		currentFontSize = cookie ? cookie : 12;
		setFontSize(currentFontSize, 'CenterNav');
		setFontSize(currentFontSize, 'RightNav');
		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=.wyndhamworldwide.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


