// pharmachannel.js
// Function to popup windows with specified width en height
function WindowPopup(URL, width, height)
{
day = new Date();
id = day.getTime();
w_left = screen.availWidth / 2 - width / 2;
w_top = screen.availHeight / 2 - height / 2;
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height+',left='+w_left+',top='+w_top+',screenX='+w_left+',screenY='+w_top);");
}
function ResizablePopup(URL, width, height)
{
day = new Date();
id = day.getTime();
w_left = screen.availWidth / 2 - width / 2;
w_top = screen.availHeight / 2 - height / 2;
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + width + ',height=' + height+',left='+w_left+',top='+w_top+',screenX='+w_left+',screenY='+w_top);");
}
// Function to attach the follow function to the onmousemove event
function startFollowingMouse()
{
document.onmousemove = follow;
}
// Prototype function to compare arrays
Array.prototype.compareArrays = function(arr)
{
if (this.length != arr.length)
return false;
for (var i = 0; i < arr.length; i++)
{
if (this[i].compareArrays)
{ //likely nested array
if (!this[i].compareArrays(arr[i]))
return false;
else
continue;
}
if (this[i] != arr[i])
return false;
}
return true;
}
String.prototype.visualLength = function()
{
var ruler = document.getElementById("ruler");
ruler.innerHTML = this;
return ruler.offsetWidth;
}
String.prototype.trimToPx = function(length)
{
var tmp = this;
var trimmed = this;
if (tmp.visualLength() > length)
{
trimmed += "...";
while (trimmed.visualLength() > length)
{
tmp = tmp.substring(0, tmp.length-1);
trimmed = tmp + "...";
}
}
return trimmed;
}
xmlhttp = getxmlhttp();
// Function to create a XMLHttp Object.
function getxmlhttp ()
{
var xmlhttp = false;
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (E)
{
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
// Function to process the return value from de login function
function processLogin()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
var loginResult = eval('(' + xmlhttp.responseText + ')');
if (loginResult.loggedIn)
document.location = "uitleg.html";
else
{
document.getElementById("password_error").innerHTML = ' ' + loginResult.error;
document.getElementById("loginButtonHolder").innerHTML =
'';
}
}
}
// Function to submit login form
function submitLogin ()
{
document.getElementById("login_error").innerHTML = '';
document.getElementById("password_error").innerHTML = '';
if (document.getElementById("login").value != '')
{
if (document.getElementById("password").value != '')
{
document.getElementById("loginButtonHolder").innerHTML =
'
' +
'
Controleren gegevens...
';
var query = "login=" + document.getElementById("login").value + "&password=" + document.getElementById("password").value;
xmlhttp.open("POST", "/mijnapotheek/login.php", true);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
xmlhttp.onreadystatechange = processLogin;
xmlhttp.send(query);
}
else
{
document.getElementById("password_error").innerHTML = ' U moet een wachtwoord invullen!';
}
}
else
{
document.getElementById("login_error").innerHTML = ' U moet een login code invullen!';
}
}
// Function to log a location out
function logout()
{
xmlhttp.open("GET", "/mijnapotheek/logout.php", true);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.location = "/mijnapotheek/login.html";
}
}
xmlhttp.send(null);
}
// Functinos to retreive the absolute position of an element
function findPosX(obj)
{
var curleft = 0;
if(obj.offsetParent)
while(1)
{
curleft += obj.offsetLeft;
if(!obj.offsetParent)
break;
obj = obj.offsetParent;
}
else if(obj.x)
curleft += obj.x;
return curleft;
}
function findPosY(obj)
{
var curtop = 0;
if(obj.offsetParent)
while(1)
{
curtop += obj.offsetTop;
if(!obj.offsetParent)
break;
obj = obj.offsetParent;
}
else if(obj.y)
curtop += obj.y;
return curtop;
}
// Function to show / fill and resize (needed for IE6) the hint text popup
function showHint(index)
{
var hintText = '';
var hintObj = document.getElementById('hintBox');
switch(index)
{
case 0: hintText = 'bekijk dit filmpje'; hintObj.style.width = '93px'; hintObj.style.top = (y - 40) + 'px'; break;
case 1: hintText = 'achtergrondinformatie over dit filmpje'; hintObj.style.width = '213px'; hintObj.style.top = (y - 40) + 'px'; break;
case 2: hintText = 'wijzig dit filmpje'; hintObj.style.width = '90px'; hintObj.style.top = (y - 40) + 'px'; break;
case 3: hintText = 'Pharma Channel spant zich in om binnen 3 werkdagen uw nieuwe/gewijzigde filmpje te vertonen op uw beeldscherm.'; hintObj.style.width = '300px'; hintObj.style.height = 'auto'; hintObj.style.top = (y - 80) + 'px'; break;
}
hintObj.innerHTML = hintText;
hintObj.style.left = (x - 20) + 'px';
hintObj.style.visibility = 'visible';
}
// Function to hide the hint text popup
function hideHint()
{
document.getElementById('hintBox').style.visibility = 'hidden';
}
// Functions and variables used for following the mouse cursor
var offX = 15; // X offset from mouse position
var offY = 15; // Y offset from mouse position
var x;
var y;
function mouseX(evt)
{
if (!evt) evt = window.event;
if (evt.pageX)
return evt.pageX;
else if (evt.clientX)
return evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
else
return 0;
}
function mouseY(evt)
{
if (!evt)
evt = window.event;
if (evt.pageY)
return evt.pageY;
else if (evt.clientY)
return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
else
return 0;
}
function follow(evt)
{
x = parseInt(mouseX(evt))+offX;
y = parseInt(mouseY(evt))+offY;
}
function demoMessage()
{
alert('Dit is een demo!');
}