var photo_div=document.getElementById("photo_div");
var photo_img=document.getElementById("photo_img");
var photo_img_td=document.getElementById("photo_img_td");
var photo_title=document.getElementById("photo_title");
var photo_capt=document.getElementById("photo_capt");
var photo_head=document.getElementById("photo_div_mtable_head");
var photo_win=document.getElementById("photo_body");

/////////////////////////////////// Библиотека для движения окон /////////////////////////////
// интерфейсные функции

function begindrag(e) {
	if (this.getAttribute("id").substring(0,4)=="info"){
		initdrag(info_div,info_head,info_win);
		set_upper("info");
	}
	if (this.getAttribute("id").substring(0,5)=="photo"){
		initdrag(photo_div,photo_head,photo_win);
		set_upper("photo");
	}
	return DRAG_begindrag(e);
}
function enddrag(e) {
	document.onmousemove=test_smenu;
	return DRAG_enddrag(e);		
}


function initdrag(n_div,n_head,n_win) {
	m_div=n_div;
	m_head=n_head;
	m_win=n_win;
}


// реализация движения	

var IE=(navigator.userAgent.indexOf('MSIE')!=-1);
var OP=(navigator.userAgent.indexOf('Opera')!=-1);
var MZ=(navigator.userAgent.indexOf('Gecko')!=-1);
var mustdie=(navigator.userAgent.indexOf('Opera')==-1)&&(navigator.userAgent.indexOf('Gecko')==-1);
var delta=(MZ||IE)?1:0;
	

var DRAG_lastX, DRAG_lastY, DRAG_dragging;
var m_div="",m_head="",m_win="";

function DRAG_begindrag(e) {
	if (mustdie) {
		curx=event.clientX;
		cury=event.clientY;
		ev=event.button;
	}
	else {
		curx=e.pageX;
		cury=e.pageY;
		ev=e.which;
		//ev=event.button+1;
	}
	
	if (ev == 1) {
		document.onmousemove=DRAG_drag;
		DRAG_lastX=curx;
		DRAG_lastY=cury;
		DRAG_dragging=true;
		
		return false;
	}
	else {
		return true;
	}
}

function DRAG_enddrag(e) {
	if (mustdie) {
		ev=event.button;
	}
	else {
		ev=e.which;
		//ev=event.button+1;
	}
		
	if (ev == 1) {
			DRAG_dragging=false;
			if (m_div.offsetWidth > m_win.offsetWidth) {
				m_div.style.width = m_win.offsetWidth+"px";
			}
			if (m_div.offsetHeight > m_win.offsetHeight) {
				m_div.style.height = m_win.offsetHeight+"px";
			}
			return false;
	}
	else {
		return true;
	}
}

function DRAG_drag(e) {
	if (DRAG_dragging) {
		if (mustdie) {
			curx=event.clientX;
			cury=event.clientY;
			ev=event.button;
		}
		else {
			curx=e.pageX;
			cury=e.pageY;
			ev=e.which;
			//ev=event.button+1;
		}
		if (ev != 1) {
			DRAG_dragging=false;
			if (m_div.offsetWidth > m_win.offsetWidth) {
				m_div.style.width = m_win.offsetWidth+"px";
			}
			if (m_div.offsetHeight > m_win.offsetHeight) {
				m_div.style.height = m_win.offsetHeight+"px";
			}
			return false;
		}
		if (curx > 0 && curx < body_div.offsetWidth && cury > 0 && cury < body_div.offsetHeight) {
			moveBy(curx-DRAG_lastX, cury-DRAG_lastY);
			DRAG_lastX = curx;
			DRAG_lastY = cury;
			return false;
		}
		else {
			return enddrag(e);
		}
	}
	else {
		return true;
	}
}


