// JavaScript Document
//Site Dimmer Version 0.5
//Cynet Design

//picID should be an empty Div tag, Pic should be a picture of the color you want the site to dim to, dim is
//how dark you want the site (dimIE is in % but dont put the  % sign, dimElse is in decimal with 1 = 100%)
//time is how fast dimming should take 
//dimmer works with IE7 and below and newer versions of Firefox Opera and Safari BUT NOT IE 8 (because its sucks)
//note Video HTML and VideoID are not nessisary if you are just dimming
var c = 0;
var t;
var dimVal = 0;
var dimValIE = 0;
var brightVal;
var brightIE;
function siteDimmer(picId, pic , dimIE,dimElse, time, videoHTML,videoId){
		document.getElementById(picId).innerHTML = "<img src="+pic+" border='0' />";
		var time1 = time * 10;
		var rateElse = dimElse / time1;
		var rateIE = dimIE / time1;
		
		Dimmer(picId,dimIE, dimElse, rateElse, rateIE,videoHTML,videoId);
}
function Dimmer(picID,dimIE,dimElse,rateElse, rateIE,videoHTML,videoId){
	dimVal = dimVal + rateElse;
	dimValIE = dimValIE + rateIE; 
	document.getElementById(picID).style.opacity = dimVal+"";
	document.getElementById(picID).style.filter = "Alpha(Opacity="+dimValIE+")";
	t = setTimeout(function(){Dimmer(picID,dimIE,dimElse,rateElse,rateIE,videoHTML,videoId);} , 10);
	if(dimVal >= dimElse){
	clearTimeout(t);
	videoUp(videoHTML,videoId);
	dimVal=0;
	dimValIE=0
	}
}
//Site Brightner, does everyting. . .in reverse!
//all imput vaule meanings are same as above, except dimElse and dimIE are how far they are undimming
//note if you dont need the video removal funtcion REMOVIE IT!

function siteBrighter(picId, pic, dimIE,dimElse, time,videoId){
		var time1 = time * 10;
		var rateElse = dimElse / time1;
		var rateIE = dimIE / time1;
		brightVal = dimElse;
		brightValIE = dimIE;
		Brighter(picId, rateElse, rateIE, videoId);
}
function Brighter(picID,rateElse, rateIE,videoId){
	brightVal = brightVal - rateElse;
	brightValIE = brightValIE - rateIE; 
	document.getElementById(picID).style.opacity = brightVal+"";
	document.getElementById(picID).style.filter = "Alpha(Opacity="+0+")";
	t = setTimeout(function(){Brighter(picID,rateElse,rateIE,videoId);} , 10);
	if(brightVal <= 0){
	clearTimeout(t);
	document.getElementById(picID).innerHTML = "";
	document.getElementById(videoId).innerHTML = "";
	
	}
}
// places video, put full HTML in global Variable
function videoUp(videoHTML,videoId){
		document.getElementById(videoId).innerHTML = videoHTML;
}
	