	
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
	
	
	function DisplayPopup(strPopupUrl,strDivName,strFrameClass,strPopupClass,strCloseClass,strScroll,iX,iY)
	{
		if(strScroll == null)
		{
			strScroll = "no";
		}
		
		oPopupDiv = document.getElementById(strDivName);
		oPopupDiv.style.display = 'block';
		oPopupDiv.className = strPopupClass;
		
		var iLeft = (iX == null) ? screen.width/2-100 : iX;
		var iTop = (iY == null) ? screen.height/2-255: iY;
		
		
		oPopupDiv.style.top = (iTop<0)? "0px" : iTop + "px";
		oPopupDiv.style.left = iLeft;
	
		
		oPopupDiv.innerHTML="<div class=\"" + strCloseClass + "\" width=\"100%\"><a onclick=\"document.getElementById('" + strDivName + "').style.display='none';\">Close</a></div><iframe id=\"popupframe1\"   scrolling=\"" + strScroll + "\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\"></iframe>";
		document.getElementById('popupframe1').className = strFrameClass;
		document.getElementById('popupframe1').src = strPopupUrl;
		//document.getElementById('popupframe1').contentDocument.location.reload(true);
		return true;
		
	}
	
	function DisplayDiv(strDivName,iX,iY)
	{
	
		
		oPopupDiv = document.getElementById(strDivName);
		oPopupDiv.style.display = 'block';
		
		var iLeft = (iX == null) ? screen.width/2-100 : iX;
		var iTop = (iY == null) ? screen.height/2-255: iY;
		
		
		oPopupDiv.style.top = (iTop<0)? "0px" : iTop + "px";
		oPopupDiv.style.left = iLeft;
	
	}


	function DisplayCommentEditor(strTarget,strTitle,bReadonly,strMaxLen)
	{
		oTarget = document.getElementById(strTarget);
		
		var strQString = "target="+strTarget;
		if(strTitle != null)
		{
			strQString += "&title=" + strTitle;
		}
		
		if(bReadonly)
		{
			strQString += "&ro=y";
		}
		
		if(strMaxLen != null)
		{
			strQString += "&ml=" + strMaxLen;
		}
		
		var strDivName = 'divCommentEditor';
		oPopupDiv = document.getElementById(strDivName);
		oPopupDiv.style.display = 'block';
		oPopupDiv.className = 'commentEditorDiv';
		
		var iLeft =  findPosX(oTarget) - 200;
		var iTop = findPosY(oTarget) - 200;
	
		
		
		oPopupDiv.style.top = (iTop<0)? "10px" : iTop + "px";
		oPopupDiv.style.left = (iLeft<0) ? "10px" : iLeft + "px";
		oPopupDiv.innerHTML="<div class=\"commentEditorClose\" width=\"100%\"><a onclick=\"document.getElementById('" + strDivName + "').style.display='none';\">Close</a></div><iframe id=\"popupframe\"  src=\"/direct/comments.aspx?" + strQString + "\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\"></iframe>";
		document.getElementById('popupframe').className = 'commentEditorFrame';
	}
	
	function ShowAvailability(lblPikId,lblSimmId,strTarget)
	{   var iLeft = null;
		var iTop = null;
		
		if(strTarget != null)
		{
			var oTarget = document.getElementById(strTarget);	
			var iLeft =  findPosX(oTarget) - 200;
			var iTop = findPosY(oTarget) - 200;
		}
		
		var pik=document.getElementById(lblPikId).innerHTML;
		var simm=document.getElementById(lblSimmId).innerHTML;
		
	
		
		document.cookie="availPik=" + pik + "; path=/";
		document.cookie="availSimm=" + simm + "; path=/";
		
		DisplayPopup('/direct/Products/Availability.aspx','divPopup','availFrame','availDiv','availClose','no',iLeft,iTop);

		return false;
	}
	
	//jgill 05/16/2008 shows industry pricing information
	function ShowIndustryPricing(strTarget)
	{   var iLeft = null;
		var iTop = null;
		
		if(strTarget != null)
		{
			var oTarget = document.getElementById(strTarget);	
			var iLeft =  findPosX(oTarget) - 200;
			var iTop = findPosY(oTarget) - 200;
		}
				
		DisplayPopup('/direct/Products/IndustryPricing.aspx','divPopup','availFrame','availDiv','availClose','no',iLeft,iTop);

		return false;
	}
	
	//jropar 1/11/2010 Shows details for partial Quote
	function ShowPartialQuoteDetails( strTarget, sQuoteID )
	{   
		var iLeft = null;
		var iTop = null;
		
		if(strTarget != null)
		{
			var oTarget = document.getElementById(strTarget);	
			var iLeft =  findPosX(oTarget) + 10;
			var iTop = findPosY(oTarget) + 10;
		}
		
		DisplayPopup('/direct/Products/PartialQuoteDetail.aspx?QuoteID=' + sQuoteID ,'divQuoteDetail','pqFrame','pqDiv','pqClose','no',iLeft,iTop);

		return false;
	}
	
	function DisplayAddShoppingList(target,strDivName)
	{
		if(strDivName == null)
		{
			strDivName = 'divAddList';
		}
			
		var oDiv = document.getElementById(strDivName);
		oDiv.style.display='block';
		
		var iLeft;
		var iTop;
		if(target == null)
		{
			iLeft =  screen.availWidth/2-100;
			iTop = screen.availHeight/2-255;
		}
		else
		{
			iLeft = findPosX(target) + 100;
			iTop = findPosY(target) - 200;
		}
		
		if(iLeft + 300 > screen.width)
		{
			iLeft = iLeft - 300;
		}
				
		
		oDiv.style.top = (iTop<0)? "0px" : iTop + "px";
		oDiv.style.left = (iLeft<0) ? "10px" : iLeft + "px";
		
	}
	
	/*************Added by PD: Add to Quote********************/
	function DisplayAddToQuote(target,strDivName)
	{
	/*	if(strDivName == null)
		{
			strDivName = 'divAddToQuote';
		}
			
		var oDiv = document.getElementById(strDivName);
		oDiv.style.display='block';
		
		var iLeft;
		var iTop;
		if(target == null)
		{
			iLeft =  screen.availWidth/2-100;
			iTop = screen.availHeight/2-255;
		}
		else
		{
			iLeft = findPosX(target) + 100;
			iTop = findPosY(target) - 200;
		}
		
		if(iLeft + 300 > screen.width)
		{
			iLeft = iLeft - 300;
		}
				
		
		oDiv.style.top = (iTop<0)? "0px" : iTop + "px";
		oDiv.style.left = (iLeft<0) ? "10px" : iLeft + "px";
		*/
var myRand = rand(50000);		
		window.showModalDialog('/direct/products/addToquote.aspx?rand='+myRand, 0, 'dialogwidth:600px;dialogheight:300px;');
	
		
	}
	
	function rnd() {
today=new Date();
jran=today.getTime();

ia=9301;
ic=49297;
im=233280;
jran = (jran*ia+ic) % im;
return jran/(im*1.0);
}

