function popup(file,width,height)
{
	window.open(file,"site_path","height="+height+",width="+width+",status=no,location=no,toolbar=no,directories=no,resizable=yes,scrollbars=yes,menubar=no,top=10,left=10");
}

function open_item(obj) {
	window.open(obj.href,"","height="+600+",width="+800+",status=no,location=no,toolbar=no,directories=no,resizable=yes,scrollbars=yes,menubar=no,top=10,left=10");
	return false;
}

function makeSiteLink(name) {
	if (!window.js_base_url) {
		str = document.location.toString();
		js_base_url = str.replace("/javascript/editor/scripts/hyperlink.htm","");
		js_base_url = js_base_url.replace("/javascript/editor/scripts/moz/hyperlink.htm","");
	}
	popup(js_base_url+'/admin/index.php?mod=tree&action=mini_browser&returnname='+name,'600','400');
}

function retBack(obj, str) {
	window.close();
	obj.value = str;
}

function insertIntoWYSIWYG(str) {
	doc = "window.opener";
	for ( property in eval(doc) ) {
		fullPropertyName = "document."+property;

		if (fullPropertyName.indexOf("document.myStyle")!=-1) {
			objName = fullPropertyName.replace("document.myStyle", "");
			break;
		}
	}
	objName = eval(doc+".window."+objName);
	objName.insertCustomTag(str);
	self.window.close();
}

function check4compare(obj) {
	for(i=0; i<obj.elements.length; i++) if (obj.elements[i].type=="checkbox" && obj.elements[i].checked) return true;
	
	alert('Не выделено ни одного продукта для сравнения');
	return false;
}

function switch_loading_box (box_id) {
	
	if(document.getElementById(box_id).style.display!="none") {
		document.getElementById(box_id).style.display="none";
	}
	else {
		document.getElementById(box_id).style.display="";
		
		var ie=document.all;
		iebody=document.body;
		var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset;
		var docwidth=(ie)? iebody.clientWidth : window.innerWidth;
		docheight=(ie)? iebody.clientHeight: window.innerHeight;
		var objwidth=document.getElementById(box_id).offsetWidth;
		objheight=document.getElementById(box_id).offsetHeight;
		var test=docwidth/2-objwidth/2+"px";

		document.getElementById(box_id).style.left=docwidth/2-objwidth/2+"px";
		document.getElementById(box_id).style.top=scroll_top+docheight/2-objheight/2+"px";
	}
	
	return false;
	
}

function switch_catalog_div() {
	tObj=document.getElementById("div_text");
	dObj=document.getElementById("add_table");
	
	if (tObj.className=="x3") {
		tObj.className="x3_2";
		dObj.style.display="none";
	}
	else {
		tObj.className="x3";
		dObj.style.display="";
	}
}


/******************************************************************************************/

function switch_div(action, id) {
	if (obj=document.getElementById("menu_"+id)) {
		if (action=="show")
			obj.className="";
		else
			obj.className="hidd";
	}
	
	return false;
}

function change_img(obj) {
	if (imgObj=document.getElementById("main_img")) {
		imgObj.src=obj.href.replace("/shop_images/", "/shop_images/resized2-");
	}
	return false;
}

function show_img(obj,name) {
	
//	href=obj.childNodes[0].src;
	href=obj.href;
	href=href.replace("/shop_images/resized2-", "/shop_images/");
	href=href.replace("/shop_images/resized-", "/shop_images/");


	fotow = window.open('','foto','menubar=false,scrollbars=yes,width=900,height=730');
  	fotow.document.open();

  	fotow.document.writeln('<html><head><title>Наносфера-поэтажный план</title></head><link href="/templates/main.css" rel="stylesheet" type="text/css"><body style="margin: 0; padding: 0;"  onload="window.focus();">');
	fotow.document.writeln('<table width="900" height="100%" border="0" cellspacing="0" cellpadding="0"><tr valign="middle"><td align="center">');
	fotow.document.writeln('<div style="width: 850px; margin-bottom: 15px; text-align: left; font-size: 24px; font-weight:bold; font-family: Georgia, Verdana;">'+name+'</div>');
  	fotow.document.writeln('<a href="javascript:self.close();"><img src="'+href+'" border="0" name="i"><br></a>');
	fotow.document.writeln('<table border="0" cellspacing="0" cellpadding="0" style="margin-top : 12px;" width=850><tr><td width="95" align="left"><img src="/templates/img/logo_1.gif"></td>');
	fotow.document.writeln('<td width="*" style="font-size: 11px; color: #26194c;">м. Китай-город,<br>Лубянский проезд, 27/1<br>(495) 981-57-87; 363-74-70</td><td width="15" align="left"><img src="/templates/img/ara_minus.gif"></td>');
	fotow.document.writeln('<td width=100><a href="/" onClick="window.print(); return false">Печать</a></td><td width="15" align="left"><img src="/templates/img/ara_minus.gif"></td>');
	fotow.document.writeln('<td width=60><a href="/" onClick="javascript:self.close();">Закрыть</a></td></tr></table></td></tr></table>');


  	fotow.document.close();

	return false;
}


function scroll_to_projects(){
	var target_offset = $("#projects").offset();
	var target_top = target_offset.top;
	$('html, body').animate({scrollTop:target_top}, 500, 'swing');
}
function z(nam){
	$("div[class='proj_group']").hide();
	$("div[class*='proj_item']").hide();
	$("div.popular").hide();
	$("div[class*="+nam+"]").show();
	scroll_to_projects();
}
function z_show(nam){
	$("div[class*="+nam+"]").show();
	scroll_to_projects();
}
function z_hide_all(nam){
	$("div[class='proj_group']").hide();
	$("div[class*='proj_item']").hide();
	$("div.popular").hide();
}
function z_show_all(){
	$("div[class*='proj_item']").show();
	$("div[class='proj_group']").show();
	$("div.popular").show();
	scroll_to_projects();
}

$(document).ready(function(){
   $('#projects li a').not('.ignore').click(function(){
		$("#projects a.orange").removeClass("orange").addClass("blue");
		$(this).not('.ignore').removeClass("blue").addClass("orange");
	});
 });
