function popup(file,width,height)
{
	wind = window.open(file,"","height="+height+",width="+width+",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 = str.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);
}

function doer(id,url,price,action) {

	numObj = document.getElementById('basket_num');
	sumObj = document.getElementById('basket_sum');
//	dumObj = document.getElementById('div_'+id);
	ac1Obj = document.getElementById('do_'+id+"_1");
	ac2Obj = document.getElementById('do_'+id+"_2");

	if(numObj) num=eval(numObj.innerText);
	if(sumObj) sum=eval(sumObj.innerText);
	
	if (action=="add") {
		if(numObj) numObj.innerText = ++num;
		if(sumObj) sumObj.innerText = sum+eval(price);
		url += "add/";
		ac1Obj.style.display = "none";
		ac2Obj.style.display = "inline";
//		dumObj.innerHTML = '<strong class="orange">куплено</strong><br>';
	}
	else {
		if(numObj) numObj.innerText = --num;
		if(sumObj) sumObj.innerText = sum-eval(price);
		url += "delete/";
		ac1Obj.style.display = "inline";
		ac2Obj.style.display = "none";
//		dumObj.innerHTML = '';
	}

	window.frames.buy_window.location=url+id;
	return false;
}

function popup2(img_name) {
	generatehtml(img_name);
	return false;
}

function generatehtml(file,width,height) {

	width=500;
	height=600;

	win = window.open("","site_path","height="+height+",width="+width+",status=no,location=no,toolbar=no,directories=no,resizable=yes,scrollbars=no,menubar=no,top=10,left=10");

	myImage = new Image();

	myImage.src = file;

	if (myImage.width>0) {
		width=myImage.width+80;
		height=myImage.height+80;
	}

	win.document.write("<html>");
	win.document.write("<head>");
	win.document.write("<title>Фотогалерея</title>");
	win.document.write("<link href=\"/templates/main.css\" rel=\"stylesheet\" type=\"text/css\">");
	win.document.write("</head>");
	win.document.write("<body>");
	win.document.write("<table width=\"100%\" height=\"100%\"><tr><td align=\"center\">");
	win.document.write("<img src=\""+file+"\">");
	win.document.write("<p align=\"center\"><br><a href=\"javascript:window.close();\">закрыть</a></p>");
	win.document.write("</td></tr></table>");
	win.document.write("<script>window.resizeTo('"+width+"','"+height+"')</script>");
	win.document.write("</body>");
	win.document.write("</html>");
}
