/*
	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
*/

function CreateRollover($links)
{
	var $inactive = $links.getElementsByTagName("img")[0];
	$inactive.style.display = "block";
	
	if(!$inactive.src.match(/hover/))
	{
		var $hover = document.createElement("img");
		$hover.src = $inactive.src.replace("_inactive", "_hover");
		$hover.alt = $inactive.alt;
		$hover.width = $inactive.width;
		$hover.height = $inactive.height;
		$hover.style.display = "none";
		
		$links.onmouseover = function()
		{
			$inactive.style.display = "none";
			$hover.style.display = "block";
		};
		
		$links.onmouseout = function()
		{
			$inactive.style.display = "block";
			$hover.style.display = "none";
		};
		
		$links.appendChild($hover);
	}
}

function RegisterMenu()
{
	if(document.getElementById("menu"))
	{
		var $menu = document.getElementById("menu");
		var $links = $menu.getElementsByTagName("a");
		
		for(var i = 0; i < $links.length; i++)
		{
			CreateRollover($links[i]);
		}
	}
}

function RegisterProducts()
{
	if(document.getElementById("products"))
	{
		var $menu = document.getElementById("products");
		var $links = $menu.getElementsByTagName("a");
		
		for(var i = 0; i < $links.length; i++)
		{
			CreateRollover($links[i]);
		}
	}
}

function FieldhintInput() {
    var f = document.createElement("input"),
        isNative = !!("placeholder" in f), hint;
     
    if(!isNative) {
        $(".fieldhint").each(function(i, el) {
            hint = $(el).attr("placeholder");
            $(el).val(hint);
 
            $(el).bind({
                "focusin": function(e) {
                    if ($(el).val() === hint) {
                        $(el).val("");
                    }
                },
                "focusout": function(e) {
                    if ($(el).val() === "") {
                        $(el).val(hint);
                    }
                }
            });
        });
    }
}

window.onload = function()
{
	FieldhintInput();
	RegisterMenu();
	RegisterProducts();


	if ($.fn.autocomplete) {
	    $(".search1_autocomplete").autocomplete(
				"WebServices/LocationFinder.asmx/LocationAutoSuggest",
				{
				    delay: 0,
				    minChars: 3,
				    maxItemsToShow: 10
				}
			);
	}

}



