/*
Checks to see if user's browser has Cookies enabled
*/
function noCookies(redirect) {
	var tmpcookie = new Date();
	chkcookie = (tmpcookie.getTime() + '');
	document.cookie = "chkcookie=" + chkcookie + "; path=/";
	if (document.cookie.indexOf(chkcookie,0) < 0) {
		window.location = redirect;
	} else {
		return("true");
	}
}

/*
Swap nav image and text link underline
*/
function navRoll(nav, over) {
	if (document.getElementById) {
		if (over) {
			document.getElementById('nav'+nav).setAttribute('src', 'http://www.safelite.com/images/arrow_redbox_on.gif');
			document.getElementById('navtext'+nav).style.textDecoration='underline';
		} else {
			document.getElementById('nav'+nav).setAttribute('src', 'http://www.safelite.com/images/arrow_clearbox_off.gif');
			document.getElementById('navtext'+nav).style.textDecoration='none';
		}
	}
}

/*
Swap small arrows (leftnav image) and text link underline
*/
function arRoll(nav, over) {
	if (document.getElementById) {
		if (over) {
			document.getElementById('ar'+nav).setAttribute('src', 'http://www.safelite.com/images/arrow_redbox_inline.gif');
			document.getElementById('artext'+nav).style.textDecoration='underline';
		} else {
			document.getElementById('ar'+nav).setAttribute('src', 'http://www.safelite.com/images/arrow_greybox_off.gif');
			document.getElementById('artext'+nav).style.textDecoration='none';
		}
	}
}

/*
Swap small arrows (leftnav image) and text link underline for items already selected
*/
function arSelectedRoll(nav, over) {
	if (document.getElementById) {
		if (over) {
			document.getElementById('ar'+nav).setAttribute('src', 'http://www.safelite.com/images/arrow_redbox_inline.gif');
			document.getElementById('artext'+nav).style.textDecoration='underline';
		} else {
			document.getElementById('ar'+nav).setAttribute('src', 'http://www.safelite.com/images/arrow_redbox_inline.gif');
			document.getElementById('artext'+nav).style.textDecoration='none';
		}
	}
}


/*
Swap big arrows (main page image)
*/
function arbRoll(nav, over) {
	if (document.getElementById) {
		if (over) {
			document.getElementById('arb'+nav).setAttribute('src', 'http://www.safelite.com/images/arrow_greybox_big.gif');
		} else {
			document.getElementById('arb'+nav).setAttribute('src', 'http://www.safelite.com/images/arrow_redbox_big.gif');
		}
	}
}

/*
Swap small arrows (main page image)
*/
function arsRoll(nav, over) {
	if (document.getElementById) {
		if (over) {
			document.getElementById('ars'+nav).setAttribute('src', 'http://www.safelite.com/images/arrow_red.gif');
			document.getElementById('arstext'+nav).style.textDecoration='underline';
		} else {
			document.getElementById('ars'+nav).setAttribute('src', 'http://www.safelite.com/images/arrow_grey.gif');
			document.getElementById('arstext'+nav).style.textDecoration='none';
		}
	}
}

/*
Clear default value of text input
*/
function clearField(thefield) {
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
}

/*
pop up new scrollable, resizable window
*/
function popup(url,w,h) {
	if (!w) {w='420';}
	if (!h) {h='241';}
	newPopup = window.open (url, 'safelitepop', 'resizable,scrollbars,width='+w+',height='+h);
	newPopup.focus();
}

/*
pop up new scrollable, resizable window
*/
function popup2(url,w,h) {
	if (!w) {w='760';}
	if (!h) {h='241';}
	newPopup = window.open (url, 'safelitepop2', 'resizable,scrollbars,width='+w+',height='+h);
	newPopup.focus();
}

/*
swapImage(imgTagName,imgTagSrc)
used like this:
<a href="#anchor_name" 
	onmouseover="swapImage( 'image1' , 'img2.jpg' )" 
	onmouseout="swapImage( 'image1' , 'img1.jpg' )">
<img name="image1" src="img1.jpg" border="none">
</a>
*/
function swapImage(imgTagName,imgTagSrc) {
	if(document.images)document.images[imgTagName].src=imgTagSrc;
}

/*
	loadInOpener(url)
	is normally called from a pop-up window.
	loads url in the window that opened this window.
	use it like this:
	Load the <A HREF="#" onClick="loadInOpener('/index.html');">homepage</A> into the main window.
*/
function loadInOpener(url)
{
	window.opener.location.href = url;
}

/*
	loadInOpenerAndCloseThis(url)
	is normally called from a pop-up window.
	loads url in the window that opened this window, then closes this window.
	use it like this:
	Load the <A HREF="#" onClick="loadInOpenerAndCloseThis('/index.html');">homepage</A> into the main window.
*/
function loadInOpenerAndCloseThis(url)
{
	loadInOpener(url);
	window.opener.focus(); 
	window.close();
}