window.name="newswindow";
window.onerror = stopError;
function stopError(){return true}
function gettopic(){return true}
function autopop(){poplist = window.open("/autosinsider/poplist.htm","poplist",'toolbar=1,location=1,menubar=1,scrollbars=1,resizable=1,width=615,height=500,status=1,top=screen.availTop,left=screen.availLeft');poplist.focus}
function nationjump(){jump = window.open("/update/nation/jump.htm","jump",'toolbar=1,location=1,menubar=1,scrollbars=1,resizable=1,width=615,height=500,status=1,top=screen.availTop,left=screen.availLeft');jump.focus}
function openlink(linkURL){if (linkURL == null)linkURL = "";linkwindow = window.open(linkURL,"linkwindow",'toolbar=1,location=1,menubar=1,scrollbars=1,resizable=1,width=500,height=500,status=1,top=screen.availTop,left=screen.availLeft');linkwindow.focus}
function openschool(linkURL){if (linkURL == null)linkURL = "";schoolwindow = window.open(linkURL,"schoolwindow",'toolbar=1,location=1,menubar=1,scrollbars=1,resizable=1,width=750,height=330,status=1,top=screen.availTop,left=screen.availLeft');schoolwindow.focus}
function mom(linkURL){if (linkURL == null)linkURL = "";son = window.open(linkURL,"son",'toolbar=0,location=0,menubar=0,scrollbars=1,resizable=1,width=700,height=460,status=1,top=screen.availTop,left=screen.availLeft');son.focus}
function pop(linkURL){if (linkURL == null)linkURL = "";popwindow = window.open(linkURL,"popwindow",'toolbar=0,location=0,menubar=0,scrollbars=1,resizable=1,width=540,height=550,status=1,top=screen.availTop,left=screen.availLeft');popwindow.focus}
function pixpop(linkURL){if (linkURL == null)linkURL = "";pixwindow = window.open(linkURL,"pixwindow",'toolbar=0,location=0,menubar=0,scrollbars=1,resizable=1,width=615,height=550,status=1,top=screen.availTop,left=screen.availLeft');pixwindow.focus}
function openwingsgallery(gallery) {pixpop("http://info.detnews.com/wingsgallery/index.cfm?project=" + gallery)}
function openjoyridesgallery(gallery) {pixpop("http://info.detnews.com/joyridesgallery/index.cfm?project=" + gallery)}
function openjoyridesgallery2(gallery) {pixpop("/joyridesgallery2/index.cfm?project=" + gallery)}
function openlionsgallery(gallery) {pixpop("http://info.detnews.com/lionsgallery/index.cfm?project=" + gallery)}
function openrvmgallery(gallery) {pixpop("http://info.detnews.com/rvmgallery/index.cfm?project=" + gallery)}
function opennewsgallery(gallery) {pixpop("http://info.detnews.com/newsgallery/index.cfm?project=" + gallery)}
function openphotosofthedaygallery(gallery) {pixpop("http://info.detnews.com/photosofthedaygallery/index.cfm?project=" + gallery)}
function opensportsgallery(gallery) {pixpop("http://info.detnews.com/sportsgallery/index.cfm?project=" + gallery)}
function openautosgallery(gallery) {pixpop("http://info.detnews.com/autosgallery/index.cfm?project=" + gallery)}
function openphotoggallery(gallery) {pixpop("http://info.detnews.com/photoggallery/index.cfm?project=" + gallery)}
function opengallery(gallery) {pixpop("http://pc100.detnews.com/slideshow/frame.hbs?project=" + gallery)}
function galleryindex(){pixpop("http://pc100.detnews.com/slideshow/galleryindex.htm")}
function autosgalleryindex(){pixpop("http://pc100.detnews.com/autosgallery/galleryindex.htm")}
function gothere(form){if(form.pick.options[form.pick.selectedIndex].value != "")openlink(form.pick.options[form.pick.selectedIndex].value)}
function morningstar(){pop("http://poweredby.morningstar.com/CoverPages/CoBrandstocksWI.html?CN=DTN725&PC=1")}
function companybox(Ticker){pop("http://poweredby.morningstar.com/Stocks/Snapshot/_" + Ticker + ".html?CN=DTN725&PC=1")} 
function shareit() {pop("http://info.detnews.com/share/index.cfm?referer=" + window.location)}
function searchform(form){var search = ((document.search.searchtext.value == "") ? mom("http://detnews.com/search/fulltext.htm") : scriptsearch(document.search.searchtext.value, "phrase"))}
function searchsection(form){var search = ((document.searchsection.sectiontext.value == "") ? mom("http://detnews.com/search/fulltext.htm") : scriptsearch(document.searchsection.sectiontext.value, document.searchsection.typeofsearch.value, document.searchsection.sectionname.value))}
tvDate = new Date();var tvThisday = tvDate.getDay();var tvFiles = "twi_sunday.html*twi_monday.html*twi_tuesday.html*twi_wednesday.html*twi_thursday.html*twi_friday.html*twi_saturday.html";var tvNames = tvFiles.split("*");
function tvToday(){window.location="http://tvlistings.zap2it.com/partners/editorial_link.asp?partner_id=det&url=http://tv.zap2it.com/shows/bestbets/tv/include/" + tvNames[tvThisday]}
function tvTomorrow(){window.location="http://tvlistings.zap2it.com/partners/editorial_link.asp?partner_id=det&url=http://tv.zap2it.com/shows/bestbets/tv/include/" + tvNames[tvThisday + 1]}
function tvSportsToday(){window.location="http://tvlistings.zap2it.com/partners/editorial_link.asp?partner_id=det&url=http://tv.zap2it.com/shows/bestbets/sports/" + tvNames[tvThisday]}
function tvSportsTomorrow(){window.location="http://tvlistings.zap2it.com/partners/editorial_link.asp?partner_id=det&url=http://tv.zap2it.com/shows/bestbets/sports/" + tvNames[tvThisday + 1]}
thisDate = new Date(); var addDay = thisDate.getTime() + (1000 * 60 * 60 * 24); nextDate = new Date(); nextDate.setTime(addDay); fromDate = (thisDate.getMonth() + 1) + "/" + thisDate.getDate() + "/" + thisDate.getFullYear(); toDate = (nextDate.getMonth() + 1) + "/" + nextDate.getDate() + "/" + nextDate.getFullYear();
function tvCategory(cat){window.location="http://tvlistings.zap2it.com/partners/special_search_det.asp?Qcat=" + cat + "&QspecialCustid=100123815&QspecialSortBy=title&QspecialSearchBy=title&QspecialFromDate=" + fromDate + "&QspecialToDate=" + toDate  + "&QspecialTextType=1&QspecialWords=nothing123&Qreturncnt=25&partner_id=det"}
function comments(forum) {
	if (forum == "autostalk"){pop("http://info.detnews.com/autostalk/writeus.cfm?referer=" + window.location)}
	if (forum == "geartalk"){pop("http://info.detnews.com/autostalk/writeus.cfm?referer=" + window.location)}
	if (forum == "lions"){pop("http://info.detnews.com/detroitlionsonline/writeus.cfm?referer=" + window.location)}
	if (forum == "pistons"){pop("http://info.detnews.com/detroitpistonsonline/writeus.cfm?referer=" + window.location)}
	if (forum == "wings"){pop("http://info.detnews.com/wings/writeus.cfm?referer=" + window.location)}
	if (forum == "techtalk"){pop("http://info.detnews.com/techtalk/writeus.cfm?referer=" + window.location)}
	if (forum == "sports"){pop("http://info.detnews.com/sports/writeus.cfm?referer=" + window.location)}
	if (forum == "tigers"){pop("http://info.detnews.com/tigers/writeus.cfm?referer=" + window.location)}
	if (forum == "feedback"){pop("http://info.detnews.com/feedback/writeus.cfm?referer=" + window.location)}
}
function msinvestmentcenter() { newsquiz=window.open ("http://poweredby.morningstar.com/doc/CBCover/0,,DTN725,00.html","slideshow",'toolbar=0,menubar=0,scrollbars=1,statusbar=1,resizable=1,width=600,height=480')}
function msstockcenter() { newsquiz=window.open ("http://poweredby.morningstar.com/CoverPages/CoBrandstocksWI.html?CN=DTN725&PC=1","slideshow",'toolbar=0,menubar=0,scrollbars=1,statusbar=1,resizable=1,width=550,height=480')}
function msfundcenter() { newsquiz=window.open ("http://poweredby.morningstar.com/CoverPages/CoBrandfundsWI.html?CN=DTN725&PC=1","slideshow",'toolbar=0,menubar=0,scrollbars=1,statusbar=1,resizable=1,width=550,height=480')}
function msclassroom() { newsquiz=window.open ("http://poweredby.morningstar.com/PoweredBy/CUniv/course_cat/1,2088,F-1,00.html?CN=DTN725","slideshow",'toolbar=0,menubar=0,scrollbars=1,statusbar=1,resizable=1,width=550,height=480')}

