function  billing_thesame() {
    var shipping = $F('shipping_address').evalJSON();
    var map = $H({
        'billing_address': 'address1', 
        'billing_address2': 'address2', 
        'billing_city': 'city', 
        'billing_state': 'state_id',
        'billing_zip': 'zip'
    });
    
    if ($('bill_equals_ship').checked) {
        map.each(function(p) {
            $(p.key).value = shipping[p.value];
        });
    }
    else {
        map.each(function(p) {
            $(p.key).value = '';
        });
        $('billing_state').options[0].selected = true;
    }
}

function findPos(obj) 
{
	var curleft = curtop = 0;
	if (obj.offsetParent) 
	{
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) 
		{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}

function calendarInit(id, format)
{
    var ddObj = document.getElementById(id);
    if (!ddObj) {
        return false;
    }
    format = format || "%B %e, %Y";
    
    var ddPos = findPos(ddObj);
    Calendar.setup({
        inputField : id, // ID of the input field
        ifFormat : format, // the date format
        button : id, // ID of the button
        showsTime : false,
        position: [ddPos[0], ddPos[1]+20]
    });
}

function clearSearchFields()
{
    document.getElementById('orderDateTo').value = '';
    document.getElementById('orderDateFrom').value = '';
    document.getElementById('caseNumber').value = '';
    document.getElementById('customerName').value = '';
}

function goToStep()
{
	window.location="/step/two/"+document.getElementById('sidenav_service').value;
}