function moveBy(dx,dy) {
	new_top=m_div.offsetTop+dy;
	new_left=m_div.offsetLeft+dx;
	
	if ((new_top+m_head.offsetHeight>=15) && (body_div.offsetHeight-new_top>=35)) {
		m_div.style.top=(new_top)+"px";
	}
	
	if ((new_left+m_head.offsetWidth>=15) && (body_div.offsetWidth-new_left>=15)) {
		m_div.style.left=(new_left)+"px";
	}
	
	
	if (m_div.offsetTop+m_div.offsetHeight >= body_div.offsetHeight-delta) {
		m_div.style.height=(body_div.offsetHeight-delta - m_div.offsetTop)+"px";
	}
	else {
		if (m_div.offsetTop+m_div.offsetHeight < body_div.offsetHeight-delta) {
			m_div.style.height=(body_div.offsetHeight-delta-m_div.offsetTop)+"px";
			if (m_div.offsetHeight > m_win.offsetHeight) {
				m_div.style.height = m_win.offsetHeight+"px";
			}
		}
	}
	
	
	if (m_div.offsetLeft+m_div.offsetWidth >= body_div.offsetWidth-delta) {
		m_div.style.width=(body_div.offsetWidth-delta - m_div.offsetLeft)+"px";
	}
	else {
		if (m_div.offsetLeft+m_div.offsetWidth < body_div.offsetWidth-delta) {
			m_div.style.width=(body_div.offsetWidth-delta-m_div.offsetLeft)+"px";
			if (m_div.offsetWidth > m_win.offsetWidth) {
				m_div.style.width = m_win.offsetWidth+"px";
			}
		}
	}
	
	if (m_div.getAttribute("id") == "info_div" && mustdie) {
		info_frame.style.width=info_div.offsetWidth+"px";
		info_frame.style.height=info_div.offsetHeight+"px";
		info_frame.style.top=info_div.offsetTop+"px";
		info_frame.style.left=info_div.offsetLeft+"px";
	}
}




function listenkey(e) {
	if (mustdie) {
			key=event.keyCode;
		}
		else {
			key=e.which;
			//ev=event.button+1;
		}
		
		if (key == 27) {
			if (m_div != undefined && m_div != "") {
				if (m_div.getAttribute("id").substring(0,4)=="info"){
					if (isCloseble) {
						document.onmousemove=test_smenu;
						DRAG_dragging=false;
						hide_div();
					}
				}
				else if (m_div.getAttribute("id").substring(0,5)=="photo"){
						document.onmousemove=test_smenu;
						DRAG_dragging=false;
						hide_photo_window();
					}
			}
		}
		
		if (key == 13) {
			if (m_div != undefined && m_div != "") {
				if (m_div.getAttribute("id").substring(0,4)=="info"){
					if (winKind == 2) {
						get_logout();
					}
					else if (winKind == 6) {
							hide_div();
						}
				}
			}
		}
	return true;
}

document.onkeydown=listenkey;


//////////////////// Библиотека для формирования маленьких окон (авторизация, поиск и т.д.) ///////////
var info=document.getElementById("info_div_mtable_body");
//var fon_img=document.getElementById("fon_div_img");
var info_div=document.getElementById("info_div");
var body_div=document.getElementById("body_div");
var info_head=document.getElementById("info_div_mtable_head");
var info_win=document.getElementById("info_body");
var info_frame=document.getElementById("info_frame");
	
var IE=(navigator.userAgent.indexOf('MSIE')!=-1);
var OP=(navigator.userAgent.indexOf('Opera')!=-1);
var MZ=(navigator.userAgent.indexOf('Gecko')!=-1);
var login="";
var pass="";
var email="";
var timerID=-1;
var isCloseble=false;
var winKind=-1;
var timeOut=15; // in seconds

var info_left=document.getElementById("info_capt_l");
var info_arr=document.getElementById("info_capt_ar");
var info_capt=document.getElementById("info_capt");
var info_close=document.getElementById("info_close");
var info_right=document.getElementById("info_capt_r");
var info_close_button=document.getElementById("info_close_button");


info_head.onmousedown=begindrag;
info_head.onmouseup=enddrag;


