		var nick = "";
		var pass = "";
		var level = 0;
		var divfile = 0;
		var selectedMenu = 1;

		function x(){}


		function initMe(){
			navigation("login","maincontent");
		}


		function initMenu(arg){
			// change menu images
			old = selectedMenu;
			selectedMenu = arg;
			out(old);
			over(arg);
			
			// change title
			img = "images/title_"+arg+".png";
			document.getElementById('titleImg').src = img;

			// change content
			if(arg==1){
				writeToBlock("map","");
				navigation('folders','content',0);
				document.getElementById('box').style.visibility="visible";
			}else if(arg==2){
				writeToBlock("map","");
				navigation('discussions','content',0,0);
				document.getElementById('box').style.visibility="hidden";
			}else if(arg==3){
				writeToBlock("map","");
				navigation('approval','content',0,0);
				document.getElementById('box').style.visibility="hidden";
			}else if(arg==4){
				//writeToBlock("content","...soon...");
				writeToBlock("content","");
				navigation('contact','map',0);
				document.getElementById('box').style.visibility="hidden";
			
			}else if(arg==5){
				writeToBlock("map","");
				navigation('settings','content',0);
				document.getElementById('box').style.visibility="visible";

			}else{
				writeToBlock("content","...soon...");
			}
			setPosition();
		}


	
		function setPosition(){
		 	var ns6=document.getElementById&&!document.all;
			var ie4=document.all;
			var ns4=document.layers;

			if(nick==""){

				divW = 313+32;
				divH = 300+64;
	
				winW = (ns4||ns6)? window.innerWidth+16 : document.body.offsetWidth-20;
				winH = (ns4||ns6)? window.innerHeight : document.body.offsetHeight-20;
				
				left1 = (winW-divW);
				top1 = (winH-divH);
	
				//alert(ie4);
				arg = 0;

			}else{
				
				divH = 600;
				winW = (ns4||ns6)? window.innerWidth-16 : document.body.offsetWidth-20;
				
				left1 = (winW - 1000) / 2;
				top1 = (winH-divH);
				
				if(left1<0) left1 = 0;
				if(top1<0) top1 = 10;
				
				arg = 1;

			}
			initElementsPosition(left1,top1,arg);
		}





		function initElementsPosition(x,y,arg){

			document.getElementById('maincontent').style.left = x + 'px';
			document.getElementById('maincontent').style.top = y + 'px';

			if(arg==1){
				x = 82; y = 30;
				document.getElementById('menu').style.left = x+'px';
				document.getElementById('menu').style.top = y+'px';

				x = 82; y = 75;
				document.getElementById('bg').style.left = x + 'px';
				document.getElementById('bg').style.top = y + 'px';
				//document.getElementById('bg').style.height = 500;

				document.getElementById('partTitle').style.left = (x+30) + 'px';
				document.getElementById('partTitle').style.top = (y+30) + 'px';

				document.getElementById('map').style.left = (x) + 'px';
				document.getElementById('map').style.top = (y) + 'px';

				document.getElementById('loginInfo').style.left = (x+636) + 'px';//+ 636
				document.getElementById('loginInfo').style.top = y + 'px';// + 50

				document.getElementById('content').style.left = (x+30) + 'px';//30
				document.getElementById('content').style.top = (y+70) + 'px';//70

				document.getElementById('box').style.left = (x+670) + 'px';
				document.getElementById('box').style.top = (y+320) + 'px';
			}
		}


		function over(id){
			img = "images/m"+id+"_over.png";
			document.getElementById('m'+id).src = img;
		}

		function out(id){
			if(id!=selectedMenu){
				img = "images/m"+(id)+".png";
				document.getElementById('m'+id).src = img;
			}
		}

		function navigation(action, block, arg1, arg2, arg3, arg4){
			var args = "?nick="+nick+"&pass="+pass+"&arg1="+arg1+"&arg2="+arg2+"&arg3="+arg3+"&arg4="+arg4;
			var canRegister = true;

			if(action == "login"){
				link = "./form_login.php";
				
			}else if(action == "loginInfo"){
				link = "./loginInfo.php";

			}else if(action == "register"){
				link = "./form_register.php";

			}else if(action == "folders"){
				link = "./folders.php";

			}else if(action == "addFolder"){
				link = "./form_add_folder.php";

			}else if(action == "nameFolder"){
				link = "./form_name_folder.php";

			}else if(action == "deleteFolder"){
				link = "./form_delete_folder.php";

			}else if(action == "addFile"){
				link = "./form_add_file.php";

			}else if(action == "download"){
				window.frames["uploader"].location = "./download.php?nick="+nick+"&pass="+pass+"&arg="+arg1;
				canRegister = false;

			}else if(action == "deleteFile"){
				link = "./form_delete_file.php";

			}else if(action == "setAccessFolder"){
				link = "./form_access_folder.php";

			}else if(action == "addPerson"){
				link = "./form_add_person.php";

			}else if(action == "deleteAccess"){
				link = "./form_delete_access.php";

			}else if(action == "moveFolder"){
				link = "./form_move_folder.php";
			
			}else if(action == "moveFile"){
				link = "./form_move_file.php";

			}else if(action == "discussions"){
				link = "./discussions.php";

			}else if(action == "approval"){
				link = "./approval.php";

			}else if(action == "contact"){
				link = "./contact.php";

			}else if(action == "settings"){
				link = "./settings.php";

			}else if(action == "setAccessMessage"){
				link = "./form_access_message.php";

			}else alert(action);

			
			if(canRegister) registerRequest(link+args,block);
		}	



		function actionForm(action){
			if(action=="login"){
				myform = document.forms["loginForm"];
				myform.submit();
				writeToBlock("content","PROCESS DATA");
			}else if(action=="register"){
				myform = document.forms["registerForm"];
				myform.submit();
				writeToBlock("content","PROCESS DATA");
			}else if(action=="addFolder"){
				myform = document.forms["addFolderForm"];
				myform.submit();
				writeToBlock("content","PROCESS DATA");
			}else if(action=="nameFolder"){
				myform = document.forms["nameFolderForm"];
				myform.submit();
				writeToBlock("content","PROCESS DATA");
			}else if(action=="deleteFolder"){
				myform = document.forms["deleteFolderForm"];
				myform.submit();
				writeToBlock("content","PROCESS DATA");
			}else if(action=="addFiles"){
				myform = document.forms["addFileForm"];
				myform.submit();
				writeToBlock("content","PROCESS DATA");
			}else if(action=="deleteFile"){
				myform = document.forms["deleteFileForm"];
				myform.submit();
				writeToBlock("content","PROCESS DATA");
			}else if(action=="addPerson"){
				myform = document.forms["addPersonForm"];
				myform.submit();
				writeToBlock("content","PROCESS DATA");
			}else if(action=="deleteAccess"){
				myform = document.forms["deleteAccessForm"];
				myform.submit();
				writeToBlock("content","PROCESS DATA");
			}else if(action=="addMessage"){
				myform = document.forms["addMessageForm"];
				myform.submit();
				writeToBlock("content","PROCESS DATA");
			}else if(action=="settings"){
				myform = document.forms["settingsForm"];
				myform.submit();
				writeToBlock("content","PROCESS DATA");
			}
		}
		function addFileField(nr){
			str = "<div id=\"divfile"+nr+"\"><span class=\"label\"> file:</span> <input type=\"file\" name=\"myfile[]\" >";
			str += "<br> <div id=\'divfile"+(nr+1)+"\'><a href=\'javascript:addFileField("+(nr+1)+")\' class=\'link\'>add field</a></div>";
			writeToBlock("divfile"+nr,str);
		}
		function setUser(userName, userPass,userLevel){
			nick = userName;
			pass = userPass;
			level = userLevel;
			//document.getElementById('maincontent').style.background = 'url(images/bg2.jpg)';
			
			document.getElementById('maincontent').style.background = 'url(images/empty.png)';
			document.body.style.background = 'url(images/bg3.jpg)';

	
			// GENERATE MAIN CONTENT
			str = "	<div id=\"bg\" class=\"bg\"></div>";
			str += "<div id=\"menu\" class=\"menu\"><table width=856 height=37 cellpadding=0 cellspacing=0 border=0>";
			str += "	<tr bgcolor=\"#d81635\">";
			str += "		<td align=\"left\"><a href=\"javascript:initMenu(1);\"><img src=\"images/m1.png\" id=\"m1\" border=0 onMouseOver=\"javascript:over(1);\" onMouseOut=\"javascript:out(1);\" onFocus=\"blur();\" ></a></td>";
			str += "		<td align=\"left\"><a href=\"javascript:initMenu(2);\"><img src=\"images/m2.png\" id=\"m2\" border=0 onMouseOver=\"javascript:over(2);\" onMouseOut=\"javascript:out(2);\" onFocus=\"blur();\" ></a></td>";
			str += "		<td align=\"left\"><a href=\"javascript:initMenu(3);\"><img src=\"images/m3.png\" id=\"m3\" border=0 onMouseOver=\"javascript:over(3);\" onMouseOut=\"javascript:out(3);\" onFocus=\"blur();\" ></a></td>";
			str += "		<td align=\"left\"><a href=\"javascript:initMenu(4);\"><img src=\"images/m4.png\" id=\"m4\" border=0 onMouseOver=\"javascript:over(4);\" onMouseOut=\"javascript:out(4);\" onFocus=\"blur();\" ></a></td>";
			if(userLevel==2) str += "<td align=\"left\"><a href=\"javascript:initMenu(5);\"><img src=\"images/m5.png\" id=\"m5\" border=0 onMouseOver=\"javascript:over(5);\" onMouseOut=\"javascript:out(5);\" onFocus=\"blur();\"></a></td>";
			str += "		<td align=\"right\" width=\'100%\'><a href=\"\" style=\"color:#ffffff\"><img src=\"images/logout.png\" border=0></a></td>";
			str += "	</tr></table>";
			str += "</div>";
			str += "	<div id=\"map\" class=\"content\"></div>";
			str += "	<div id=\"partTitle\" class=\"partTitle\" ><img src=\"images/empty.png\" id=\"titleImg\"></div>";
			str += "	<div id=\"loginInfo\" class=\"loginInfo\"></div>";
			str += "	<div id=\"content\" class=\"content\"></div>";
			str += "	<div id=\"box\" class=\"box\"><img src=\"images/box.png\"></div>";


			writeToBlock("maincontent",str);
			navigation("loginInfo","loginInfo");
			initMenu(1);

	}