// this function simulates the div:hover state which standards compliant browsers allow but ie does not

function fixieHover(){
	if(is_ie){
		var divName = new Array('tests','plan','csearch','apply','pay');

		for(i=0;i<divName.length;i++){
			el                = document.getElementById(divName[i]).getElementsByTagName('div');
			el[0].onmouseover = function() { this.className = 'current'; }
			el[0].onmouseout  = function() { this.className = ''; }
		}
	}
}

function writeCbaCookie(){
	arg             = writeCbaCookie.arguments;
	document.cookie = 'CB_AUDIENCE='+arg[0] + '; path=/; expires='+cookieTime(3000);
}		

var noredirect       = '?student';
var stay             = new RegExp('\\'+noredirect);
var newLocation      = null;
document.cookie      = 'CB_TEST=1; path=/;';
var hasCookies       = (document.cookie.indexOf('CB_TEST=1')<0) ? 0 : 1;
var url              = (hasCookies) ? document.location.href : noredirect;

if(!stay.test(url)){

	re = /CB_AUDIENCE=/;
	if(!re.test(document.cookie)){
		writeCbaCookie('1-1-1');
		newLocation = '/splash';
	}
	else{
		if(pg = document.cookie.match(/CB_AUDIENCE=(prof|parents)/)){
			writeCbaCookie(pg[1]);
			newLocation = '/'+pg[1];
		}	
		else{
			if((cookieValueArray = document.cookie.match(/CB_AUDIENCE=(\d),(\d),(\d)/))){
				writeCbaCookie(cookieValueArray[1]+'-'+cookieValueArray[2]+'-'+cookieValueArray[3]);				
				newLocation     = '/splash';
			}
			else{
				if((cookieValueArray = document.cookie.match(/CB_AUDIENCE=(\d)-(\d)-(\d)/))){
					writeCbaCookie(cookieValueArray[1]+'-'+cookieValueArray[2]+'-'+cookieValueArray[3]);				
					newLocation = '/splash';
				}
			}
		}
	}
}

if(newLocation){
	if(stay.test(url)){
		newLocation = newLocation + noredirect;
	}
	window.location.href = newLocation;
}
