self.Main = function()
{
	Main.loadPage = function(page)
	{
		$("layout").className = page;
		$("placeholder").innerHTML = "Carregando...";
		
		if (page == "tecnico") $("container").style.height = "695px";
		else $("container").style.height = "480px";
		
		switch (page)
		{
			case "home":
			/* case "marca":
				$("placeholder").innerHTML = "";
				*/
				break;
			default:
				_ajax.execute({url: page + ".html", onComplete: function(response)
				{
					$("placeholder").innerHTML = response.text;
					
					if (page == "contato") $("contato")["contato[]"][0].focus();
				}});
		}
	};

	Main.simpleLoadPage = function(page)
	{
		$("placeholder").innerHTML = "Carregando...";
		
		_ajax.execute({url: page, onComplete: function(response)
		{
			$("placeholder").innerHTML = response.text;
		}});
	};
	
	Main.popUpImg = function(url, width, height)
	{
		var l = (screen.width - width)/2;
		var t = (screen.height - height)/2;
		var w = window.open("", "", "width=" + width + ", height=" + height + ", left=" + l + ", top=" + t);
		w.document.write("<html><body style='margin: 0;'><img src='" + url + "' title='Clique para fechar' onclick='window.close();' /></body></html>");
		w.document.close();
	};
	
	Main.popUp = function(url, width, height, params)
	{
		if (params == null) params = "";
		
		_ajax.execute({url: url, onComplete: function(response)
		{
			var l = (screen.width - width)/2;
			var t = (screen.height - height)/2;
			var w = window.open("", "", "width=" + width + ", height=" + height + ", left=" + l + ", top=" + t);
			w.document.write("<html><head><link href='css/styles.css' rel='stylesheet' type='text/css' /></head><body>" + response.text + "</body></html>");
			w.document.close();
			w.params = params;
		}});
	};
	
	Main.popUpOld = function(pg, w, h)
	{
		var x;
		var y;
		
		x = (screen.width - w)/2;
		y = (screen.height - h)/2;
		window.open(pg, '', 'scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no, fullscreen=no,width='+w+',height='+h+',left='+x+',top='+y+'');
	};
	
	Main.enviar = function(form)
	{
		var f = new Form(form);
		
		if (f.validate()) _ajax.execute({url: "enviar.php", postData: f.buildURL()});
	};
	
	Main.showFlash = function(url)
	{
		Main.popUp("look_main.html", 350, 680, url);
	};
	
	var $ = function(id)
	{
		return document.getElementById(id);
	};
	
	var _ajax = new AJAX();
};

new Main();