function showResponse() {
	if((x = MM_findObj("response_wrapper"))!=null) x.style.visibility='visible';
	if((x = MM_findObj("response_bg"))!=null) x.style.visibility='visible';
}
function hideResponse() {
	if((x = MM_findObj("response_wrapper"))!=null) x.style.visibility='hidden';
	if((x = MM_findObj("response_bg"))!=null) x.style.visibility='hidden';
	if((x = MM_findObj("frm_response"))!=null) x.innerHTML = "Loading...";
	makeRequest('calendar-main','./quick_calendar.php','');
}
function showForm(){
	if((x = MM_findObj("rqformbg"))!=null) x.style.visibility='visible';
	if((x = MM_findObj("formcontainer"))!=null) x.style.display='block';
	scrolltoTop();
}
function hideForm(){
	if((x = MM_findObj("rqformbg"))!=null) x.style.visibility='hidden';
	if((x = MM_findObj("formcontainer"))!=null) x.style.display='none';
}
function showSuggestion(){
	if((x = MM_findObj("rqformbg"))!=null) x.style.visibility='visible';
	if((x = MM_findObj("suggestion_box"))!=null) x.style.display='block';
	scrolltoTop();
}
function hideSuggestion(){
	if((x = MM_findObj("rqformbg"))!=null) x.style.visibility='hidden';
	if((x = MM_findObj("suggestion_box"))!=null) x.style.display='none';

}

function scrolltoTop() {
	var ScrollTop = document.body.scrollTop;
	if (ScrollTop == 0)
	{	if (window.pageYOffset)
			ScrollTop = window.pageYOffset;
		else
			ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	
	if(ScrollTop >1)
	{	var t;
		scroll(0,ScrollTop*1/2);
		t=setTimeout('scrolltoTop()',1);
	}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function changeformdata( x, y)
{
	document.getElementById('frm_appt_id').value = x;
	document.getElementById('frm_appt').value = y;
}

function left(str, n){
	if (n <= 0)
	    return str;
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}



	var http_request = false;
	function makeRequest(source, url, parameters) {
		//alert("Called Make Request: [source]=" +source + " & [url] = " + url + " & [param] =" + parameters);
		http_request = false;
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
		
			//alert("XML HTP Request");		
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) {
				http_request.overrideMimeType('text/html');
				}
		} else if (window.ActiveXObject) { // IE
			//alert("ActiveX Request");
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e) {}
			}
		}


		if (!http_request) {
			//alert('Cannot create XMLHTTP instance');
			return false;
		}

		 if (source=="contactus")
		{	//alert('posting info from contactus');
			http_request.onreadystatechange = alertContactUsResponseSection;
			http_request.open('POST', url, true);
			http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			http_request.setRequestHeader("Content-length", parameters.length);
			http_request.setRequestHeader("Connection", "close");
			http_request.send(parameters);
		}
	}



	function alertContactUsResponseSection() 
	{		//alert('setting response message');
			if (http_request.readyState == 4)
			{
					if (http_request.status == 200) 
					{				//alert(http_request.responseText);
							result = http_request.responseText;
							document.getElementById('form-messages').innerHTML = result;
					} else {
							//alert('There was a problem with the request.');
					}
			}
	}

   
   function sendContactinfo(obj) 
   {	//alert("Called SendContact Info ");
   		   var poststr = "frm_name=" + escape(encodeURI( document.getElementById("frm_name").value ))  +
			        "&frm_message=" + escape(encodeURI( document.getElementById("frm_message").value )) + 
					"&frm_subject=" + escape(encodeURI( document.getElementById("frm_subject").value )) +
					"&frm_phone=" + escape(encodeURI( document.getElementById("frm_phone").value )) +
					"&frm_email=" + escape(encodeURI( document.getElementById("frm_email").value )) ;
					//alert("Collected Data into string");
	      makeRequest('contactus','/library/php-response.php', poststr);

   }
   



