var aBlock='';
var s_vars=[];

function pgStartTemplate() {
	_gaq.push(["_addOrganic", "blogs.yandex.ru", "text"]);
	_gaq.push(["_addOrganic", "go.mail.ru", "q"]);
	_gaq.push(["_addOrganic", "gogo.ru", "q"]);
	_gaq.push(["_addOrganic", "nova.rambler.ru", "query"]);
	_gaq.push(["_addOrganic", "rambler.ru", "words"]);
	_gaq.push(["_addOrganic", "nigma.ru", "s"]);
	_gaq.push(["_addOrganic", "search.qip.ru", "query"]);
	_gaq.push(["_addOrganic", "webalta.ru", "q"]);
	_gaq.push(["_addOrganic", "aport.ru", "r"]);
	_gaq.push(["_addOrganic", "liveinternet.ru", "ask"]);
	_gaq.push(["_addOrganic", "gde.ru", "keywords"]);
	_gaq.push(["_addOrganic", "quintura.ru", "request"]);
	_gaq.push(["_addOrganic", "poisk.ru", "text"]);
	_gaq.push(["_addOrganic", "km.ru", "sq"]);
	_gaq.push(["_addOrganic", "bigmir.net", "q"]);
	_gaq.push(["_addOrganic", "akavita.by", "z"]);
	_gaq.push(["_addOrganic", "tut.by", "query"]);
	_gaq.push(["_addOrganic", "all.by", "query"]);
	_gaq.push(["_addOrganic", "i.ua", "q"]);
	_gaq.push(["_addOrganic", "meta.ua", "q"]);
	_gaq.push(["_addOrganic", "online.ua", "q"]);
	_gaq.push(["_addOrganic", "a.ua", "s"]);
	_gaq.push(["_addOrganic", "ukr.net", "search_query"]);
	_gaq.push(["_addOrganic", "search.com.ua", "q"]);
	_gaq.push(["_addOrganic", "search.ua", "query"]);
	_gaq.push(["_addOrganic", "search.babylon.com", "q"]);
	_gaq.push(["_addOrganic", "icq.com", "q"]);
	_gaq.push(["_addOrganic", "search.winamp.com", "q"]);
}

function contentLoad() {
	var page = '', menuId='', ptype = 0, defpage="page="+config['site_defpage'].toString(); locChecked=false;
	if (window.location.hash!=null && window.location.hash!="" && window.location.hash!="#") {
		ptype = 1; page = window.location.hash.toString().substr(1);
	} else if (window.location.search!=null && window.location.search!="" && window.location.search!="?") {
		ptype = 2; page = window.location.search.toString().substr(1);
	} else if (window.location.pathname!=null && window.location.pathname!="" && window.location.pathname!="/") {
		ptype = 2; page = window.location.pathname.replace("/","");
	} else {
		ptype = 1; page = defpage;
	}
	if (window.location.pathname=="/" && window.location.search=="" && window.location.hash=="" && mhash=="") {
		mhash=window.location.hash;
		if (locChecked == false) {
			if (mhash != window.location.hash) { mhash=window.location.hash };
			locChecked=true; locationCheck();
		}
		return false;
	}
	s_vars=parseStr(page); s_vars['furl']='';
	if (s_vars['page']===null || s_vars['page']==undefined) {
		fromSrcArr=explode("&",page,2); s_vars=parseStr(fromSrcArr[1]);
		s_vars['furl']=fromSrcArr[0];
		fromSrcArr[0]="furl="+fromSrcArr[0];
		if (isset(furl_assoc[strtolower(s_vars['furl'])])) { s_vars['page']=furl_assoc[strtolower(s_vars['furl'])]; } else { s_vars['page']="0.0"; }
	}
	if (ptype==2) {
		window.location.href='/#'+page; return false;
	} else {
		if (page!=defpage && "page="+furl_assoc[page.toLowerCase()]!=defpage) { window.location.hash=page; } else { window.location.hash=""; }
	}
	mhash=window.location.hash;
	menuClick(page,null,true);
	if (locChecked == false) {
		if (mhash != window.location.hash) { mhash=window.location.hash }; locChecked = true; locationCheck();
	}
}

