// JavaScript Document

function select_language(selection) { 
	if(!selection == "")
	{
		selected_text = document.getElementById('lstCountry').options[document.getElementById('lstCountry').selectedIndex].text;
		
		set_cookie ("hids_countrycode", selected_text,'/',0);
		document.location.href=document.location.href='../../'+selection+'/html/index.html?cc='+selection+'&cname='+escape(selected_text);
		////*** alert("value: " + selection);
	} else {
		//*** alert('selection was empty');
		document.location.href=document.location.href;
	}
}

function get_cookie ( cookie_name)
{
	//alert("getting cookie with name: " + cookie_name); 
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

  if ( results ) {
	  //alert("found cookie with name: " + cookie_name + " and value: " + unescape(results[1]));
	  return ( unescape ( results[1] ) );
  } else {
	 //alert("did not find cookie with name: " + cookie_name);
   	 return null;
  }
}

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

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

  document.cookie = cookie_string;
  //*** alert('set cookie to: ' + 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();
  alert("deleting cookie");
}

