<!--//--><![CDATA[//><!--

navList = function() {
	if (document.all&&document.getElementById&&document.getElementById("nav")) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}
window.onload=navList;

//--><!]]>

/* clear field value function: removes the default value onfocus, and adds back if nothing entered */
function fieldClear(obj) {
	if(obj.Val) {
		if (obj.value == '') { 
			obj.value = obj.Val;
			obj.Val = null;
			obj.first = null;
		} 
		else {
			obj.Val = null;
		}
	} else if (!obj.first) { 
		obj.Val = obj.value;
		obj.value = ''; 
		obj.first = 'true';
	} 
}

function popOpen(id) {
	var topOffset = 20;
	setSize(topOffset);
	var overShade = document.getElementById(id);
	var topPad =  pos+topOffset;
	// height-padding = div height
	overShade.style.height = (ph - topPad) + 'px'; /* remove topPad from height */
	overShade.style.width = pw + 'px';
	overShade.style.paddingTop = topPad + 'px';
	overShade.style.display = 'block';
	if (document.all && !navigator.appVersion.match(/MSIE 7.0/)) {
		coverSelects(overShade);
	}
}
function popClose(id) {
	document.getElementById(id).style.display = "";
	if (document.all && !navigator.appVersion.match(/MSIE 7.0/)) {
		document.getElementById("popup-cover").outerHTML = "";
	}
		
}
function setSize(topOffset) { /* sets size of shade */
	if (window.pageYOffset != null) { /* moz and safari */
		pos = window.pageYOffset;
		ph = document.documentElement.scrollHeight;
		pw = document.documentElement.scrollWidth;
		if (document.body.scrollHeight > document.documentElement.scrollHeight) {
			ph = document.body.scrollHeight;
			pw = document.body.scrollWidth;
		}
	} else if (document.documentElement.scrollTop > document.body.scrollTop) { /* ie, catch if Standards compliance mode */
		pos = document.documentElement.scrollTop;
		ph = document.documentElement.scrollHeight;
		pw = document.documentElement.scrollWidth;
		if (document.documentElement.clientHeight > document.documentElement.scrollHeight) {
			ph = document.documentElement.clientHeight;
		}
	} else if (document.body != null) { /* if IE 5.5 */
		pos = document.body.scrollTop;
		ph = document.body.scrollHeight;
		pw = document.body.scrollWidth;
		if (document.documentElement.scrollHeight > document.body.scrollHeight) {
			ph = document.documentElement.scrollHeight;
		}
		ph = ph + pos + topOffset; /* fix box model */
	}
}	

/* covers select form elements with iframe in IE 6&< so they do not show through the popup */
function coverSelects(par) {
		var covHeight = document.body.scrollHeight+"px"; // add the negative margin to the height
		var coverFrame = "<IFRAME id='popup-cover' style='";
		coverFrame = coverFrame + "height:"+covHeight+";' ";
		coverFrame = coverFrame + "src='javascript:false;' frameBorder='0' scrolling='no'></IFRAME>";
		par.insertAdjacentHTML("afterEnd",coverFrame); // create new iframe that is the size of the popup window
}


/* Add by OpenBusiness (nfe) */
/* Checkbox */
function checkBox(id)
{

	//alert(document.getElementById('inputCheck' + id).value);
	if(document.getElementById('inputCheck' + id).value == '')
	{
		document.getElementById('imgCheck' + id).src = "/img/checkbox/true.png"; //change the image
		document.getElementById('inputCheck' + id).value = id; //change the field value
		//check[id] = true; //change the value for this checkbox in the array
	}
	else
	{
		document.getElementById('imgCheck' + id).src = "/img/checkbox/false.png";
		document.getElementById('inputCheck' + id).value = "";
		//check[id] = false;
	}
}

function double_list_move(src, dest)
{
	for (var i = 0; i < src.options.length; i++)
	{
		if (src.options[i].selected)
		{
			dest.options[dest.length] = new Option(src.options[i].text, src.options[i].value);
			src.options[i] = null;
			--i;
		}
	}
	sortSelectOptions(src);
	sortSelectOptions(dest);
}

function cloneListAndSelectAll(src, dest)
{
	for (var i = 0; i < src.options.length; i++)
	{
		dest.options[dest.length] = new Option(src.options[i].text, src.options[i].value, false, true);
	}
}


function sortSelectOptions(what)
{
    var copyOption = new Array();

    for (var i=0;i<what.options.length;i++)
        copyOption[i] = new Array(what[i].value,what[i].text);

    copyOption.sort(function(a,b) { return a[0]-b[0]; });

    for (var i=what.options.length-1;i>-1;i--)
        deleteOption(what,i);

    for (var i=0;i<copyOption.length;i++)
        addOption(what,copyOption[i][1],copyOption[i][0])
}

function deleteOption(object,index)
{
    object.options[index] = null;
}

function addOption(object,text,value)
{
    var defaultSelected = false;
    var selected = false;
    var optionName = new Option(text, value, defaultSelected, selected)
    object.options[object.length] = optionName;
    object.options[object.length-1].selected = false;
    
}

function posOrder()
{
	posWinVar = window.open('/pos/index', 'posWindow', 'status=no, toolbar=no, location=no, menubar=no, resizable=no, scrollbars=yes, height=800, width=964');
	posWinVar.focus();
}

function searchWin(searchUrl)
{
	searchWinVar = window.open(searchUrl, 'searchWindow', 'status=no, toolbar=no, location=no, menubar=no, resizable=no, scrollbars=no, width=900, height=680');
	searchWinVar.focus();
}

function productStockWin(searchUrl)
{
	h=400;
	w=400;

	height=Math.round((window.screen.height-h)/2);
	width=Math.round((window.screen.width-w)/2);

	searchWinVar = window.open(searchUrl, 'Real_Time_Stock', 'status=no, toolbar=no, location=no, menubar=no, resizable=no, scrollbars=no, width='+w+', height='+h+', top='+height+', left='+width);
	searchWinVar.focus();
}
