// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//
// 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 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 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 changeTextExpanded(){
		document.getElementById('nicoretteSelector').innerHTML = '<a href="javascript:void{}" onclick="flashMovie.toggle(); changeTextClosed();"><img src="../../CommonNicorette/Images/Global/nicoretteSelectorExpanded.gif" alt="Open" /></a>';
	}
	function changeTextClosed(){
		document.getElementById('nicoretteSelector').innerHTML = '<a href="javascript:void{}" onclick="flashMovie.toggle(); changeTextExpanded();"><img src="../../CommonNicorette/Images/Global/nicoretteSelectorClosed.gif" alt="Closed" /></a>';
	}

	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)
	}

	var theImages = new Array()

	theImages[0] = '<a href="quit-smoking/quit-smoking/weight-Control.aspx")%>" title="Click here for help with weight control"><img src="CommonNicorette/Images/Photos/photo1.jpg" alt="Weight Control" title="Weight Control" /></a>'
	theImages[1] = '<a href="quit-smoking/quit-smoking/budget-Calculator.aspx")%>" title="Click here for the budget calculator"><img src="CommonNicorette/Images/Photos/photo2.jpg" alt="Budget Calculator" title="Budget Calculator" /></a>'

	
	// do not edit anything below this line
	
	var j = 0
	var p = theImages.length;
	var preBuffer = new Array()
	for (i = 0; i < p; i++){
	   preBuffer[i] = new Image()
	   //preBuffer[i].src = theImages[i]
	}
	var whichImage = Math.round(Math.random()*(p-1));
	function showImage(){
	document.write(''+theImages[whichImage]+'');
	}
	
	var theLargeImages = new Array()

	theLargeImages[0] = '01_05.jpg'
	theLargeImages[1] = '02_05.jpg'
	theLargeImages[2] = '03_05.jpg'
	theLargeImages[3] = '04_05.jpg'
	theLargeImages[4] = '05_05.jpg'
	
	// do not edit anything below this line
	
	var j = 0
	var p = theLargeImages.length;
	var preBuffer = new Array()
	for (i = 0; i < p; i++){
	   preBuffer[i] = new Image()
	   preBuffer[i].src = theLargeImages[i]
	}
	var whichLargeImage = Math.round(Math.random()*(p-1));
	function showLargeImage(){
	document.write('<img src="../CommonNicorette/Images/Photos/'+theLargeImages[whichLargeImage]+'" alt="Nicorette Photo" title="Nicorette Photo" />');
	}
	
function popUp(name, url) {
	   window.open(url,name,'toolbar=0,menubar=0,scrollbars=1,resizable=0,status=0,location=0,left=30,top=30,width=280,height=240');
	}	