function openWin(winURL, winName, winWidth, winHeight) {
  var winTop = 250;
  var winLeft = 75;
  if (screen.availWidth <= 800) {
    var winLeft = screen.availWidth - winWidth;
  }
  var theWin = window.open(winURL, winName, "width=" + winWidth + ",height=" + winHeight + ",top=" + winTop + ",left=" + winLeft + ",screenY=" + winTop + ",screenY=" + winLeft + ",toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no");
}
function findreplace(inString, removeString, replaceString) {
	var outString = "", i = 0;
	while (i <= (inString.length - 1)) {
		if ((i <= (inString.length - removeString.length)) && (inString.substring(i, i + removeString.length)) == removeString){outString += replaceString; i += removeString.length}
		else {outString += inString.charAt(i); i++}
	} 
	return outString;
}
function removeSpaces(inString) {
	var outString = "";
	for (i = 0; i < inString.length; i++ ){if (inString.charAt(i) == " " && inString.charAt(i + 1) == " "){continue}outString += inString.charAt(i)}
	if (outString.charAt(0) == " "){outString = outString.substring(1, outString.length - 1)}
	if (outString.charAt(outString.length - 1) == " "){outString = outString.substring(0, outString.length - 1)}
	return outString;
}
function scriptsearch(searchterm, searchtype, selectedsection, dateline){
	document.startsearch.getit.value = searchterm;
    var s = "\\*'*=*>*<*)*(*{*}*!*@*&*[*\"*]*.*,* and * not *;*?";
	var a = s.split("*");
	for (i = 0; i < a.length; i++) searchterm = findreplace(searchterm, a[i], "");
	if (searchtype == "phrase"){
	searchterm = removeSpaces(searchterm);
	searchterm = findreplace(searchterm, " ", "<SENTENCE>");
	}
	if (searchtype == "anywords"){searchterm = findreplace(removeSpaces(new String(searchterm.toLowerCase())), " ", " <OR> ")}
	if (searchtype != "phrase" && searchtype != "anywords"){searchterm = findreplace(removeSpaces(new String(searchterm.toLowerCase())), " ", " <AND> ");searchtype = "allwords"}
	if (selectedsection != "" && selectedsection != null){searchterm = "(SECTION=" + removeSpaces(new String(selectedsection.toLowerCase())) + ") <AND> " + searchterm} 
	if (dateline != "" && dateline != null){searchterm = "(DATELINE=" + removeSpaces(new String(dateline.toUpperCase())) + ")<AND>" + searchterm} 
	searchterm += "<AND>(FILEDATE>=01/01/2000)<IN>blockquote";
	// searchterm += " <IN> blockquote <AND> (FILEDATE >= 01/01/2000)";
	document.startsearch.SearchType.value = searchtype;
	document.startsearch.QueryText.value = searchterm;
	mom(); 
	document.startsearch.submit();
}
function notiframe(alternatepage){
	if (document.all || document.getElementByID){return true}
	else {window.location=alternatepage}
} 
function townie(){
	var town = document.picktown.town.options[document.picktown.town.selectedIndex].value;
	if (town != null && town != ""){
		openlink('/includes/index/gototown.htm');
		var townarray = town.split(",");
		document.gettown.getit.value = townarray[0]; document.gettown.town.value = townarray[1]; document.gettown.homes.value = townarray[2]; document.gettown.profile.value = townarray[3]; 
		var dateline = (new String(townarray[0].toUpperCase()));
		document.gettown.QueryText.value = "(DATELINE=" + dateline + ")<AND>" + findreplace(removeSpaces(townarray[0]), " ", "<SENTENCE>") + "<IN>blockquote";
		document.gettown.submit();
	}
}
function schoolit() {
	var school = document.picktown.schools.options[document.picktown.schools.selectedIndex].value;
	if (school != null && school != "") {
		openschool('http://www.ses.standardandpoors.com');
		setTimeout("schoolit2();", 3000);	
	}
}
function schoolit2() {
	schoolwindow.location = "http://www.ses.standardandpoors.com/NASApp/SPSOnline/SPSServlet/LoginPageRequest?StateCode=MI&Role=-1&StateResidence=-1";
	setTimeout("schoolit3();", 3000);
}
function schoolit3() {
	schoolwindow.location = "http://www.ses.standardandpoors.com/NASApp/SPSOnline/SPSServlet/ValidateLocationLevelRequest?LocLevel=2941";
	setTimeout("schoolit4();", 3000);
}
function schoolit4() {
	var school = document.picktown.schools.options[document.picktown.schools.selectedIndex].value;
	schoolwindow.location = school;
}	
