function viewimage(viewer_type,parm_string,w,h,parent_type,parent_id) {
popUpWindow=window.open('/utility/image_viewer.asp?image_type=' + viewer_type + '&w=' + w +'&h='+ h + '&' + parm_string + '&parent_type=' + parent_type + '&parent_id=' + parent_id ,'w','width='+w+',height='+h+',scrollbars=no,toolbars=no,resizable=no,menubar=no,status=no');
popUpWindow.focus();
}

function openBrWindow(theURL) { 
window.open(theURL,'w','width=400,height=400,scrollbars=no,toolbars=no,resizable=no,menubar=no,status=no');
}


// FOR IE FLICKER BUG
if (document.all) {
	try {document.execCommand("BackgroundImageCache", false, true);} 
	catch(err) {}
}


// EMBEDS FLASH
var getIt = 'You need Flash (version 8+) to view this... please download it <a href="http://www.adobe.com/go/getflashplayer" target="_blank">here</a>.<br />'

function embedFlash (url,w,h) {
document.write('<object type="application/x-shockwave-flash" data="'+url+'" width="'+w+'" height="'+h+'" menu="false">');
document.write('<param name="movie" value="'+url+'">');
document.write('<param name="menu" value="false">');
document.write(getIt);
document.write('<\/object>');
}


// EMBEDS A YOUTUBE MODULE
function embedYouTube (url) {
document.write('<object type="application/x-shockwave-flash" data="'+url+'" width="200" height="170" menu="false" wmode="transparent">');
document.write('<param name="movie" value="'+url+'">');
document.write('<param name="menu" value="false">');
document.write('<param name="wmode" value="transparent">');
document.write(getIt);
document.write('<\/object>');
}


// EMBEDS AN UPLOADED FLV
function embedVideo (url) {
document.write('<object type="application/x-shockwave-flash" data="/params/video/player.swf?video='+url+'" width="200" height="170" menu="false" wmode="transparent">');
document.write('<param name="movie" value="/params/video/player.swf?video='+url+'">');
document.write('<param name="menu" value="false">');
document.write('<param name="wmode" value="transparent">');
document.write(getIt);
document.write('<\/object>');
}

// SHOP
function plus(thisOne) {
x = document.getElementById("qty"+thisOne)
x.value=parseFloat(x.value)+1
}

function minus(thisOne) {
x = document.getElementById("qty"+thisOne)
if (x.value!='0'){x.value=parseFloat(x.value)-1}
}


// TOGGLE BEWTEEN CONTENT
function showContent(x){

var theItem = x.parentNode
var theList = theItem.parentNode.childNodes
var i = theList.length-1

do {if (theList[i].tagName!=null){theList[i].className = "";}}
while (i--)

theItem.className = "on"

}


// JUMP TO PAGE
function goTo(){
var s = document.getElementById('book_section')
document.location.href = s[s.selectedIndex].value
}



function image_switch(which,src,pid,txt,out) {
if (src != '') {
	if (document.getElementById('pimage_' + which)) {
	var i=document.getElementById('pimage_' + which);
	if (out) {i.src='/uploads/shop/img/CategoryImages/' + src;}
	else {i.src='/uploads/shop/img/ProductImages/' + src;}
	i.alt=txt;
	i.title='click to view more about ' + txt
	}
}
if (parseFloat("0" + pid)>0) {
	if (document.getElementById('phref_' + which)) {
	var h=document.getElementById('phref_' + which);
	h.href='product.asp?pID=' + pid;
	}
}
}


function resizeMe(x){
var theIframe = document.getElementById(x)
var theIframeHeight = Math.max(theIframe.contentWindow.document.body.scrollHeight, theIframe.contentWindow.document.documentElement.scrollHeight);
theIframe.style.height = theIframeHeight+"px"
theIframe.contentWindow.document.getElementById('iframe_content').style.visibility = "visible"
}



/*

Better(?) Image cross fader (C)2004 Patrick H. Lauke aka redux

Inspired by Steve at Slayeroffice http://slayeroffice.com/code/imageCrossFade/ 

preInit "Scheduler" idea by Cameron Adams aka The Man in Blue
http://www.themaninblue.com/writing/perspective/2004/09/29/ 

Tweaked to deal with empty nodes 19 Feb 2006

*/

/* general variables */

var galleryId = 'banners'; /* change this to the ID of the gallery list */
var	gallery; /* this will be the object reference to the list later on */
var galleryImages; /* array that will hold all child elements of the list */
var currentImage; /* keeps track of which image should currently be showing */
var previousImage;
var preInitTimer;
preInit();

/* functions */

function preInit() {
	/* an inspired kludge that - in most cases - manages to initially hide the image gallery list
	   before even onload is triggered (at which point it's normally too late, and the whole list already
	   appeared to the user before being remolded) */
	if ((document.getElementById)&&(gallery=document.getElementById(galleryId))) {
		gallery.style.visibility = "hidden";
		if (typeof preInitTimer != 'undefined') clearTimeout(preInitTimer); /* thanks to Steve Clay http://mrclay.org/ for this small Opera fix */
	} else {
		preInitTimer = setTimeout("preInit()",2);
	}
}

