function order(pid) {
	window.open('https://secure.vanguardsw.com/vgscripts/order.dsb?closeonexit&pid='+pid, '', 'width=700, height=700, toolbar=0, location=0, directories=0, status=0, menuBar=0, scrollBars=1, resizable=1');
	return false;
}

function OpenWindow(url,w,h){
	window.open(url,'','width='+w+',height='+h+',left='+(screen.availWidth-w-12)/2+',top='+(screen.availHeight-h-59)/2+',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
}

function openApp(url) {
	var w = Math.min(800,screen.availWidth)-12;
	var h = screen.availHeight-38;
	window.open(url,'','width='+w+',height='+h+',left='+(screen.availWidth-w-12)/2+',top=0,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
}

function openVideo(url) {
	var w = 800-11;
	var h = 600-62;
	OpenWindow(url,w,h);
}

function openHelp(e,topic) {
	var ie4 = document.all&&navigator.userAgent.indexOf("Opera")==-1;

	if(ie4) {
		x=window.screenLeft-document.body.scrollLeft;
		y=window.screenTop-document.body.scrollTop+20;
	}
	else
	{
		x=window.screenX-window.pageXOffset;
		y=window.screenY-window.pageYOffset+42;
	}

	for(j=e; j; j=j.offsetParent)
		x+=j.offsetLeft;
	x=Math.min(x,screen.availWidth-418);

	for(j=e; j; j=j.offsetParent)
		y+=j.offsetTop;
	y=Math.min(y,screen.availHeight-490);
	
	window.open(topic,'','width=400,height=450,left='+x+',top='+y+',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
}

function itemRect(item) {
	var obj = new Object();
	var x=0, y=0;

	for(var j=item; j; j=j.offsetParent) {
		x += j.offsetLeft;
		y += j.offsetTop;
	}

	obj.x = x;
	obj.y = y;
	obj.cx = item.width;
	obj.cy = item.height;

	return obj;
}

function bodyRect() {
	var obj = new Object();

	obj.x = 0;
	obj.y = 0;
	obj.cx = document.body.scrollWidth;
	obj.cy = document.body.scrollHeight;

	return obj;
}

function windowRect() {
	var obj = new Object();

	if(self.pageYOffset)
	{
		obj.x = self.pageXOffset;
		obj.y = self.pageYOffset;
	}
	else if(document.body)
	{
		obj.x = document.body.scrollLeft;
		obj.y = document.body.scrollTop;
	}

	if(self.innerHeight)
	{
		obj.cx = self.innerWidth;
		obj.cy = self.innerHeight;
	}
	else if(document.body)
	{
		obj.cx = document.body.clientWidth;
		obj.cy = document.body.clientHeight;
	}


	return obj;
}

function tagImages(start) {
	var n,item,j,top,left;

	for(n=0;n<document.all.length;n++) {
		item=document.all[n];

		if(item.className=="clicktoenlarge") {
			var obj=itemRect(item);

			top=obj.y+obj.cy-12;
			left=obj.x+obj.cx-79;

			if(start==1) {
				item.clicktag="clicktag"+n;
				document.write('<img src="/_envelope/clicktoenlarge.gif" style="position:absolute;top:'+top+';left:'+left+'" onclick="enlargeImage(document.all['+n+'])" id="clicktag'+n+'" class="noprint">');
			}
			else {
				document.all[item.clicktag].style.top=top;
				document.all[item.clicktag].style.left=left;
			}
		}
	}
}

function enlargeImage(img) {
	var irect=itemRect(img);
	var brect=bodyRect();
	var wrect=windowRect();

	var cx=irect.cx*3;
	var cy=irect.cy*3;

	x=irect.x-irect.cx;
	y=irect.y-irect.cy;

	var w=10;

	x=Math.min(x,wrect.x+wrect.cx-cx-w-40);
	x=Math.max(x,wrect.x+w);

	y=Math.min(y,wrect.y+wrect.cy-cy-w-16);
	y=Math.max(y,wrect.y+w);


	document.all.imagebackground.style.width=brect.cx;
	document.all.imagebackground.style.height=brect.cy;
	document.all.imagebackground.style.display='block';

	document.all.imagewait.style.top=irect.y+irect.cy/2-26;
	document.all.imagewait.style.left=irect.x+irect.cx/2-34;
	document.all.imagewait.style.display='block';

	document.all.imagecontainer.innerHTML='<img src="'+img.src.replace("-small","-large")+'">';
	document.all.imagecontainer.style.top=y;
	document.all.imagecontainer.style.left=x;
	document.all.imagecontainer.style.display='block';
}

function shrinkImage(img) {
	document.all.imagebackground.style.display='none';
	document.all.imagewait.style.display='none';
	document.all.imagecontainer.style.display='none';
}

function showMore(item,expand) {
	var irect=itemRect(item);
	var brect=bodyRect();
	var wrect=windowRect();
	var n;

	if(item.sourceIndex==undefined)
		for(n=0;n<document.all.length&&document.all[n]!=item;n++);
	else
		n=item.sourceIndex;

	if(expand) {
		var div = document.all[n+1];
		
		if(0) {
			document.all.imagebackground.style.width=brect.cx;
			document.all.imagebackground.style.height=brect.cy;
			document.all.imagebackground.style.display='none';
		}

		div.style.top=Math.max(irect.y-200,wrect.y+10);
		div.style.left=(wrect.cx-600)/2;
		div.style.display='block';

		document.all.imagebackground.style.width=brect.cx;
		document.all.imagebackground.style.height=brect.cy;
		document.all.imagebackground.style.display='block';

	}
	else {
		var div = document.all[n-4];

		div.style.display='none';
		document.all.imagebackground.style.display='none';
	}
}

var fadeData;

function fadeText(item,text,colors) {
	if(item) {
		fadeData=new Object();
		fadeData.item=item;
		fadeData.text=text;
		fadeData.colors=colors;
		fadeData.color=colors.length;
	}

	fadeData.color--;

	if(fadeData.color==0)
		fadeData.item.innerHTML=fadeData.text;

	fadeData.item.style.color=fadeData.colors[Math.abs(fadeData.color)];

	if(fadeData.color>-fadeData.colors.length)
		setTimeout("fadeText()",50);
}

/***********************************************
* Ultimate Fade-In Slideshow (v1.51): 
* © Dynamic Drive (http://www.dynamicdrive.com)
***********************************************/

var fadebgcolor="white"

var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
 
var dom=(document.getElementById) //modern dom browser
var iebrowser=document.all
 
function fadeshow( theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder ) {
	this.pausecheck=pause
	this.mouseovercheck=0
	this.delay=delay
	this.degree=10 //initial opacity degree (10%)
	this.curimageindex=0
	this.nextimageindex=1
	fadearray[fadearray.length]=this
	this.slideshowid=fadearray.length-1
	this.canvasbase="canvas"+this.slideshowid
	this.curcanvas=this.canvasbase+"_0"
	if( typeof displayorder!="undefined" )
		theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
	this.imageborder=parseInt(borderwidth)
	this.postimages=new Array() //preload images
	for( p=0; p<theimages.length; p++ ) {
//		this.postimages[p]=new Image()
		this.postimages[p]=new Object()
		this.postimages[p].src=theimages[p]
	}
 
	var fadewidth=fadewidth+this.imageborder*2
	var fadeheight=fadeheight+this.imageborder*2
 
	if( iebrowser&&dom||dom ) //if IE5+ or modern browsers (ie: Firefox)
		document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div></div>')
	else
		document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
 
	if( iebrowser&&dom||dom ) //if IE5+ or modern browsers such as Firefox
		this.startit()
	else {
		this.curimageindex++
		setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
	}
}

function fadepic( obj ) {
	if( obj.degree<100 ) {
		obj.degree+=10
		if( obj.tempobj.filters&&obj.tempobj.filters[0] ) {
			if( typeof obj.tempobj.filters[0].opacity=="number" ) //if IE6+
				obj.tempobj.filters[0].opacity=obj.degree
			else //else if IE5.5-
				obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
		}
		else if( obj.tempobj.style.MozOpacity )
			obj.tempobj.style.MozOpacity=obj.degree/101
		else if( obj.tempobj.style.KhtmlOpacity )
			obj.tempobj.style.KhtmlOpacity=obj.degree/100
		else if( obj.tempobj.style.opacity&&!obj.tempobj.filters )
			obj.tempobj.style.opacity=obj.degree/101
	}
	else{
		clearInterval(fadeclear[obj.slideshowid])
		obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0") ? obj.canvasbase+"_0" : obj.canvasbase+"_1"
		obj.tempobj=iebrowser ? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
		obj.populateslide(obj.tempobj, obj.nextimageindex)
		obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1) ? obj.nextimageindex+1 : 0
		setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
	}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex) {
	picobj.innerHTML='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
}
 
 
fadeshow.prototype.rotateimage=function() {
	if( this.pausecheck==1 ) //if pause onMouseover enabled, cache object
		var cacheobj=this
	if( this.mouseovercheck==1 )
		setTimeout(function() {cacheobj.rotateimage()}, 100)
	else if( iebrowser&&dom||dom ) {
		this.resetit()
		var crossobj=this.tempobj=iebrowser ? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
		crossobj.style.zIndex++
		fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
		this.curcanvas=(this.curcanvas==this.canvasbase+"_0") ? this.canvasbase+"_1" : this.canvasbase+"_0"
	}
	else{
		var ns4imgobj=document.images['defaultslide'+this.slideshowid]
		ns4imgobj.src=this.postimages[this.curimageindex].src
	}
	this.curimageindex=(this.curimageindex<this.postimages.length-1) ? this.curimageindex+1 : 0
}
 
fadeshow.prototype.resetit=function() {
	this.degree=10
	var crossobj=iebrowser ? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
	if( crossobj.filters&&crossobj.filters[0] ) {
		if( typeof crossobj.filters[0].opacity=="number" ) //if IE6+
			crossobj.filters(0).opacity=this.degree
		else //else if IE5.5-
			crossobj.style.filter="alpha(opacity="+this.degree+")"
	}
	else if( crossobj.style.MozOpacity )
		crossobj.style.MozOpacity=this.degree/101
	else if( crossobj.style.KhtmlOpacity )
		crossobj.style.KhtmlOpacity=this.degree/100
	else if( crossobj.style.opacity&&!crossobj.filters )
		crossobj.style.opacity=this.degree/101
}
 
 
fadeshow.prototype.startit=function() {
	var crossobj=iebrowser ? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
	this.populateslide(crossobj, this.curimageindex)
	if( this.pausecheck==1 ) { //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
		var cacheobj=this
		var crossobjcontainer=iebrowser ? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
		crossobjcontainer.onmouseover=function() {cacheobj.mouseovercheck=1}
		crossobjcontainer.onmouseout=function() {cacheobj.mouseovercheck=0}
	}

	this.rotateimage()
}
