// JavaScript Document
function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );

  if ( secure )
        cookie_string += "; secure";

  document.cookie = cookie_string;
}

function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

function set_traditional_search()
{
	var t = this.document.getElementById("traditional_bt");
	var to = this.document.getElementById("traditional_options");
	var i = this.document.getElementById("intuitive_bt");
	
	set_cookie("search_method","Traditional Search", 2020, 01, 01, null, ".milim.com");		// THIS IS FOR THE LIVE ENVIRONMENT
	//set_cookie("search_method","Traditional Search", 2021, 01, 01, null, null);			// THIS IS FOR LOCAL TESTING
	
	this.document.keyForm.action = "http://search.milim.com/result1a.lasso";
	this.document.keyForm.method = "POST";
	
	i.style.display = 'none';
	t.style.display = 'block';
	to.style.display = 'inline';
}

function set_intuitive_search()
{
	var t = this.document.getElementById("traditional_bt");
	var to = this.document.getElementById("traditional_options");
	var i = this.document.getElementById("intuitive_bt");
	
	set_cookie("search_method","Intuitive Search", 2020, 01, 01, null, ".milim.com");		// THIS IS FOR THE LIVE ENVIRONMENT
	//set_cookie("search_method","Intuitive Search", 2021, 01, 01, null, null);				// THIS IS FOR LOCAL TESTING
	
	this.document.keyForm.action = "http://search.milim.com/more.lasso";
	this.document.keyForm.method = "GET";
	
	to.style.display = 'none';
	t.style.display = 'none';
	i.style.display = 'block';
}

function choose_search()
{
	var s = this.document.keyForm.searchMethod.options[this.document.keyForm.searchMethod.options.selectedIndex].value;
	
	if(s == "Traditional Search")
	{
		set_traditional_search();
	}
	else if(s == "Intuitive Search")
	{
		set_intuitive_search();
	}
}

function check_search()
{
	var s = get_cookie("search_method");
	
	if(s == "Intuitive Search")
	{
		set_intuitive_search();
	}
	else
	{
		set_traditional_search();
	}
}
