/* $Header: /cvs/evision/src/www/b2b/lite/js/shopITGridNL.js,v 1.2 2009/07/15 07:57:02 aeg Exp $ */

function st(obj) { if (obj) obj.select(); }

function doOnBodyLoad() {
	if (oldDoBodyLoad) oldDoBodyLoad();
	if (window.parent.window) {
		if (window.parent.window.onFrameLoad) {
			window.parent.window.onFrameLoad(document);
		}
	}
	doProcWicImg()	
}

function doProcWicImg() {
	for (var i = 1; i <= cntSuffix; i++) doProcessWicImg(i);
}

function doProcessWicImg(suff) {
	var eText = document.getElementById('wicText' + (suff ? '_' + suff : ''));
	var eImg = document.getElementById('wicImg' + (suff ? '_' + suff : ''));
	if (eImg && eText) {
		eImg.onload = function () { doShowWicImg(suff); };
		eImg.src = (suff ? ('/catalogimg/wic/1/' + document.getElementById('ART_' + suff).value + '?RESIZE=70x70') : wicImgURL);
	}
}

function doShowWicImg(suff) {
	var eText = document.getElementById('wicText' + (suff ? '_' + suff : ''));
	var eImg = document.getElementById('wicImg' + (suff ? '_' + suff : ''));
	if (eImg && eText) {
		eText.style.display = 'none';
		eImg.style.display = '';
	}
}

function doOnBodyUnLoad() {
	if (oldDoBodyUnLoad) oldDoBodyUnLoad();
	if (window.parent.window) {
		if (window.parent.window.onFrameUnLoad) {
			window.parent.window.onFrameUnLoad();
		}
	}
}

function openWindow(url, width, height, scrollbars, wname, top, left) {
	var scrW = window.screen.availWidth;
	var scrH = window.screen.availHeight;
	var w, h, sb, wnm;
	if (!(w = width)) w = 640;
	if (!(h = height)) h = 480;
	if (!(sb = scrollbars)) sb = '1';
	var l = (left ? left : Math.round((scrW - w) / 2));
	var t = (top ? top : Math.round((scrH - h) / 2) - 20);
	if (!(wnm = wname)) wnm = '_blank';

	var sFeatures = "toolbar=0"
		+ ", directories=0"
		+ ", status=0"
		+ ", menubar=0"
		+ (", scrollbars=" + sb)
		+ ", resizable=1"
		+ (", width=" + w)
		+ (", height=" + h)
		+ (", left=" + l)
		+ (", top=" + t);

	var newWin = window.open(url, wnm, sFeatures);
	newWin.status = "";
	newWin.focus();
}

function vC(suff) {
	var f = document.forms['view_item'];
	f.elements['ItemCode'].value = document.getElementById('ART_' + suff).value;
	var uID = Math.round(1000000 * Math.random());
	openWindow('/purchasing/blank.jsp', '800', '600', '1', 'p' + uID);
	f.target = 'p' + uID;
	f.	submit();
}

function doViewChange(value) {
	if (window.parent.window) {
		if (window.parent.window.doChangeView) {
			window.parent.window.doChangeView(value);
		}
	}
}