function show_div(kind) {
	info_div.style.visibility="hidden";
	//hide_div();
	
	if (timerID != -1) {clearTimeout(timerID); timerID=-1;}
	
	info_txt="";
	top_txt="";
	winKind=kind;
	switch (kind) {
// окно передачи
		case 0: 
				info_left.style.background="url('/f/i/wind/cap_blue_left.png') no-repeat";
				info_arr.style.background="url('/f/i/wind/cap_blue_arr.png') no-repeat";
				info_capt.style.background="url('/f/i/wind/cap_blue_fon.png') repeat-x";
				info_close.style.background="url('/f/i/wind/cap_blue_fon.png') repeat-x";
				info_right.style.background="url('/f/i/wind/cap_blue_right.png') no-repeat";
				top_txt=t_transfer;
		info_txt="<table width='80%' border='0' align='center'>"+
					"<tr><td height='50px' align='center' valign='middle'>"+
						"<img src='/f/i/wind/photo_loading.gif' height='32px' width='32px' alt=''>"+
					"</td></tr>"+
				"</table>";
				info_close_button.style.visibility="hidden";
				timerID=setTimeout('set_closeble()',(timeOut*1000));
				isCloseble=false;
				break;	
		
// авторизация в системе
		case 1: 
				info_left.style.background="url('/f/i/wind/cap_blue_left.png') no-repeat";
				info_arr.style.background="url('/f/i/wind/cap_blue_arr.png') no-repeat";
				info_capt.style.background="url('/f/i/wind/cap_blue_fon.png') repeat-x";
				info_close.style.background="url('/f/i/wind/cap_blue_fon.png') repeat-x";
				info_right.style.background="url('/f/i/wind/cap_blue_right.png') no-repeat";
				top_txt=t_auth;
		info_txt="<table width='80%' border='0' align='center' class='auth_div_stable'>"+
					"<tr>"+
						"<td width='40%'>"+t_login+"</td>"+
						"<td>"+
							"<input class='ajax_input' id='w_auth_login' name='w_auth_login' type='text' size='25' maxlength='20' onkeypress='return kp_auth(event);'>"+
						"</td>"+
					"</tr>"+
					"<tr>"+
						"<td>"+t_pass+"</td>"+
						"<td>"+
							"<input class='ajax_input' id='w_auth_password' name='w_auth_password' type='password' size='25' maxlength='16' onkeypress='return kp_auth(event);'>"+
						"</td>"+
					"</tr>"+
					"<tr><td></td><td align='left'><a href='' onclick='return get_auth();'>"+t_enter+"</a></td></tr>"+
					"<tr><td></td><td align='left'><a href='' onclick='return show_div(3)'>"+t_remember+"</a></td></tr>"+
				"</table>";
				info_close_button.style.visibility="visible";
				isCloseble=true;
				break;
				
// выход из системы
		case 2:	
				info_left.style.background="url('/f/i/wind/cap_blue_left.png') no-repeat";
				info_arr.style.background="url('/f/i/wind/cap_blue_arr.png') no-repeat";
				info_capt.style.background="url('/f/i/wind/cap_blue_fon.png') repeat-x";
				info_close.style.background="url('/f/i/wind/cap_blue_fon.png') repeat-x";
				info_right.style.background="url('/f/i/wind/cap_blue_right.png') no-repeat";
				top_txt=t_exit;
		info_txt="<table border='0' align='center' class='auth_div_stable' cellpadding='5px'>"+
					"<tr><td align='center' colspan='2'>"+t_real_exit+"</td></tr>"+
					"<tr><td align='center'><a href='' onclick='return get_logout()'>"+t_yes+"</a></td>"+
					"<td align='center'><a href='' onclick='return hide_div()'>"+t_no+"</a></td></tr>"+
				"</table>";
				info_close_button.style.visibility="hidden";
				isCloseble=true;
				break;
				
// восстановление пароля
		case 3: 
				info_left.style.background="url('/f/i/wind/cap_blue_left.png') no-repeat";
				info_arr.style.background="url('/f/i/wind/cap_blue_arr.png') no-repeat";
				info_capt.style.background="url('/f/i/wind/cap_blue_fon.png') repeat-x";
				info_close.style.background="url('/f/i/wind/cap_blue_fon.png') repeat-x";
				info_right.style.background="url('/f/i/wind/cap_blue_right.png') no-repeat";
				top_txt=t_recovery;
		info_txt="<table width='80%' border='0' align='center' class='auth_div_stable'>"+
					"<tr>"+
						"<td width='40%'>"+t_login+"</td>"+
						"<td>"+
							"<input class='ajax_input' id='w_auth_login' name='w_recov_login' type='text' size='30' maxlength='20' onkeypress='return kp_lost(event);'>"+
						"</td>"+
					"</tr>"+
					"<tr>"+
						"<td>"+t_email+"</td>"+
						"<td>"+
							"<input class='ajax_input' id='w_auth_e_mail' name='w_auth_e_mail' type='text' size='30' maxlength='30' onkeypress='return kp_lost(event);'>"+
						"</td>"+
					"</tr>"+
					"<tr><td></td><td align='left'><a href='forgot' onclick='return get_forgot()'>"+t_recover+"</a></td></tr>"+
				"</table>";
				info_close_button.style.visibility="visible";
				isCloseble=true;
				break;
				
// ошибка авторизации
		case 4: 
				info_left.style.background="url('/f/i/wind/cap_red_left.png') no-repeat";
				info_arr.style.background="url('/f/i/wind/cap_red_arr.png') no-repeat";
				info_capt.style.background="url('/f/i/wind/cap_red_fon.png') repeat-x";
				info_close.style.background="url('/f/i/wind/cap_red_fon.png') repeat-x";
				info_right.style.background="url('/f/i/wind/cap_red_right.png') no-repeat";
				top_txt=t_auth_err;
		info_txt="<table width='80%' border='0' align='center' class='auth_div_stable'>"+
					"<tr>"+
						"<td colspan='2' style='text-align: center; color: red; padding-bottom: 10px;'>"+t_error_msg+"</td>"+
					"</tr>"+
					"<tr>"+
						"<td width='40%'>"+t_login+"</td>"+
						"<td>"+
							"<input class='ajax_input' id='w_auth_login' name='w_auth_login' type='text' value='"+login+"' size='25' maxlength='20' onkeypress='return kp_auth(event);'>"+
						"</td>"+
					"</tr>"+
					"<tr>"+
						"<td>"+t_pass+"</td>"+
						"<td>"+
							"<input class='ajax_input' id='w_auth_password' name='w_auth_password' type='password' size='25' maxlength='16' onkeypress='return kp_auth(event);'>"+
						"</td>"+
					"</tr>"+
					"<tr><td></td><td align='left'><a href='enter' onclick='return get_auth();'>"+t_enter+"</a></td></tr>"+
					"<tr><td></td><td align='left'><a href='restore' onclick='return show_div(3)'>"+t_remember+"</a></td></tr>"+
				"</table>";
				info_close_button.style.visibility="visible";
				isCloseble=true;
				break;
// окно регистрации
		case 5: 
				info_left.style.background="url('/f/i/wind/cap_blue_left.png') no-repeat";
				info_arr.style.background="url('/f/i/wind/cap_blue_arr.png') no-repeat";
				info_capt.style.background="url('/f/i/wind/cap_blue_fon.png') repeat-x";
				info_close.style.background="url('/f/i/wind/cap_blue_fon.png') repeat-x";
				info_right.style.background="url('/f/i/wind/cap_blue_right.png') no-repeat";
				top_txt=t_registration;
		info_txt="<form onkeypress='return kp_reg(event);'><table width='95%' border='0' align='center' class='auth_div_stable'>"+
					"<tr><td colspan='2' style='text-align: center; color: red;' id='registration_mess'>"+"</td></tr>"+
					"<tr><td colspan='2'>"+t_name+"<br><input class='account_text' type='text' id='reg_name' name='reg_name' maxlength='50'></td></tr>"+
					"<tr><td colspan='2'>"+t_login+"<br><input class='account_text' type='text' id='reg_login' name='reg_login' maxlength='20'></td></tr>"+
					"<tr><td colspan='2'>"+t_pass+"<br><input class='account_text' type='password' id='reg_pass1' name='reg_pass1' maxlength='16'></td></tr>"+
	 				"<tr><td colspan='2'>"+t_pass2+"<br><input class='account_text' type='password' id='reg_pass2' name='reg_pass2' maxlength='16'></td></tr>"+
	 				"<tr><td colspan='2'>"+t_email+"<br><input class='account_text' type='text' id='reg_email' name='reg_email' maxlength='100'></td></tr>"+
					"<tr><td colspan='2'>"+t_country+"<br><input class='account_text' type='text' id='reg_country' name='reg_country' maxlength='50'></td></tr>"+
					"<tr><td colspan='2'>"+t_city+"<br><input class='account_text' type='text' id='reg_city' name='reg_city' maxlength='50'></td></tr>"+
					"<tr><td colspan='2'>"+t_address+"<br><input class='account_text' type='text' id='reg_address' name='reg_address' maxlength='100'></td></tr>"+
	 				"<tr><td colspan='2'>"+t_company+"<br><input class='account_text' type='text' id='reg_company' name='reg_company' maxlength='100'></td></tr>"+
					"<tr><td colspan='2'>"+t_position+"<br><input class='account_text' type='text' id='reg_position' name='reg_position' maxlength='30'></td></tr>"+
					"<tr><td colspan='2'>"+t_from+"<br><input class='account_text' type='text' id='reg_from' name='reg_from' maxlength='255'></td></tr>"+
	 				"<tr><td colspan='2'><a href='new' onclick='return get_register()'>"+t_go+"</a></td></tr>"+
	 			"</table></form>";
	 			info_close_button.style.visibility="visible";
	 			isCloseble=true;
				break;
// окно с кнопкой Ок
		case 6: 
				info_left.style.background="url('/f/i/wind/cap_blue_left.png') no-repeat";
				info_arr.style.background="url('/f/i/wind/cap_blue_arr.png') no-repeat";
				info_capt.style.background="url('/f/i/wind/cap_blue_fon.png') repeat-x";
				info_close.style.background="url('/f/i/wind/cap_blue_fon.png') repeat-x";
				info_right.style.background="url('/f/i/wind/cap_blue_right.png') no-repeat";
				top_txt=t_information;
		info_txt="<table width='95%' border='0' align='center' class='auth_div_stable'>"+
					"<td style='text-align: center; color: green; padding-bottom: 10px;' id='registration_mess'></td></tr>"+
					"<td align='center'><a href='' onclick='return hide_div()'>Ok</a></td></tr>"+
	 			"</table>";
	 			info_close_button.style.visibility="hidden";
	 			isCloseble=true;
				break;
// окно с поиском
		case 7: 
				info_left.style.background="url('/f/i/wind/cap_blue_left.png') no-repeat";
				info_arr.style.background="url('/f/i/wind/cap_blue_arr.png') no-repeat";
				info_capt.style.background="url('/f/i/wind/cap_blue_fon.png') repeat-x";
				info_close.style.background="url('/f/i/wind/cap_blue_fon.png') repeat-x";
				info_right.style.background="url('/f/i/wind/cap_blue_right.png') no-repeat";
				top_txt=t_search;
		info_txt="<form action='"+t_searchurl+"' id='searchform' name='searchform' method='post' onkeypress='return kp_search(event);'><input type='hidden' name='submiting' value='search'>"+
			        "<table width='90%' border='0' align='center' class='auth_div_stable'>"+
					"<tr>"+
						"<td>"+
							"<input class='account_text' id='search_fild' name='search_fild' type='text' size='35' maxlength='50'>"+
						"</td>"+
					"</tr>"+
					"<tr><td align='left'><a href='' onclick='document.getElementById(\"searchform\").submit(); return false;'>"+t_searchsm+"</a></td></tr>"+
				"</table>";
				info_close_button.style.visibility="visible";
				isCloseble=true;
				break;
	}
	
	info_capt.innerHTML=top_txt;
	info.innerHTML=info_txt;
	
	info_div.style.width="359px";
	info_div.style.height="auto";
	initdrag(info_div,info_head,info_win);
	set_upper("info");
	
	reshow_info_div();
	
	info_div.style.visibility="visible";
	if (mustdie) {
		info_frame.style.width=info_div.offsetWidth+"px";
		info_frame.style.height=info_div.offsetHeight+"px";
		info_frame.style.top=info_div.offsetTop+"px";
		info_frame.style.left=info_div.offsetLeft+"px";
	}
	//fon_img.style.visibility = "visible";
	return false;
}

