function xmlhttpPost(strURL, strFormName, strElem) {
        var xmlHttpReq = false;
	var strSubmit = formData2QueryString(strFormName)
        xmlHttpReq = getNewRequest();

	xmlHttpReq.open('POST', strURL, true);
        xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        xmlHttpReq.onreadystatechange = function() {
                if (xmlHttpReq.readyState == 4) {
                    document.getElementById(strElem).innerHTML = xmlHttpReq.responseText;
				setTimeout("closeBox('rsvp');",1300);
                }
        }
        xmlHttpReq.send(strSubmit);

}
function elementfade(opacity,cur,strElement){

	document.body.style.cursor = cur;
	document.getElementById(strElement).style.filter = "alpha(opacity:"+opacity+")";
// Older Mozilla and Firefox
document.getElementById(strElement).style.MozOpacity = opacity/100;
// Safari 1.2, newer Firefox and Mozilla, CSS3
document.getElementById(strElement).style.opacity = opacity/100;
}

function getNewRequest(){
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            http_request = new XMLHttpRequest();
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }
return http_request;
}


// The var docForm should be a reference to a <form>

function formData2QueryString(docForm) {

  var submitContent = '';
  var formElem;
  var lastElemName = '';
  
  for (i = 0; i < document.forms[docForm].elements.length; i++) {
    
    formElem = document.forms[docForm].elements[i];
    switch (formElem.type) {
      // Text fields, hidden form elements
      case 'text':
      case 'hidden':
      case 'password':
      case 'textarea':
      case 'select-one':
        submitContent += formElem.name + '=' + encodeURIComponent(formElem.value) + '&'
        break;
        
      // Radio buttons
      case 'radio':
        if (formElem.checked) {
          submitContent += formElem.name + '=' + escape(formElem.value) + '&'
        }
        break;
        
      // Checkboxes
      case 'checkbox':
        if (formElem.checked) {
          // Continuing multiple, same-name checkboxes
          if (formElem.name == lastElemName) {
            // Strip of end ampersand if there is one
            if (submitContent.lastIndexOf('&') == submitContent.length-1) {
              submitContent = submitContent.substr(0, submitContent.length - 1);
            }
            // Append value as comma-delimited string
            submitContent += ',' + escape(formElem.value);
          }
          else {
            submitContent += formElem.name + '=' + escape(formElem.value);
          }
          submitContent += '&';
          lastElemName = formElem.name;
        }
        break;

	//Multiple-Select
        case 'select-multiple':
	for (var c = 0; c < formElem.length; c++) {
	if (formElem.options[c].selected){
		if (formElem.name == lastElemName) {
			// Append value as comma-delimited string
			submitContent += ',' + escape(formElem.options[ c ].value);

        	  }
       		   else {
			submitContent += formElem.name + '=' + escape(formElem.options[ c ].value);
		}
		lastElemName = formElem.name;
		}
	}
	submitContent += '&';
	break; 

	}
  }
  // Remove trailing separator
  submitContent = submitContent.substr(0, submitContent.length - 1);
  return submitContent;

}


var inView = function(element){
	var elemSize = $(element).getDimensions();
	var windowPos = document.viewport.getScrollOffsets();
	var windowSize = document.viewport.getDimensions();
	var mTop = windowSize.height / 2 - elemSize.height / 2 + windowPos.top;
	var mLeft = windowSize.width / 2 - elemSize.width / 2;
		$(element).setStyle({
 		top: mTop+'px',
 		left: mLeft+'px'
		})
}



function fader(what, opacity){
what=document.getElementById(what);
opacity = (opacity == 100)? 99.999 : opacity;
// IE/Win
what.style.filter = "alpha(opacity:"+opacity+")";
// Older Mozilla and Firefox
what.style.MozOpacity = opacity/100;
// Safari 1.2, newer Firefox and Mozilla, CSS3
what.style.opacity = opacity/100;
}



var opened="rsvp";

function initbox(elem){
if($(opened).visible()){
$(opened).toggle()
}
opened=elem;
$(elem).toggle();
inView(elem);
}

function closeBox(elem){
$(elem).toggle();
}

function endIntro(){
$('bg_img').toggle();
$('container').scrollTo()
$('intro_img').toggle();
}


//check = new Array(); //this is an array that stores all the true/false values for each checkbox

function checkBox(id)
    {

    if(id==1) //if a value is not true, use this rather than == false, 'cos the first time no value will be set and it will be undefined, not true or false
        {
        $('imgCheck1').src = "checked.jpg"; //change the image
        $('inputCheck1').value = "true"; //change the field value
        $('imgCheck2').src = "unchecked.jpg";
        $('inputCheck2').value = "false";

        }
    else
        {
        $('imgCheck1').src = "unchecked.jpg"; //change the image
        $('inputCheck1').value = "false"; //change the field value
        $('imgCheck2').src = "checked_no.jpg";
        $('inputCheck2').value = "true";
        }
    }
function sayit(){
alert("Sorry, I can't figure out who you are\nShoot us an email if you would like to attend.\n<thathoosier@yahoo.com>"); 
}
