// JavaScript Document

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

var ver = 0;

if (isIE)
{
	try
	{
		ver = parseFloat(navigator.appVersion.substr(navigator.appVersion.lastIndexOf("MSIE") + 5, 3));
	}
	catch(e)
	{
		ver = 0;
	}
}
//alert(ver);

function onMouseOver(Src)
{
	try
	{
		Src.style.background = "#B1D9F3";

		for (var i = 0; i < Src.childNodes.length; i++)
		{
			Src.childNodes[i].style.background = "#B1D9F3";
			Src.childNodes[i].style.color = "#FFFFFF";
		}
	}
	catch (e)
	{
		//alert(e.message);
	}
}

function onMouseOut(Src)
{
	try
	{
		Src.style.background = "";

		for (var i = 0; i < Src.childNodes.length; i++)
		{
			Src.childNodes[i].style.background = "";
			Src.childNodes[i].style.color = "#FFFFFF";
		}
	}
	catch (e)
	{
		//alert(e.message);
	}
}

function onMouseOver1(Src)
{
	try
	{
		Src.style.background = "#B1D9F3";

		for (var i = 0; i < Src.childNodes.length; i++)
		{
			Src.childNodes[i].style.background = "#B1D9F3";
			Src.childNodes[i].style.color = "#FFFFFF";
		}
	}
	catch (e)
	{
		//alert(e.message);
	}
}

function onMouseOut1(Src)
{
	try
	{
		Src.style.background = "#748A98";

		for (var i = 0; i < Src.childNodes.length; i++)
		{
			Src.childNodes[i].style.background = "#748A98";
			Src.childNodes[i].style.color = "#FFFFFF";
		}
	}
	catch (e)
	{
		//alert(e.message);
	}
}

function onLogin()
{
	if (_Login.value == "")
		return;
		
	var s = _Login.value;
	switch(s.toLowerCase())
	{
		case "infigure" :
			window.open('http://80.179.16.129/Monitoring/Monitoring.html');
			document.getElementById("_ClientsLogin").innerHTML = "";
			break;
			
		case "meir" :
			document.getElementById("_Img").src = "Images/" + s.toLowerCase() + "Login.jpg";
			document.getElementById("_Title").innerText = "Statistics - Meir Medical Center";
			document.getElementById("_dvMain").innerHTML = doClientsLogin(s.toLowerCase());
			document.getElementById("_ClientsLogin").innerHTML = "";
			break;
			
		case "rabin" :
			document.getElementById("_Img").src = "Images/" + s.toLowerCase() + "Login.jpg";
			document.getElementById("_Title").innerText = "Statistics - Rabin Medical Center";
			document.getElementById("_dvMain").innerHTML = doClientsLogin(s.toLowerCase());
			document.getElementById("_ClientsLogin").innerHTML = "";
			break;
 			  
		case "schneider" :
			document.getElementById("_Img").src = "Images/" + s.toLowerCase() + "Login.jpg";
			document.getElementById("_Title").innerText = "Statistics - Schneider Children's Medical Center of Israel";
			document.getElementById("_dvMain").innerHTML = doClientsLogin(s.toLowerCase());
			document.getElementById("_ClientsLogin").innerHTML = "";
			break;
	}
	//alert(_Login.value);
}

function doClientsLogin(Client)
{
	var retVal = "";
		
	retVal += '<table width="700">';
	switch (Client)
	{
		case "meir" :
			retVal += '<tr>';
			retVal += '<td width="333" align="left">';
			retVal += '<label onclick=window.open("http://91.135.106.39/Statistics/Statistics.html"); style="font-size:12px; font-family:MS Reference Sans Serif; cursor:pointer;">Hospitalization</label>';
			retVal += '</td>';
			retVal += '</tr>';
			retVal += '<tr>';
			retVal += '<td width="333" align="left">';
			retVal += '<label onclick=window.open("http://80.179.220.179/Statistics/Statistics.html"); style="font-size:12px; font-family:MS Reference Sans Serif; cursor:pointer;">Clinics</label>';
			retVal += '</td>';
			retVal += '</tr>';
			break;
		
		case "rabin" :
			retVal += '<tr>';
			retVal += '<td width="333" align="left">';
			retVal += '<label onclick=window.open("http://91.135.106.33/Statistics/Statistics.html"); style="font-size:12px; font-family:MS Reference Sans Serif; cursor:pointer;">Gur Shasha</label>';
			retVal += '</td>';
			retVal += '</tr>';
			break;

		case "schneider" :
			retVal += '<tr>';
			retVal += '<td width="333" align="left">';
			retVal += '<label onclick=window.open("http://91.135.106.38/Statistics/Statistics.html"); style="font-size:12px; font-family:MS Reference Sans Serif; cursor:pointer;">Schneider</label>';
			retVal += '</td>';
			retVal += '</tr>';
			break;
	}
	retVal += '<tr><td height="10"></td></tr>';
	retVal += '<tr>';
	retVal += '</table>';
	
	return retVal;
}

function doStatistics()
{
	//doHttpRequest("Statistics.aspx");
}

function doHttpRequest(url)
{
    var Request = null;

	try
	{
		// Mozilla-based browsers	
		if (window.XMLHttpRequest) 
			Request = new XMLHttpRequest();	
		else if (window.ActiveXObject) 
		{		
			Request = new ActiveXObject("Msxml2.XMLHTTP");		
			if (!Request) 
				Request = new ActiveXObject("Microsoft.XMLHTTP");		
		}
	}
	catch (e)
	{
		alert("doHttpRequest :: " + e.message);
		Request = null;
	}                
				
	if (Request)
	{
		try
		{
			var url = url;// + "?sid=" + Math.random();
//alert("doHttpRequest :: " + url);
			
//			Request.onreadystatechange = handleResponse;
			Request.open("POST", url, false);
			Request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			Request.send("sid=" + Math.random());
		}
		catch (e)
		{
			alert("doHttpRequest :: " + e.message);
		}
	}
}

function checkClient()
{
	try
	{
		if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
			location.replace("/Mobile/Infigure.Html");
		else if (navigator.userAgent.match(/Symbian/i))//(navigator.userAgent.indexOf("Symbian") != -1)
			location.replace("/Mobile/Infigure.Html");
		else
			document.getElementById('_Body').style.visibility = 'visible';
	}
	catch (e)
	{
		//alert("doHttpRequest :: " + e.message);
		document.getElementById('_Body').style.visibility = 'visible';
	}
}