function hide_div() {
	info_div.style.visibility="hidden";
	info_close_button.style.visibility="hidden";
	if (mustdie) {
		info_frame.style.width=0+"px";
		info_frame.style.height=0+"px";
		info_frame.style.top=0+"px";
		info_frame.style.left=0+"px";
	}
	//fon_img.style.visibility="hidden";
	info_capt.innerHTML="";
	info.innerHTML="";
	if (timerID != -1) {clearTimeout(timerID); timerID=-1;}
	isCloseble=false;
	winKind=-1;
	if (photo_div != undefined) {
		if (photo_div.style.visibility == "visible") {
			initdrag(photo_div,photo_head,photo_win);
		}
	}
	//fon_img.style.width = 0+"px";
	//fon_img.style.height = 0+"px";
	return false;
}

function reshow_info_div() {
	var winwidth=!OP ? document.documentElement.clientWidth : window.innerWidth;
	var winheight=!OP ? document.documentElement.clientHeight : window.innerHeight;
	var wintop=!OP ? document.documentElement.scrollTop : window.pageYOffset;
	//fon_img.style.width = body_div.offsetWidth+"px";
	/*if (body_div.offsetHeight>winheight) {
		fon_img.style.height = body_div.offsetHeight+"px";
	}
	else {
		fon_img.style.height = winheight+"px";
	}*/
	info_div.style.left = (Math.round((body_div.offsetWidth-info_div.offsetWidth)/2))+"px";
	ipostop=(winheight-info_div.offsetHeight)/2;
	if (ipostop<0){ipostop=0;} 
	info_div.style.top=(ipostop+wintop)+"px";
}


