autoJoinRan = false;
/**
  Function to submit the form values required by the 
  auction applet.
*/
function submitToApplet(type, rowId) 
{ 
	var	rowParams = joinSaleParams.get(rowId),
    		formName = rowParams.get("formName"),
   			rowIndex = rowParams.get("rowIndex"),
  			repeatCount = rowParams.get("repeatCount"),
   			nonBuyer = rowParams.get("nonBuyer"),
   			yardNum = rowParams.get("yardNum"),
   			yardName = rowParams.get("yardName"),
   			lane = rowParams.get("lane"),
   			boarFlag = rowParams.get("boarFlag"),
   			domainName = rowParams.get("domainName"),
   			serverName = rowParams.get("serverName"),
   			jarQ = rowParams.get("jarQ"),
   			jarF = rowParams.get("jarF"),
        	appwindowName = "AppletWindow" + type + rowIndex;
    //Set the form target to open in the new window.
    $(formName).target = "AppletWindow" + type + rowIndex;
  
    //Set the common field values.
    $(formName).repeat.value = repeatCount;
    $(formName).nonBuyer.value = nonBuyer;
    $(formName).yardNum.value = yardNum;
    $(formName).yardName.value = yardName;
    $(formName).lane.value = lane;
    $(formName).boarFlag.value = boarFlag;
    $(formName).host.value = domainName;
    $(formName).buyerFinalBidsURL.value = 'http://'+serverName+'/cgi-bin/buyer/bid/final.dtw/disp' ;
    $(formName).minBidURL.value = 'http://' + serverName +'/cgi-bin/buyer/bid/virtual/minbid.dtw/disp?lot=';
    $(formName).buyerHomeURL.value = 'http://' + serverName + '/cgi-bin/buyer/index.dtw/fetch">';
	var actionURL =  'http://'+ domainName + '/cgi-bin/public/virtual/bid.dtw/disp';
	if (type == 'Q')
	{
			$(formName).jar.value = jarQ;
			$(formName).codebase.value = "com.copart.vb2.applets.buyer.LiteBuyerApplet.class";
			$(formName).height.value = "315";
			$(formName).width.value = "380";
			options = 'resizable=no,scrollbars=no,width=385,height=315,screenX=0,screenY=0,status=yes';
	}
	else {
		$(formName).jar.value = jarF;
		$(formName).codebase.value = "com.copart.vb2.applets.buyer.BuyerApplet.class";
		$(formName).height.value = "540";
		$(formName).width.value = "705";
		options = 'resizable=no,scrollbars=no,width=713,height=550,screenX=0,screenY=0,status=yes';
	}
	
	//Open the popup window.
	popUpWindow = window.open('http://www.copart.com/loading.htm',appwindowName,options);
	
	//Set the form action and submit.
	$(formName).action = 'http://'+ domainName + '/cgi-bin/public/virtual/bid.dtw/disp';
	$(formName).submit();
}

function popupWin(path,winWidth,winHeight,scrollBar,resizable){
	if (winWidth==null||winWidth=="") winWidth=400;
	if (winHeight==null||winHeight=="") winHeight=300;
	if (scrollBar==null||scrollBar=="") scrollBar='yes';
	if (resizable==null||resizable=="") resizable='yes';
	var window_handler="";
   	var options="";
	options='width='+winWidth+', height='+winHeight+', scrollbars='+scrollBar+', resizable='+resizable;
	if (typeof(window_handler) == "object" && !window_handler.closed ) {
		window_handler.close();
	}
   window_handler=window.open(path,'window_handler',options);
   window_handler.focus();
}

/**
 *  Makes an AJAX call to auto refresh the virtual sales page.
 *	This function refreshes the page every (minutes) value.
 */
function autoRefreshPage()
{
    window.location.href=window.location;;
}
setTimeout("autoRefreshPage()", 900000); 

function autoJoin(yard, lane ,type)
{
	if (yard != "" && !autoJoinRan) 
	{
		autoJoinRan = true;
		var 	ajRow = yard+lane,
				rowParams = joinSaleParams.get(ajRow);
		if( type != 'F'  &&  type !='Q' ) { type='F'; }
		if (typeof rowParams !== 'undefined' && rowParams.get("domainName") != '')
		{
			//$(ajRow).setAttribute("class", "highlightSale");
			$(ajRow).className='highlightSale';
			$(ajRow).scrollIntoView(true);
			submitToApplet(type, ajRow);
       }
  }
}