function menuClick(fromSrc, dataPut, restrictCache) {
	var i=0, page="", fromSrcArr=[]; pages=[], menuId="", menuIds=[], defpage="page="+config['site_defpage'].toString();
	if (document.getElementById("data_body-1")!=undefined && document.getElementById("data_body-1").reqState!=undefined && document.getElementById("data_body-1").reqState!=null && document.getElementById("data_body-1").reqState!=-1) { if (locChecked==false) { setTimeout("mhash='"+location.hash+"';locChecked=true;locationCheck();",3000); } return false; }
	locChecked=false;
	if (dataPut==null) { dataPut=1; }
	if (restrictCache==null) { restrictCache=false; }
	s_vars=parseStr(fromSrc); s_vars['furl']='';
	if (s_vars['page']===null || s_vars['page']==undefined) {
		fromSrcArr=explode("&",fromSrc,2); s_vars=parseStr(fromSrcArr[1]);
		s_vars['furl']=fromSrcArr[0];
		fromSrcArr[0]="furl="+fromSrcArr[0];
		if (isset(furl_assoc[strtolower(s_vars['furl'])])) { s_vars['page']=furl_assoc[strtolower(s_vars['furl'])]; } else { s_vars['page']="0.0"; }
	}
	if (s_vars['page']!==null && s_vars['page']!==undefined) {
		page=s_vars['page']; pages = explode('.',page);
		if (!is_numeric(pages[0])) { page=config['site_defpage'].toString(); pages = explode('.',page); }
		if (menu_assoc[s_vars['page']]) {
			menuId=menu_assoc[s_vars['page']];
			menuIds=explode('.',menuId);
		} else {
			menuId=-1;
		}
	} else {
		location.href="/";
		locChecked=true; locationCheck();
		return true;
	}
	if (window.location.pathname!='/' && window.location.pathname!='' && window.location.pathname!=null) { window.location.pathname='/'; }
	if (fromSrc!=defpage && "page="+furl_assoc[fromSrc.toLowerCase()]!=defpage) {
		window.location.hash = "#"+fromSrc; mhash = window.location.hash;
	} else {
		window.location.hash="#"; mhash = window.location.hash;
	}
	if (window.location.hash=="") {
		if (document.getElementById("page_seo")!=null) { classChange("",document.getElementById("page_seo")); }
	} else {
		if (document.getElementById("page_seo")!=null) { classChange("invisible",document.getElementById("page_seo")); }
	}
	locChecked=true; locationCheck();
	if (menuId!=-1) {
		smlist = document.getElementById('menu_list_'+menuId);
		mlist = document.getElementById('menu_list_'+menuIds[0]);
		sbmlist = document.getElementById('box_menu_list_'+menuId);
		bmlist = document.getElementById('box_menu_list_'+menuIds[0]);
	} else {
		smlist = null;
		mlist = null;
		sbmlist = null;
		bmlist = null;
	}
	mSelected = getElementsByStyleClass ('menu_list_select');
	smSelected = getElementsByStyleClass ('menu_sublist_select');
	bmSelected = getElementsByStyleClass ('box_menu_list_select');
	sbmSelected = getElementsByStyleClass ('box_menu_sublist_select');
	for (i=0;i<bmSelected.length;i++) {
		if (bmSelected[i]!=bmlist ) {
			classChange("box_menu_list",bmSelected[i]);
			if (document.getElementById(bmSelected[i].id+"_sub")!=null && document.getElementById(bmSelected[i].id+"_sub").className!="box_menu_sub_visible") {
				classChange("box_menu_sub_invisible",document.getElementById(bmSelected[i].id+"_sub"));
			}
		}
	}
	for (i=0;i<mSelected.length;i++) {
		if (mSelected[i]!=mlist ) {
			classChange("menu_list",mSelected[i]);
			if (document.getElementById(mSelected[i].id+"_sub")!=null && document.getElementById(mSelected[i].id+"_sub").className!="menu_sub_visible") {
				classChange("menu_sub_invisible",document.getElementById(mSelected[i].id+"_sub"));
			}
		}
	}
	for (i=0;i<sbmSelected.length;i++) {
		if (sbmSelected[i]!=sbmlist) {
			classChange("box_menu_sublist",sbmSelected[i]);
		}
	}
	for (i=0;i<smSelected.length;i++) {
		if (smSelected[i]!=smlist) {
			classChange("menu_sublist",smSelected[i]);
		}
	}
	if (menuId!=-1) {
		if (bmSelected[0]!=bmlist) {
			classChange("box_menu_list_select",bmlist);
			if (document.getElementById(bmlist.id+"_sub")!=null && document.getElementById(bmlist.id+"_sub").className!="box_menu_sub_visible") {
				classChange("box_menu_sub",document.getElementById(bmlist.id+"_sub"));
			}
		}
		if (mSelected[0]!=mlist) {
			classChange("menu_list_select",mlist);
			if (document.getElementById(mlist.id+"_sub")!=null && document.getElementById(mlist.id+"_sub").className!="menu_sub_visible") {
				classChange("menu_sub",document.getElementById(mlist.id+"_sub"));
			}
		}
		if (menuIds[1]!=null) {
			if (sbmlist!=null && sbmSelected[0]!=sbmlist) {
				classChange("box_menu_sublist_select",sbmlist);
			}
			if (smlist!=null && smSelected[0]!=smlist) {
				classChange("menu_sublist_select",smlist);
			}
		}
	}
	if (dataPut==1) {
		if (menuId!=-1) {
			smlink=document.getElementById('menu_list_'+menuId+'_link');
			sbmlink=document.getElementById('box_menu_list_'+menuId+'_link');
			if (smlink!=null) {
				smlink.href='#'+fromSrc;
			}
			if (sbmlink!=null) {
				sbmlink.href='#'+fromSrc;
			}
		}
		var attr='';
		if (s_vars['furl']!="") { attr=implode("&",fromSrcArr); } else { attr=fromSrc; }
		getReqToID('/?ajax=2&sessid='+getCookie(config['session_name'])+'&'+attr,"data_body-1",2,restrictCache);
	}
	if (s_vars['furl']!="") { fromSrc="/"+fromSrc; } else { fromSrc="/?"+fromSrc; }
	if(_gaq!==null){ _gaq.push(['_trackPageview', fromSrc]); _gaq.push(['_trackEvent', 'Forms', 'AJAX Form']); }
	scrollToTop(146);
	return false;
}