function fader(imageNumber,opacity) {
	/* helper function to deal specifically with images and the cross-browser differences in opacity handling */
	var obj=galleryImages[imageNumber];
	if (obj.style) {
		if (obj.style.MozOpacity!=null) {  
			/* Mozilla's pre-CSS3 proprietary rule */
			obj.style.MozOpacity = (opacity/100) - .001;
		} else if (obj.style.opacity!=null) {
			/* CSS3 compatible */
			obj.style.opacity = (opacity/100) - .001;
		} else if (obj.style.filter!=null) {
			/* IE's proprietary filter */
			obj.style.filter = "alpha(opacity="+opacity+")";
		}
	}
}

function fadeInit() {
	if (document.getElementById && document.getElementById(galleryId)!=null) {
		preInit(); /* shouldn't be necessary, but IE can sometimes get ahead of itself and trigger fadeInit first */
		galleryImages = new Array;
		var node = gallery.firstChild;
		/* instead of using childNodes (which also gets empty nodes and messes up the script later)
		we do it the old-fashioned way and loop through the first child and its siblings */
		while (node) {
			if (node.nodeType==1) {
				galleryImages.push(node);
			}
			node = node.nextSibling;
		}
		for(i=0;i<galleryImages.length;i++) {
			/* loop through all these child nodes and set up their styles */
			galleryImages[i].style.position='absolute';
			galleryImages[i].style.top=0;
			galleryImages[i].style.zIndex=0;
			/* set their opacity to transparent */
			fader(i,0);
		}
		/* make the list visible again */
		gallery.style.visibility = 'visible';
		/* initialise a few parameters to get the cycle going */
		currentImage=0;
		previousImage=galleryImages.length-1;
		opacity=100;
		fader(currentImage,100);
		/* start the whole crossfade process after a second's pause */
		window.setTimeout("crossfade(100)", 1000);
	}
}

function crossfade(opacity) {
		if (opacity < 100) {
			/* current image not faded up fully yet...so increase its opacity */
			fader(currentImage,opacity);
			/* fader(previousImage,100-opacity); */
			opacity += 10;
			window.setTimeout("crossfade("+opacity+")", 100);
		} else {
			/* make the previous image - which is now covered by the current one fully - transparent */
			fader(previousImage,0);
			/* current image is now previous image, as we advance in the list of images */
			previousImage=currentImage;
			currentImage+=1;
			if (currentImage>=galleryImages.length) {
				/* start over from first image if we cycled through all images in the list */
				currentImage=0;
			}
			/* make sure the current image is on top of the previous one */
			galleryImages[previousImage].style.zIndex = 0;
			galleryImages[currentImage].style.zIndex = 100;
			/* and start the crossfade after a second's pause */
			opacity=0;
			window.setTimeout("crossfade("+opacity+")", 4000);
		}
		
}

/* initialise fader by hiding image object first */
addEvent(window,'load',fadeInit)



/* 3rd party helper functions */

/* addEvent handler for IE and other browsers */
function addEvent(elm, evType, fn, useCapture) 
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
// By Scott Andrew
{
 if (elm.addEventListener){
   elm.addEventListener(evType, fn, useCapture);
   return true;
 } else if (elm.attachEvent){
   var r = elm.attachEvent("on"+evType, fn);
   return r;
 }
} 

function isObject(a) {
    return (a && typeof a == 'object');
}

// EXPAND ALL FOR EXTRA CONTENT - BLOG_LIST MODULE
function xBL(p,a,c){
for (var i = 0; i <= c; i++) {
var m=document.getElementById('d' + a + '_' + i);
var x =document.getElementById('e' + a + '_' + i);
var n =document.getElementById('a' + a + '_' + i);
if (p.innerHTML=='+') {
	if (isObject(x)) {m.style.display='none'; x.style.display='block';}
	if (isObject(n)) {n.innerHTML='-';}}
else {
	if (isObject(x)) {m.style.display='block'; x.style.display='none';}
	if (isObject(n)) {n.innerHTML='+';}}
}
if (p.innerHTML=='+') {
p.innerHTML='-';
} else {
p.innerHTML='+';
}
return false;
}

// SHOW/HIDE FOR EXTRA CONTENT
function more(a,i){
var m=document.getElementById('d' + a + '_' + i);
var x =document.getElementById('e' + a + '_' + i);
var n =document.getElementById('a' + a + '_' + i);
if (isObject(x)) {
	if (x.style.display!='block'){
		x.style.display='block';
		m.style.display='none';
		n.innerHTML='-';}
	else {
		x.style.display='none';
		m.style.display='block';
		n.innerHTML='+';}
}
return false;
}
