var prefsLoaded = false;
var defaultFontSize =  75;
var currentFontSize = defaultFontSize;

function revertStyles(){
	currentFontSize = defaultFontSize;
	changeFontSize(0);
}

function toggleColors(){
	if(currentStyle == "White"){
		setColor("Black");
	}else{
		setColor("White");
	}
}

function changeFontSize(sizeDifference){
	currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 5);

	if(currentFontSize > 100){
		currentFontSize = 100;
	}else if(currentFontSize < 75){
		currentFontSize = 75;
	}
	setFontSize(currentFontSize);
};

function setFontSize(fontSize){
	var stObj = (document.getElementById) ? document.getElementById('centcol') : document.all('centcol');
	document.body.style.fontSize = fontSize + '%';
	//stObj.style.border = "1px solid #000";
};

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+"; path=/";
};

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
};


function setUserOptions(){
	if(!prefsLoaded){
		cookie = readCookie("fontSize");
		currentFontSize = cookie ? cookie : defaultFontSize;
		setFontSize(currentFontSize);
		prefsLoaded = true;
	}
}

function saveSettings()
{
  createCookie("fontSize", currentFontSize, 365);
}

function suckerFishInit() {
	var sfEls = document.getElementById("navbar").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
		this.className+=(this.className.length>0? " ": "") + "sfhover";		}
		// event added to keep menu items from disappearing
		sfEls[i].onMouseDown=function() {
		this.className+=(this.className.length>0? " ": "") + "sfhover";
		}
		// event added to keep menu items from disappearing
		sfEls[i].onMouseUp=function() {
		this.className+=(this.className.length>0? " ": "") + "sfhover";
		}
		sfEls[i].onmouseout=function() {
		this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
		}
	}
}

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

function set_inner_html(elem,value){
	var x = document.getElementById(elem);
	if (value) x.innerHTML = value; else x.innerHTML = '';
}
function change_featured(id,thumbimage)
{
	var main_img = document.getElementById('main_img');
	main_img.src = thumbimage;
	set_inner_html('main_title', document.getElementById('p_title_'+id).innerHTML);	
	set_inner_html('main_business', document.getElementById('p_business_'+id).innerHTML);		
	set_inner_html('main_phone', document.getElementById('p_phone_'+id).innerHTML);	
	set_inner_html('main_fax', document.getElementById('p_fax_'+id).innerHTML);		
	set_inner_html('main_email', document.getElementById('p_email_'+id).innerHTML);	
	set_inner_html('main_website', document.getElementById('p_website_'+id).innerHTML);	
	set_inner_html('main_summary', document.getElementById('p_summary_'+id).innerHTML);
	var main_link = document.getElementById('main_link');
	var main_website_link = document.getElementById('main_website_link');
	main_website_link.href = document.getElementById('p_website_'+id).innerHTML;
	var the_img = document.getElementById('p_img_'+id);
	//the_img.style.border='3px solid red';
	main_link.href = document.getElementById('p_link_'+id).value;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

