function _Logic(){
	this.Lang="arm";
	this.Static=new Static();
	this.Feedback=null;
	this.News=new News();;
	this.URLProcessor=null;
	this.TopMenu=null;
	this.LeftMenuState="";
	this.CVTree=null;
	this.CVBuilder=null;
}
_Logic.prototype={
	Init: function(){				
		AjaxEngine.LoadingDIV=$("loading");
		
		this.URLProcessor=new URLProcessor();
		this.URLProcessor.Init(document, this.URLHandler);
		
		this.TopMenu=new HorizontalMenu(getXMLDoc("top_menu.xml"));
		$("top_menu_holder").appendChild(this.TopMenu.DOMObject);		
		this.News.LoadNewsList(0,"date", this.Lang);
		
		
		p=this.URLProcessor.ProcessURL(document.location.href);
		if (p!=null)
			this.URLHandler(document.location.href, p);
		else{
			this.Static.Load("front", this.Lang);
			$("info_holder").appendChild(this.Static.DOMObject);
			this.ChangeLeftMenuState("news");			
		}		
	},
	
	URLHandler: function (href, p){
		if (p==null)
			return;
			
		var _this=Logic;		
		info=$("info_holder");	

		info.innerHTML="";
		
		switch (p[0]){
			case "static":				
				_this.Static.Load(p[1], _this.Lang);
				info.appendChild(_this.Static.DOMObject);
				break;
			case "feedback":
				if (_this.Feedback==null)				
					_this.Feedback=new Feedback();				
				_this.Feedback.LoadFeedbackForm();				
				info.appendChild(_this.Feedback.DOMObject);
				break;
			case "news":
				_this.News.LoadNews(p[1], _this.Lang);
				info.appendChild(_this.News.DOMObject);
				
				break;
			case "cv":
				if (p[1]=="struct"){
					_this.Static.Load("sssstruct", _this.Lang);
					info.appendChild(_this.Static.DOMObject);
				}	
				else{
					if (_this.CVBuilder==null)
						_this.CVBuilder=new CVBuilder();
					_this.CVBuilder.BuildCV(p[1], _this.Lang);
					info.appendChild(_this.CVBuilder.DOMObject);
				}				
				
				break;
			case "gallery":
				//temprary solution
				AjaxEngine.sendGETRequest("ajaxControl.php?action=getGalleries", tgalhandler);
				break;
			case "anonce":
				//temprary solution
				AjaxEngine.sendGETRequest("ajaxControl.php?action=getAnonce&page="+p[1]+"&lang="+_this.Lang, tanoncehandler);
				break;
			case "special":
				//temprary solution
				AjaxEngine.sendGETRequest("ajaxControl.php?action=getSpecialAnonce", tanoncehandler);
				break;
			case "conference":
				//temprary solution
				if (p[1]=="list")
					AjaxEngine.sendGETRequest("ajaxControl.php?action=getConferencesList&page="+p[2]+"&lang="+_this.Lang, tanoncehandler);
				else
					AjaxEngine.sendGETRequest("ajaxControl.php?action=getConference&id="+p[1]+"&lang="+_this.Lang, tanoncehandler);
					
				break;
			
		}	
		switch (p[0]){
			case "cv":
				_this.ChangeLeftMenuState("cv");	
				break;
			default:
				_this.ChangeLeftMenuState("news");
				break;
		}				
		
	},
	
	ChangeLeftMenuState: function(state){		
		if (this.LeftMenuState==state)
			return;
		
		leftMenu=$("left_menu_holder")
		leftMenu.innerHTML="";			
		
		switch (state){
			case "news":
				this.LeftMenuState="news";
				leftMenu.appendChild(this.News.ListDOMObject);
				break;
			case "cv":
				this.LeftMenuState="cv";
				if (this.CVTree==null)
					this.CVTree=new Tree(getXMLDoc("struct.xml"));
				leftMenu.appendChild(this.CVTree.DOMObject);
				break;
				
				
		}
	}
		
}

var Logic=new _Logic();

//this must be modified, temprary solution
function tgalhandler(xmlHttp){		
	$("info_holder").innerHTML=xmlHttp.responseText;
}

//this must be modified, temprary solution
function tanoncehandler(xmlHttp){		
	$("info_holder").innerHTML=xmlHttp.responseText;
}