function opacity(id, opacStart, opacEnd, millisec) {

    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }

}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function illuminate(month,day,year){

document.asdf.x_month.value = month;
document.asdf.x_day.value = day;
document.asdf.x_year.value = year;

data = "<div style=text-align:right;><span onClick=closeBox() style=cursor:pointer;color:#F00;font-weight:bold;>X</span></div><br>";
data += "<div class=q style=width:250px><center>"+month+" "+day+"</center></div><br>";
data += "<div class=d style=width:250px><center>Start Time:&nbsp;<select name=start_hour onChange=document.asdf.x_start_hour.value=this.value><option value=12>12</option><option value=1>1</option><option value=2>2</option><option value=3>3</option><option value=4>4</option><option value=5>5</option><option value=6>6</option><option value=7>7</option><option value=8>8</option><option value=9>9</option><option value=10>10</option><option value=11>11</option></select>&nbsp;:&nbsp;";
data += "<select name=start_minute onChange=document.asdf.x_start_minute.value=this.value><option value=0>00</option><option value=10>10</option><option value=20>20</option><option value=30>30</option><option value=40>40</option><option value=50>50</option></select>&nbsp;";
data += "<select name=start_am onChange=document.asdf.x_start_am.value=this.value><option value=pm>PM</option><option value=am>AM</option></select>";
data += "<br><br>";
data += "&nbsp;&nbsp;End Time:&nbsp;<select name=end_hour onChange=document.asdf.x_end_hour.value=this.value><option value=12>12</option><option value=1>1</option><option value=2>2</option><option value=3>3</option><option value=4>4</option><option value=5>5</option><option value=6>6</option><option value=7>7</option><option value=8>8</option><option value=9>9</option><option value=10>10</option><option value=11>11</option></select>&nbsp;:&nbsp;";
data += "<select name=end_minute onChange=document.asdf.x_end_minute.value=this.value><option value=0>00</option><option value=10>10</option><option value=20>20</option><option value=30>30</option><option value=40>40</option><option value=50>50</option></select>&nbsp;";
data += "<select name=end_am onChange=document.asdf.x_end_am.value=this.value><option value=pm>PM</option><option value=am>AM</option></select>";
data += "<br><br></center></div>";
data += "</div><center><span onClick=darken() class=q style=cursor:pointer>Add&nbsp;date&nbsp;and&nbsp;close</span><br><br></center>";
if(navigator.appName == "Microsoft Internet Explorer"){
myspeed = 200;
} else {
myspeed = 500;
}
opacity('foo', 0, 100, (myspeed+100));
document.getElementById('foo').innerHTML=data;
if(navigator.appName == "Microsoft Internet Explorer"){
topnum = 150+document.body.scrollTop;

leftnum = document.body.clientWidth/2-document.getElementById('foo').offsetWidth/2;
} else {
topnum = (window.innerHeight/2-document.getElementById('foo').offsetHeight/2)+window.pageYOffset;
leftnum = window.innerWidth/2-document.getElementById('foo').offsetWidth/2;
}

document.getElementById('foo').style.top=topnum+"px";
document.getElementById('foo').style.left=leftnum+"px";
document.getElementById('foo').style.backgroundColor="#FFFFFF";
//document.getElementById('jeep').className='coffee_active';
//opacity('jeep',0,60,myspeed);
}


function clearDates(){
document.asdf.alldates.value = "";
document.getElementById('datediv').style.display = "none";
document.getElementById('datediv').innerHTML = "";
document.getElementById('clearlink').style.display = "none";
eraseCookie('alldates');
}