function deactiveBlock(id) {
	if (dProcess==true) {
		classChange("",document.getElementById('box_hdr-'+id));
		classChange("box_hdr_r",document.getElementById('box_hdr_pic-'+id));
		classChange("box_bg",document.getElementById('box_bg_pic-'+id));
		aBlock='';
	}
}

function activeBlock(id,ap) {
	if (aBlock==id+"."+ap) {
		dProcess=false;
	}
	if (ap=="0") {
		dProcess=true;
		setTimeout("deactiveBlock("+id+")",5);
	} else if (ap=="1" && aBlock!=id+"."+ap) {
		dProcess=false;
		aBlock=id+"."+ap;
		elements = [];
		elements = getElementsByStyleClass ('box_active');
		for (var i = 0; i < elements.length; i++) {
			classChange("",elements[i]);
		}
		classChange("box_active",document.getElementById('box_hdr-'+id));
		elements = [];
		elements = getElementsByStyleClass ('box_hdr_ra');
		for (var i = 0; i < elements.length; i++) {
			classChange("box_hdr_r",elements[i]);
		}
		elements = [];
		elements = getElementsByStyleClass ('box_hdr_rna');
		for (var i = 0; i < elements.length; i++) {
			classChange("box_hdr_r",elements[i]);
		}
		classChange("box_hdr_ra",document.getElementById('box_hdr_pic-'+id));
	} else if (ap=="2" && aBlock!=id+"."+ap) {
		dProcess=false;
		aBlock=id+"."+ap;
		elements = [];
		elements = getElementsByStyleClass ('box_active');
		for (var i = 0; i < elements.length; i++) {
			classChange("",elements[i]);
		}
		classChange("box_active",document.getElementById('box_hdr-'+id));
		elements = [];
		elements = getElementsByStyleClass ('box_hdr_ra');
		for (var i = 0; i < elements.length; i++) {
			classChange("box_hdr_r",elements[i]);
		}
		elements = [];
		elements = getElementsByStyleClass ('box_hdr_rna');
		for (var i = 0; i < elements.length; i++) {
			classChange("box_hdr_r",elements[i]);
		}
		classChange("box_hdr_rna",document.getElementById('box_hdr_pic-'+id));
	}
}

function activeBoxMenu(self,ap) {
	if (ap=="0" && self.className=="box_menu_list_active") {
		classChange("box_menu_list",self);
	} else if (ap=="1" && self.className=="box_menu_list") {
		classChange("box_menu_list_active",self);
	}
}

function activeMenu(self,ap) {
	if (ap=="0" && self.className=="menu_list_active") {
		classChange("menu_list",self);
	} else if (ap=="1" && self.className=="menu_list") {
		classChange("menu_list_active",self);
	}
}

function activeButton(self,ap) {
	if (ap=="0" && self!=null && self.className=="button_active") {
		classChange("button",self);
	} else if (ap=="1" && self!=null && self.className=="button") {
		classChange("button_active",self);
	}
}

function activeBoxSubmenu(self,ap) {
	if (ap=="0" && self.className=="box_menu_sublist_active") {
		classChange("box_menu_sublist",self);
	} else if (ap=="1" && self.className=="box_menu_sublist") {
		classChange("box_menu_sublist_active",self);
	}
}

function activeSubmenu(self,ap) {
	if (ap=="0" && self.className=="menu_sublist_active") {
		classChange("menu_sublist",self);
	} else if (ap=="1" && self.className=="menu_sublist") {
		classChange("menu_sublist_active",self);
	}
}

function activeMenuItem(self,ap) {
	if (ap=="0" && self!=null && self.className=="menu_item_active") {
		classChange("menu_item",self);
	} else if (ap=="1" && self!=null && self.className=="menu_item") {
		classChange("menu_item_active",self);
	}
}

function activeGroupItem(self,ap) {
	if (ap=="0" && self!=null && self.className=="group_item_active") {
		classChange("group_item",self);
	} else if (ap=="1" && self!=null && self.className=="group_item") {
		classChange("group_item_active",self);
	}
}

