var dir;
function grow(targetid){
	theheight=document.getElementById(targetid).offsetHeight;
	thewidth=document.getElementById(targetid).offsetWidth;
if(dir=="down"){
			document.getElementById(targetid).style.display="block";
		if(theheight<300){
		document.getElementById(targetid).style.height=theheight+10+'px';
		}else if(theheight<350){
		document.getElementById(targetid).style.height=theheight+50+'px';
		}else{
			//<img src=images/ajax/ajax-loader2.gif width=16 height=16>
			//document.getElementById(targetid).innerHTML='<a href="#" onclick="growless(\'slimThis\');return false">Close</a>';
	callPage2(nextToLoad);
		clearInterval(change);
		}
}else{
		if(theheight>100){
			document.getElementById(targetid).innerHTML='';
			document.getElementById(targetid).style.height=theheight-50+'px';
		}else if(theheight>15){
			document.getElementById(targetid).innerHTML='';
			document.getElementById(targetid).style.height=theheight-20+'px';
		}else{
			document.getElementById(targetid).style.height='0px';
			document.getElementById(targetid).style.display="none";
			clearInterval(change);
		}
}
}
var nextToLoad;
function growmore(targetid,location){
	nextToLoad='html_parse/'+location;
	change=setInterval("grow('slimThis')",25);
	dir='down';
			document.getElementById(targetid).innerHTML='<img src=images/ajax/ajax-loader2.gif width=16 height=16>';
}
function growless(targetid){
	change=setInterval("grow('slimThis')",25);
	dir='up';
}

function callPage2(path){
	div2show='slimThis';
	//show loading animation in div - i put text in here for now
	document.getElementById(div2show).innerHTML =  '<img src=images/ajax/ajax-loader2.gif width=16 height=16>';
	http.open("GET", escape(path), true);
	http.onreadystatechange = updateDiv;
	http.send(null);
}

//<a href="#" onclick="growmore('slimThis');return false">Make Div Grow More</a><br>
//<a href="#" onclick="growless('slimThis');return false">Make Div Grow Less</a>

//start ignoring this section
function getHTTPObject2() {
    if (typeof XMLHttpRequest != 'undefined') {
        return new XMLHttpRequest();
    }
    try {
        return new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            return new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
    }
    return false;
}

//end ignore

var http = getHTTPObject2();
var div2show;

function callPage(path,div){
	div2show=div;
	//show loading animation in div - i put text in here for now
	document.getElementById(div2show).innerHTML =  '<img src=images/ajax/ajax-loader2.gif width=16 height=16>';
	http.open("GET", escape(path), true);
	http.onreadystatechange = updateDiv;
	http.send(null);
}

function updateDiv() {
	if (http.readyState == 4) {
	    //div2.style.visibility='visible';	
		//display document in div
		document.getElementById(div2show).innerHTML =  http.responseText;
	}
}

var xmlHttp = getHTTPObject2();

function submitContactForm() {
  var stringy=buildGetString('contactForm');
	var url = "php_parse/submitContactForm.php?" + stringy;
  	xmlHttp.open("POST", url, true);
 	xmlHttp.onreadystatechange = updateRep;
  	xmlHttp.send(null);  
}

function updateRep() {
  if (xmlHttp.readyState == 4) {
	  callPage('html_parse/c_thanks.php','contentDiv');
	}
}
var formNamer;
var r1;
function buildGetString (formName){
	formNamer=formName;
		var x=document.getElementById(formName);
		var stringy='';
		for (var i=0;i<x.length;i++){
			var sid=x.elements[i].name;
			r1=i;
				if(x.elements[i].type=='select'){
					var sva=getCheckedValue(i);
					//alert(sva);
				}else{
					var sva=x.elements[i].value;
				}
		  stringy=stringy+sid+'='+sva+'&';
		  }
		  return stringy;
}

function getCheckedValue(r1) {
	x2=document.getElementById(formNamer);
	x=x2.elements[r1].name;
	var sel = document.getElementById("x");
	var w=sel.options[sel.selectedIndex].value;
	return w;
}

