// CSS Switcher Function
function switchStylestyle(styleName) {
    $('link[@rel*=style][title]').each(function(i) {
        this.disabled = true;
        if (this.getAttribute('title') == styleName) this.disabled = false;
    });
    createCookie('style', styleName, 365);
}

// Greeting
function greeting() {
    day = new Date()
    hr = day.getHours()

    if ((hr >= 0) && (hr <= 11))
        document.write("Good Morning")
    if ((hr >= 12) && (hr <= 17))
        document.write("Good Afternoon")
    if ((hr >= 18) && (hr <= 23))
        document.write("Good Evening")
}

// Configure status message not to show
var statusmsg = ""
function hidestatus() {
    window.status = statusmsg
    return true
}

// Contact Form Only allow numeric input
function isNumberKey(evt) {
    var charCode = (evt.which) ? evt.which : evt.keyCode;

    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

    return true;
}

// Breadcrumb
jQuery(document).ready(function() {

    // Bread Crumb
    jQuery("#breadCrumb").jBreadCrumb();
    jQuery("#breadCrumbFooter").jBreadCrumb();

    // Fader
    jQuery('.fade_effect').fadeIn(2000);

    // CSS Switcher
    $('.styleswitch').click(function() {
        switchStylestyle(this.getAttribute("rel"));
        return false;
    });
    var c = readCookie('style');
    if (c) switchStylestyle(c);
});

// Resource Center Audio Player http://flash-mp3-player.net/players/maxi/
function play() {
document.getElementById("audioplayer").SetVariable("player:jsPlay", "");
}

function badBrowser(){
	if($.browser.msie && parseInt($.browser.version) <= 6){ return true;}
	
	return false;
}
//IE6 Browser Upgrade Warning
function getBadBrowser(c_name)
{
	if (document.cookie.length>0)
	{
	c_start=document.cookie.indexOf(c_name + "=");
	if (c_start!=-1)
		{ 
		c_start=c_start + c_name.length+1; 
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}	

function setBadBrowser(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

if(badBrowser() && getBadBrowser('browserWarning') != 'seen' ){
	$(function(){
		$("<div id='browserWarning'><p>Your browser is no longer supported. For a better web browsing experience, please upgrade to a modern browser.</p><ul class='browserList'><li><a href='http://www.google.com/chrome/index.html' target='_blank' class='chrome'>Google Chrome</a></li><li><a href='http://www.apple.com/safari/' target='_blank' class='safari'>Safari</a></li><li><a href='http://www.mozilla.com/?from=sfx&amp;uid=267821&amp;t=44' target='_blank' class='firefox'>Firefox</a></li><li><a href='http://www.microsoft.com/windows/internet-explorer/default.aspx' target='_blank' class='ie'>Internet Explorer 8</a></li></ul><a href='#' id='warningClose'>Close Warning</a></div> ")
			.css({
				backgroundColor: '#fcfdde',
				'width': '100%',
				'border-top': 'solid 1px #000',
				'border-bottom': 'solid 1px #000',
				'text-align': 'center',
				'position': 'absolute',
				'z-index':'500',
				padding:'5px 0px 5px 0px'
			})
			.prependTo("body");
		
		$('#warningClose').click(function(){
			setBadBrowser('browserWarning','seen');
			$('#browserWarning').slideUp('slow');
			return false;
		});
	});	
}

//configure popup window
function wopen(url, name, w, h)
{
  // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  w += 32;
  h += 54;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=no, resizable=no');
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
}

function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}
