/**
 *	Spirit Concurrent Versioning
 *	~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *	Copyright 		: Isotope Communications 2006
 *	Version 		: 0.1 alpha
 * 	Author  		: Jim Morrsion
 *
 *	Requirements	: prototype, cookies, json
 */

 
var lanFramework = new Class.create();

lanFramework.prototype = {
	
	initialize : function () {
		this.load_cookie();
	},
	
	load_cookie : function (){
		this.cookies = new HTTP.Cookies();
		this.cookie = this.cookies.readJSON('lan');
		if ( !this.cookie ) {
			this.cookie = new Object();
		}
		//alert(this.cookie.toJSONString());
		this.valid = this.cookie.ticket;
	},

	set_cookie : function (){
		this.cookies.writeJSON('lan',this.cookie,'+1M','/');
	},
	
	change : function ( v, c, d ) {
		if ( v == -1 ) {
			this.cookie.version = '';
			this.cookie.code 	= '';
			this.cookie.ticket 	= '';
		} else {
			this.cookie.version = v;
			this.cookie.code 	= c;
		}
		this.set_cookie();
		if ( d ) {
			document.location.href = d;
		} else { 
			document.location.reload(1);
		}
	},
	
	show : function () {
		if ( $('lan_list') ) {
			$('lan_list').show();
		} else {
			
		}
		this.reset_timer();
	},
	
	hide : function () {
		this.reset_timer();
		this.hideTimer = setTimeout( this.do_hide, 200 );
	},
	
	do_hide : function () {
		if ( $('lan_list') ) {
			Element.hide( $('lan_list') ) ;
		}
	},
	
	reset_timer : function () {
		if ( this.hideTimer ){
			clearTimeout( this.hideTimer );
		}
	},
	
	xnull : null 
}
oLan = new lanFramework();
