document.observe("dom:loaded", function() {
	AjaxLoad.initComponent("main-main_right");

	HoverBox.init();
});





var AjaxLoad = {
		currentFocus: undefined,
		currentLocation: window.location.href.split("?")[0],
		initComponent: function (componentPath) {

			$$("div#"+componentPath+" a").invoke("observe", "click", function(event) {
				
					if(this.rel=='lightbox'){return;}
					if (this.href==window.location.href.split("?")[0]) {Lightbox.close(); Event.stop(event);return;}
					if (this.href==window.location.href.split("?")[0]+"#" || this.target=="_blank") { return;}
					/*use suitable effect from rel*/		
					if (this.rel == "break") {return;}
					
					if (this.href.split("?")[0] != AjaxLoad.currentLocation) {
						var loadMode = "partialAsk";
					} else {
						var loadMode = "partial";
					}
				
					if (this.rel == "break") {
				
						AjaxLoad.doLoad(this.href, "get",  loadMode,"", "main-main");
					} else {
						
						AjaxLoad.doLoad(this.href, "get",  loadMode,"", componentPath);
					}
				
						
					Event.stop(event);
				
				
					
			});
			
			$$("div#"+componentPath+" form").invoke("observe", "submit", function(event) {
				var form2 = this;
				
				$$("div#"+componentPath+" form input, div#"+componentPath+" form textarea").each(function(input) {
					//input.disable();
				});
				
				AjaxLoad.doLoad(form2.action, "post",  "partial", form2.serialize(true), componentPath);
								
				
				$$("input, select, area").each(function (input) {
					input.disabled=true;
				
				});
				
				
				Event.stop(event);		
			});		
			
			
		}, 
		doLoad: function (url, method, loadMode, parameters, componentPath) {
		
							
				new Ajax.Request(url+(url.indexOf("?")>=0 ? "&": "?")+"partialLoad=true", {
						method: method,
						parameters: parameters,
						onSuccess: function(transport) {

						
					
								
							$(componentPath).innerHTML = transport.responseText;
					
							AjaxLoad.initComponent("main-main_right");
							$$("div.selection_hover").each(function (k) {
								
								k.removeClassName("selection_hover_hover");								
								
							});
							
						} 
					});		
		
		}
		
	}

	