function set_upper(win) {
	if (win == "info") {
		if (photo_div != undefined) {
			info_div.style.zIndex=302;
			photo_div.style.zIndex=300;
		}
	}
	if (win == "photo") {
		info_div.style.zIndex=300;
		photo_div.style.zIndex=302;
	}
}

function set_closeble() {
	info_close_button.style.visibility="visible";
	isCloseble=true;
}


///////////////////////////////////// Библиотека ajax-технологии /////////////////////////////////////
loc = document.location.href;
xend = loc.indexOf("/") + 2;
xend = loc.indexOf("/",xend) + 1;
var locat = loc.substring(0, xend);loc = loc.substring(xend);

function kp_auth(e){
	if (e.keyCode == 13)
		return get_auth();

	return true;
}

function kp_lost(e){
	if (e.keyCode == 13)
		return get_forgot();

	return true;
}

function kp_reg(e){
	if (e.keyCode == 13)
		return get_register();

	return true;
}

function kp_profile(e){
	if (e.keyCode == 13)
		return set_profile();

	return true;
}

function kp_search(e){
	if (e.keyCode == 13)
		document.getElementById("searchform").submit();

	return true;
}

function kp_subm(e){
	if (e.keyCode == 13)
		return false;

	return true;
}

function str_encode(str) {
	newstr='';
	for (i=0;i<str.length;i++){
		newstr+="#"+str.charCodeAt(i);
	}
	return newstr;
}

