function know_thy_width(){
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		winW = window.innerWidth;
		winH = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		winW = document.documentElement.clientWidth;
		winH = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		winW = document.body.clientWidth;
		winH = document.body.clientHeight;
	}
	
	document.getElementById('filter').style.width = winW + 'px';
	document.getElementById('filter').style.height = winH + 'px';
}

function gradient(id, level)
{
	var box = document.getElementById(id);
	box.style.opacity = level;
	box.style.MozOpacity = level;
	box.style.KhtmlOpacity = level;
	box.style.filter = "alpha(opacity=" + level * 100 + ")";
	box.style.display="block";
	return;
}


function fadein(id) 
{
	var level = 0;
	while(level <= 1)
	{
		setTimeout( "gradient('" + id + "'," + level + ")", (level* 1000) + 10);
		level += 0.01;
	}
}


// Open the lightbox

function step_1_done(){

    var date_arr=document.free_estimate_form_start.moving_date.value.split('/'); 
    
    move_month = date_arr[0];
	move_date =  date_arr[1];
	move_year =  date_arr[2];

	//move_month = document.free_estimate_form_start.move_month.value;
	//move_date = document.free_estimate_form_start.move_date.value;
	//move_year = document.free_estimate_form_start.move_year.value;

              if 	(selected_movers=='Local movers')
              {     
    zip_from = document.free_estimate_form_start.zip_from_start.value;
	//zip_to = document.free_estimate_form_start.zip_to_start.value;

	 new Ajax.Updater('box','/files/local_movers/free_estimate.php?zip_from='+zip_from+'&move_date='+move_date+'&move_month='+move_month+'&move_year='+move_year,{ method: 'get', evalScripts: true, onFailure: function(){ alert('Something went wrong with Interstate movers...') } });
              }
              
              
              if 	(selected_movers == 'Interstate movers')
              {
    zip_from = document.free_estimate_form_start.zip_from_start.value;
	zip_to = document.free_estimate_form_start.zip_to_start.value;
	
	 new Ajax.Updater('box','/files/interstate_movers/free_estimate.php?zip_from='+zip_from+'&zip_to='+zip_to+'&move_date='+move_date+'&move_month='+move_month+'&move_year='+move_year,{ method: 'get', evalScripts: true, onFailure: function(){ alert('Something went wrong with Interstate movers...') } });
              }
              
              
              if 	(selected_movers == 'International movers')
              {
              	
              	    zip_from = document.free_estimate_form_start.zip_from_start.value;
	country_to = document.free_estimate_form_start.country_to_start.value;
              	
      new Ajax.Updater('box','/files/international_movers/free_estimate.php?zip_from='+zip_from+'&country_to='+country_to+'&move_date='+move_date+'&move_month='+move_month+'&move_year='+move_year,{ method: 'get', evalScripts: true, onFailure: function(){ alert('Something went wrong with Interstate movers...') } });
              }
              
              
              if 	(selected_movers == 'Auto movers')
              { 
              	
    zip_from = document.free_estimate_form_start.zip_from_start.value;
	zip_to = document.free_estimate_form_start.zip_to_start.value;
              	
 	 new Ajax.Updater('box','/files/auto_transport/free_estimate.php?zip_from='+zip_from+'&zip_to='+zip_to+'&move_date='+move_date+'&move_month='+move_month+'&move_year='+move_year,{ method: 'get', evalScripts: true, onFailure: function(){ alert('Something went wrong with Auto movers...') } });             	
              }
              
              
              if 	(selected_movers == 'Storage')
              { 
              	
              	    zip_from = document.free_estimate_form_start.zip_from_start.value;
              	
   	 new Ajax.Updater('box','/files/storage/free_estimate.php?zip_from='+zip_from+'&move_date='+move_date+'&move_month='+move_month+'&move_year='+move_year,{ method: 'get', evalScripts: true, onFailure: function(){ alert('Something went wrong with Interstate movers...') } });           	
              }


	

//	document.getElementById('moving_date').innerHTML='Move Date: ' + move_month + '/' + move_date + '/' + move_year + '<input type="hidden" name="MM" value="' + move_month + '"> <input type="hidden" name="DD" value="' + move_date + '"> <input type="hidden" name="YY" value="' + move_year + '">';
//	document.getElementById('moving_from').innerHTML='Moving From: ' + zip_from;
//	document.getElementById('moving_to').innerHTML='Moving To: ' + zip_to;
	
//	document.free_estimate_form.zip_from.value = zip_from;
//	document.free_estimate_form.zip_to.value = zip_to;
	
//	document.free_estimate_form.move_date.value=move_date;
//	document.free_estimate_form.move_month.value=move_month;
//	document.free_estimate_form.move_year.value=move_year;

}

