if (self.location==top.location) {
	 window.location="http://www.qualityheadwear.com"
}


var iBannerCount = 1;
var sBanner;

//==============================================================================
// default status
// Description: Check user's browser if 4.0 and up
//==============================================================================
function def_status() {
				 window.status = "Welcome to Quality Headwear!";
}


//==============================================================================
// Check browser type
// Description: Check user's browser if 4.0 and up
//==============================================================================

var NS4 = (document.layers);
var IE4 = (document.all);

var NS6 = (navigator.appName.indexOf("Netscape") > -1)
		&& (navigator.appVersion.substring(0,1) >= 5);

//var OP5 = (navigator.appName.indexOf("Opera") > -1)
		//&& (navigator.appVersion.substring(0,1) >= 5);

IE4=(IE4 || NS6)

var ver4 = (NS4 || IE4 || NS6);
var isMac = (navigator.appVersion.indexOf("Mac") != -1);

// redirect if no version 4+ browser
if (!ver4) {
	window.location="/warning.asp?sMiss=browser"
}


//==============================================================================
// Function: checkFlash( )
// Description: Detect Macromedia Flash Player
//==============================================================================
function checkFlash() {

   if ((navigator.appName == "Microsoft Internet Explorer" &&
      navigator.appVersion.indexOf("Mac") == -1 && navigator.appVersion.indexOf("3.0") == -1) ||
      (navigator.plugins && navigator.plugins["Shockwave Flash"]) || navigator.plugins["Shockwave Flash 2.0"]){

      if (NS4 || NS6) {
         var plugin = (navigator.mimeTypes && 
            navigator.mimeTypes["application/x-shockwave-flash"] ? 
            navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0);
   
         if (plugin && 
            parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= 4) { 
            //Flash 4 or greater is available
         } else { 
            //Flash 4 is not available
            window.location='warning.asp?sMiss=flash';
         }
      }   

      //Load a pre-defined HTML page with Shockwave in it into the browser window.
	  //window.location='yourshocked.html';
   } else {
	  //Load a pre-defined HTML page without Shockwave into the browser window.
	  window.location='warning.asp?sMiss=flash';
   }
}


//==============================================================================
// Function: testCookies( )
// Description: Detect Cookie
//==============================================================================
function testCookies() {
   var sVal = "true";
   var expdate = new Date ();
   var expString = "";
   
   expdate.setTime (expdate.getTime() + (1000 * 60 * 60));
   expString = "expires=" + expdate.toGMTString();

   document.cookie = "COOKIE_TEST=" + escape(sVal) + ";" + expString + ";";
   document.cookie = "SESSCOOKIETEST=" + escape(sVal) + ";";
   //alert(document.cookie);
   sCoo = getCookie("COOKIE_TEST");
   sSess = getCookie("SESSCOOKIETEST");
   //alert("Cookie=" + sCoo + " Session=" + sSess);
   
   if (sCoo != "true" || sSess != "true") {
      //alert("cookies are OFF");
      window.location='warning.asp?sMiss=cookie';
   //} else {
      //alert("cookies are ON");
   }
   document.cookie = "COOKIE_TEST=";
}


//==============================================================================
// Function: setCookie( [Promo Item names], [Promo Item values] )
// Description: Check user's browser if 4.0 and up
//==============================================================================
function setCookie(sName, sValue) {
   var expdate = new Date ();
   var expString = "";

   //expdate.setTime (expdate.getTime() + (1000 * 60 * 60));
   //expString = "expires=" + expdate.toGMTString();
   
   //document.cookie = sName + "=" + escape(sValue) + ";" + expString + ";";
   document.cookie = sName + "=" + escape(sValue) + ";";
}


//==============================================================================
// Function: getCookie( [Promo Item names] )
// Description: Get cookie values
//==============================================================================
function getCookie(sName) {
   var sValue = null;
   var myCookie = document.cookie + ";";
   var sTag = sName + "=";
   var endPos;
   
   if (myCookie.length > 0) {
      var beginPos = myCookie.indexOf(sTag);
	  if (beginPos != -1) {
	     beginPos = beginPos + sTag.length;
		 endPos = myCookie.indexOf(";", beginPos);
		 if (endPos == -1) {
		    endPos = myCookie.length;
	     }
		 sValue = unescape(myCookie.substring(beginPos, endPos));
	  }
   }
   return sValue;
}



//==============================================================================
// Function: onONE( [Item file names], [Form path] )
// Description: Change Image when selected
//==============================================================================
function onONE(sVal, sform) {

   if (sVal == null) {
      if (NS4) {
		 sVal = sform.selectedIndex;
      } else {
         sVal = document.Prod_Item.COLOR.value;
      }
	  sImage = aProd[sVal][0];
	  
   } else {
      sImage = aProd[sVal][0];
      if (NS4) {
		 document.Prod_Item.COLOR.selectedIndex = sVal;
      } else {
         document.Prod_Item.COLOR.value = sVal;
      }
   }
   document.Large.src = "../images/products/250x250/" + sImage;
}


