// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//
// Title : RedBox Digital site functions
// Author : RedBox Digital
//
// Description : Core functionality for standard sites developed by RedBox Digital
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

var newWindow = null;

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight){
	
	closeWin();
	
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=no,location=no,scrollbars=yes,status=yes,menubar=no,width="+strWidth+",height="+strHeight+",top=300,left=100";
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}


function showFrame(frame) {
		document.getElementById(frame.id).style.display = 'block';
	}
	function hideFrame(frame) {
		document.getElementById(frame.id).style.display = 'none';
	}
	function hideForms() {
		var thisone = document.getElementsByTagName("select");
		for (i=0; i<thisone.length; i++) {
			thisone[i].style.visibility = 'hidden';
		}
	}
	function showForms() {
		var thisone = document.getElementsByTagName("select");
		for (i=0; i<thisone.length; i++) {
			thisone[i].style.visibility = 'visible';
		}	
	}
	function imgSwap(oImg)
	{
	   var strOver  = "On"    // image to be used with mouse over
	   var strOff = "Off"     // normal image
	   var strImg = oImg.src
	   if (strImg.indexOf(strOver) != -1) 
		  oImg.src = strImg.replace(strOver,strOff)
	   else
		  oImg.src = strImg.replace(strOff,strOver)
	}


function pageup(e) {
	UAGENT = navigator.userAgent.toUpperCase();
	if (UAGENT.indexOf("MSIE") >=0) { posi = event.y; }
	else { posi = e.pageY; }
	moveObje(posi);
}
	function moveObje(position) {
	move = position / 15;
	point = parseInt(position - move);
	scrollTo(0,point);
	if (point > 0) { setTimeout("moveObje(point)",15); }
}

function printpage()
{
window.print()
}

 	// W3C Valid XHTML - new window
 
	function externalLinks() {
	 if (!document.getElementsByTagName) return;
	 var anchors = document.getElementsByTagName("a");
	 for (var i=0; i<anchors.length; i++) {
	   var anchor = anchors[i];
	   if (anchor.getAttribute("href") &&
		   anchor.getAttribute("rel") == "external")
		 anchor.target = "_blank";
	 }
	}
	window.onload = externalLinks;


function popupWindow(winURL,winName,winWidth,winHeight) 
	{ 
	iLeft = (window.screen.availWidth/2)-(winWidth/2); 
	iTop = (window.screen.availHeight/2)-(winHeight/2); 
	window.open(winURL,winName, "left=" + iLeft + ",top=" + iTop + ",width=" + winWidth + ",height=" + winHeight + ",toolbar=no,scrollbars=no,directories=no,status=no,menubar=no,resizable=no,location=no"); 
	return false; 
}

function ShowLoadingFunction()
{
	divPleasewaitScreen = document.getElementById('pleasewaitScreen');
	divPleasewaitScreen.style.pixelTop = (document.body.scrollTop + 50);
	divPleasewaitScreen.style.visibility="visible";	
}

function enableForm(theform) {
	if (document.all || document.getElementById) {
		for (i = 0; i < theform.length; i++) {
		var formElement = theform.elements[i];
			if (true) {
				formElement.disabled = false;
			}
		}
	}
}

function disableForm(theform) {
	if (document.all || document.getElementById) {
		for (i = 0; i < theform.length; i++) {
		var formElement = theform.elements[i];
			if (true) {
				formElement.disabled = true;
			}
		}
	}
}

function MultipleFieldsValidatorEvaluateIsValid(val) 
{
    controltovalidateIDs = val.controlstovalidate.split(',');
    var iCount = controltovalidateIDs.length;

    switch (val.condition) 
    {
        case 'OR':
            //for(var controltovalidateIDIndex in controltovalidateIDs) 
            while (iCount-- != 0)
            {
                //var controlID = controltovalidateIDs[controltovalidateIDIndex];
                var controlID = controltovalidateIDs[iCount];
                if (ValidatorTrim(ValidatorGetValue(controlID)) != '') 
                {
                    return true;
                } 
            }
            return false;
        break;
        case 'XOR':
            //for(var controltovalidateIDIndex in controltovalidateIDs)
            while (--iCount != 0)
            {
                //var controlID = controltovalidateIDs[controltovalidateIDIndex];
                var controlID = controltovalidateIDs[iCount];
                //if (controltovalidateIDIndex == '0')
                if (iCount == 0) 
                {
                    var previousResult = !(ValidatorTrim(ValidatorGetValue(controlID)) == '');
                    continue;
                }
                var currentResult = !(ValidatorTrim(ValidatorGetValue(controlID)) == '');
                if (currentResult != previousResult) 
                {
                    return true;
                }
                previousResult != currentResult;
            }
            return false;
        break;
        case 'AND':
            //for(var controltovalidateIDIndex in controltovalidateIDs)
            while (--iCount != 0)
            {
                //var controlID = controltovalidateIDs[controltovalidateIDIndex];
                var controlID = controltovalidateIDs[iCount];
                if (ValidatorTrim(ValidatorGetValue(controlID)) == '') 
                {
                    return false;
                } 
            }
            return true;
        break;
    }
    return false;
}

function isNumberKey(evt)
{
 var charCode = (evt.which) ? evt.which : event.keyCode
 
 if (charCode > 31 && (charCode < 48 || charCode > 57))
 {
    event.returnValue = false;
    return false;
 }

 return true;
}

<!-- DISABLE RIGHT CLICK ON IMAGES JS -->
var clickmessage='McNeil Healthcare (UK) Limited, 2010';

function disableclick(e) {
if (document.all) {
if (event.button==2||event.button==3) {
if (event.srcElement.tagName=="IMG"){
alert(clickmessage);
return false;
}
}
}
else if (document.layers) {
if (e.which == 3) {
alert(clickmessage);
return false;
}
}
else if (document.getElementById){
if (e.which==3&&e.target.tagName=="IMG"){
alert(clickmessage)
return false
}
}
}

function associateimages(){
	for(i=0;i<document.images.length;i++)
	document.images[i].onmousedown=disableclick;
}

if (document.all)
document.onmousedown=disableclick
else if (document.getElementById)
document.onmouseup=disableclick
else if (document.layers)
associateimages()