function get_auth() {
	
	
	if (page_number=='fp'){	
		var login=str_encode(document.getElementById('auth_login').value);
		var password=str_encode(document.getElementById('auth_password').value);
	}
	else {
		var login=str_encode(document.getElementById('w_auth_login').value);
		var password=str_encode(document.getElementById('w_auth_password').value);
	}
	
	show_div(0);
	
	rnd=Math.round(1000+8999*Math.random());
	
	url=locat+lang+"/account/login/"+rnd+escape(login)+"/"+rnd+escape(password)+"/"+page_number+"/ajax/";
	
	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url;
	document.body.appendChild(jsel);

	
	return false;
}

function get_logout() {
	show_div(0);
	url=locat+lang+"/account/logout/"+page_number+"/ajax/";
	
	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url;
	document.body.appendChild(jsel);
	
	return false;
}

function get_register() {
	var name=str_encode(document.getElementById('reg_name').value);
	var login=str_encode(document.getElementById('reg_login').value);
	var pass1=str_encode(document.getElementById('reg_pass1').value);
	var pass2=str_encode(document.getElementById('reg_pass2').value);
	var email=str_encode(document.getElementById('reg_email').value);
	var country=str_encode(document.getElementById('reg_country').value);
	var city=str_encode(document.getElementById('reg_city').value);
	var address=str_encode(document.getElementById('reg_address').value);
	var company=str_encode(document.getElementById('reg_company').value);
	var position=str_encode(document.getElementById('reg_position').value);
	var from=str_encode(document.getElementById('reg_from').value);
	
	show_div(0);
	
	rnd=Math.round(1000+8999*Math.random());

	submme = 1;
	url=locat+lang+"/account/new/"+rnd+escape(name)+"/"+rnd+escape(login)+"/"+rnd+escape(pass1)+"/"+rnd+escape(pass2)+"/"+rnd+escape(email)+"/"+rnd+escape(country)+"/"+rnd+escape(city)+"/"+rnd+escape(address)+"/"+rnd+escape(company)+"/"+rnd+escape(position)+"/"+rnd+escape(from)+"/"+submme+"/"+page_number+"/ajax/";
	
	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url;
	document.body.appendChild(jsel);
		
	return false;
}

