function $(id) { return document.getElementById(id); }

try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

function Show(id)
{
	var o = document.getElementById(id);
	o.style.display = 'block';
}
function Hide(id)
{
	var o = document.getElementById(id);
	o.style.display = 'none';
}

function ValidEmail(email)
{
	if (email == '') return false;

	return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email));
}

function IsNumeric(strString)
//  check for valid numeric strings	
{
	var strValidChars = "0123456789.-";
	var strChar;
	var blnResult = true;

	if (strString.length == 0) return false;

	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
			blnResult = false;
	}
	return blnResult;
}

function OpenWinCenter(popUrl, popName, popWidth, popHeight, feat)
{
	pop_left = 0;
	pop_top = 0;
	scrCenter_x = screen.width/2;
	scrCenter_y = screen.height/2;
	if ((popWidth == "") || (popWidth == undefined)) {
		popWidth = 650;
		popHeight = 550;
		resize = "yes";
	} else {
		resize = "no";
//		alert(popWidth);
	}
	if (feat != '') feat = ','+feat;
	pop_left = scrCenter_x - (popWidth/2);
	pop_top = scrCenter_y - (popHeight/2) - 30;
	popupWin = window.open(popUrl, popName, 'width=' + popWidth + ',height=' + popHeight + ',left=' + pop_left + ',top=' + pop_top + ',resizable='+resize+feat);
	popupWin.focus();
}

function OpenWin(url, targ, feat)
{
	var oWin = window.open(url, targ, feat);
	oWin.focus();
}

function CheckMinQtyOriginal(obj, minQty)
{
	if(obj.value > 0 && obj.value < minQty){
		alert('Minimum quantity should be equal or greater than ' + minQty);
		obj.value=''; 
		return false;
	}
}

function CheckMinQty(obj, divBy, times)
{
	var mod;
	if(IsNumeric(obj.value)) {
		if(obj.value > 0 && obj.value != ""){
			mod = obj.value % divBy;
			
			if(obj.value > (divBy * times)){
				alert('Max order quantity cannot exceed ' + (divBy * times));
				obj.value=''; 
				return false;
			}
			else {
				if(mod > 0) {
					alert('Must be ordered in quantities of ' + divBy);	
					obj.value=''; 
					return false;
				}
				 else {
				 	return true;
				 }
			}
		}
	 }
	 else {
	 	alert("Value must be numeric");
		obj.value=''; 
		return false;
	 }
}






