
    function Set_Cookie( name, value, expires, path, domain, secure ) 
    {
        // set time, it's in milliseconds
        var today = new Date();
        today.setTime( today.getTime() );

        /*
        if the expires variable is set, make the correct 
        expires time, the current script below will set 
        it for x number of days, to make it for hours, 
        delete * 24, for minutes, delete * 60 * 24
        */
        if ( expires )
        {
        expires = expires * 1000 * 60 * 60 * 24;
        }
        var expires_date = new Date( today.getTime() + (expires) );

        document.cookie = name + "=" +escape( value ) +
        ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
        ( ( path ) ? ";path=" + path : "" ) + 
        ( ( domain ) ? ";domain=" + domain : "" ) +
        ( ( secure ) ? ";secure" : "" );
    }

    // this fixes an issue with the old method, ambiguous values 
    // with this test document.cookie.indexOf( name + "=" );
    function Get_Cookie( check_name ) {
	    // first we'll split this cookie up into name/value pairs
	    // note: document.cookie only returns name=value, not the other components
	    var a_all_cookies = document.cookie.split( ';' );
	    var a_temp_cookie = '';
	    var cookie_name = '';
	    var cookie_value = '';
	    var b_cookie_found = false; // set boolean t/f default f
    	
	    for ( i = 0; i < a_all_cookies.length; i++ )
	    {
		    // now we'll split apart each name=value pair
		    a_temp_cookie = a_all_cookies[i].split( '=' );
    		
    		
		    // and trim left/right whitespace while we're at it
		    cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
    	
		    // if the extracted name matches passed check_name
		    if ( cookie_name == check_name )
		    {
			    b_cookie_found = true;
			    // we need to handle case where cookie has no value but exists (no = sign, that is):
			    if ( a_temp_cookie.length > 1 )
			    {
				    cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			    }
			    // note that in cases where cookie is initialized but no value, null is returned
			    return cookie_value;
			    break;
		    }
		    a_temp_cookie = null;
		    cookie_name = '';
	    }
	    if ( !b_cookie_found )
	    {
		    return null;
	    }
    }		


// WRITE PNG'S
var userAgent = window.navigator.userAgent
var isIE = (window.navigator.userAgent.indexOf("MSIE") != -1);
var isFirefox = (window.navigator.userAgent.indexOf("Firefox") != -1);
var isIE6 = (parseFloat(userAgent.substring(userAgent.indexOf("MSIE ") + 5)) <= 6);
var isSafari = (navigator.userAgent.indexOf("Safari") > 0);