function get_forgot () {
	
	var login=str_encode(document.getElementById('w_auth_login').value);
	var email=str_encode(document.getElementById('w_auth_e_mail').value);
	
	show_div(0);
	
	rnd=Math.round(1000+8999*Math.random());
	
	url=locat+lang+"/account/forgot/"+rnd+escape(login)+"/"+rnd+escape(email)+"/ajax/";
		
	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url;
	document.body.appendChild(jsel);
	
	return false;
}

function get_profile() {
	show_div(0);
	
	st=escape(str_encode("hрогаfasfdie"));
	
	rnd=Math.round(1000+8999*Math.random());
	url=locat+lang+"/account/profile/get"+"/"+page_number+"/ajax/"+rnd+"/";
	
	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url;
	document.body.appendChild(jsel);
	
	return false;
}

function set_profile() {
	var name=str_encode(document.getElementById('reg_name').value);
	var pass1=str_encode(document.getElementById('reg_pass1').value);
	var pass2=str_encode(document.getElementById('reg_pass2').value);
	var email=str_encode(document.getElementById('reg_email').value);
	var country=str_encode(document.getElementById('reg_country').value);
	var city=str_encode(document.getElementById('reg_city').value);
	var address=str_encode(document.getElementById('reg_address').value);
	var company=str_encode(document.getElementById('reg_company').value);
	var position=str_encode(document.getElementById('reg_position').value);
	var from=str_encode(document.getElementById('reg_from').value);
	
	show_div(0);
	
	rnd=Math.round(1000+8999*Math.random());
	
	submme = 1;
	url=locat+lang+"/account/profile/"+rnd+escape(name)+"/"+rnd+escape(pass1)+"/"+rnd+escape(pass2)+"/"+rnd+escape(email)+"/"+rnd+escape(country)+"/"+rnd+escape(city)+"/"+rnd+escape(address)+"/"+rnd+escape(company)+"/"+rnd+escape(position)+"/"+rnd+escape(from)+"/"+submme+"/"+page_number+"/ajax/";
	
	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url;
	document.body.appendChild(jsel);
		
	return false;
}


