var isIE6 = (navigator.userAgent.toLowerCase().substr(25,6)=="msie 6") ? true : false;
var cWidth=document.documentElement.clientWidth;
var cHeight=document.documentElement.clientHeight;	
var t=0;

function modalState(id,state,l){
	var mode = document.getElementById(id);
	var lPos=(cWidth/2)-l;
	var $scrollingDiv = $("#"+id);
	var offset = $scrollingDiv.offset();

	if (cHeight<=768){
		t=5;	
	} else {
		t=(cHeight/6);
	}

	switch(state){
		case "show":
		$(mode).fadeIn('slow');
		mode.style.top=offset.top+t+"px";
		mode.style.left=lPos+"px";
		
		break; 
		
		case "hide":
		$(mode).fadeOut();
		break;
	}
	
$().ready(function() {
	$(window).scroll(function(){			
		$scrollingDiv
			.stop()
			.animate({"top": ($(window).scrollTop()+t) + "px"}, "slow" );	
	});
	
	$(window).resize(function() {
		cWidth=document.documentElement.clientWidth;
		cHeight=document.documentElement.clientHeight;	
	});
});	
}

function dimmer(layer,state){
	var dimmerSettings=document.getElementById(layer);
	if(!isIE6){
		dimmerSettings.style.display=state;
		dimmerSettings.style.position="fixed";
	} else {
		if (cHeight<910){
			cHeight="1000px";	
		}
		dimmerSettings.style.display=state;
		dimmerSettings.style.height=cHeight;
		dimmerSettings.style.width=cWidth;
	}
}
