// 90927 RKR changed name of popup window for added images to avoid cross-impact on other popups in demos, etc.
// 70827 RKR added top and left windows open parameters in popwin2() to drive IE as well as Mozilla
// 60119 RKR revised popwin(2) and poppix(2)
// 50909 RKR added function winmax()
// 50702 RKR bsearch:  added bnewlayermode=2 to use radio buttons ffoption in srch form 
//           instead of togglelayer fftype select to pick field(s) to search.
//           bsearch(bnewlayermode) set in bsearch.cfm via v.doFieldPick=2 (def, Basics v.FFFieldPick)

function winmax() {
	window.moveTo(0,0);
	window.resizeTo(window.screen.availWidth,window.screen.availHeight);
};

function MM_findObj(n, d) { //v3.0
  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); 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 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_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 retwin(auctid,type,dlink) {
	if (type>0) newurl = "auctions/" + auctid + "/ful_inf.htm"
	else newurl = dlink;
	infoWin=window.open(newurl,"infoWin","height=450,width=620,scrollbars,resizable");
};

function popwin(pg,name,h,w,qstr) {	
	detWin = window.open(pg + "?name=" + escape(name)+"&"+qstr, "detWin", "height="+h+",width="+w+",scrollbars=1,resizable=1,status=0,menubar=0,toolbar=0,location=0");
	detWin.focus();
};

function popwin2(pg,name,h,w,qstr,x,y,scroll) {	
	var args=popwin2.arguments;
	var pscroll = '1';
	if (args.length >7) pscroll = args[7];
	var py = 20;
	if (args.length >6) py=args[6];
	var px = 20;
	if (args.length >5) px=args[5];
	detWin = window.open(pg + "?name=" + escape(name)+"&"+qstr, "detWin", "height="+h+",width="+w+",scrollbars="+pscroll+",left="+px+",top="+py+",screenX="+px+",screenY="+py+",resizable=1,status=0,menubar=0,toolbar=0,location=0");
	//if (window.screen) detWin.moveTo=(px,py);
	detWin.focus();
};


/* function poppix(name,ht,wd,hline,TID) {
	if (name.length > wd/10) pht = ht + 110
	else pht = ht+100; pwd = wd+20;
	if (pwd<200) pwd=200;
	newurl = "pixframe.cfm?name=" + escape(name) + "&ht=" + ht + "&wd=" + wd + "&hline=" + escape(hline) + "&TID=" + TID;
	winspec = "height=" + pht + ",width=" + pwd + ",scrollbars=0,resizable=1,status=0";
	detWin = window.open(newurl, "detWin", winspec);
	detWin.focus();
}; */


// new RKR 40716
function poppix2 (vtid,itemno,TVen) {
	var newurl = 'webSnips/pixframe2.cfm?vtid='+vtid+'&itemno='+itemno;
	if (TVen) newurl=newurl+'&T=T';
	winPix = window.open(newurl,'winPix','height=100,width=300,screenX=50,screenY=50,resizable=1,status=0');
};
var whitespaceonly = " \t\n\r";
function isOnlyWhitespace (s)
{   var i;
    if ((s == null) || (s.length == 0)) return true;
    for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if (whitespaceonly.indexOf(c) == -1) return false;
    };
    return true;
};

function bsearch(aliasskuname, bnewlayermode) {
	var missing_search_term = '';
		if (document.srch.key.value == '' || isOnlyWhitespace(document.srch.key.value)) {
		// sku is present and valid 
		if (aliasskuname != '') {
			missing_search_term = 'SEARCH TERM MISSING\n\nPlease enter either\n\n1) the first letters of a search term to be found, or\n2) a(n)' +aliasskuname+ ', without punctuation, to find an individual item.';
		} else {
 			missing_search_term = 'SEARCH TERM MISSING\n\nPlease enter either\n\n1) the first letters of a search term to be found, or\n2) an ITEM ID#, without punctuation, to find an individual item.';
		};
		alert(missing_search_term);
		return false;
    };  

	// LAYER MODE (new fast find functionality) 
	if 	(bnewlayermode>0) {
		// ffoption radio buttons in form replace togglelayer:  read buttons to fill document.srch.fftype.value
		if (bnewlayermode==2) {
			for (var i = 0; i < document.srch.ffoption.length; i++) {	
				if (document.srch.ffoption[i].checked) {
					document.srch.fftype.value=document.srch.ffoption[i].value;
					break;
				};
			};
		};
		// Test for numeric data for ITEMNO
		if(document.srch.fftype.value == 1) {
			if (isNaN(document.srch.key.value)) {
				alert('SEARCH TERM TYPE MISMATCH\n\nWhen searching for an Item ID #, you may only specify numeric data.');
				return false;
			} 
			else {
				document.srch.SType.value='1';
				return true;
			}
		} 
		// Sku
		else if(document.srch.fftype.value == 4) 
			document.srch.SType.value='7';	
		// Item description
		else if(document.srch.fftype.value == 3) 
			document.srch.SType.value='3';	
		// Product Categories
		else if(document.srch.fftype.value == 2) 
			document.srch.SType.value='2';	
		// Make
		else if(document.srch.fftype.value == 5) 
			document.srch.SType.value='10';	
		// Model
		else if(document.srch.fftype.value == 6) 
			document.srch.SType.value='11';	

	// NON-LAYER MODE (classic fast find functionality)
	} else {	
	
		// Test for numeric entries 
		if (!isNaN(document.srch.key.value)) {
			if (aliasskuname != '') {
				document.srch.SType.value='1,7,2,3';
			} else {
				document.srch.SType.value='1,2,3';
			};
		
		} else {
			if (aliasskuname != '') {
				document.srch.SType.value='7,2,3';
			} else {
				document.srch.SType.value='2,3';
			};
		 }
			
    }
	return true;
}; 

function DataInput() {
	var selindex = document.SearchForm.TemplateVenue.selectedIndex;
	document.SearchForm.TemplateVenueText.value =  document.SearchForm.TemplateVenue.options[selindex].text;
}


function DspImages(itemno) {
	addimgWin = window.open("DspImages.cfm?itemno="+itemno, "addimgWin", "width=500,height=400,scrollbars=yes,resizable,screenX=20,screenY=20");
	detWin.focus();
};

