function calcHeight()
{
var the_height=document.body.scrollHeight;
var the_height2=parseInt(document.body.scrollHeight);
obj = parent.document.getElementById("1");
obj.style.height = the_height+20;
obj.style.height = the_height2+20+"px";
}
function SetName() {
window.name="main_photo";
}
function bw() {
	if (picture.className=='bw') {
  		picture.className='';
  		document.all.bw.src = "../../images/b_w3_2.gif";
 	 } else {
  	 	picture.className='bw';
	  	document.all.bw.src = "../../images/b_w3.gif";
	 }
}

function moveit(event, h) {
  var el, x, y;
  el = document.getElementById(h);
  el.style.visibility = "visible";
  el.visibility = "show";
  if (window.event) {
    x = window.event.clientX ;
    y = window.event.clientY ;
  }
  else {
    x = event.clientX;
    y = event.clientY;
  }
  el.style.left = x + 12 + "px";
  el.style.top  = y + 23 +"px";
}
function hideit(h) {
  var el = document.getElementById(h);
  el.style.visibility = "hidden";
  el.visibility = "hide";
}

var Cropflag = false;

var CurrentSide = null;
var x0 = 0;
var y0 = 0;

function MouseDown(side)
{
	CurrentSide = side;
	ev = window.event;
	x0 = ev.x;
	y0 = ev.y;
}

function MouseUp()
{
	CurrentSide = null;
}

function MouseMove()
{
	ev = window.event;
	if((CurrentSide == null) || (ev.button != 1)) return;
	dx = ev.x - x0;
	dy = ev.y - y0;

	style = document.all[CurrentSide].style;
	switch (CurrentSide)
	{
		case "top":
			if(style.pixelHeight >= 8) style.pixelHeight += dy;
			if(style.pixelHeight < 8) style.pixelHeight = 8;
			else {x0 = ev.x; y0 = ev.y;}
		break;
		case "bottom":
			if(style.pixelHeight >= 8) style.pixelHeight -= dy;
			if(style.pixelHeight < 8) style.pixelHeight = 8;
			else {x0 = ev.x; y0 = ev.y;}
		break;
		case "left":
			if(style.pixelWidth >= 8) style.pixelWidth += dx;
			if(style.pixelWidth < 8) style.pixelWidth = 8;
			else {x0 = ev.x; y0 = ev.y;}
		break;
		case "right":
			if(style.pixelWidth >= 8) style.pixelWidth -= dx;
			if(style.pixelWidth < 8) style.pixelWidth = 8;
			else {x0 = ev.x; y0 = ev.y;}
		break;
	}
}

function Crop(left, top, right, bottom)
{
	if(!Cropflag) flipCrop();

	document.all.left.style.pixelWidth = left + 8;
	document.all.right.style.pixelWidth = right + 8;
	document.all.top.style.pixelHeight = top + 8;
	document.all.bottom.style.pixelHeight = bottom + 8;

	window.scrollTo(0,0);
}

function AddClipping()
{
	x1 = document.all.left.style.pixelWidth - 8; if(x1 < 0) x1 = 0;
	y1 = document.all.top.style.pixelHeight - 8; if(y1 < 0) y1 = 0;
	x2 = document.all.right.style.pixelWidth - 8; if(x2 < 0) x2 = 0;
	y2 = document.all.bottom.style.pixelHeight - 8; if(y2 < 0) y2 = 0;

	s = '*Crop('+x1+','+y1+','+x2+','+y2+')*';

	document.comment.komentar.value += s;
	document.comment.komentar.focus();
}

function flipCrop()
{
	Cropflag = !Cropflag;
	if(Cropflag)
	{
		document.all.crop.src = "../../images/crop_2.gif";
		document.all.cropper.style.display = "";
		document.all.ins.style.display = "";
	}
	else
	{
		document.all.crop.src = "../../images/crop.gif";
		document.all.cropper.style.display = "none";
		document.all.ins.style.display = "none";
	}
}
function send_(koi) {
 var obj = document.getElementById(koi);
 var what = "Въведете поне един символ!";
  if (obj.komentar.value == "")  {
    alert (what);
  } else {
    obj.submit();
  }
} 
