function MM_openBrWindow(theURL,winName,features)
        { //v2.0
	        window.open(theURL,winName,features);
        }
//---------------------------------------------------------
function ConfirmDelete(strObject)
	{
	if (!confirm('This will permanently delete this ' + strObject +'.\nClick [OK] to continue.'))
		{
		window.event.returnValue = false;
		}
	}
//---------------------------------------------------------
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//---------------------------------------------------------
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
//---------------------------------------------------------
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//---------------------------------------------------------
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*---------------------------------------------------------
Author: Erik Roll
Desc:   The following two functions swap out the image for the various tabs
        on mouseover and mouseout.  
----------------------------------------------------------*/
function egOver(tab){
    var strClass=document.getElementById(tab).className;
    if(strClass!=strClass.substring(0,4)+'selected'){
    strClass=strClass.substring(0,4);
    strClass=strClass+'moused';}
    document.getElementById(tab).className=strClass;
    strHRColor = getBaseColorByID(tab);
    if(tab=="btn7"){
        document.getElementById(tab).style.color='black';}
  }

function egOut(tab){
    strHRColor = getBaseColorByID(tab);
    var hexPageTrimColor = new RGBColorLite(pageTrimColor);
    hexPageTrimColor = hexPageTrimColor.toHex();
    var strClass=document.getElementById(tab).className;
    strClass=strClass.replace(/moused/,'');
    document.getElementById(tab).className=strClass;
 }

/*---------------------------------------------------------
Author: Erik Roll
Desc:   The following function uses magic values (base colors) but
        removed the need for magic attributes in the tabs! 
        ( id="tab1" color="#F58436" )!
----------------------------------------------------------*/
function getBaseColorByID(tabID){
    var pos;
    
    pos=tabID.indexOf('btn1');
   
    if(pos>0){
      return '#f58436';}
   
    pos=tabID.indexOf('btn2');
    if(pos>0){
      return '#8f479b';}
   
    pos=tabID.indexOf('btn3');
    if(pos>0){
      return '#547891';}
      
    pos=tabID.indexOf('btn4');
    if(pos>0){
      return '#d0177a';}
      
    pos=tabID.indexOf('btn5');
    if(pos>0){
      return '#166736';}
      
    pos=tabID.indexOf('btn6');
    if(pos>0){
      return '#9ab13b';}
   
    pos=tabID.indexOf('btn7');
    if(pos>0){
      return '#fedc00';}
   
    pos=tabID.indexOf('btn8');
    if(pos>0){
      return '#a82e3b';}
     
     return '#aaaaaa';
}

/*---------------------------------------------------------
Author: Erik Roll
Desc:   Allows the page to determine which category is selected, 
        and load with the appropriate tab/button 'pushed' and 'highlighted'.
----------------------------------------------------------*/
function getSelectedTabName(){
    // force conversion to HEX (FF uses RGBs when it pulls colors)
    var pageBaseColor = new RGBColorLite(pageTrimColor);
    var obj='Tab';
    pageBaseColor = pageBaseColor.toHex();
    for ( var i=1, len=BaseColors.length; i<len; ++i )
    { 
        if(pageBaseColor.toUpperCase()==BaseColors[i])
            { 
            obj=obj+i;
            break;  
            }
    }
   return obj; 
}
  
/*---------------------------------------------------------
Author: Erik Roll
Desc:   Sets the border color of an image.
----------------------------------------------------------*/        
function SetBorder(obj){
    obj.style.borderColor=pageTrimColor;
    // integrated Moz Hack
    var browser=navigator.appName;
        if(browser=="Netscape"){
        obj.parentNode.className="productThumbMoz";
        }
}/**
 * A class to parse color values.
 * This is a lighter version of a bigger RGBColor class found on the following link
 * @link   http://www.phpied.com/rgb-color-parser-in-javascript/
 * @license Use it if you like it
 * @author Stoyan Stefanov <sstoo@gmail.com>
 */
function RGBColorLite(color_string)
{
    this.ok = false;

    // strip any leading #
    if (color_string.charAt(0) == '#') { // remove # if any
        color_string = color_string.substr(1,6);
    }

    color_string = color_string.replace(/ /g,'');
    color_string = color_string.toLowerCase();


    // array of color definition objects
    var color_defs = [
        {
            re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
            example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],
            process: function (bits){
                return [
                    parseInt(bits[1]),
                    parseInt(bits[2]),
                    parseInt(bits[3])
                ];
            }
        },
        {
            re: /^(\w{2})(\w{2})(\w{2})$/,
            example: ['#00ff00', '336699'],
            process: function (bits){
                return [
                    parseInt(bits[1], 16),
                    parseInt(bits[2], 16),
                    parseInt(bits[3], 16)
                ];
            }
        },
        {
            re: /^(\w{1})(\w{1})(\w{1})$/,
            example: ['#fb0', 'f0f'],
            process: function (bits){
                return [
                    parseInt(bits[1] + bits[1], 16),
                    parseInt(bits[2] + bits[2], 16),
                    parseInt(bits[3] + bits[3], 16)
                ];
            }
        }
    ];

    // search through the definitions to find a match
    for (var i = 0; i < color_defs.length; i++) {
        var re = color_defs[i].re;
        var processor = color_defs[i].process;
        var bits = re.exec(color_string);
        if (bits) {
            channels = processor(bits);
            this.r = channels[0];
            this.g = channels[1];
            this.b = channels[2];
            this.ok = true;
        }

    }

    // validate/cleanup values
    this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r);
    this.g = (this.g < 0 || isNaN(this.g)) ? 0 : ((this.g > 255) ? 255 : this.g);
    this.b = (this.b < 0 || isNaN(this.b)) ? 0 : ((this.b > 255) ? 255 : this.b);

    // some getters
    this.toRGB = function () {
        return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')';
    }
    this.toHex = function () {
        var r = this.r.toString(16);
        var g = this.g.toString(16);
        var b = this.b.toString(16);
        if (r.length == 1) r = '0' + r;
        if (g.length == 1) g = '0' + g;
        if (b.length == 1) b = '0' + b;
        return '#' + r + g + b;
    }

}