//==============================================================================
// Function: onSize( [Item file names] )
// Description: Change size depends on size availabilities
//==============================================================================
function onSize(sVal) {
   var sProduct_Size = 0;
   
   if (sVal == null) {
      if (NS4) {
		 sVal = oFORM.COLOR.selectedIndex;
      } else {
         sVal = document.Prod_Item.COLOR.value;
      }	  
   }
   
   sProduct_Size = aProd[sVal][1];
      
   if (NS4) {
      document.Prod_Item.SIZE.selectedIndex = "0";
   } else {
      document.Prod_Item.SIZE.value = "0";
   }
   
   if (NS6 || NS4) {
	  oFORM.SIZE.length = 1;
	  
	  if (sProduct_Size == 1) {
	     oFORM.SIZE.length = 2;
		 oFORM.SIZE.options[1].value = "1";
	     oFORM.SIZE.options[1].text = "M";
	  }
   } else {
      Prod_Item.SIZE.length = 1;
	  
      if (sProduct_Size == 1) {
         Prod_Item.SIZE.length = 2;
		 Prod_Item.SIZE.options[1].value = "1";
         Prod_Item.SIZE.options[1].text = "M";
      }
   }
}


//==============================================================================
// Function: ChangeProduct( [Form path] )
// Description: Change Category for header jump menu
//==============================================================================
function ChangeProduct(sform) {

   if (NS4) {
      var sCatalog = sform.Prod_Cat.options[sform.Prod_Cat.selectedIndex].value;
   } else {
      var sCatalog = document.Catalog.Prod_Cat.value;
   }

   if (sCatalog == "search") {
     document.location.href="search.asp";
   } else if (sCatalog != 0) {
     document.location.href="product_list.asp?iCat=" + sCatalog;
   }
}


//==============================================================================
// Function: knp_Link( [Link to file] )
// Description: redirect and link to another page
//==============================================================================
function knp_Link(sLink) {
   document.location.href = sLink;
}


//==============================================================================
// Function: roll_banner( )
// Description: rotate banner for promotional products
//==============================================================================
function roll_banner() {
   var iCount = getCookie('iCount');
   if (iBannerCount == iCount) {
      iBannerCount = 0;
   }
 
   var sImage = getCookie('sImage' + iBannerCount);
 
   document.Banner.src = "../images/products/90x90/" + sImage;
	 
   iBannerCount++;

   if (iCount > 1) {
      sBanner = setTimeout("roll_banner()",5000);
   }
}


//==============================================================================
// Function: PromoItems( [Width of table], [Number] )
// Description: Display Promotion Items
//==============================================================================
function PromoItems(iWidth, iNum) {
   var sNowColor = "E8EFF9";
   var sImage = getCookie('sImage0');
   var iCount = getCookie('iCount');
   var sProdCatID;
   var sProdName;
   var sProdCode;

   if (iWidth != "100%") {
      document.write ("<img src='../images/products/90x90/" + sImage + "' width='90' height='90' name='Banner' border='0'><br>");
      document.write ("<p>");
   }
   
   
   document.write ("<table width='" + iWidth + "' border='0' cellpadding='3' bordercolor='#E8EFF9' cellspacing='0'");

   for (i = 0; i < iCount; i++) {
     sImage = getCookie('sImage' + i);
     sProdCatID = getCookie('sProdCatID' + i);
	 sProdName = getCookie('sProdName' + i);
	 sProdCode = getCookie('sProdCode' + i);
	 
     if (iNum != null) {
	    if (i % 2 == 0) {
	       sNowColor = "E8EFF9";
	    } else {
	       sNowColor = "D2DFF2";
        }
     }

	 document.write ("<tr bgcolor='#" + sNowColor + "'>"); 
     document.write ("<td width='15' align='center' valign='top'><img src='../images/bullet.gif' width='10' height='10' name='bullet" + i + "'></td>");
     document.write ("<td align='left' valign='top'><div class='noline'><a href='product.asp?iCat=" + sProdCatID + "&prodID=" + sProdCode + "' onMouseOver=\"swap_img('Banner','" + sImage + "', 'bullet" + i + "')\" onMouseOut=\"unswap_img('Banner', 'bullet" + i + "')\">" + sProdName + "</a></div></td>");
     document.write ("</tr>");
   }
   document.write ("</table>");
   
   if (iWidth != "100%") {
      document.write ("</p><p>&nbsp;</p>");
   }
}


//==============================================================================
// Function: swap_img( [Image name], [Item file names], [Bullet name] )
// Description: Swap images if mouse over
//==============================================================================
function swap_img (imgName, sImage, bullet) {
   document[imgName].src = "../images/products/90x90/" + sImage;
   document[bullet].src = "../images/bullet-on.gif";
   clearTimeout(sBanner);
}


//==============================================================================
// Function: swap_img( [Image name], [Bullet name] )
// Description: Swap images if mouse out
//==============================================================================
function unswap_img (imgName, bullet) {
   var iCount = getCookie('iCount');

   document[bullet].src = "../images/bullet.gif";
   
   if (iCount > 1) {
      sBanner = setTimeout("roll_banner()",5000);
   }
}


//==============================================================================
// Function: MM_preloadImages( )
// Description: Preload Images
//==============================================================================
function MM_preloadImages() {
  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: openLink( [Link to file] )
// Description: Open another window
//==============================================================================
function openLink(sLink) {
  window.open(sLink,'ImageWindow','location=no,toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no,width=400,height=400')
}




//==============================================================================
// Function: goBack(  )
// Description: Go back one page
//==============================================================================
function goBack() {
   window.history.go(-1);
}
//-->