// JavaScript Document
document.lastImgs = new Array;

function PreloadImages() { 
  images = new Array;
  for (x=0; x<PreloadImages.arguments.length; x++) {
  	images[x]=new Image;
  	images[x].src=PreloadImages.arguments[x];
  	}
}

function SwapImage () {
  if (document.images) {
   if (document.lastImgs.length) {
      RestoreImage();
   }
   a = SwapImage.arguments;
   inum = 0;
   for (x = 0; x < a.length; x+=2) {
      oldimg = a[x];
      newimg = a[x+1];
      if (document.images[oldimg].src.indexOf(newimg) == -1) {
         document.images[oldimg].oldsrc = document.images[oldimg].src;
         document.images[oldimg].src=newimg;
      }
      
      document.lastImgs[inum] = oldimg;
      inum++;
   
    }
  }
}

function RestoreImage () {
  if (document.images) {
   for (x = 0; x < document.lastImgs.length; x++) {
      img = document.lastImgs[x];
      document.images[img].src=document.images[img].oldsrc;
   }
   document.lastImgs = new Array;
  }
}

function newWindow(url, height, width, nameW) {
    if (nameW==""){nameW='popup';}
 if (navigator.appVersion.indexOf('4') != -1) {
 // Vars for centering the new window on Version 4 Browsers
 xTop = screen.width/2 - (width/2);
 yTop = screen.height/2 - (height/2);
 window.open(url, nameW, 'height='+height+',width='+width+',scrollbars=1,resizable=0,menubar=0,toolbar=0,status=0,location=0,directories=0,left=' + xTop + ',top=' + yTop + '');
 } else {
 window.open(url, nameW, 'height='+height+',width='+width+',scrollbars=1,resizable=0,menubar=0,toolbar=0,status=0,location=0,directories=0,left=150,top=200');
 }
}

function ChangePhoto (oldimg, newimg) {

   document.images[oldimg].src=newimg;

}

function imgSwap(oImg)
{
   var strOver  = "_over"    // image to be used with mouse over
   var strOff = "_off"     // normal image
   var strImg = oImg.src
   if (strImg.indexOf(strOver) != -1) 
      oImg.src = strImg.replace(strOver,strOff)
   else
      oImg.src = strImg.replace(strOff,strOver)
}
function imgSwapOn(oImg)
{
   var strOver  = "_over"    // image to be used with mouse over
   var strOff = "_on"     // normal image
   var strImg = oImg.src
   if (strImg.indexOf(strOver) != -1) 
      oImg.src = strImg.replace(strOver,strOff)
   else
      oImg.src = strImg.replace(strOff,strOver)
}
function imgSwapOff(oImg)
{
   var strOver  = "_off"    // image to be used with mouse over
   var strOff = "_on"     // normal image
   var strImg = oImg.src
   if (strImg.indexOf(strOver) != -1) 
      oImg.src = strImg.replace(strOver,strOff)
   else
      oImg.src = strImg.replace(strOff,strOver)
}
function pulldown_menu()
{
// Create a variable url to contain the value of the 
// selected option from the the form named pulldown and variable selectname
var url = document.pulldown.selectname.options[document.pulldown.selectname.selectedIndex].value

// Re-direct the browser to the url value
window.location.href = url 
}
function showIt(inID) {
          document.getElementById(inID).style.display = 'block';
     }
function hideIt(inID) {
	      document.getElementById(inID).style.display = 'none';
     }	 

function setCookie(cookieName,value) {
	//set it to expire in ten years
	var date = new Date();
	date.setTime(date.getTime() + 10 * 365 * 24 * 60 * 60 * 1000);
	document.cookie = cookieName + "=" + value + "; expires=" + date.toGMTString() + "; path=/";
}

function SizeFonts(size) {
	//set up hash of font sizes for elements
	switch(size) {
		case 'small':
			var e_sizes = $H({div: '14px',p: '19px',tt:'13px',blockquote:'10px',td: '12px',tr: '14px',input: '14px',a: '14px',textarea: '14px',h1: '22px',h2: '18px',h3: '13px', h4: '14px', h5: '14px', h6: '14px'});
			break;
		case 'medium':
			var e_sizes = $H({div: '16px',p: '20px',tt:'14px',blockquote:'11px',td: '15px',tr: '16px',input: '16px',a: '16px',textarea: '16px',h1: '26px',h2: '19px',h3: '16px', h4: '16px', h5: '16px', h6: '16px'});
			break;
		case 'large':
			var e_sizes = $H({div: '18px',p: '21px',tt:'15px',blockquote:'12px',td: '17px',tr: '18px',input: '18px',a: '18px',textarea: '18px',h1: '32px',h2: '20px',h3: '18px', h4: '18px', h5: '18px', h6: '18px'});
			break;
	}
	e_sizes.each(function(pair) {
		//get all the tags
		var elems = $$(pair.key);
		elems.each(function(elem) {
			if(!elem.hasClassName('font_size_control|bottom_link'))
				elem.setStyle({fontSize: pair.value});
		});
	});
	var control_links = document.getElementsByClassName('font_size_control');
	control_links.each(function(link) {
		if(link.id == 'font_size_' + size) {
			var dec = 'none';
			var l_color = '#72511e';
		} else {
			var dec = 'underline';
			var l_color = '#5993ad';
		}
		link.setStyle({textDecoration: dec, color: l_color});
	});
	setCookie('wsFontSize',size);
}
