/*
	Copyright DTDigital         :: www.dtdigital.com.au ::
	Unauthorised modification / use is a criminal offence, and
	will be prosecuted to the fullest extent permitted by law.
	All Rights Reserved
*/

NAVarr = new Array("home", "stores", "range", "diy", "gifts", "sustainability", "services", "contact", "entersite");
if (document.images)
{
	for (var NAVitem in NAVarr)
	{ 
		 for (var NAVicount=0; NAVicount < 2; NAVicount++)
		 { 
				eval("b" + NAVarr[NAVitem] + NAVicount + " = new Image()");
				eval("b" + NAVarr[NAVitem] + NAVicount + ".src = 'assets/swap_" + NAVarr[NAVitem] + "_" + NAVicount + ".gif'");
		 } 
	} 
}

function BturnOn(imageName)
{
	if (document.images)
	{
		var imageNumber = "";
		if (arguments.length > 1) imageNumber = arguments[1];
		document [imageName + imageNumber].src = eval("b" + imageName + "1.src");
	}
}

function BturnOff(imageName)
{
	if (document.images)
	{
		var imageNumber = "";
		if (arguments.length > 1) imageNumber = arguments[1];
		document [imageName + imageNumber].src = eval("b" + imageName + "0.src");
	}
}

function BturnOnInput(obj,imageName)
{
	if (obj.src)
	{
		obj.src = eval("b" + imageName + "1.src");
	}
}

function BturnOffInput(obj,imageName)
{
	if (obj.src)
	{
		obj.src = eval("b" + imageName + "0.src");
	}
}

function ddRedirect(dd)
{
	if (dd.options[dd.selectedIndex].value != "") self.location = dd.options[dd.selectedIndex].value;
}


function ismaxlength(obj, maxlength)
{
	if (obj.value.length>maxlength)
	{
		obj.value=obj.value.substring(0,maxlength)
	}
}

function addQuantityToLink(link)
{
	var quantityValue = document.getElementById("ProductDetailQuantity").value
	
	return link.href + "&quantity=" + quantityValue;
}


//Online Catalogue
function openOnlineCataloguePopup()
{
	Width = 1000;
	Height = 680;
	TopPosn = screen.height ? (screen.height - Height) / 2 : 100;
	LeftPosn = screen.width ? (screen.width - Width) / 2 : 100;
	window.open("emag/bunnings/index.html?document=catalogue/" + getEmagRegion(), "_blank", "top="+TopPosn+",left="+LeftPosn+",width="+Width+",height="+Height+", resizable=yes");
}

		              
function getEmagRegion()
{
	if (window.emagRegion)
	{
		return emagRegion;
	}
	else 
	{
		return "catalogue";
	}
}


var _jQueryLoaded = (typeof(jQuery) == "function");

if (_jQueryLoaded)
{
	$(document).ready(function()
	{
		$("a.hideselectsinie6").mouseover(function()
		{
			$("select.hideselectinie6").css("visibility", "hidden");
		});
		
		$("a.hideselectsinie6").mouseout(function()
		{
			$("select.hideselectinie6").css("visibility", "visible");
		});
		
		// Fixes flicker on nav in IE6.
        var isLocationActive = false;
        
        $(".hoverify").hover(function() {
            if($(this).find("img:first").attr("src").match("_1"))
            {
                isLocationActive = true;
            } else {
                $(this).find("img:first").attr("src", ($(this).find("img").attr("src").replace("_0", "_1")));
            }
        }, function() {
            (isLocationActive) ? isLocationActive = false : $(this).find("img:first").attr("src", ($(this).find("img").attr("src").replace("_1", "_0")));
        });
		$(".search1_autocomplete").autocomplete(
			"WebServices/keywords.aspx",
			{
			    delay: 0,
			    minChars: 0,
			    maxItemsToShow: 10
			}
		);
		
	});
}
