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:   This function preloads the mouseover images for the varioius
        category tabs to prevent blinking/make the swap faster.
----------------------------------------------------------*/
function preloader(){
   // Load the image sources into an array
   images = new Array();
   images[0]="Images/SiteDesign/imgColorTab1Over.jpg";
   images[1]="Images/SiteDesign/imgColorTab2Over.jpg";
   images[2]="Images/SiteDesign/imgColorTab3Over.jpg";
   images[3]="Images/SiteDesign/imgColorTab4Over.jpg";
   images[4]="Images/SiteDesign/imgColorTab5Over.jpg";
   images[5]="Images/SiteDesign/imgColorTab6Over.jpg";
   images[6]="Images/SiteDesign/imgColorTab7Over.jpg";
   images[7]="Images/SiteDesign/imgColorTab8Over.jpg";
   // create an Image Object to hold the preloaded images
      imageObj = new Array;
   var i = 0;
   // start the preloading!
   for(i=0; i<=7; i++){
        imageObj[i] = new Image;
        imageObj[i].src=images[i];}
  
}
/*---------------------------------------------------------
Author: Erik Roll
Desc:   The following two functions swap out the image for the various tabs
        on mouseover and mouseout.  They also set the bar at the top of the
        page to match the hovered tab.
----------------------------------------------------------*/
function bgOver(tab){
document.getElementById(tab).className='moused';
strHRColor = getBaseColorByID(tab);
if(tab=="Tab7"){
    document.getElementById(tab).style.color='black';}
//changeBGImage(strBGImage, tab);
changeHRColor(strHRColor);
}

function bgOut(tab){
strHRColor = getBaseColorByID(tab);
var hexPageTrimColor = new RGBColorLite(pageTrimColor);
hexPageTrimColor = hexPageTrimColor.toHex();
if(strHRColor!=hexPageTrimColor){
    document.getElementById(tab).className='';
    //strBGImage = "url('Images/SiteDesign/imgColor"+tab+theme+".jpg')";
    if(tab=="Tab7")
        {document.getElementById(tab).style.color='white';}
    //changeBGImage(strBGImage, tab);
    }
changeHRColor(pageTrimColor);}

/*---------------------------------------------------------
Author: Erik Roll
Desc:   The actual swap functions used by the previous two.
----------------------------------------------------------*/

function changeBGImage(strNew, tab){
document.getElementById(tab).style.backgroundImage=strNew;}

/*---------------------------------------------------------
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){
switch(tabID)
   {case(tabID="Tab1"):
      return "#f58436";
    case(tabID="Tab2"):
      return "#8f479b";
    case(tabID="Tab3"):
      return "#547891";
    case(tabID="Tab4"):
      return "#d0177a";
    case(tabID="Tab5"):
      return "#166736";
    case(tabID="Tab6"):
      return "#9ab13b";
    case(tabID="Tab7"):
      return "#fedc00";
    case(tabID="Tab8"):
      return "#a82e3b";}
}

/*---------------------------------------------------------
Author: Erik Roll
Desc:   Allows the page to determine which category is selected, 
        and load with the appropriate tab/button 'pushed' and 'highlighted'.
----------------------------------------------------------*/
function setSelectedTab(){
    // force conversion to HEX (FF uses RGBs when it pulls colors)
    var pageBaseColor = new RGBColorLite(pageTrimColor);
    var obj='';
    pageBaseColor = pageBaseColor.toHex();
    switch(pageBaseColor)
       {// Shirts & Blouses
       case "#f58436":
            obj = 'Tab1';
            break;
        // Pants, Skirts & Shorts
        case "#8f479b":
            obj = 'Tab2';
            break;
        // Chefs APparel & Aprons
        case "#547891":
            obj = 'Tab3';
            break;
        // Suit Separates
        case "#d0177a":
            obj = 'Tab4';
            break;
        // Security
        case "#166736":
            obj = 'Tab5';
            break;
        // Hospitality
        case "#9ab13b":
            obj = 'Tab6';
            break;
        // Signature Collection
        case "#fedc00":
            obj = 'Tab7';
            break;
        // Belts & Ties
        case "#a82e3b":
            obj = 'Tab8';
            break;
    }
    if (obj != '') {
    document.getElementById(obj).style.backgroundImage="url('Images/SiteDesign/imgColor" + obj + "Over.jpg')";
    document.getElementById(obj).parentElement.style.borderStyle='inset';}
}
  
/*---------------------------------------------------------
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;
    }

}

/*---------------------------------------------------------
Author: Erik Roll
Desc:   This function should position an element on top of a reference element droped onto the page for this purpose.
----------------------------------------------------------*/       
	function SetUploadCtrlsPosition(obj, refObj){
	obj.style.posLeft = refObj.offsetLeft;
	alert(refObj.offsetLeft);
	alert(obj.style.posLeft);
	obj.style.posTop = findPosY(refObj);
	alert(findPosY(refObj));
	alert(obj.style.posTop);
		}
  // Function findPosX(obj) used as part of public domain
  // by Peter-Paul Koch & Alex Tingle - Many Thanks!
function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  // Copied and modified from above. - Erik Roll  
function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }