function RandomString()
{
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 8;
	var randomstring = "";
	for (var i = 0; i < string_length; i++)
	{
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum, rnum + 1);
	}
	return randomstring;
}

function ShowPics(cid, foto, width, height)
{
	width1 = width + 10;
	height1 = height + 10;
	document.onmousemove = fmouse;
	var html = "";
	html = "<div style='border: 1px solid #000000; width: " + width1 + "px; height: " + height1 + "px; z-index: -1;' align='center'><img src='img/catalog/" + cid + "/b" + foto + "?sx=" + RandomString() + "' border='0'></div>";
	document.getElementById("img").innerHTML = html;
	document.getElementById("img").style.visibility = "visible";
}

var global_width = 0; 
var global_heigh = 0;

function ShowPicsLeft(cid, foto, width, height)
{
	width1 = width + 10;
	height1 = height + 10;
	//document.onmousemove = "fmouse_left(" + width + ", " + height +");";
	document.onmousemove = fmouse_left;

  global_width = width; 
  global_heigh = height;
	
	var html = "";
	html = "<div style='border: 1px solid #000000; width: " + width1 + "px; height: " + height1 + "px; z-index: -1;' align='center'><img src='img/catalog/" + cid + "/b" + foto + "?sx=" + RandomString() + "' border='0'></div>";
	document.getElementById("img").innerHTML = html;
	document.getElementById("img").style.visibility = "visible";
}


function HidePics()
{
	document.getElementById("img").innerHTML = "";
	document.onmousemove = "";
	document.getElementById("img").style.visibility = "hidden";
}
function fmouse()
{
	var tempX = 0;
	var tempY = 0;
	var IE = document.all?true:false;
	if (IE)
	{
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	}
	else
	{
		tempX = e.pageX; tempY = e.pageY;
	}
		
	if (tempX < 0) tempX = 0;
	if (tempY < 0) tempY = 0;
		
	//if ((tempX + 400) > screen.width)		
	//	tempX = tempX - 400;
		
	//if ((tempY + 300) > screen.height)
	//	tempY = tempY - 300;
	
	document.getElementById("img").style.left = tempX + "px";
	document.getElementById("img").style.top = tempY + "px";
}

function fmouse_left()
{
	var tempX = 0;
	var tempY = 0;
	var IE = document.all?true:false;
	if (IE)
	{
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	}
	else
	{
		tempX = e.pageX; tempY = e.pageY;
	}
		
	if (tempX < 0) tempX = 0;
	if (tempY < 0) tempY = 0;
		
	//if ((tempX + 400) > screen.width)		
	//	tempX = tempX - 400;
		
	//if ((tempY + 300) > screen.height)
	//	tempY = tempY - 300;
	tempX = tempX - global_width - 20;
	//alert(global_width);
	
	document.getElementById("img").style.left = tempX + "px";
	document.getElementById("img").style.top = tempY + "px";
}


function ShowPics2(cid, foto, width, height)
{
	document.onmousemove = fmouse;
	var html = "";
	html = "<div style='border: 1px solid #000000; width: " + width + "px; height: " + height + "px; z-index: 0;' align='center'><img src='../img/catalog/" + cid + "/b" + foto + "?sx=" + RandomString() + "' border='0'></div>";
	document.getElementById("img").innerHTML = html;
	document.getElementById("img").style.visibility = "visible";
}

function AddVal(id)
{
	var el = "cb" + id;
	if (document.getElementById(el).checked)
	{
		if (MyForm.ids.value)
			MyForm.ids.value = MyForm.ids.value + ";" + id;
		else
			MyForm.ids.value = id;
	}
	else
	{
		if (MyForm.ids.value)
		{
			var temp = new Array();
			var tempstr = "";
			temp = MyForm.ids.value.split(';');
			for (var i = 0; i < temp.length; i++)
			{
				if (temp[i] != id)
				{
					if (tempstr)
						tempstr = tempstr + ";" + temp[i];
					else
						tempstr = tempstr + temp[i];					
				}
			}
			MyForm.ids.value = tempstr;
		}
	}
}