function rand(number) {
return Math.ceil(rnd()*number);
}	
	/**********************************************************/
	
	
	
	
	function DisplayAddNonCatalogItem(target)
	{
		var oDiv = document.getElementById('divAddNonCatalogItem');
		oDiv.style.display='block';
		
			
		var iLeft;
		var iTop;
		if(target == null)
		{
			iLeft =  screen.width/2-100;
			iTop = screen.height/2-255;
		}
		else
		{
			iLeft = findPosX(target) -150;
			iTop = findPosY(target) - 400;
		}
		
		
		oDiv.style.top = (iTop<0)? "10px" : iTop + "px";
		oDiv.style.left = (iLeft<0) ? "10px" : iLeft + "px";
		oDiv.focus();
		
	}
	
	function DisplayConfirmationBox()
	{
		var oDiv = document.getElementById('divConfirm');
		oDiv.style.display='block';
		var iLeft =  screen.width/2-100;
		var iTop = screen.height/2-255;
		
		
		oDiv.style.top = (iTop<0)? "10px" : iTop + "px";
		oDiv.style.left = (iLeft<0) ? "10px" : iLeft + "px";
		
	}
	
	function DisplayControl(strControl,target)
	{
		var oDiv = document.getElementById(strControl);
		oDiv.style.display='block';
		
		
		var iLeft;
		var iTop;
		if(target == null)
		{
			iLeft =  screen.width/2-100;
			iTop = screen.height/2-255;
		}
		else
		{
			iLeft = findPosX(target) -100;
			iTop = findPosY(target) - 200;
		}
		
		
		
		oDiv.style.top = (iTop<0)? "0px" : iTop + "px";
		oDiv.style.left = (iLeft<0) ? "10px" : iLeft + "px";
		
		
		
	}


