/////////////////////////////////// Библиотека для раздела "Проекты" /////////////////////////////
function get_cases() {
	if (typeof contents_active != 'undefined') {
		hide_contents();
	}
	(cases_active) ? hide_cases() : show_cases();
	return false;
}

function hide_cases() {
	m_cases_div.style.visibility="hidden";
	m_cases_corner.style.visibility="hidden";
	cases_active=false;
}

function show_cases() {
	m_cases_div.style.visibility="visible";
	m_cases_corner.style.visibility="visible";
	cases_active=true;
}

///////////////////////// Библиотека для формирования оглавления в проектах и продуктах /////////////////////
function get_contents() {
	if (typeof cases_active != 'undefined') {
		hide_cases();
	}
	if (contents_active) {
		hide_contents();
	}
	else {
		reshow_contents(); 
		show_contents();
		
	}
	return false;
}

function hide_contents() {
	m_contents_div.style.visibility="hidden";
	m_contents_corner.style.visibility="hidden";
	contents_active=false;
}

function show_contents() {
	m_contents_div.style.visibility="visible";
	m_contents_corner.style.visibility="visible";
	contents_active=true;
}

function reshow_contents() {
	var m_project_contents=document.getElementById("project_contents_"+current_project_page);

	m_contents_corner.style.top=(m_project.offsetTop+m_project_contents.offsetTop+m_project_contents.offsetHeight-6-m_contents_corner.offsetHeight/2)+"px";
	m_contents_corner.style.left=(m_project.offsetLeft-m_contents_corner.offsetWidth-5)+"px";
	
	m_contents_div.style.top=(m_project.offsetTop+m_project_contents.offsetTop+m_project_contents.offsetHeight-6-m_contents_div.offsetHeight/2)+"px";
	m_contents_div.style.left=(m_contents_corner.offsetLeft-m_contents_div.offsetWidth)+"px";	
}

function jmp_2_page(no) {
	if (current_project_page == no && !first) {return false;}
	first=false;
	document.getElementById("page_"+current_project_page).style.display="none";
	
	document.getElementById("page_num_"+current_project_page).style.color="#1E65B0";
	document.getElementById("page_lnk_"+current_project_page).style.color="#1E65B0";
	document.getElementById("page_lnk_"+current_project_page).style.textDecoration="underline";
	document.getElementById("page_lnk_"+current_project_page).style.cursor="pointer";
	document.getElementById("page_lnk_"+current_project_page).onmouseover=function(){this.style.color="#000000";};
	document.getElementById("page_lnk_"+current_project_page).onmouseout=function(){this.style.color="#1E65B0";};
	
	current_project_page=no;
	document.getElementById("page_"+current_project_page).style.display="";
	
	document.getElementById("page_num_"+current_project_page).style.color="#000000";
	document.getElementById("page_lnk_"+current_project_page).style.color="#000000";
	document.getElementById("page_lnk_"+current_project_page).style.textDecoration="none";
	document.getElementById("page_lnk_"+current_project_page).style.cursor="default";
	document.getElementById("page_lnk_"+current_project_page).onmouseover=function(){};
	document.getElementById("page_lnk_"+current_project_page).onmouseout=function(){};
	
	
	if (no != list_page) {if (typeof cases_active != 'undefined'){hide_cases();}reshow_contents(); show_contents();}
	else {hide_contents();}
	reshow_print();
	return false;
}

///////////////////////// Библиотека для формирования окна просмотра фотографий /////////////////////
var photo_exist=1;
var preload=new Image();

photo_head.onmousedown=begindrag;
photo_head.onmouseup=enddrag;

function tphoto(n_title,n_img,n_prev) {
	this.p_title=n_title;
	this.p_img=n_img;
	this.p_prev=n_prev;
}

function hide_photo_window() {
	photo_div.style.visibility="hidden";
	//fon_img.style.visibility="hidden";
	//fon_img.style.width=0+"px";
	//fon_img.style.height=0+"px";
	if (info_div.style.visibility == "visible") {
		initdrag(info_div,info_head,info_win);
	}
	return false;
}

function show_photo(url,width,height,alt) {
	photo_img.src="/f/i/wind/photo_loading.gif";
	photo_capt.style.width=(width-51)+"px";
	photo_img_td.style.height=(height)+"px";
	photo_title.innerHTML=alt;
	photo_win.style.width=(width+41)+"px";
	photo_div.style.width="auto";
	photo_div.style.height="auto";
	initdrag(photo_div,photo_head,photo_win);
	set_upper("photo");
	reshow_photo_window();
	photo_div.style.visibility="visible";
	//fon_img.style.visibility="visible";
	preload.onload=function(){
		photo_img.src=url;
		return false;
	}
	preload.src=url;
	return false;
}


function reshow_photo_window() {
	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";
	}*/
	photo_div.style.left = (Math.round((body_div.offsetWidth-photo_div.offsetWidth)/2))+"px";
	ppostop=(winheight-photo_div.offsetHeight)/2;
	if (ppostop<0) {ppostop=0;}
	photo_div.style.top=(ppostop+wintop)+"px";
}

///////////////////////// Библиотека для версии для печати /////////////////////
function get_print() {
	if (print_active) {
		hide_print();
	}
	else {
		show_print();
	}
	
	return false;
}

function show_print(){
	reshow_print();
	
	m_print_corner.style.visibility="visible";
	m_print_div.style.visibility="visible";
	print_active=true;
}

function hide_print(){
	m_print_corner.style.visibility="hidden";
	m_print_div.style.visibility="hidden";
	print_active=false;
}

function reshow_print(){
	if (current_project_page != list_page) {
		var m_project_print=document.getElementById("project_print_"+current_project_page);
	
		m_print_cur_page.href=printlink+"page"+current_project_page+"/print/";
	
		m_print_corner.style.top=(m_project.offsetTop+m_project_print.offsetTop+m_project_print.offsetHeight)+"px";
		m_print_corner.style.left=(m_project.offsetLeft+m_project_print.offsetLeft+m_project_print.offsetWidth/2)+"px";	
	
		m_print_div.style.top=(m_print_corner.offsetTop+m_print_corner.offsetHeight)+"px";
		m_print_div.style.left=(m_print_corner.offsetLeft+m_print_corner.offsetWidth/2-m_print_div.offsetWidth/2)+"px";	
	}
	else {
		hide_print();
	}
}
