function gid(id){
var d=document
if(d.getElementById){return d.getElementById(id);}
else if(d.all){return d.all[id];}
else if(d.layers){return d.layers[id];}
return null;
}
function gids(id){return gid(id).style;}

function elemOk(id) {
gids(id).color="darkblue"
gids(id).backgroundColor="yellow"
}
function elemFail( id ) {
gids(id).color="black"
gids(id).backgroundColor="#ffa0a0"
}
function elemWait( id ) {
gids(id).color="green"
gids(id).backgroundColor="#c0c0c0"
}

function tag_value( xml, tag ) {
if (document.all){return xml.responseXML.getElementsByTagName(tag)[0].text;}
else{ return xml.responseXML.getElementsByTagName(tag)[0].textContent; }
}

function AJAX() {
    this._call = Math.random();
    this._method = "GET";
    this._vars = null;
    if(window.XMLHttpRequest) { // Mozilla, Safari, etc.
        this._request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // IE
        try {
            this._request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                this._request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                alert('Failed to create');
            }
        }
    }
}

AJAX.prototype.execute = function(url,parser) {
    var xml = this._request;
    this._call++;
    xml.open(this._method, url, true);
    xml.setRequestHeader('Content-Type', 'text/xml');
    var readystate = function() {
        try {
            if((xml.readyState == 4) && (xml.status == 200)) {
                parser(xml);
                xml.onreadystatechange = function(){};
                xml = null;
            }
        } catch(e) {
            // alert(e);
        }
    }
    this._request.onreadystatechange = readystate;
    this._request.send(this._vars);
}

AJAX.prototype.get = function(url,parser) {
    var xml = this._request;
    this._call++;
    xml.open(this._method, url, true);
    xml.setRequestHeader('Content-Type', 'text/html');
    var readystate = function() {
        try {
            if((xml.readyState == 4) && (xml.status == 200)) {
                parser(xml);
                xml.onreadystatechange = function(){};
                xml = null;
            }
        } catch(e) { // alert(e); 
	}
    }
    this._request.onreadystatechange = readystate;
    this._request.send(this._vars);
}

function reduce_param( form ) {
	form.style.display = "none";
	for ( i = 0; i < form.length; ) {
		if ( form.elements[ i ].name != "" 
			&& ( form.elements[ i ].name == "pg" || form.elements[ i ].value == "" ) ) {
			try {
				var el = form.elements[ i ];			
				el.parentNode.removeChild( el );
				i --;
			} catch( e ) {
				alert( e );
			}
		}
		i ++;
	}
	return true;
}

