/* *********
*
* zonevip
* для работы необходим mootools 1.2
*
********* */


/* 
*****  возвращает путь к файлу и имя файла  ****
dir_name - путь от корня до файла не включая его
file_name - полное имя файла
ext - расширение с точкой
остальные для формата   имя_файла_нечто_состояние_язык.расширение
lang - язык
 state - состояние 
name - все что до двух предыдущих
*/
var File = new Class({

	initialize: function (path)
	{
		this.path = path; 
		this.dir_name='/';
		this.string_array=this.path.split('/');
		for(i=3;i<this.string_array.length-1;i++)
		{
			this.dir_name = this.dir_name + this.string_array[i] + '/';
		}
		this.file_name = this.string_array[this.string_array.length -1];
	
		//парсим имя файла
		this.tmp = new Array();
		this.tmp = this.file_name.split('.');//расширение по точке
		this.ext = '.' + this.tmp[1];
		this.tmp2 = new Array();
		this.tmp2 = this.tmp[0].split('_');//  _ - разделитель
		this.lang = '_' + this.tmp2[this.tmp2.length - 1];
		this.state = '_' + this.tmp2[this.tmp2.length - 2];
		this.name = this.tmp2[0];
		for(i=1;i<(this.tmp2.length - 2);i++)
		{
			this.name = this.name + '_' + this.tmp2[i];
		}
	}
});

/*************************************
*
*
*
**************************************/

var mWindow = new Class({

	Implements: [Events, Options],
	
	options: {
		url: '',
		query: '',
		width: 250,
		height: 160,
		title: '',
		x: 30,
		y: 30,
		evalResponse: true,
		evalScripts: true,
		demo: true
		
	},
	
	initialize: function(options){
			this.setOptions(options);
	},
	
	setTitle: function(title){
		title = title.standardize();
		//title = title.stripTags();
		this.options.title = title;
	},
	
	open: function(query){
		
		var cleanQuery = this.options.query.cleanQueryString(function(set){
			return !set.split("=")[0].match(/id/);
			
		});

		if(cleanQuery.length == 0) this.options.query = '?' + query;
		else this.options.query = '?' + cleanQuery + '&' + query;
		
		this.create();
		this.wind();
	},
	
	create: function(){
		var _self = this;
		this.wind = function(){
			new MochaUI.Window({
				id: 'mwindow',
				title: _self.options.title,
				resizable: false,
				loadMethod: 'xhr',
				contentURL: _self.options.url + _self.options.query,
				
				width: _self.options.width,
			
				height: _self.options.height,
				
				x: _self.options.x,
				
				y: _self.options.y,
				
				onContentLoaded: function(){
					//var c_width = $('mwindow_content').getScrollSize().x;
					//var c_height = $('mwindow_content').getScrollSize().y;
					
				},
				cornerRadius: 2
			});
		}
	}
	

	
});


var wFoto;
var w;

function popup_toggle(elem){
	elem = $(elem);
	
	$('popup_image_container').getFirst('img').destroy();
	$('popup_image_container').setStyle('background-image',"url('/gif/zaparketom/preload.gif')");
	
	var myImage = new Asset.image(elem.href,{
		onload: function(){
			var ins = function(){
				this.inject($('popup_image_container'));
				$('popup_image_container').setStyle('background-image','none');
			};
			ins.delay(500,this);
			
			
		}
	});
	
	
		
}

/* *************************************
*
*  UMI REQUEST
*
************************************ */

var umiRequest = new Class({
	initialize: function (){

		},
	send: function (request){
			this.cook = document.cookie;//получаем все куки
			request.setHeader('Cookie', this.cook);
			request.send();
		}
});

