//<!--

//Open a popup window for the editor
function openPopup(url)
{
	width=520;
	height=550;
	x=parseInt(screen.width/ 2.0) - (width /2.0);
	y=parseInt(screen.height/ 2.0) - (height /2.0);
	
	var win=window.open(url,"editorPopup","top="+y+",left="+x+",scrollbars=no,dialog=yes,minimizable=no,modal=yes,width="+width+",height="+height+",resizable=no");
}

//Popup window for other popups
function openAPopup(url, x, y)
{
	width=x;
	height=y;
	x=parseInt(screen.width/ 2.0) - (width /2.0);
	y=parseInt(screen.height/ 2.0) - (height /2.0);
	
	var win=window.open(url,"popup","top="+y+",left="+x+",scrollbars=Yes,dialog=yes,minimizable=no,modal=yes,width="+width+",height="+height+",resizable=no");
}

function setupXmlHttp()
{
	var xmlHttp;
  
  	try
    {    
		// Firefox, Opera 8.0+, Safari    
		xmlHttp=new XMLHttpRequest();    
	}
  	catch (e)
    {   
		// Internet Explorer    
		try
      	{      
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		}
    	catch (e)
      	{      
			try
        	{        
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			}
      		catch (e)
        	{        
				alert("Your browser does not support AJAX!");        
				return false;        
			}      
		}    
	}
	
	return xmlHttp;
}

function ajaxFunction(therapyId)
{  
	if(therapyId > 0)
	{
		var xmlHttp = setupXmlHttp();
	
		try
	    {
			xmlHttp.onreadystatechange=function()
			{	
				if(xmlHttp.readyState==4)
	    		{
					//Set up seperator variables
					var _separator = ":";
					var separator = ",";
					//Get the ajax response
					var passedString = xmlHttp.responseText.substring(xmlHttp.responseText.indexOf('ajaxResults[')+12,xmlHttp.responseText.indexOf(']ajaxResults'));
					
					//Split the response into 2 arrays				
					var _arrays = passedString.split(_separator);
					//Split each array into its own array
					var dropVal = _arrays[0].split(separator);
					var dropText = _arrays[1].split(separator);
					
					//Apply the array contents to the availableDays dropdown
					if(dropVal[0] != "")
					{
						//Set the length of the dropdown
						document.getElementById("ctl00_contentPh_therapist").length = dropVal.length+1;
					
						//Add 'any' to the dropdown
						document.getElementById("ctl00_contentPh_therapist").options[0].value = -1;
						document.getElementById("ctl00_contentPh_therapist").options[0].text = "Please select a therapist...";
					
						//Apply the array contents to the dropdown
						for(x=1;x<=dropVal.length;x++)
						{
							document.getElementById("ctl00_contentPh_therapist").options[x].value = dropVal[x-1];
							document.getElementById("ctl00_contentPh_therapist").options[x].text = dropText[x-1];
						}
					}
					else
					{
						document.getElementById("ctl00_contentPh_therapist").length = 1;
					
						//Add 'any' to the dropdown
						document.getElementById("ctl00_contentPh_therapist").options[0].value = -1;
						document.getElementById("ctl00_contentPh_therapist").options[0].text = "Please select a therapist...";
					}
	    		}
			}
		}
	    catch (e)
	    {        
			alert("Your browser does not support AJAX!");        
		}
		
		var url = "ajax/getTherapists.aspx?therapyId=" + therapyId;
	    
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);  
	}
	else
	{
		document.getElementById("ctl00_contentPh_therapist").length = 1;
					
		//Add 'any' to the dropdown
		document.getElementById("ctl00_contentPh_therapist").options[0].value = -1;
		document.getElementById("ctl00_contentPh_therapist").options[0].text = "Please select a therapist...";
	}
}

function ajaxReloadProfileContent(therapistId)
{  
		var xmlHttp = setupXmlHttp();
	
		try
	    {
			xmlHttp.onreadystatechange=function()
			{	
				if(xmlHttp.readyState==4)
	    		{
					//Get the ajax response
					var passedString = xmlHttp.responseText.substring(xmlHttp.responseText.indexOf('ajaxResults[')+12,xmlHttp.responseText.indexOf(']ajaxResults'));
				
					//Apply it to the page
					if(passedString.length > 0)
						document.getElementById("therapistProfileContent").innerHTML = passedString;
	    		}
			}
		}
	    catch (e)
	    {        
			alert("Your browser does not support AJAX!");        
		}
		
		var url = "../ajax/getTherapistProfile.aspx?therapistId=" + therapistId;
	    
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);  
}

function ajaxReloadTherapyContent(therapyId)
{  
		var xmlHttp = setupXmlHttp();
	
		try
	    {
			xmlHttp.onreadystatechange=function()
			{	
				if(xmlHttp.readyState==4)
	    		{
					//Get the ajax response
					var passedString = xmlHttp.responseText.substring(xmlHttp.responseText.indexOf('ajaxResults[')+12,xmlHttp.responseText.indexOf(']ajaxResults'));
				
					//Apply it to the page
					if(passedString.length > 0)
						document.getElementById("therapyDetailsContent").innerHTML = passedString;
	    		}
			}
		}
	    catch (e)
	    {        
			alert("Your browser does not support AJAX!");        
		}
		
		var url = "../ajax/getTherapyDetails.aspx?therapyId=" + therapyId;
	    
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);  
}

function ajaxReloadTherapistTherapyContent(therapistId, therapyId)
{  
		var xmlHttp = setupXmlHttp();
	
		try
	    {
			xmlHttp.onreadystatechange=function()
			{	
				if(xmlHttp.readyState==4)
	    		{
					//Get the ajax response
					var passedString = xmlHttp.responseText.substring(xmlHttp.responseText.indexOf('ajaxResults[')+12,xmlHttp.responseText.indexOf(']ajaxResults'));
				
					//Apply it to the page
					document.getElementById("therapyDetailsContent").innerHTML = passedString;
	    		}
			}
		}
	    catch (e)
	    {        
			alert("Your browser does not support AJAX!");        
		}
		
		var url = "../ajax/getTherapistTherapyDetails.aspx?therapistId=" + therapistId + "&therapyId=" + therapyId;
	    
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);  
}

function hpClick()
{
    if(document.getElementById("ctl00_contentPh_therapist").value != '-1')
        window.location.href = document.getElementById("ctl00_contentPh_therapist").value;
    else if (document.getElementById("ctl00_contentPh_therapies").value != '-1')
        window.location.href = "therapy.aspx?therapyId=" + document.getElementById("ctl00_contentPh_therapies").value;
}

//-->
