var transparentImage = "images/transparent.gif";


function fixTrans()
{
	if (typeof document.body.style.maxHeight == 'undefined') {

	var imgs = document.getElementsByTagName("img");
	
	for (i = 0; i < imgs.length; i++)
	{	
		if (imgs[i].src.indexOf(transparentImage) != -1)
		{
			return;
		}

		if (imgs[i].src.indexOf(".png") != -1)
			{
				var src = imgs[i].src;
				imgs[i].src = transparentImage;
				imgs[i].runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
			}
		}	
	}
}

if (document.all && !window.opera)
	attachEvent("onload", fixTrans);
	

function openWindow(url) {
				 var newWin =
				 window.open(url,'','width=500,height=450,resizable=yes');
}

function newImage(arg) {
				 if (document.images) {
						rslt = new Image();
								 rslt.src = arg;
													return rslt;
													}
}

function changeImages() {
				 if (document.images && (preloadFlag == true)) {
						for (var i=0; i<changeImages.arguments.length; i+=2) {
										 document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
								}
								}
}

var preloadFlag = false;
function preloadImages() {
				 if (document.images) {
						texas_map_over = newImage("/images/texas_map_over.gif");
													 texas_map_over003 =
													 newImage("/images/texas_map_over-03.gif");
																texas_map_over004 =
																newImage("/images/texas_map_over-04.gif");
																				texas_map_over005 =
																				newImage("/images/texas_map_over-05.gif");
																								texas_map_over006 =
																								newImage("/images/texas_map_over-06.gif");
																												texas_map_over007 =
																												newImage("/images/texas_map_over-07.gif");
																																texas_map_over008 = newImage("/images/texas_map_over-08.gif");
																																									
																																												//stowaway
																																																if
																																																(document.getElementById("Ecom_ShipTo_Postal_CountyID")
																																																!=
																																																null)
																																																{
																																																								var county_obj = document.getElementById("Ecom_ShipTo_Postal_CountyID");
																																																															 county_obj.style.display = 'none'; 
																																																																												}
																																																																												 if (document.getElementById("CountySelectorDescriptor") != null) {
																																																																																																								 var countySelector_obj = document.getElementById("CountySelectorDescriptor");
																																																																																																																				countySelector_obj.style.display = 'none';
																																																																																																																																				 }
																																																																																																																																				  //
																																																																																																																																					 preloadFlag = true;
																																																																																																																																					 }
}

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;
}
/* Functions that swaps images. */
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];}
}
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 set_int_ship_only(){ //called when Country select box is clicked
				 var countryval =
				 document.getElementsByName("Ecom_ShipTo_Postal_CountryCode")[0].value;
				 if (countryval != 'US'){
						document.getElementsByName("ship_Method")[0].value = 3;
																															 }
																															 else if
				 (countryval == 'US'){
										 var shipval =
				 document.getElementsByName("ship_Method")[0].value;
								if (shipval = 3){
														document.getElementsByName("ship_Method")[0].value
				 = 1;
					 }
					 }
}
function check_ship_method (){  //called when Shipping Method select box is
				 clicked
				 //alert("test");
				 var countryval =
				 document.getElementsByName("Ecom_ShipTo_Postal_CountryCode")[0].value;
				 if (countryval != 'US'){
						document.getElementsByName("ship_Method")[0].value = 3;
																															 alert("International Shipping must be selected for addresses outside of the United States.");
																															 }
}
function checkforTX (){  //called when State is selected
				 //alert("test");
				 var state_val =
				 document.getElementsByName("Ecom_ShipTo_Postal_StateProv")[0].value;
				 var county_obj =
				 document.getElementById("Ecom_ShipTo_Postal_CountyID");
				 var countySelector_obj =
				 document.getElementById("CountySelectorDescriptor");
				 if (state_val == 'TX'){
						//document.getElementsByName("ship_Method")[0].value = 3;
																																 //alert("International Shipping must be selected for addresses outside of the United States.");
																																												//alert("Texas is selected");
																																																			 county_obj.style.display = ''; //show county selector
																																																																countySelector_obj.style.display = '';
																																																																}else{
																																																																 //alert("Texas is not selected");
																																																																								county_obj.style.display = 'none'; //hide county selector
																																																																																				 countySelector_obj.style.display = 'none';
																																																																																				 }
}




//JQUERY SITE CODE
//to avoid conflict with jquery
jQuery.noConflict();
jQuery(document).ready(function($){
    //variable to track whether search box is visible or not
    var var_open_indicator;
    var_open_indicator = "closed";

    //CLICK HANDLER FOR SEARCH LINK
    $('#navigation12').click(function() {
        //check if the searchbox is visible or not and hide or show as appropriate
        switch(var_open_indicator){
            case "closed":
                var_open_indicator = "open";
                $('#searchBox').animate({
                    top: "123px"
                    }, { duration: "slow" } );
                break;
            case "open":
                var_open_indicator = "closed";
                $('#searchBox').animate({
                    top: "173px"
                    }, { duration: "slow" } );
                break;
        }
        return false;
  });
});

   window.addEvent('domready', function(){
	//Accordion effect on for secondary navigation under 'SUBSCRIBE TODAY'
	var szNormal = 47, szSmall = 47, szFull = 88, szFull_x = 81;

	var kwicks = $$("#color_bars .bars");
	var fx = new Fx.Elements(kwicks, {wait: false, duration: 300, transition: Fx.Transitions.Back.easeOut});

	kwicks.each(function(kwick, i) {
		kwick.addEvent("mouseenter", function(event) {
			var o = {};
			if(kwick.hasClass('dept'))
				o[i] = {height: [kwick.getStyle("height").toInt(), szFull_x]}
			else
				o[i] = {height: [kwick.getStyle("height").toInt(), szFull]}

			kwicks.each(function(other, j) {
				if(i != j) {
					var w = other.getStyle("height").toInt();
					if(w != szSmall) o[j] = {height: [w, szSmall]};

				}
			});
			fx.start(o);
		});
	});

	kwicks.addEvent("mouseleave", function(event) {
		var o = {};
		kwicks.each(function(kwick, i) {
        	if(kwick.hasClass('dept'))
				o[i] = {height: [kwick.getStyle("height").toInt(), szFull_x]}
			else
				o[i] = {height: [kwick.getStyle("height").toInt(), szNormal]}

		});
		fx.start(o);
	});

   });



