function popHaze(){	
closedPop = false;
	i=10;
	j=10;
	maxHeight = 950;
	maxWidth = 700;
	speed = 10;
	obj = document.getElementById("foo");
	fades = document.getElementById("fader");
	obj.style.display="block";
	fades.style.display="block";
	calcInput = document.getElementById("userTotalUnsecuredDebt2");
	calcPopInput = document.getElementById("loanamount");
	if(!window.innerWidth) {
		fades.style.width = document.documentElement.clientWidth+"px";
	}else{
		fades.style.width = window.innerWidth+"px";
	}
	xer = document.documentElement.clientWidth/2;
	yer = document.documentElement.clientHeight/2;
	obj.style.top = yer+"px";
	finalX = xer - (maxWidth/2);
	fades.style.height = "100%";
	fades.style.minHeight = "2000px";
	/*function doWidth(){
		xer = document.documentElement.clientWidth/2;
		yer = document.documentElement.clientHeight/2;
		if(i*speed<maxWidth) {	
			i++;
			obj.style.left = (xer-(i*speed)/2)+"px";
			//alert(obj.style.width);
			obj.style.width = (i*speed)+"px";
		}
	}
	function doHeight() {
		if(j*speed<maxHeight) {	
			j++;
			obj = document.getElementById("foo");
			//alert(obj.style.width);
			if(!window.innerHeight) {
				obj.style.top = ((yer-(j*speed)/2)+170)+"px";
			}else{
				obj.style.top = ((yer-(j*speed)/2)+110)+"px";
			}
			obj.style.height = (j*speed)+"px";
		}	
	}*/
	doWidth = new Animator().addSubject(
    new NumericalStyleSubject(
        "foo",
        "width",
        0,
        maxWidth));
	doX = new Animator().addSubject(
    new NumericalStyleSubject(
        "foo",
        "left",
        xer,
        finalX));
	doHeight = new Animator().addSubject(
    	new NumericalStyleSubject(
        "foo",
        "height",
        0,
        maxHeight));
	doY = new Animator().addSubject(
    	new NumericalStyleSubject(
        "foo",
        "top",
        yer,
        0));
	fadeInCalc = new Animator().addSubject(
		new NumericalStyleSubject(
			"calculates",
			"opacity",
			0,
			1));
	function populateBox() {
		document.getElementById("caculates").style.display = 'block';	
		a = new Ajax('calc_pop.php', this);
		
	}
	setTimeout(populateBox, 2000);
	//setTimeout(calcOnPop, 2100);
	doWidth.toggle();
	doX.toggle();
	setTimeout("doHeight.toggle();doY.toggle();", 500);
	//setInterval(doWidth, 1);
	//setInterval(doHeight, 1);
	
	
	
}
function popHaze2(){	
	i=10;
	j=10;
	maxHeight = 300;
	maxWidth = 400;
	speed = 10;
	popDivName = "foo2";
	obj = document.getElementById(popDivName);
	fades = document.getElementById("fader");
	obj.style.display="block";
	fades.style.display="block";
	if(!window.innerWidth) {
		fades.style.width = document.documentElement.clientWidth+"px";
	}else{
		fades.style.width = window.innerWidth+"px";
	}
	xer = document.documentElement.clientWidth/2;
	yer = document.documentElement.clientHeight/2;
	obj.style.top = yer+"px";
	finalX = xer - (maxWidth/2);
	fades.style.height = "100%";
	fades.style.minHeight = "2000px";
	/*function doWidth(){
		xer = document.documentElement.clientWidth/2;
		yer = document.documentElement.clientHeight/2;
		if(i*speed<maxWidth) {	
			i++;
			obj.style.left = (xer-(i*speed)/2)+"px";
			//alert(obj.style.width);
			obj.style.width = (i*speed)+"px";
		}
	}
	function doHeight() {
		if(j*speed<maxHeight) {	
			j++;
			obj = document.getElementById("foo");
			//alert(obj.style.width);
			if(!window.innerHeight) {
				obj.style.top = ((yer-(j*speed)/2)+170)+"px";
			}else{
				obj.style.top = ((yer-(j*speed)/2)+110)+"px";
			}
			obj.style.height = (j*speed)+"px";
		}	
	}*/
	doWidth = new Animator().addSubject(
    new NumericalStyleSubject(
        popDivName,
        "width",
        0,
        maxWidth));
	doX = new Animator().addSubject(
    new NumericalStyleSubject(
        popDivName,
        "left",
        xer,
        finalX));
	doHeight = new Animator().addSubject(
    	new NumericalStyleSubject(
        popDivName,
        "height",
        0,
        maxHeight));
	doY = new Animator().addSubject(
    	new NumericalStyleSubject(
        popDivName,
        "top",
        yer,
        20));
	fadeInCalc = new Animator().addSubject(
		new NumericalStyleSubject(
			"calculates",
			"opacity",
			0,
			1));
	function populateBox() {
		document.getElementById("call_div").style.display = 'block';	
		a = new Ajax('http://service.ringcentral.com/ringme/callback.asp?mbid=9B8148F80F2CDC184F9315A5C08475B8579257462943,0,&amp;referer=http://www.FederalConsumerRelief.org/get-help-now/index.htm', this);
		
	}
	setTimeout(populateBox, 1000);
	//setTimeout(calcOnPop, 2100);
	doWidth.toggle();
	doX.toggle();
	setTimeout("doHeight.toggle();doY.toggle();", 500);
	//setInterval(doWidth, 1);
	//setInterval(doHeight, 1);
	
	
	
}
function Ajax(postUrl, scope){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById('caculates').innerHTML=xmlhttp.responseText;
			function calcOnPop(){
				calcPopInput = document.getElementById("loanamount");
				calcInput = document.getElementById("userTotalUnsecuredDebt2");
				if(calcInput.value !="" && calcInput.value !="Enter Your Debt Amount"){
					calcPopInput.value = calcInput.value;
					calculate();
				}
			}
			calcOnPop();
   			
		}
	  }
	xmlhttp.open("get", postUrl);
	xmlhttp.send(null);
}

