// Temporary variables to hold mouse x-y pos.s
var mouseX = 0; // Toa do mouse that 
var mouseY = 0; // Toa do mouse that 

<!--
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    mouseX = event.clientX + document.body.scrollLeft
    mouseY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    mouseX = e.pageX
    mouseY = e.pageY
  }  
  // catch possible negative values in NS4
  if (mouseX < 0){mouseX = 0}
  if (mouseY < 0){mouseY = 0}  

return true
}

//-->


function previewimg(imgpath)
{
	var imgsrc =  document.frmAdmin.imgpath.value ;
	document.images.img_view.src = imgsrc ; 

}
function preview_select_img(obj_src, obj_des, frm )
{
	var objsrc = eval("document." + frm + "." + obj_src );	
	var objdes = eval("document.images." + obj_des );	
	if( (typeof(objsrc) != "undefined" ) 
		&& (typeof(objdes) != "undefined" ) 
		&& (typeof(objsrc.options) != "undefined" )
		&& (typeof(objsrc.selectedIndex) != "undefined" ) ) 
	{
		var idselect = objsrc.selectedIndex ;
		if( idselect >= 0  ) 
		{
			if(objsrc.options[idselect].title != "" )	
				objdes.src = objsrc.options[idselect].title  ;		
			else
				objdes.src = "images/spacer.gif"  ;		
		}
	}
	
}

/**
	Script multi selection 
*/
function funcChooseList(chose, list, frname) {
	dml = frname;
	objc = dml.elements[chose];
	objl = dml.elements[list];
    var ll = objl.length;
	var lc = objc.length;
	var ok = true;
	var minSelect = -1;
	if(ll != 0) {
		var i = 0;
		while(i < ll) {
			if(eval(objl).options[i].selected == true) {
				if (ok) {
					minSelect = i;
					ok = false;
				}
				opt = new Option();
				opt.text = eval(objl).options[i].text;
				opt.value = eval(objl).options[i].value;
				eval(objc).options[lc++] = opt;
				eval(objl).options[i] = null;
				--ll;
			} else 
				++i;
		}
	}
	if ((ll > 0) && (minSelect != -1)) {
		if(minSelect < ll)
			eval(objl).options[minSelect].selected = true;
		else 
			eval(objl).options[0].selected = true;
	}
}
//
function chooseObject(name, frName, postObject ) 
{
	dml = eval(frName);
	Obj = dml.elements[name];
	Len = Obj.length;
	if(Len > 0) 
	{
		str = "";
		for(i = 0; i < Len; i++) 
			str += "<input type=hidden name="+ postObject +"[] value=" + eval(Obj).options[i].value + ">";
		document.all['Atts'].insertAdjacentHTML('BeforeEnd', str);
		//dml.submit();
		return true;
	}
	return false; 
	//check();
}
function searchVal(search_obj, frm , obj ) 
{
	var fr = eval("document." + frm) ;
	var search_var= eval("document." + frm + "." + search_obj) ;	
	val = search_var.value;
	val = val.toLowerCase();
	ret = false;
	if(val != "") {
		obj = fr.elements[obj];
		len = obj.length;
		for(ii = 0; ii < len; ii ++) {
			str = obj.options[ii].text;
			str = str.toLowerCase();
			if(str.indexOf(val) != -1) {
				ret = true;
				obj.options[ii].selected = true;
			} else
				obj.options[ii].selected = false;
		}
	}
}

function show_product_tip(imgpath, textdisplay , x, y)
{
	//widthXToolTip = 160 ; 
	//widthYToolTip = 100 ; 	
	
	widthXToolTip = x ; 
	widthYToolTip = y ; 	
	
	beginX = 0 ;
	beginY = 0 ;
	
	PositionX = mouseX  ;
	if ( ( mouseX + widthXToolTip ) > (screen.width - 12) )
		PositionX = screen.width - (widthXToolTip  + 12)  ; 
	PositionY = mouseY - beginY  -  widthYToolTip - 16;
	
	//PositionX = 500 ;
	//PositionY = 300;
	
	bubble = document.getElementById("producttip");
	bubble.style.left =  PositionX + "px";
	bubble.style.top =  PositionY + "px";
	bubble.style.width =  widthXToolTip + "px";
	bubble.style.height =  widthYToolTip + "px";
	bubble.style.display = "block";	
	//bubble.style.width= widthXToolTip -10  + "px";
	//document.getElementById("bubtext").innerHTML = words +"("+ mouseX +"x"+ mouseY + ")";
	bubble.innerHTML = "<img src=\""+ imgpath +"\" width="+ widthXToolTip +" height="+ (widthYToolTip-20)+"><br><center><b>" + textdisplay  +"</b></center>";
	//alert('1111')
	
}
function hide_product_tip()
{
	bubble = document.getElementById("producttip");
	bubble.style.display = "none";	
}

function OpenProductWindow(vLink, vWidth, vHeight ) 
{
	winDef = 'status=no,resizable=no,scrollbars=2,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	//newwin = open('', '_blank', winDef);
	newwin = open('', '_self', winDef);
	newwin = window.open(vLink, "OpenProductWindow", winDef);
	/*
	newwin.document.writeln('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
	newwin.document.writeln('<a href="" onClick="window.close(); return false;">') ;
	newwin.document.writeln('<img src="', vLink, '" alt="Close window" border=0>');
	newwin.document.writeln('</a>');	
	newwin.document.writeln('</body>');
	*/
	newwin. focus();

}
