// JavaScript Document
function output_normal(imgfile, width, height,style) {
	var version = navigator.userAgent;
	if (version.indexOf('Firefox') == -1) {
		var content = '<img src=\"images/blank.gif\" border=\"0\" style=\"'+ style+ 'width: '+ width +'px; height: '+ height +'px; ' + 
		'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + imgfile + '\',sizingMethod=\'scale\')\" />';
		document.write(content);
	}
	else  {
		var content = '<img border=\"0\"  style=\"'+style+'\" src=\"' + imgfile + '\" width=\"'+ width +'\" height=\"'+ height +'\"></div>';
		document.write(content);
	}
}

function fillAddress() {
	document.f1.company2.value = document.f1.company.value;
	document.f1.fname2.value = document.f1.fname.value;
	document.f1.lname2.value = document.f1.lname.value;
	document.f1.address2.value = document.f1.address.value;
	document.f1.city2.value = document.f1.city.value;
	document.f1.prov2.value = document.f1.prov.value;
	document.f1.postal2.value = document.f1.postal.value;
	document.f1.country2.value = document.f1.country.value;	
	document.f1.phone2.value = document.f1.phone.value;
}

function openWindow(url,w,h) {
	popupWin=window.open(url,'remote','width='+w+',height='+h+',top=220,left=250');
}

function checkform(thisform) {
	return_value = true;
	error_message = "";
	var emailRe = /^[^@]+@[^@.]+\.[^@]*\w\w$/;
	with(thisform){
		if (thisform.first_name.value.length == 0) {
			error_message += "Please input first name.\n";
			return_value = false;
		}
		if (thisform.last_name.value.length == 0) {
			error_message += "Please input last name.\n";
			return_value = false;
		}
			
		if ((thisform.email.value.length == 0 || !thisform.email.value.match(emailRe)) && thisform.phone.value.length == 0) {
			error_message += "Please input one of the following email/contact number.\n";
			return_value = false;
		}
	}
	if (return_value == false) {
		alert(error_message);
	}
	return return_value;	
}

function doClearField(theText) {
     if (theText.value == theText.defaultValue) {
         theText.value = "";
	}
}
//<input name="email" style="width:180px" value="Please Enter E-mail" onFocus="doClearField(this)">

function characternumber( e){
	var matchString = new RegExp("[a-zA-Z0-9\-]");
	var unicode=e.charCode? e.charCode : e.keyCode;
	if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
		if(!String.fromCharCode(unicode).match(matchString))
		return false //disable key press
	}
}
/*
<div style="padding-top:20px;padding-left:10px" align="left">
	<form action="result.php" method="GET">
		<b>Search By Name or Item Number:</b><br>
		<input type="text" name="keyword" style="width:120px;height:15px;margin-top:2px;margin-bottom:3px" onkeypress="return characternumber(event)">
		<input type="submit" value="Search">
	</form>
</div>*/

function checkAll(e, itemName){
	var item = document.getElementsByName(itemName);
	for (var i=0; i<item.length; i++)
		item[i].checked = e.checked;
}

function checkItem(e, allName){
	var allItem = document.getElementsByName(allName)[0];
	if(!e.checked)
		allItem.checked = false;
	else {
		var item = document.getElementsByName(e.name);
		for (var i=0; i<item.length; i++)
		if(!item[i].checked)
			return;
		allItem.checked = true;
	}
}
