﻿imgCt = 10;
imgLng = 20; /* Number of Rotator photos */
picQty = 4; /* Number of CRJU photos */

var timer = null;
aTag ="";

function doMasthead(num){
	randomNum = Math.floor ((Math.random() * num));
	var Buffer = "";
	Buffer = Buffer+"<a href='http://www.kellogg.edu/index.html'><div id='masthead"+randomNum+"'><span><strong>KELLOGG COMMUNITY COLLEGE</strong></span></div></a>";
	document.write(Buffer);
	
}

/*function doMasthead(){
	randomNum = Math.floor ((Math.random() * imgCt));
	var Buffer = "";
	Buffer = Buffer+"<a href='http://www.kellogg.edu/index.html'><div id='masthead"+randomNum+"'><span><strong>KELLOGG COMMUNITY COLLEGE</strong></span></div></a>";
	document.write(Buffer);
	
}*/

/* Cycles through different mastheads on the website */
function doMastheadNew(){
	randomNum = Math.floor ((Math.random() * imgCt));
	var Buffer = "";
	Buffer = Buffer+"<a href='http://www.kellogg.edu/index.html'><div id='masthead"+randomNum+"'><span><strong>KELLOGG COMMUNITY COLLEGE</strong></span></div></a>";
	Buffer+="<div id=\"addressline\" align=\"right\"><span style=\"padding-left:100px;\">450 North Avenue &#149; Battle Creek, MI. 49017 &#149; 269.965.3931</span>";
	Buffer+="	<span style=\"padding-left:40px;\"><input type=\"text\" name=\"q\" size=\"24\" maxlength=\"255\" value=\"\" alt=\"Input Search\" />	<input type=\"submit\" name=\"sa\" value=\"Search\" alt=\"Input Search\" /></span>";
	Buffer+="</div>";
	document.write(Buffer);
	
}

/* Cycles through different mastheads on the website */
function doMastheadLib(){
	randomNum = Math.floor ((Math.random() * 6));
	var Buffer = "";
	Buffer = Buffer+"<a href='http://www.kellogg.edu'><div id='masthead"+randomNum+"'><span><strong>KELLOGG COMMUNITY COLLEGE</strong></span></div></a>";
	document.write(Buffer);
	
}

function doMastheadCRJU(){
	randomNum = Math.floor ((Math.random() * picQty));
	var Buffer = "";
	Buffer = Buffer+"<a href='http://www.kellogg.edu'><div id='masthead"+randomNum+"'><span><strong>KELLOGG COMMUNITY COLLEGE</strong></span></div></a>";
	document.write(Buffer);
}

function doMastheadAthl(){
	randomNum = Math.floor ((Math.random() * 4));
	var Buffer = "";
	Buffer = Buffer+"<a href='http://www.kellogg.edu'><div id='masthead"+randomNum+"'><span><strong>KELLOGG COMMUNITY COLLEGE</strong></span></div></a>";
	document.write(Buffer);
	
}

function doMastheadMS(){
	randomNum = Math.floor ((Math.random() * 5));
	var Buffer = "";
	Buffer = Buffer+"<a href='http://www.kellogg.edu/index.html'><div id='masthead0"+randomNum+"'><span><strong>KELLOGG COMMUNITY COLLEGE</strong></span></div></a>";
	document.write(Buffer);
	
}


/* Cycles through different student images on the website */
function doRotater(){
	randomNum = Math.floor ((Math.random() * imgLng));
	var Buffer = "";
	Buffer = Buffer+"<div id='rotater"+randomNum+"' style='position:absolute;'><a href='http://www.kellogg.edu/index.html'><img src='images/KCClogo.gif' width='200' height='70' alt='KCC Logo' align='left' border='0' /></a></div>";
	document.write(Buffer);
	
}

/* Creates and writes the footer for all pages. Calls setBookmark to set a favorite using the title of the page */
function doFooter(){
	var buffer="";
	buffer= buffer+"<div id='footer'><a href='http://www.kellogg.edu'>home</a><a href='http://www.kellogg.edu/about/contact.html'>contact us</a><a href='http://www.kellogg.edu/staff/'>staff directory</a><a href='http://www.kellogg.edu/about/sitemap.html'>sitemap</a>\n";
    buffer= buffer+"<script>\n";
	buffer= buffer+"	var buffer;";
	buffer= buffer+"buffer=\"<a href=\\\"#\\\" onclick=\\\"setBookmark(window.location,'\"+document.title+\"');\\\">bookmark page</a>\";";
	buffer= buffer+"	document.write(buffer)\n";
    buffer= buffer+"</script>\n";
    buffer= buffer+"<a href='https://wa.kellogg.cc.mi.us/KCCLive/WebAdvisor?CONSTITUENCY=WBST&type=P&pid=ST-WESTS12A' target='_blank'>schedules</a>\n";
	buffer= buffer+"</div>\n";
	document.write(buffer);
}

/* Sets the bookmark */
function setBookmark(url,title){
	if (title == "") title = url;
	if(document.all){
		window.external.AddFavorite(url,title);
	}
	else if(window.sidebar){
		window.sidebar.addPanel(title,url,"");
	}
	else if( window.opera && window.print )
	{
		var mbm = document.createElement('a');
		mbm.setAttribute('rel','sidebar');
		mbm.setAttribute('href',url);
		mbm.setAttribute('title',title);
		mbm.click();
	}
}

// ************ Multi Browser Detection Routine
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