var xmlhttp;
function loadXMLDoc(url, scoper)
{
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=state_Change(scoper);
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function state_Change(scope)
{
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
  if (xmlhttp.status==200)
    {// 200 = "OK"
	scope.calcOnPop();
    document.getElementById('caculates').innerHTML=xmlhttp.responseText;
    }
  else
    {
    alert("Problem retrieving data:" + xmlhttp.statusText);
    }
  }
}
function closePop2(){
	//document.getElementById('fader').style.display="none";
	document.getElementById('fader').style.width="0px";
	document.getElementById('fader').style.height="0px";
	//document.getElementById('foo').style.display="none";
	document.getElementById('foo2').style.width="1px";
	document.getElementById('foo2').style.height="1px";
	document.getElementById('foo2').style.top = -1000;
	document.getElementById('call_div').style.display = "none";
	closedPop = true;

}
//Form Functions
//Rollover functions for Nav igation and Nav drop down
inputs = new Array(["name", "Name"], ["email", "Email Address"], ["phone", "Phone Number"]);
textAreas = new Array(["comments", "Questions/Comments"]);

function clearLabel(divId){
	obj = document.getElementById(divId);
	if(obj.poped == false|| obj.poped == undefined){
		for(var i=0;i<textAreas.length;i++){
			if(divId==textAreas[i][0]){
				obj.innerHTML = "";
				return 0;
			}
		}
		obj.value ="";	
	}
}
function addLabel(divId){
	obj = document.getElementById(divId);
	for(var i=-0;i<textAreas.length;i++){
		if (divId==textAreas[i][0]){
			if(obj.value==''){
				obj.style.color="#999";
				obj.poped = false
				obj.innerHTML = "Questions/Comments";
			}
			return 0;
		}
	}
	if(obj.value ==""){
		obj.style.color="#999";
		obj.poped = false;
		switcher = "switch (divId){";
		for(var i=0;i<inputs.length;i++){
			switcher +=" case '"+inputs[i][0]+"': obj.value = '"+inputs[i][1]+"'; break;";
		}
		switcher +="}";
		eval (switcher);
	}
}
function closePop2(){
	//document.getElementById('fader').style.display="none";
	document.getElementById('fader').style.width="0px";
	document.getElementById('fader').style.height="0px";
	//document.getElementById('foo').style.display="none";
	document.getElementById('foo2').style.width="1px";
	document.getElementById('foo2').style.height="1px";
	document.getElementById('foo2').style.top = -1000;
	document.getElementById('call_div').style.display = "none";
}
function darkenText(divId){
	obj = document.getElementById(divId);
	obj.style.color="#000";
	obj.poped = true;
}
function getHead(img){
	document.getElementById('header').style.background = "url(images/"+img+") no-repeat";	
}
