﻿/**
* This method will return a string with recommendations for
* a better viewing experience
*/
function makeRecommendation(){
	var result = "";
	return result;
//	var index = navigator.appVersion.indexOf("MSIE");
//	if(index > -1){
//		var temp = navigator.appVersion.substr(index + 5);
//		temp = parseFloat(temp);
//		if(temp < 7){
//			result += "Best experienced in FF or IE7 "
//		}
//	}
//	if(screen.width < 1024 || screen.height < 768){
//		result += "Best viewed with 1024x768 screen resolution or better ";
//	}
//	return result;
}


/**
* Short cut for getting the element by id
* @param anon the string of the element id
*/
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}//end $
/**
* This method is used to get around the "new feature"
* in IE for embedding content in websites
* @param container element id of the container
* @param movie the url of the movie
* @param width the width
* @para, height the height
*/
function showFlash(container, movie, width, height) {
    var output = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='"+width+"' height='"+height+"' id='myflash'>";
    output += "<param name='allowScriptAccess' value='sameDomain' />";
    output += "<param name='movie' value='" + movie + "' />";
    output += "<param name='quality' value='high' />";
    output += "<embed src='" + movie + "' quality='high' width='"+width+"' height='"+height+"' name='mymovie' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
    output += "</object>"; 
    $(container).innerHTML = output;
}//end showFlash 
/**
* This method will toggle the display mode on an element from 
* none to block and back again
*/
function toggle(elementId){
   var element = document.getElementById(elementId);
   if(element.style.display == "")
       element.style.display = "none";
   else if(element.style.display == "none")
       element.style.display="block";
   else 
       element.style.display="none";
}//end toggle

var previousNewsItemId;

/**
* This method will copy a news item div contents
* into the news item display panel
*
* @param divToShowId The div that will recieve
* @param newsItemId The div that contains the contents to place in divToShowId
*/
function showNewsItem(divToShowId, newsItemId){
    var div = document.getElementById(divToShowId);
    var element = document.getElementById(newsItemId);
    div.innerHTML = element.innerHTML;
}//end showNewsItem
/**
* This method will set the innerHTML of a given div
* to have an embed with the url parameter as the source
*
* @param frameId the Div to put the results in
* @param url the url of the media to display
*/
function setVideoFrame(frameId, url){
    var element = document.getElementById(frameId);
    element.innerHTML = "<embed src=\"" + url + "\" width=\"100%\" height=\"100%\"></embed>";
}//end setVideoFrame
/**
* This method will change the image
* src to the provided url
* 
* @param element the image element
* @param url the url to use
*/
function changeImage(element, url){
    element.src = url;
}//end changeImage
/**
* This method will set the given elements class
* to the class specified
*/
function setClass(elementId, className){
	var element = document.getElementById(elementId);
	element.className = className;
}//end setClass
/**
* This method will select a given submenu item
* and unselect all others. This is required 
* when using ajax because otherwise the 
* submenu class will not update
* 
* @param submenuId the element id of the submenu
* @param itemId the element if of the menut item in the submenu to select
*/
function selectSubMenuItem(submenuId, itemId){
    var menu = document.getElementById(submenuId);
    var item = document.getElementById(itemId);
    var nodes = menu.getElementsByTagName("span");
    for(var i=0;i<nodes.length;i++){
       if(nodes[i].id == item.id){
            nodes[i].className = "selected";
       }
       else{
            nodes[i].className ="";
       }
    }//end for
}//end selectSubMenuItem
/**
* This method will use the Ajax.aspx page to
* retrieve content for a given page. It will then
* populate the divId.innerHTML with the return text
*
* @param divID elementId in the dom to populate
* @param pageName page name parameter that ajax.aspx expects
* @param pageParameter page parameter that ajax.aspx expects
*/
function updateDiv(divId, pageName, pageParameter){
    var updateDivId  = divId;
    var httpRequest = getHttpRequestObject();
    httpRequest.onreadystatechange = function() {
		//Anonymous function called by the request object 
		var div = document.getElementById(updateDivId);
		if(div != null){
			if(httpRequest.readyState == 4 && httpRequest.status == 200){
				div.innerHTML = httpRequest.responseText;
			}
		}
    }//end anonymous method
    //Send the request
    var request = "/Web/Ajax.aspx?pageName=" + escape(pageName) + "&page=" + escape(pageParameter);
    httpRequest.open('GET', request, true);
    httpRequest.send(null);
}//end updateDiv
/**
* This method is used to retrieve the http request object
* It works in Safari, Mozilla , IE 7 and IE 6. Untested in 
* other browsers. 
*/
function getHttpRequestObject(){
	var httpRequest = null;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		httpRequest = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) { // IE
		try {
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) {
			try {
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) {}
		}
	}
    return httpRequest;
}//end getHttpRequestObject
/**
* This method will toggle the class used on the directions block
* 
* If there is no class set calling this method will set the class
* to showDirections
*
* @param blockId the element if of the block to toggle
*/
function toggleDirections(blockId){
	var block = document.getElementById(blockId);
	if(block.className == "showDirections"){
		block.className = "hideDirections";
	}
	else{
		block.className = "showDirections";
	}
}//end toggleDirections