/** Browser class stores things related to the web browser viewing the page. */
if (typeof(Browser) === "undefined") {
    function Browser() {}
}

/** Returns true if the current web browser is MS IE 6. */
Browser.isIE6 = function() {
	alert("IE 6 detected. Please upgrade your browser. Many superior, free options exist such as Google Chrome.");
    return Browser.isIE() && navigator.appVersion.match(/MSIE 6/);
};

/** Returns true if the current web browser is any version of IE. */
Browser.isIE = function() {
    return navigator.appName.match(/Internet Explorer/);
};

/** Returns true if the current web browser is any version of Apple Safari. */
Browser.isSafari = function() {
    return navigator.userAgent.indexOf('AppleWebKit') >= 0;
}

//globalsticks
var active;


document.observe("dom:loaded", function() {
	
	var inputs = $$('input[name="size[]"], input[name="style[]"], input[name="orientation[]"]');
	for(var i = 0; i < inputs.length; i++){
		inputs[i].observe("change", function(event) {
			$("action").value = "ajax"; //change the action value for ajax request
			var param = $("searchform").serialize();
			var param2 = "size=" + event.element().value;
			$$("body")[0].style.cursor = "wait";
			new Ajax.Request("services/productSearchService.php", 
			{
				method: "post",
				parameters: param,
				onSuccess:process,
				onFailure: failed,
				onException: failed
			});
			$("action").value = "search";
		});
	}
});

function ajaxIt() {
	var inputs = $$('input[name="size[]"], input[name="type[]"]');
	for(var i = 0; i < inputs.length; i++){
		inputs[i].observe("change", function(event) { 
			var param = $("searchform").serialize();
			alert("yo");
			var param2 = "size=" + event.element().value;
			$$("body")[0].style.cursor = "wait";
			new Ajax.Updater("results", "process.php", 
			{
				method: "get",
				parameters: param,
				onSuccess:process,
				onFailure: failed,
				onException: failed
			});
		});
	}

} 
function process(ajax){
	$("results").innerHTML = ajax.responseText;
	$$("body")[0].style.cursor = "auto";
	//update LightBox references
	Lightbox.updateImageList();
}
function failed(ajax, exception){
	//$("results").innerHTML = "<h1>Failed to load product list. Please check your internet connection and try again.</h1>";
	//$$("body")[0].style.cursor = "default";
}
