// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//
// Title : RedBox Digital site functions
// Author : RedBox Digital
//
// Description : Core functionality for standard sites developed by RedBox Digital
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function theflash(movie, width, height) {
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '">');
    document.writeln('<param name="movie" value="' + movie + '">');
	document.writeln('<param name="allowScriptAccess" value="sameDomain" />');
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="menu" value="false">');
	document.writeln('<param name="wmode" value="transparent">');
	document.writeln('<embed src="' + movie + '" width="' + width + '" height="' + height + '" quality="high" allowScriptAccess="sameDomain" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false" wmode="transparent"></embed>');
    document.writeln('</object>');
}

function fullScreen(pagina) {
if (navigator.appName == "Microsoft Internet Explorer"){ // better be ie6 at least
window.open(pagina, '', 'width=' + (screen.width-5) + ',height=' + (screen.height-30) + ', scrollbars=yes, resizable=yes').focus();
}
else { // i.e. if Firefox
window.open(pagina, '', 'width=' + (screen.width-5) + ',height=' + (screen.height-30) + ', scrollbars=yes, resizable=yes, menubar=no, titlebar=no, toolbar=no ').focus();
}
}

<!-- DISABLE RIGHT CLICK ON IMAGES JS -->
var currYear = new Date();
var clickmessage='Johnson & Johnson Inc. 2007-'+currYear.getFullYear();

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()


/***********************************************
* Random Content (from DIVs)
***********************************************/

if (document.getElementById)
document.documentElement.className = 'jsclass'; //hide content for DOM capable browsers


var randomcontentdisplay={
	divholders:new Object(),
	masterclass: "randomcontent",

	init:function(){
		if (!document.getElementById)
			return
		var alldivs=document.getElementsByTagName("div")
		var randomcontentsearch=new RegExp(this.masterclass+"\\s+(group\\d+)", "i") //check for CSS class="randomcontent groupX" (x=integer)
		for (var i=0; i<alldivs.length; i++){
			if (randomcontentsearch.test(alldivs[i].className)){
				if (typeof this.divholders[RegExp.$1]=="undefined") //if array to hold this group of divs doesn't exist yet
					this.divholders[RegExp.$1]=new Array() //create array first
					this.divholders[RegExp.$1].push(alldivs[i]) //add this div to the array
			}
		}
	this.showone()
	},

	showone:function(){
		for (group in this.divholders){ //loop thru each array within object
			var chosenOne=Math.floor(Math.random()*this.divholders[group].length) //randomly pick one entry from array
			this.divholders[group][chosenOne].style.display="block" //display content corresponding to the chosen entry
		}
	}
}


function open_window(fileName, windowName, windowWidth, windowHeight, scrollbars, resizable) {
	window.open(fileName, windowName, 'toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=' + scrollbars + ', resizable=' + resizable + ', left=' + centre(windowWidth, screen.availWidth) + ', top=' + centre(windowHeight, screen.availHeight) + ', width=' + windowWidth + ', height=' + windowHeight);
}

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 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 getQSValue(ji) {
	hu = window.location.search.substring(1);
	gy = hu.split("&");
	for (i=0;i<gy.length;i++) {
		ft = gy[i].split("=");
		if (ft[0] == ji) {
			return ft[1];
		}
	}
	return "";
}

function redirect () 
{
	window.location.href = getQSValue('url');
}

function printpage()
{
window.print()
}

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 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)
	}

	