function darken(){
///////////this is neow!  make a script to see if idiots put end time after start time
poo = document.asdf;
if(poo.x_start_am.value == "pm"){
var tempstarthours = parseInt(poo.x_start_hour.value) + 12;
} else {
var tempstarthours = poo.x_start_hour.value;
}
if(poo.x_end_am.value == "pm" && poo.x_end_hour.value != "12"){
var tempendhours = parseInt(poo.x_end_hour.value) + 12;
} else {
var tempendhours = poo.x_end_hour.value;
}
if(poo.x_end_am.value == "am" && poo.x_end_hour.value == "12"){
var tempendhours = parseInt(poo.x_end_hour.value) + 13;
}
//alert(poo.x_month.value+" "+poo.x_day.value+", "+poo.x_year.value+" "+tempstarthours+":"+poo.x_start_minute.value);
var jsst = Number(new Date(poo.x_month.value+" "+poo.x_day.value+", "+poo.x_year.value+" "+tempstarthours+":"+poo.x_start_minute.value));
var jset = Number(new Date(poo.x_month.value+" "+poo.x_day.value+", "+poo.x_year.value+" "+tempendhours+":"+poo.x_start_minute.value));
//alert("start: "+jsst+" End:"+jset);
if(jset < jsst){
alert("Your end time occurs before your start time occurs.\n\nBe sure to check your AM on the end time.");
exit();
}


if(document.asdf.alldates.value == "" && document.asdf.x_start_hour != "12" && document.asdf.x_end_hour != "12"){
document.asdf.alldates.value = document.asdf.x_month.value+" "+document.asdf.x_day.value+" From "+document.asdf.x_start_hour.value+":"+document.asdf.x_start_minute.value+" "+document.asdf.x_start_am.value.toUpperCase()+" To "+document.asdf.x_end_hour.value+":"+document.asdf.x_end_minute.value+" "+document.asdf.x_end_am.value.toUpperCase()+" "+document.asdf.x_year.value;
document.getElementById('datediv').innerHTML = document.asdf.x_month.value+" "+document.asdf.x_day.value+" From "+document.asdf.x_start_hour.value+":"+document.asdf.x_start_minute.value+" "+document.asdf.x_start_am.value.toUpperCase()+" To "+document.asdf.x_end_hour.value+":"+document.asdf.x_end_minute.value+" "+document.asdf.x_end_am.value.toUpperCase()+" "+document.asdf.x_year.value;
document.getElementById('datediv').style.display = "block";
document.getElementById('clearlink').style.display = "block";
} else {
document.asdf.alldates.value += ", "+document.asdf.x_month.value+" "+document.asdf.x_day.value+" From "+document.asdf.x_start_hour.value+":"+document.asdf.x_start_minute.value+" "+document.asdf.x_start_am.value.toUpperCase()+" To "+document.asdf.x_end_hour.value+":"+document.asdf.x_end_minute.value+" "+document.asdf.x_end_am.value.toUpperCase()+" "+document.asdf.x_year.value;
document.getElementById('datediv').innerHTML += ", "+document.asdf.x_month.value+" "+document.asdf.x_day.value+" From "+document.asdf.x_start_hour.value+":"+document.asdf.x_start_minute.value+" "+document.asdf.x_start_am.value.toUpperCase()+" To "+document.asdf.x_end_hour.value+":"+document.asdf.x_end_minute.value+" "+document.asdf.x_end_am.value.toUpperCase()+" "+document.asdf.x_year.value;

}
document.asdf.x_start_hour.value = "12";
document.asdf.x_start_minute.value = "00";
document.asdf.x_start_am.value = "pm";
document.asdf.x_end_hour.value = "12";
document.asdf.x_end_minute.value = "00";
document.asdf.x_end_am.value = "pm";
///////set cookie for info
createCookie('alldates',document.asdf.alldates.value,30)
opacity('foo',100,0,myspeed);
//opacity('jeep',60,0,myspeed);
setTimeout("clearItUp()",myspeed);

}


function closeBox(){
opacity('foo',100,0,myspeed);
//opacity('jeep',60,0,myspeed);
setTimeout("clearItUp()",myspeed);
}


function clearItUp(){
//document.getElementById('jeep').className='coffee';
document.getElementById('foo').innerHTML='';
document.getElementById('foo').style.top="0";
document.getElementById('foo').style.left="0";
}
function closeOver(){
document.getElementById('boxes').src='images/close_over.png';
}
function closeOut(){
document.getElementById('boxes').src='images/close.png';
}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
