var notify = null;
var chkTimer = null;
window.addEvent('domready', function() {
	document.Notify = new NotificationsManager();
});


function changeLang(alias) {
	str = window.location.href;
	langs = new Array('/en/', '/ru/', '/de/', '/fr/', '/es/', '/it/', '/pt/');
	var ch = false;
	for(j=0;j<6;j++) {
		if (str.lastIndexOf(langs[j]) !== -1) {
			st = str.indexOf(langs[j]);
			ns = str.substr(0, st+1);
			ns += alias+str.substr(st+3);
			ch = true;
			break;
		}
	}
	if (ch == false) {
		bd = base_url.substr(7);
		st = str.indexOf(bd);
		ns = base_url+alias+'/'+str.substr(st+bd.length);
	}
	window.location.href = ns;
	
	var myTips = new Tips($$('.tip'), {
		maxTitleChar: 50
	} );
}
function submitForm(frmID) {
	$(frmID).submit();
}
function resetForm(frmID) {
	$(frmID).reset();
}

function setAutoRemove(id, val) {
	$(id).addEvent('focus', function() {
		if (this.get('value') == val) {
			this.set('value', '');
		}
	});
	$(id).addEvent('blur', function() {
		if (this.get('value') == '') {
			this.set('value', val);
		}
	});
	$(id).set('value',val);
}
function confirmAction(title, description) {
	res = 0;
		var cont = new Element('div', { 'id':'confirm_content'});
		new Element('div', {'class':'mb10'}).setHTML(description).inject(cont);
		
		var btnCancel = new Element('b', {'class':'but o_94 fleft mr10'}).setHTML('Cancel');
		var btnOk = new Element('b', {'class':'but b_94 fleft'}).setHTML('OK');
		
		btnCancel.inject(cont);
		btnOk.inject(cont);
		new Element('div', {'class':'clear'}).inject(cont);
		
		//ht = parseInt((description.length() / 35))*20;
		//wd = parseInt(description.length*5.7);
		var frmConfirm = document.mochaUI.newWindow({
						id					:'frmConfirm',
						title				:title,
						width				:225,
						height			:70,
						draggable		:true,
						content			:cont.getHTML(),
						resizable		:false,
						scrollbars		:false,
						modal			:true
					});
	return res;
}

function submitOnEnter(ev, el) {
	if (ev.keyCode == 13 && $(el)) {
		$(el).submit();
	}
}