// JavaScript Document
// Firebug issues
try{ console.log('[init] OK'); }catch(e){ console={ log:function(){} } }

// Debug mode
var debug=true;
// Site url
var site_url='www.rienamemettre.com';


/**
 * Home init
 * @version 2008.11.11.0002
 */
function home_init(){
	Sortable.create('zones_home_1',{
		containment: ['zones_home_1','zones_home_2'], 
		dropOnEmpty: true, 
		handle: 'zone_home_handle',
		onUpdate: function(container){
			//alert(container.id);
		}
	});
	
	Sortable.create('zones_home_2',{
		containment: ['zones_home_1','zones_home_2'], 
		dropOnEmpty: true,
		handle: 'zone_home_handle',
		onUpdate: function(container){
			//alert(container.id);
		}
	});
	
//	Effect.Appear('look_laius');

}

function show_look_data(){
	$('look_laius').style.marginTop="-300px";
	$('look_laius').style.height="300px";
}

function hide_look_data(){
	$('look_laius').style.marginTop="-26px";
	$('look_laius').style.height="26px";
}

/**
 *	Une ville a été choisie
 *	@version 2008.10.11
 */
function addItemToList(el){
	var date=new Date;
	date.setDate(date.getDate()+14);
	EcrireCookie('meteo_zone_id', el.id, date, '/', '.rienamemettre.com', false);
	document.getElementById('ldj_ville').innerHTML=el.innerHTML;
	window.location.href="http://"+site_url+"/";
}

function EcrireCookie(nom, valeur){
	var argv=EcrireCookie.arguments;
	var argc=EcrireCookie.arguments.length;
	var expires=(argc > 2) ? argv[2] : null;
	var path=(argc > 3) ? argv[3] : null;
	var domain=(argc > 4) ? argv[4] : null;
	var secure=(argc > 5) ? argv[5] : false;
	document.cookie=nom+"="+escape(valeur)+
	((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
	((path==null) ? "" : ("; path="+path))+
	((domain==null) ? "" : ("; domain="+domain))+
	((secure==true) ? "; secure" : "");
}

function change_ville(){
	document.getElementById('ldj_ville').innerHTML='<span style="display:inline-block; vertical-align:top; margin-top:-1px;"><input type="text" id="autocomplete" style="height:16px; width:140px; font-size:12px; border:1px solid #999;" value="" onfocus="javascript:this.value=\'\';" name="ville" /></span><span id="indicator1" style="display:none; vertical-align:top;"> </span><div id="autocomplete_choices" class="autocomplete"></div>';
	
	new Ajax.Autocompleter("autocomplete", "autocomplete_choices", "/ajax_villes.php", {
	  paramName: "value", 
	  minChars: 3, 
	  updateElement: addItemToList,
	  indicator: 'indicator1'
	});
}