function writePngImage(url, width, height, alt) {
	if (!isIE6)
		document.write("<img alt=\"" + alt + "\" src=\"" + url + "\" style=\"width: " + width + "px; height: " + height + "px;\">");
	else
		document.write("<img src=\"spacer.png\" style=\"width: " + width + "px; height: " + height + 
			"px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "', sizingMethod=scale);\">");
}


// USE ALT STYLE SHEETS
function BrowserInfo() {
	var agent = window.navigator.userAgent;
	if (agent.indexOf("MSIE") != -1) {
			var start = agent.indexOf("MSIE");
			this.name = "MSIE";
			this.version = parseFloat(agent.substring(start + 5, agent.indexOf(";", start)));
	} else if (agent.indexOf("Firefox") != -1) {
			var start = agent.indexOf("Firefox");
			this.name = "Firefox";
			this.version = agent.substring(start + 8, agent.length);
			var firstDec = this.version.indexOf(".") + 1;
			while (this.version.indexOf(".", firstDec) != -1)
				this.version = this.version.substring(0, firstDec) + this.version.substring(firstDec).replace(".", "");
			this.version = parseFloat(this.version);
	} else {
			this.name = "Unknown";
			this.version = 0;
	}
}

var info = new BrowserInfo();
var isIE6 = (info.name == "MSIE" && info.version < 7);


if (info.name == "MSIE" && info.version < 7)
	document.writeln('<link href="SchwinnTemplates/stylesIE6.css" rel="stylesheet" type="text/css" />');
else
	document.writeln('<link href="SchwinnTemplates/stylesDynamic.css" rel="stylesheet" type="text/css" />');


// RENDERFLASH
function renderFlash(src, width, height, features) {
	document.writeln('<embed src="' + src + '" quality="high" width="' + width + 
					 '" height="' + height + '" align="middle" allowscriptaccess="sameDomain" ' +
					 'type="application/x-shockwave-flash" ' + features + 
  					 'pluginspage="http://www.macromedia.com/go/getflashplayer" />');
}


// MOUSOVER IMAGES
function swap(img_name, img_src) {
	document.getElementById(img_name).src = img_src;   
}


// EXPANDING NAV
function toggleElement(id) {
	var html = document.getElementById(id);
	if (html.style.display != "none") {
		html.style.height = html.offsetHeight + "px";
		html.style.overflow = "hidden";
		html.style.lineHeight = "20px";
		animStep(id, false, html.offsetHeight);
	} else {
		html.style.display = "";
		html.style.overflow = "";
		html.style.height = "";
		var h = html.offsetHeight;
		html.style.overflow = "hidden";
		html.style.lineHeight = "20px";
		html.style.height = "0px";
		animStep(id, true, h);
	}
	
	return false;
}

function displaySubNav(index) {
	for (var i = 1; i < 5; i++) {
		var html = document.getElementById("subnav" + i);
	}
	
	toggleElement("subnav" + index);
	return false;
}
function animStep(id, expanding, height) {
	var html = document.getElementById(id);
	var newHeight = parseInt(html.style.height);
	
	if (expanding) {
		newHeight += 50;
		
		if (newHeight >= height) {
			html.style.height = height + "px";
			return;
		}
	} else {
		newHeight -= 50;
		if (newHeight <= 0) {
			html.style.height = "0px";
			html.style.display = "none";
			return;
		}
	}
	
	html.style.height = newHeight + "px";
	setTimeout("animStep('" + id + "', " + expanding + ", " + height + ");", 50);
}


// COUNTRY PANEL
function EventInfo(evt) {
	if (evt == null)
		evt = window.event;

	this.event = evt;
	
	/* Standard Event Information */
	this.altKey = evt.altKey;
	this.clientX = evt.clientX;
	this.clientY = evt.clientY;
	this.ctrlKey = evt.ctrlKey;
	this.keyCode = evt.keyCode;
	this.screenX = evt.screenX;
	this.screenY = evt.screenY;
	this.shiftKey = evt.shiftKey;
	this.type = evt.type;
	
	if (window.event == null) {
		/* Mozilla Specific Information */
		this.fromElement = evt.relatedTarget;
		this.srcElement = evt.target;
		this.toElement = evt.currentTarget;
		
		this.cancelBubble = function() { this.event.stopPropagation(); };
		this.returnValue = function(value) { this.event.preventDefault(); };
	} else {
		/* IE Specific Information */
		this.fromElement = evt.fromElement;
		this.srcElement = evt.srcElement;
		this.toElement = evt.toElement;

		if (this.type == "blur")
			this.toElement = document.activeElement;
		
		this.cancelBubble = function() { this.event.cancel = true; };
		this.returnValue = function(value) { this.event.returnValue = value; };
	}
	
	this.relatedTarget = this.fromElement;
	this.target = this.srcElement;
	this.currentTarget = this.toElement;
	this.stopPropagation = this.cancelBubble;
	this.preventDefault = this.returnValue;

	this.realX = this.clientX + document.body.scrollLeft;
	this.realY = this.clientY + document.body.scrollTop;
}

var timerId;
function showPanel(evt, id, x, y) {
	var evt = new EventInfo(evt);
	
	var panel = document.getElementById(id);
	if (panel == null)
		return;

	if (panel.style.display == "none") {
		var leftEdge = document.body.clientWidth / 2 - (760 / 2) - 50;
		var bottomEdge = document.body.clientHeight - 392;
		
		panel.style.left = leftEdge + "px";
		panel.style.top = bottomEdge + "px";//evt.realY;
		panel.style.display = "";
	} else {
		clearTimeout(timerId);
	}
}

function hidePanel(evt, id) {
	var evt = new EventInfo(evt);
	clearTimeout(timerId);
	timerId = setTimeout("hidePanel2('" + id + "');", 100);
	return false;
}
	
function hidePanel2(id) {
	var panel = document.getElementById(id);
	if (panel == null)
		return;

	panel.style.display = "none";
}

function addEventHandler(obj, event, handler) {
    if (isIE) {
        
    } else {
        
    }
}

function printpage() {
	window.print();
}

function searchReplaceFocus(element, searchText) {
	if(element.value == searchText) {
		element.value = "";
	}
}

function searchReplaceBlur(element, searchText) {
	if(element.value == "") {
		element.value = searchText;
	}
}

function checkPngs() {
	if (isIE6) {
		var inputs = document.getElementsByTagName("input");
		for (var i = 0; i < inputs.length; i++) {
			if (inputs[i].src.toLowerCase().indexOf(".png") != -1 && inputs[i].src.toLowerCase().indexOf("spacer.png") == -1) {
				inputs[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + inputs[i].src + "', sizingMethod=scale);";
				inputs[i].src = "SchwinnTemplates/spacer.png";
			}
		}
	}
}