function get_subscribe() {
	document.getElementById('subm_mess').innerHTML='';
	var email=str_encode(document.getElementById('submit_e_mail').value);
	var action=str_encode(document.getElementById('subscribe').value);
	
	show_div(0);
	
	rnd=Math.round(1000+8999*Math.random());
	
	url=locat+lang+"/dispatch/unsubscribe/"+rnd+escape(email)+"/"+escape(action)+"/"+page_number+"/ajax/";
	
	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url;
	document.body.appendChild(jsel);
	
	return false;
}

function get_unsubscribe() {
	document.getElementById('subm_mess').innerHTML='';
	var email=str_encode(document.getElementById('submit_e_mail').value);
	var action=str_encode(document.getElementById('subscribe').value);
	
	show_div(0);
	
	rnd=Math.round(1000+8999*Math.random());
	
	url=locat+lang+"/dispatch/unsubscribe/"+rnd+escape(email)+"/"+escape(action)+"/"+page_number+"/ajax/";
	
	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url;
	document.body.appendChild(jsel);
	
	return false;
}

///////////////////////////////////// Библиотека меню /////////////////////////////////////

var def_menu=-1;

var cur_menu=0;

var m_menu_td=document.getElementById("menu_td");

var mustdie=(navigator.userAgent.indexOf('Opera')==-1)&&(navigator.userAgent.indexOf('Gecko')==-1);
var in_menu=false;

function hide_smenu(no) {
	if (submenus[no]!="") {
		submenus[no].style.visibility="hidden";
		corners[no].style.visibility="hidden";
	}
}

function show_smenu(no){
	hide_smenu(cur_menu);
	cur_menu=no;
	if (submenus[no]!="") {
		submenus[no].style.visibility="visible";
		corners[no].style.visibility="visible";
		return true;
	}
	return true;
}

function test_smenu(e) {
	if (in_menu) {
		if (mustdie) {
			curx=event.clientX;
			cury=event.clientY;
		}
		else {
			curx=e.pageX;
			cury=e.pageY;
		}
		if ((curx<m_menu_td.offsetLeft)||(curx>m_menu_td.offsetLeft+m_menu_td.offsetWidth)||(cury<m_menu_td.offsetTop)||(cury>m_menu_td.offsetTop+m_menu_td.offsetHeight)) {
			if (def_menu!=-1) {
				show_smenu(def_menu);
			} 
			else {
				hide_smenu(cur_menu);
			}
			in_menu=false;
		}
	}
}


function over_menu() {
	in_menu=true;
}

function get_def_menu() {
	reshow_smenu();
	for (i=0; i<submenus.length; i++) {
		if (submenus[i]!="") {
			if (submenus[i].style.visibility=="visible") {
				def_menu=i; cur_menu=i; return;
			}
		}
	}
	def_menu=-1; cur_menu=0;
}

function reshow_smenu() {
	for (i=0; i<submenus.length; i++) {
		if (submenus[i]!="") {
			m_item=document.getElementById("menu_item_"+i);
			left=m_menu_td.offsetLeft+m_item.offsetLeft+m_item.offsetWidth/2-submenus[i].offsetWidth/2;
			if (left < m_menu_td.offsetLeft+2){
				submenus[i].style.left=(m_menu_td.offsetLeft+2)+"px";
			}
			else {
				submenus[i].style.left=left+"px";
			}
			if (left+submenus[i].offsetWidth > body_div.offsetWidth-2){
				submenus[i].style.left=(body_div.offsetWidth-submenus[i].offsetWidth-2)+"px";
			}
		}
	}
}

///////////////////////////////////// Библиотека масштабирования окон /////////////////////////////////////
function resize_00() {
	reshow_smenu();
	reshow_info_div();
}

function resize_10() {
	reshow_smenu();
	reshow_info_div();
	reshow_contents();
	reshow_print();
}

function resize_01() {
	reshow_smenu();
	reshow_info_div();
	reshow_photo_window();
}

function resize_11() {
	reshow_smenu();
	reshow_info_div();
	reshow_contents();
	reshow_print();
	reshow_photo_window();
}