var thumbnailviewer = {
	enableTitle: true, 
	enableAnimation: true, 
	definefooter: '<div class="footerbar">CLOSE X</div>', 
	defineLoading: '<img src="/images/loading.gif" /> Loading...', 
	scrollbarwidth: 16,
	opacitystring: 'filter:progid:DXImageTransform.Microsoft.alpha(opacity=10); -moz-opacity: 0.1; opacity: 0.1',
	targetlinks:[], 

createthumbBox:function(){
	document.write('<div id="thumbBox" onClick="thumbnailviewer.closeit()"><div id="thumbImage"></div>'+this.definefooter+'</div>')
	document.write('<div id="thumbLoading">'+this.defineLoading+'</div>')
	this.thumbBox=document.getElementById("thumbBox")
	this.thumbImage=document.getElementById("thumbImage") 
	this.thumbLoading=document.getElementById("thumbLoading")
	this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body 
	this.close_descr = null;
},

centerDiv:function(divobj){ 
	var ie=document.all && !window.opera
	var dom=document.getElementById
	var scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
	var scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
	var docwidth=(ie)? this.standardbody.clientWidth : window.innerWidth-this.scrollbarwidth
	var docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
	var docheightcomplete=(this.standardbody.offsetHeight>this.standardbody.scrollHeight)? this.	standardbody.offsetHeight : this.standardbody.scrollHeight 
	var objwidth=divobj.offsetWidth 
	var objheight=divobj.offsetHeight
	var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2+"px" : scroll_top+	10+"px"
	divobj.style.left=docwidth/2-objwidth/2+"px" 
	divobj.style.top=Math.floor(parseInt(topposition))+"px"
	divobj.style.visibility="visible"
},

showthumbBox:function(){ 
	this.centerDiv(this.thumbBox)
	if (this.enableAnimation){ 
		this.currentopacity=0.1
		this.opacitytimer=setInterval("thumbnailviewer.opacityanimation()", 20)
	}
},


loadimage:function(link){ 
	if (this.thumbBox.style.visibility=="visible") 
	this.closeit()
	var imageHTML='<img src="'+link.getAttribute("href")+'" style="'+this.opacitystring+'" />' 
	this.centerDiv(this.thumbLoading) 
	this.thumbImage.innerHTML=imageHTML 
	this.featureImage=this.thumbImage.getElementsByTagName("img")[0] 
	this.featureImage.onload=function(){ 
		thumbnailviewer.thumbLoading.style.visibility="hidden" 
		thumbnailviewer.showthumbBox()
	}
	if (document.all && !window.createPopup) 
		this.featureImage.src=link.getAttribute("href")
	this.featureImage.onerror=function(){ 
		thumbnailviewer.thumbLoading.style.visibility="hidden" 
	}
},

setimgopacity:function(value){ 
	var targetobject=this.featureImage
	if (targetobject.filters && targetobject.filters[0]){ //IE syntax
		if (typeof targetobject.filters[0].opacity=="number") //IE6
			targetobject.filters[0].opacity=value*100
		else //IE 5.5
			targetobject.style.filter="alpha(opacity="+value*100+")"
	} else if (typeof targetobject.style.MozOpacity!="undefined")
		targetobject.style.MozOpacity=value
	else if (typeof targetobject.style.opacity!="undefined") 
		targetobject.style.opacity=value
	else 
		this.stopanimation()
},

opacityanimation:function(){ 
	this.setimgopacity(this.currentopacity)
	this.currentopacity+=0.1
	if (this.currentopacity>1)
	this.stopanimation()
},

stopanimation:function(){
	if (typeof this.opacitytimer!="undefined") clearInterval(this.opacitytimer)
},

closeit:function(){ 
	this.stopanimation()
	this.thumbBox.style.visibility="hidden"
	this.thumbImage.innerHTML=""
	this.thumbBox.style.left="-2000px"
	this.thumbBox.style.top="-2000px"
	if(this.close_descr != null) this.close_descr();
},

cleanup:function(){ 
	this.thumbLoading=null
	if (this.featureImage) this.featureImage.onload=null
	this.featureImage=null
	this.thumbImage=null
	for (var i=0; i<this.targetlinks.length; i++) this.targetlinks[i].onclick=null
	this.thumbBox=null
	this.close_descr = null
},

dotask:function(target, functionref, tasktype){ 
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener) target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent) target.attachEvent(tasktype, functionref)
},

init:function(){ 
	if (!this.enableAnimation) this.opacitystring=""
	var pagelinks=document.getElementsByTagName("a")
	for (var i=0; i<pagelinks.length; i++){ //BEGIN FOR LOOP
	if (pagelinks[i].getAttribute("rel") && pagelinks[i].getAttribute("rel")=="thumbnail"){ 
		pagelinks[i].onclick=function(){
			thumbnailviewer.stopanimation() 
			thumbnailviewer.loadimage(this) 
			return false
		}
	this.targetlinks[this.targetlinks.length]=pagelinks[i] 
	} //end if 
	} //END FOR LOOP
	this.dotask(window, function(){
		if (thumbnailviewer.thumbBox.style.visibility=="visible") 
			thumbnailviewer.centerDiv(thumbnailviewer.thumbBox)
		}, "resize")
} //END init()

}

thumbnailviewer.createthumbBox() 
thumbnailviewer.dotask(window, function(){thumbnailviewer.init()}, "load") 
thumbnailviewer.dotask(window, function(){thumbnailviewer.cleanup()}, "unload")


function getprice(aform, num,retail,sale,sku)
{
    var retaildiv = document.getElementById("retailform" + num);
    var salediv = document.getElementById("saleform" + num);
    
    retaildiv.innerHTML= '<strike>$' + retail[aform.selform.options[aform.selform.selectedIndex].value] + '<\/strike>';
    salediv.innerHTML= '$' + sale[aform.selform.options[aform.selform.selectedIndex].value];
    aform.add.value = sku[aform.selform.options[aform.selform.selectedIndex].value];
}