// JavaScript Document
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;

function preloadImages() {
	if (document.images) {
		menu_projectors_over = newImage("interface/menu_projectors_hover.gif");
		menu_packages_over = newImage("interface/menu_packages_hover.gif");
		menu_screens_over = newImage("interface/menu_screens_hover.gif");
		menu_mounts_over = newImage("interface/menu_mounts_hover.gif");
		menu_cables_over = newImage("interface/menu_cables_hover.gif");
		menu_audio_over = newImage("interface/menu_audio_hover.gif");
		menu_refurbished_over = newImage("interface/menu_refurbished_hover.gif");
		preloadFlag = true;
	}
}

function SearchEnabled(thisForm)
{
	return (thisForm.keyword.value.length > 0);
}

var dom = document.getElementById ? true : false;
var all = document.all ? true : false;

function GetField(fieldID)
{
	if (dom || all)
	{
		return document.getElementById(fieldID);
	}
	return null;
}

function BeginSearch(thisForm)
{
	if (thisForm.value == "Product search")
		thisForm.value = "";
}
function ValidateSearch(thisForm)
{
	if ((thisForm.keyword.value == "") || (thisForm.keyword.value == "Product search"))
	{
		window.alert("Invalid keyword");
		thisForm.keyword.focus();
		return false;
	}
	return true;
}
function PopupPic(sPicURL) { 
     window.open("utils/popup.html?"+sPicURL, "","resizable=1,HEIGHT=200,WIDTH=200"); 
} 
function displayWindow(theURL,winName,width,height,features) {
    var window_width = width;
    var window_height = height;
    var newfeatures = features;
    var window_top = (screen.height-window_height)/2;
    var window_left = (screen.width-window_width)/2;
    newWindow=window.open(''+ theURL + '',''+ winName + '','width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',' + newfeatures + '');
    newWindow.focus();
}


function ViewOrder(orderID){
	displayWindow('order.cfm?recID=' + orderID, 'order' + orderID, 760, 600, "scrollbars=yes,resizable=yes");
}

function ViewQuote(orderID){
	displayWindow('quote.cfm?recID=' + orderID, 'quote' + orderID, 760, 600, "scrollbars=yes,resizable=yes");
}

function ChangePwd(){
	displayWindow('account_pwd.cfm', 'changepwd', 460, 400, "scrollbars=yes,resizable=yes");
}

function ForgotPassword(){
	displayWindow('password.cfm', 'changepwd', 460, 400, "scrollbars=yes,resizable=yes");
}


function TermsAndConditions(){
	displayWindow('termsandconditions.cfm', 'terms', 660, 520, "scrollbars=yes,resizable=yes");
}

function Disclaimer(){
	displayWindow('disclaimer.cfm', 'terms', 660, 520, "scrollbars=yes,resizable=yes");
}

function Quote(recID){
	displayWindow('quote.cfm?pid=' + recID, 'quote',460,500, "scrollbars=yes,resizable=yes");
}

function ShowPrice(recID){
	displayWindow('showprice.cfm?id=' + recID, 'showprice',460,500, "scrollbars=yes,resizable=yes");
}

function PrintCart(){
	displayWindow('print_cart.cfm', 'print_cart',760,400, "scrollbars=yes,resizable=yes");
}

function EmailCart(){
	displayWindow('email_cart.cfm', 'email_cart',760,400, "scrollbars=yes,resizable=yes");
}

function next(thisField, maxLength, target)
{
	if (thisField.value.length == maxLength)
	{
		var obj = GetField(target);
		if(obj) obj.focus();
	}
}

function CheckPwd(f, addRegister)
{
	if (f.EmailAddress.value.length < 5)
	{
		window.alert("Enter your email address!");
		return false;
	}
	if (f.Password.value.length < 6)
	{
		window.alert("The password must be at lest 6 characters long!");
		return false;
	}
	
	if(addRegister)
	{
		if(f.register.checked)
		{
			if (f.Password.value != f.confPassword.value)
			{
				window.alert("The passwords do not match!");
				return false;
			}
		}
	}
	return true;
}

function CheckPwds(f)
{

	if (f.Password.value.length < 6)
	{
		window.alert("The password must be at lest 6 characters long!");
		return false;
	}
	
	if (f.Password.value != f.confPassword.value)
	{
		window.alert("The passwords do not match!");
		return false;
	}

	return true;
}


function CheckLogin(f)
{
	if (f.EmailAddress.value.length < 5)
	{
		window.alert("Enter your email address!");
		return false;
	}
	
	if (f.Password.value.length < 6)
	{
		window.alert("The password must be at lest 6 characters long!");
		return false;
	}
	if (f.Password.value != f.confPassword.value)
	{
		window.alert("The passwords do not match!");
		return false;
	}
	else return true;
}


function CopyFields(thisform)
{
var thisform = document.forms.register;
if(thisform.UseBAForShippingFlag.checked == true)
	{
	
	thisform.ShpCompanyName.value = thisform.CompanyName.value;
	thisform.ShpFirstName.value = thisform.FirstName.value;
	thisform.ShpMiddleInitial.value = thisform.MiddleInitial.value;
	thisform.ShpLastName.value = thisform.LastName.value;
	thisform.ShpStateCode.value = thisform.StateCode.value;
	thisform.ShpStreetAddress.value = thisform.StreetAddress.value;
	thisform.ShpStreetAddress2.value = thisform.StreetAddress2.value;
	thisform.ShpCity.value = thisform.City.value;
	thisform.ShpZip.value = thisform.Zip.value;
	thisform.ShpPhone.value = thisform.Phone.value;
	thisform.ShpFax.value = thisform.Fax.value;
	thisform.ShpPhone0.value = thisform.Phone0.value;
	thisform.ShpPhone1.value = thisform.Phone1.value;
	thisform.ShpPhone2.value = thisform.Phone2.value;
	}
}
function ResetPRCode()
{
	var thisform = document.forms.register;
	if (thisform.ponumber.value == "Purchase order #")
		thisform.ponumber.value = "";
}

function showHide(chk, blockId){
	if (chk.checked != null){
		if (chk.checked){
			document.getElementById(blockId).className =  'show';
		}
		else{
			document.getElementById(blockId).className =  'hide';
		}
	}
		else{
			if (document.getElementById(blockId).className ==  'show'){
				document.getElementById(blockId).className = 'hide';
			}
				else{
					document.getElementById(blockId).className = 'show';					
				}
		}

	return;
}

function DisplayPage(page)
{
	document.searchproducts.pg.value = page;
	document.searchproducts.submit();
}
function ReloadPage()
{
	document.searchproducts.submit();
}
function ShowEpsonLink(url){
	displayWindow(url, 'epsonLink',760,400, "scrollbars=yes,resizable=yes");
}
