
var browserAgent, browserVersion, browserPlatform;
var browserUserAgent = navigator.userAgent;
var browserUserAgentLowerCase = browserUserAgent.toLowerCase();

browserAgent = "Unknown Browser";
browserVersion = "Unknown Version";
browserPlatform = "Unknown Platform";

if (browserUserAgentLowerCase.indexOf('safari') >= 0) {
  browserAgent = "Apple Safari";
  browserVersion = browserUserAgent.substring(browserUserAgentLowerCase.indexOf('safari') + 7);
} else if (browserUserAgentLowerCase.indexOf('msie') >= 0) {
  browserAgent = "Microsoft Internet Explorer";
  browserVersion = browserUserAgentLowerCase.split("msie");
  browserVersion = browserVersion[1].split(";");
  browserVersion = browserVersion[0];
} else if (browserUserAgentLowerCase.indexOf('firefox') >= 0) {
  browserAgent = "Firefox";
  browserVersion = browserUserAgent.substring(browserUserAgentLowerCase.indexOf('firefox') + 8);
} else if (navigator.appName=="Netscape") {
  browserAgent = "Netscape Navigator";
  browserVersion = navigator.appVersion;
}

if (browserUserAgentLowerCase.indexOf('linux') >= 0) browserPlatform = "Linux";
else if (browserUserAgentLowerCase.indexOf('x11') >= 0) browserPlatform = "Unix";
else if (browserUserAgentLowerCase.indexOf('macintosh') >= 0) {
  browserPlatform = "Macintosh";
  browserPlatformArray = browserUserAgent.substring(browserUserAgent.indexOf('(') + 1, browserUserAgent.indexOf(')') - 1 ).split(';');
  for (i = 0; i <= browserPlatformArray.length; i++) {
	if (undefined != browserPlatformArray[i]) {
      if (browserPlatformArray[i].toLowerCase().indexOf('mac') >= 0) {
        browserPlatform = browserPlatformArray[i];
      }
	}
  }
} else if (browserUserAgentLowerCase.indexOf('windows') >= 0) {
  browserPlatform = "Windows";
  browserPlatformArray = browserUserAgent.substring(browserUserAgent.indexOf('(') + 1, browserUserAgent.indexOf(')') - 1 ).split(';');
  for (i = 0; i <= browserPlatformArray.length; i++) {
	if (undefined != browserPlatformArray[i]) {
      if (browserPlatformArray[i].toLowerCase().indexOf('windows') >= 0) {
	      browserPlatform = browserPlatformArray[i];
      }
	}
  }
}

function checkBrowser() {
	if (browserAgent == "Microsoft Internet Explorer") {
	   if (browserPlatform.toLowerCase().indexOf('windows') >= 0) {
	     if (parseFloat(browserVersion) >= 5.5) {
 	       document["imgBrowser"].src="http://online.riohondo.edu/student/images/pass.gif";
		 }
	   } else if (browserPlatform.toLowerCase().indexOf('mac') >= 0) {
	     if (parseFloat(browserVersion) == 5.2) {
		  	document["imgBrowser"].src="http://online.riohondo.edu/student/images/pass.gif";
	      }
	   }
	} else if (browserAgent == "Netscape Navigator") {
	   if (browserPlatform.toLowerCase().indexOf('windows') >= 0) {
	     if (parseFloat(browserVersion) == 7.1) {
 	       document["imgBrowser"].src="http://online.riohondo.edu/student/images/pass.gif";
		 }
	   } else if (browserPlatform.toLowerCase().indexOf('mac') >= 0) {
	     if (parseFloat(browserVersion) == 7.1) {
		  	document["imgBrowser"].src="http://online.riohondo.edu/student/images/pass.gif";
	      }
	   }
	   	} else if (browserAgent == "Firefox") {
	   if (browserPlatform.toLowerCase().indexOf('windows') >= 0) {
	     if (parseFloat(browserVersion) == 3.0) {
 	       document["imgBrowser"].src="http://online.riohondo.edu/student/images/pass.gif";
		 }
	   } else if (browserPlatform.toLowerCase().indexOf('mac') >= 0) {
	     if (parseFloat(browserVersion) == 3.0) {
		  	document["imgBrowser"].src="http://online.riohondo.edu/student/images/pass.gif";
	      }
	   }
	} else if (browserAgent == "Apple Safari") {
	   if (browserPlatform.toLowerCase().indexOf('mac') >= 0) {
	     if (parseFloat(browserVersion) == 2.0) {
		  	document["imgBrowser"].src="http://online.riohondo.edu/student/images/pass.gif";
	      }
	   }
	}
}

function returnBrowserAgent() {
  return browserAgent;
}

function returnBrowserVersion() {
  return browserVersion;
}

function returnBrowserPlatform() {
  return browserPlatform;
}

function checkPopup() {
	window.open("popup.html","popup","toolbar=no, width=250, height=250");
}

function checkCookies() {
   navigator.cookiesAreEnabled = checkCookiesAreEnabled();
   if (navigator.cookiesAreEnabled) {
     document["imgCookies"].src="http://online.riohondo.edu/student/images/pass.gif";
   } 
}



function checkCookiesAreEnabled() {
  SetCookie( "scooby", "doo" );
  if ( GetCookie( "scooby" ) ) {
    DeleteCookie( "scooby" );
    return true;
  } else {
    return false;
  }
}

function GetCookie( name ) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while ( i < clen ) {
    var j = i + alen;
    if ( document.cookie.substring(i, j) == arg ) return getCookieVal(j);
    i = document.cookie.indexOf( " ", i ) + 1;
    if ( i == 0 ) break;
  }
  return null;
}

function DeleteCookie( name, path, domain ) {
  if ( GetCookie( name ) ) {
    document.cookie = name + "=" +
    ( ( path ) ? "; path=" + path : "" ) +
    ( ( domain ) ? "; domain=" + domain : "" ) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function SetCookie( name, value, expires, path, domain, secure ) {
  document.cookie = name + "=" + escape (value) +
  ( ( expires ) ? "; expires=" + expires.toGMTString() : "" ) +
  ( ( path ) ? "; path=" + path : "" ) +
  ( ( domain ) ? "; domain=" + domain : "" ) +
  ( ( secure ) ? "; secure" : "" );
}

function getCookieVal( offset ) {
  var endstr = document.cookie.indexOf ( ";", offset );
  if ( endstr == -1 ) endstr = document.cookie.length;
  return unescape( document.cookie.substring( offset, endstr ) );
}


function runChecks() {
  checkBrowser();
  document["imgJavaScript"].src="http://online.riohondo.edu/student/images/pass.gif";
  checkCookies();
  checkPopup();
}

