var Geo = Class.create();

Geo.prototype = {
	initialize: function() {
	
	        this.country_code = 'US';	
	        this.country_code3 = 'USA';	
	        this.country_name = 'United States';	
	        this.region = '';	
	        this.city = '';	
	        this.postal_code = '';	
	        this.latitude = '38';	
	        this.longitude = '-97';	
	        this.dma_code = '0';	
	        this.area_code = '0';	
	        this.east = '-7719030';	
	        this.north = '6510996';	
		
		this.timer = null;
	},
    processRedirect: function(conditions) {
    	this.url = url;
    	var self = this;
    	for(j=0;j<conditions.length;j++) {
	    	for(i=0;i<conditions[j].conditions.length;i++) {
	    		var val = eval('this.'+conditions[j].conditions[i].name);
	    		if(val == conditions[j].conditions[i].value) {
	    			$('redirector').update(new Element('a', { 'href': 'javascript:gl.cancel()', 'class': 'cancel' }).update('Cancel'));
	    			$('redirector').insert(new Element('img', { 'style': 'float: left; margin-right: 6px;', 'src': '/images/flags/'+this.country_code.toLowerCase()+'.png' }));
	    			$('redirector').insert('You are being redirected to ');
	    			$('redirector').insert(new Element('a', { 'href': conditions[j].url }).update(conditions[j].url.truncate(42, '...')));		    			
	    			$('redirector').setStyle({
						'display': 'block',
					});
					var url = conditions[j].url;	
	    			this.timer = setTimeout ( function() {
						clearTimeout(self.timer);
						window.location = url;
					}, 100 );    			
	    			i = 99999;
	    		}
	    	}
	    }
    },
    cancel: function() {
    	var self = this;
    	clearTimeout(self.timer);
    	Effect.Fade('redirector');
    }
};



