
function MoveCropFrame(posx, posy)
{
	var x;
	var y;
	var obj;
		
	if (NS6) {
		x = this.screenX;
		y = this.screenY;
		obj = this.parent;

		x= posx;
		y= posy-80;

		bssm=document.getElementById("baselayer").style;
		bssm.left = x;
		bssm.top = y;
		//bssm.visibility="visible";

	} else if (IE) {


		x= posx;
		y= posy-80;

		bssm=document.all("baselayer").style;
		bssm.left = x;
		bssm.top = y;
		//bssm.visibility="visible";
	} else if (NS) {
		bssm=document.layers["layer1"];
		bssm2=bssm.document.layers["layer2"];
		ssm=bssm2.document.layers["layer"];
		bssm2.clip.left=0;
		ssm.visibility = "show";
	}
}


function DisplayLayer(cropImage_idx, cropImage_val, image_id, url, prewidth, preheight, rotate, effect,  posx, posy)
{
	DisplayLayerEx(cropImage_idx, cropImage_val, image_id, url, prewidth, preheight, rotate, effect,  posx, posy, '')	
}

function DisplayLayerEx(cropImage_idx, cropImage_val, image_id, url, prewidth, preheight, rotate, effect,  posx, posy, isPrintAll)
{
	var frameObj;
	if (IE) { 
		//frameObj = document.getElementById("CropFrame").Document; //Works on all IE except MAC. 
		frameObj = document.frames["CropFrame"].document; 
	} else {
		frameObj = document.getElementById("CropFrame").contentDocument; 
	}
	MoveCropFrame(posx, posy);

	frameObj.DisplayForm.crop_opt.value = cropImage_val;
		
	frameObj.DisplayForm.cropidx.value = cropImage_idx;
	frameObj.DisplayForm.url.value = url;
	frameObj.DisplayForm.imageId.value = image_id;
	frameObj.DisplayForm.rotate.value = rotate;
	frameObj.DisplayForm.effect.value = effect;
	frameObj.DisplayForm.width.value = prewidth;
	frameObj.DisplayForm.height.value = preheight;
	frameObj.DisplayForm.isPrintAll.value = isPrintAll;
		
	frameObj.DisplayForm.submit();
}

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
  }
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0;}
  if (tempY < 0){tempY = 0;}
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  return true;
}

NS6 = (document.getElementById&&!document.all);
IE = (document.all);
NS = (navigator.appName=="Netscape" && navigator.appVersion.charAt(0)=="4");


// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;

// Set-up to use getMouseXY function onMouseMove
document.onmousedown = getMouseXY;

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEDOWN);

// Create a Crop Layer
if (IE||NS6) {
	document.write('<DIV ID="baselayer" style="visibility:hidden;Position : Absolute ;Left : -420px ;Top : -600px; width: 400px; height:510px;">');
}
if (NS) {
	document.write('<LAYER name="layer1" top="0" LEFT=0 visibility="show"><ILAYER name="layer2"><LAYER visibility="hide" name="layer" bgcolor="#D9D9D9">');
}

document.write('<IFRAME src="crop_image.asp" ID="CropFrame" NAME="CropFrame" STYLE="Left:0px; Top:0px; width: 400 px; height:510px;" WIDTH="400" HEIGHT="510" MARGINHEIGHT=0 MARGINWIDTH=0 FRAMEBORDER=0 SCROLLING=NO></IFRAME>');

if (NS) {
	document.write('</ILAYER></LAYER>');
}
if (IE||NS6) {
	document.write('</DIV>');
}