function openbox(free_estimate_form_start, fadin){
	
	
	zip_from = document.free_estimate_form_start.zip_from_start.value;
    if 	(selected_movers != 'International movers' && selected_movers != 'Storage' && selected_movers != 'Local movers')	zip_to = document.free_estimate_form_start.zip_to_start.value;
    
    var date_arr=document.free_estimate_form_start.moving_date.value.split('/'); 
    
    move_month = date_arr[0];
	move_date =  date_arr[1];
	move_year =  date_arr[2];
    
	//move_month = document.free_estimate_form_start.move_month.value;
	//move_date = document.free_estimate_form_start.move_date.value;
	//move_year = document.free_estimate_form_start.move_year.value;
    
	if 	(selected_movers == 'International movers') country_to = document.free_estimate_form_start.country_to_start.value;
	
	if ($("state_from_1").value == $("state_to_1").value) {}
	
	var reg=/^\d{5}$/;
    var form_okay=true;
    
    
    if (selected_movers=='') { alert('Please select type of move to continue');form_okay=false; return form_okay; }
    
   if ((selected_movers=='Interstate movers' || selected_movers=='Auto movers')) {
	if((zip_from == '' || zip_to == '' || !reg.test(zip_from) || !reg.test(zip_to) )) { alert('Please verify that both ZIP code fields are correct to continue'); form_okay=false;  return form_okay; }    
	}
	
	   if ((selected_movers=='Local movers' || selected_movers=='Storage')) {
	if((zip_from == '' || !reg.test(zip_from) )) { alert('Please verify that ZIP code field are correct to continue'); form_okay=false;  return form_okay; }    
	}
	
	if (selected_movers=='International movers' ) {
		if(zip_from == '' || country_to == '' || !reg.test(zip_from)  ){ alert('Please verify that ZIP code fields are correct or choose country to continue'); form_okay=false;  return form_okay; }    
	}
	
	
//	if (!($("state_from_1").value == $("state_to_1").value) && (selected_movers=='Local movers')) { alert('You select not same states! \n Maybe you need interstate moving?'); form_okay=false;  return form_okay; }
	
//	if (($("state_from_1").value == $("state_to_1").value) && (selected_movers=='Interstate movers')) { alert('You select same states! \n Maybe you need local moving?'); form_okay=false;  return form_okay; }
	
	if(move_month == '' || move_date == '' || move_year == '' ){ alert('Please verify that all date fields are correct to continue'); form_okay=false;  return form_okay; }
	
	
	if (form_okay) { 
		
		step_1_done();
	
		//document.body.style.overflow='hidden';
		
	//	document.getElementById('zip_container_from').style.display='none';
	//	document.getElementById('zip_container_to').style.display='none';
	//	document.getElementById('show_calendar').style.display='none';
	
		var box = document.getElementById('box'); 
		document.getElementById('filter').style.display='block';
		if (document.body.offsetHeight >= document.getElementById('main-div').offsetHeight)
		document.getElementById('filter').style.height=document.body.offsetHeight+ 'px';
		else
		document.getElementById('filter').style.height=document.getElementById('main-div').offsetHeight+ 'px';
		document.getElementById('filter').style.width=(document.body.scrollWidth)+ 'px';
		

	//	var btitle = document.getElementById('boxtitle');
	//	btitle.innerHTML = 'Free Household Moving Quote';
  
		//myform.from_zip.value = free_estimate_form_start.SZIP.value;
		//myform.to_zip.value = free_estimate_form_start.RZIP.value;
	

	
		if(fadin){
			gradient("box", 0);
			fadein("box");
		}else{ 	
			box.style.display='block';
		}
	}
}


// Close the lightbox

function closebox()
{
   document.getElementById('box').style.display='none';
   document.getElementById('filter').style.display='none';
	document.body.style.overflow='auto';
}




