// Copyright Channel Intelligence, Inc. 2003-2005 - Patent Pending
function cii_CBL_DataService_API_version(){return '1.10';}
function cii_ShowLowestPrice(rsSKU,rsPre,rsPost){
	if(oCIICBLDataObject[rsSKU.toUpperCase()]&&oCIICBLDataObject[rsSKU.toUpperCase()].instockCount&&oCIICBLDataObject[rsSKU.toUpperCase()].instockCount > 0){
		if(!rsPre){rsPre='';}else{rsPre+=' ';}
		if(!rsPost){rsPost='';}else{rsPost=' '+rsPost;}
		document.write(rsPre+oCIICBLDataObject[rsSKU.toUpperCase()].lowestInstockPrice+rsPost);
	}
}
function cii_ShowLowestInstockPrice(rsSKU,rsPre,rsPost){
	if(oCIICBLDataObject[rsSKU.toUpperCase()]&&oCIICBLDataObject[rsSKU.toUpperCase()].dealerCount&&oCIICBLDataObject[rsSKU.toUpperCase()].dealerCount > 0){
		if(!rsPre){rsPre='';}else{rsPre+=' ';}
		if(!rsPost){rsPost='';}else{rsPost=' '+rsPost;}
		document.write(rsPre+oCIICBLDataObject[rsSKU.toUpperCase()].lowestPrice+rsPost);
	}
}
function cii_ShowCBLButton(rsSKU,roPrime,roAlt,rnInst,rnRGID,rsLID){
	var bOutputLink=true;
	var oLink;
	var aOut=new Array();
	if(!rsSKU){return;}
	if(!rnRGID){rnRGID=-1;}
	if(!rsLID){rsLID='';}
	if(!oCIICBLDataObject[rsSKU.toUpperCase()]||!oCIICBLDataObject[rsSKU.toUpperCase()].dealerCount){return;}
	if(oCIICBLDataObject[rsSKU.toUpperCase()].dealerCount>0&&roPrime){
		oLink=roPrime;
	}else if(oCIICBLDataObject[rsSKU.toUpperCase()].dealerCount<=0&&roAlt){
		oLink=roAlt;
	}else{
		return;
	}
	if(oLink["linkurl"]&&oLink["linkurl"]!=''){
		aOut[aOut.length]='<a href="'+ciiPlcHldr(oLink["linkurl"],rsSKU,rnInst,rnRGID,rsLID)+'">';
	}else if(oLink["customlinkurl"]&&oLink["customlinkurl"]!=''){
		aOut[aOut.length]=ciiPlcHldr(oLink["customlinkurl"],rsSKU,rnInst,rnRGID,rsLID);
	}else if(oCIICBLDataObject[rsSKU.toUpperCase()].dealerCount>0){
		if(rnRGID>0){
			aOut[aOut.length]='<a href="JavaScript:manu_CDRuleGroupLink(\x27olympus\x27,\x27'+rsSKU+'\x27,\x27'+rnRGID+'\x27,null,null,null,\x27'+rsLID+'\x27)">';
		}else{
			aOut[aOut.length]='<a href="JavaScript:manu_CDLink(\x27olympus\x27,\x27'+rsSKU+'\x27,null,null,null,\x27'+rsLID+'\x27)">';
		}
	}else{
		bOutputLink=false;
	}
	if(oLink["imageurl"]&&oLink["imageurl"]!=''){
		aOut[aOut.length]='<img src="'+oLink["imageurl"]+'" border="0"';
		oImage=new Image();
		oImage.src=oLink["imageurl"];
		if(oImage.width&&oImage.width>1&&oImage.height&&oImage.height>1){aOut[aOut.length]=' height="'+oImage.height+'" width="'+oImage.width+'"';}
		if(oLink["onmouseover"]&&oLink["onmouseover"]!=''){aOut[aOut.length]=' onMouseOver="'+oLink["onmouseover"]+'"';}
		if(oLink["onmouseout"]&&oLink["onmouseout"]!=''){aOut[aOut.length]=' onMouseOut="'+oLink["onmouseout"]+'"';}
		aOut[aOut.length]=' alt="'+oLink["alt"]+'" />';
	}else if(oLink["customimagehtml"]&&oLink["customimagehtml"]!=''){
		aOut[aOut.length]=ciiPlcHldr(oLink["customimagehtml"],rsSKU,rnInst,rnRGID,rsLID);
	}else if(oLink["linktext"]){
		aOut[aOut.length]=ciiPlcHldr(oLink["linktext"],rsSKU,rnInst,rnRGID,rsLID);
	}
	if(bOutputLink){aOut[aOut.length]='</a>';}
	document.write(aOut.join(''));
}
function ciiReplace(rsStr,rsOStr,rsNStr){
	var nLen=rsStr.length;
	var nOLen=rsOStr.length;
	var nPos=rsStr.indexOf(rsOStr);
	if((nLen==0)||(nOLen==0)) return rsStr;
	if((!nPos)&&(rsOStr!=rsStr.substring(0,nOLen))) return rsStr;
	if(nPos==-1) return rsStr;
	var sStr=rsStr.substring(0,nPos)+rsNStr;
	if(nPos+nOLen<nLen){sStr+=cii_StrRep(rsStr.substring(nPos+nOLen,nLen),rsOStr,rsNStr);}
	return sStr;
}
function ciiPlcHldr(rsStr,rsSKU,rnInst,rnRGID,rsLID){
	if(!rsStr){rsStr='';}
	if(!rsSKU){rsSKU='';}
	if(!rnInst){rnInst=1;}
	if(!rnRGID){rnRGID='';}
	if(!rsLID){rsLID='';}
	rsStr=ciiReplace(rsStr,"<sku />",rsSKU);
	rsStr=ciiReplace(rsStr,"<sku/>",rsSKU);
	rsStr=ciiReplace(rsStr,"<sku>",rsSKU);
	rsStr=ciiReplace(rsStr,"<instance>",rnInst);
	rsStr=ciiReplace(rsStr,"<instance/>",rnInst);
	rsStr=ciiReplace(rsStr,"<instance />",rnInst);
	rsStr=ciiReplace(rsStr,"<rgid>",rnRGID);
	rsStr=ciiReplace(rsStr,"<rgid/>",rnRGID);
	rsStr=ciiReplace(rsStr,"<rgid />",rnRGID);
	rsStr=ciiReplace(rsStr,"<linkid>",rsLID);
	rsStr=ciiReplace(rsStr,"<linkid/>",rsLID);
	rsStr=ciiReplace(rsStr,"<linkid />",rsLID);
	return rsStr;
}