﻿

 
 // Detta ska göras när DOM-trädet finns - OnDomReady
$(document).ready(function(){

	addAutoCompletion();
	
	// Add click event to searchbutton
	$("#ctl00_buttonSearch").click(function(event){  
	        checkSearchParams(event);   
	    }
	);
	
	$('a#ctl00_hlLogin').attr('href', '/Login.aspx?height=240&width=390&mode=1');
	$("a#ctl00_hlLogin").attr("target", "_blank");

});


/*******************************
** Lägger till autocompletion på input-fält
********************************/
function addAutoCompletion()
{
	//Var
    var url = "http://" + location.host + "/AutoComplete.ashx?autoCompleteMode=where";
    $("#location").suggest(url,{
	    delimiter: ","
    });
    
    //Vad
	url = "http://" + location.host + "/AutoComplete.ashx?autoCompleteMode=what";
    $("#srcword").suggest(url, {
		delimiter: "," ,
		minchars: 3,
		headerClass: "header"
    });
}

function checkSearchParams(event)
{
   if( $("#srcword").val().length<=1 && $("#location").val().length<=1 )
   {
        $("#search-form li span.message").css("display", "block");
        event.preventDefault();
   }
   else
   {
        $("#search-form li span.message").css("display", "none");
   }
}
