var objectArray = new Array;
var activeObject='none';
var gmapArray = new Array;
var activeGmap='none';

/* Create Timestamp for localConnection connection */
var timestamp = new Date();
var flashWidth=533;
var flashHeight=364;
var ovmap;
var marker_count=0;
var smallPanoLoad=0;
var smallPanoLoaded=false;
var home="";
var fov="";
var tilt="";
var pan="";
var pt_code1=pt_code2=qt_code1=qt_code2='';
var loading='<div id="loading"><div id="loading-img"></div></div>';

Array.prototype.removeDuplicates = function () {
	var arr = new Array;
	for(var i = 0; i < this.length; i++){
		if (arr[this[i][0]]){this.splice(i,1);i--;}
		else arr[this[i][0]]=1;
	}
}

Array.prototype.empty = function () {
	for(i = 0; i <= this.length; i++){
		this.shift();
	}
}

if (!(!document.getElementsByTagName || !document.getElementById)) {
	document.write(panoStyles());
}

function panoStyles() {
  var cssText = "";
  cssText += "<style type=\"text/css\">\n";
  cssText += ".panoramaInStyle .nojs { display:none }\n";
  cssText += "</style>\n";
  return cssText;
}

function initDoc() {
	if (!(!document.getElementsByTagName || !document.getElementById)) {
		var anchors = document.getElementsByTagName('a');
		// loop through all anchor tags
		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];
			var relAttribute = String(anchor.getAttribute('rel'));
			if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('objbox'))){
				anchor.onclick = function () {panoUpdate(this); return false;}
				objectArray.push(new Array(anchor.getAttribute('href').substr(anchor.getAttribute('href').indexOf('#')+1), anchor.getAttribute('title')));
			}
			if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('gmapbox'))){
				anchor.onclick = function () {panoUpdate(this); return false;}
				gmapArray.push(new Array(anchor.getAttribute('href').substr(anchor.getAttribute('href').indexOf('#')+1), anchor.getAttribute('title')));
			}
		}
		var anchors = document.getElementsByTagName('area');
		// loop through all anchor tags
		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];
			var relAttribute = String(anchor.getAttribute('rel'));
			if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('objbox'))){
				anchor.onclick = function () {panoUpdate(this); return false;}
				objectArray.push(new Array(anchor.getAttribute('href').substr(anchor.getAttribute('href').indexOf('#')+1), anchor.getAttribute('title')));
			}
			if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('gmapbox'))){
				anchor.onclick = function () {panoUpdate(this); return false;}
				gmapArray.push(new Array(anchor.getAttribute('href').substr(anchor.getAttribute('href').indexOf('#')+1), anchor.getAttribute('title')));
			}
		}
	}
}

function panoUpdate(nestedLink) {
	objectNum = -1;
	gmapNum = -1;

	if (!document.getElementsByTagName){ return; }

	var lnktype = nestedLink.getAttribute('rel');
	// if image is NOT part of a set..
	if((lnktype == 'objbox')){
		// add single object to imageArray
		objectNum++;
		objectArray.push(new Array(nestedLink.getAttribute('href'), nestedLink.getAttribute('title')));			
	} else if((lnktype == 'gmapbox')){
		// add single map to imageArray
		gmapNum++;
		gmapArray.push(new Array(nestedLink.getAttribute('href'), nestedLink.getAttribute('title')));			
	} else {
	// if image is part of a set..
		// loop through anchors, find other images in set, and add them to imageArray

		nested = nestedLink.getAttribute('href');
		node = nested.substr(nested.indexOf('#')+1);

		if (lnktype.indexOf('objbox') != -1){
			objectArray.removeDuplicates();
			objectNum++;
			while(objectArray[objectNum][0] != node) { objectNum++;}
		}
		else if (lnktype.indexOf('gmapbox') != -1){
			gmapArray.removeDuplicates();
			gmapNum++;
			while(gmapArray[gmapNum][0] != node) { gmapNum++;}
		}
	}
	if (objectNum>=0) {
		activeObject = objectNum;	// update global var
		var panoForLoad=objectArray[objectNum][0];
		changePano(panoForLoad,'panorama-viewer');
	}	
	else if (gmapNum>=0) {
		changeGmap(gmapNum,'panorama-viewer');
	}
}

function insertPano() {
	var divs = document.getElementsByTagName('div');
	for (i = 0; div = divs[i]; i++) {
		if (div && hasClass(div, 'panoramaInStyle')) {
			div.innerHTML=loading;
			var QTclass = div.className.match(/quicktime\(([^\)]*)\)/);
			var qtURL = (QTclass!=null)?QTclass[1]:'';
			var PTclass = div.className.match(/ptviewer\(([^\)]*)\)/);
			var ptURL = (PTclass!=null)?PTclass[1]:'';
			var FLclass = div.className.match(/pano2qtvr\(([^\)]*)\)/);
			var flURL = (FLclass!=null)?FLclass[1]:'';
			var FLVRclass = div.className.match(/flashvr\(([^\)]*)\)/);
			var flvrURL = (FLVRclass!=null)?FLVRclass[1]:'';
			if (document.all && navigator.userAgent.indexOf("Macintosh")>=0)
				var ptURL,flURL,flvrURL='';
			var content='', tw=document.writeln; 
			document.writeln=function(txt){content+=txt+"\n"};
			writevrcode(qtURL,ptURL,flURL,flvrURL,flashWidth,flashHeight);
		    document.writeln('<div id="panorama-data">');
		    document.writeln('<a id="FSLink" href="#">'+openFSHTML()+'</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a id="GmapLink" href="#">'+openGmapHTML()+'</a>');
		    document.writeln('</div>');
			document.writeln=tw;
//			alert(content);
			div.innerHTML=content;
			document.getElementById('FSLink').onclick = function() {
				soSmallCont=false; smallPanoLoad=flvrURL; stopPano(); openFS(flvrURL); return false;
			}
			document.getElementById('GmapLink').onclick = function() {
				soSmallCont=false; smallPanoLoad=flvrURL; changeGmap(0,'panorama-viewer'); return false;
			}
			if (flvrURL) smallPanoLoaded=true;
			return smallPanoLoaded;
		}
	}
}

function changePano(n,o) {
//	if ((typeof smallPanoLoaded!="undefined") && !smallPanoLoaded) {
		$(o).style.backgroundColor="#fff";
		$(o).innerHTML=loading;
		var content='', tw=document.writeln; 
	    document.writeln=function(txt){content+=txt+"\n"};
		nr=sprintf('%04d',n);
	    writevrcode("http://www.fellini.ee/pano/"+nr+"/"+nr+"s.mov",n,"http://www.fellini.ee/pano/"+nr+"/"+nr+"s.swf",n,flashWidth,flashHeight);
    	document.writeln('<div id="panorama-data">');
	    document.writeln('<a id="FSLink" href="#">'+openFSHTML()+'</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a id="GmapLink" href="#">'+openGmapHTML()+'</a>');
    	document.writeln('</div>');
	    document.writeln=tw;
//  alert(content);
//	document.all('code').value =content;
		$(o).innerHTML=content;
		smallPanoLoaded=true;
		document.getElementById('FSLink').onclick = function() {
			soSmallCont=false; smallPanoLoad=n; stopPano(); openFS(n); return false;
		}
		document.getElementById('GmapLink').onclick = function() {
			soSmallCont=false; smallPanoLoad=n; changeGmap(activeObject,'panorama-viewer'); return false;
		}
//	}
}

function stopPano() {
	if((typeof smallPanoLoaded!="undefined") && smallPanoLoaded) {
		cleanupObjects();
		var o = document.getElementById('panorama-viewer');
      	if (o) o.innerHTML = continueHTML();
		smallPanoLoaded=false;
	}
}

function changeGmap(gmapNum,o) {
	if (GBrowserIsCompatible()) { 
		activeGmap = gmapNum;	// update global var
		var gmapForLoad=gmapArray[gmapNum][0];
		var gmapCaption=gmapArray[gmapNum][1];
		writeGmap(gmapForLoad,gmapNum,gmapCaption,o);
	} else {
		alert("Sorry, the Google Maps API is not compatible with this browser");
		return;
    }
}

function writeGmap(n,on,c,o) {
	if (GBrowserIsCompatible()) { 
		$(o).innerHTML=loading;
		useLatitude=latitude[n];
		useLongitude=longitude[n];
		LatDMS = toDMS(useLatitude, 'S', 'N');
		LongDMS = toDMS(useLongitude, 'W', 'E');
		PSLinkText=openPSHTML();
		FSLinkText=openFSHTML();

		var map = new GMap2($(o));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(useLatitude,useLongitude),17,G_SATELLITE_MAP);

		var point = new GLatLng(useLatitude,useLongitude);
		var marker = createMarker0(point,"blue",'<strong>'+c+'</strong><br>Location: '+LatDMS+', '+LongDMS+'<br><ul><li><a href="#" onClick="changePano('+n+',\'panorama-viewer\'); return false;"><strong>'+PSLinkText+'</strong></a></li><li><a href="#" onClick="soSmallCont=false; openFS('+n+'); return false;"><strong>'+FSLinkText+'</strong></a></li></ul><br><br>');
		map.addOverlay(marker);
		GEvent.trigger(marker,'click'); 

	} else {
		alert("Sorry, the Google Maps API is not compatible with this browser");
    }
}

function setMap(vl){
	if(changeDMS(vl))return;
	map.setCenter(new GLatLng(document.getElementById('latitude').value,document.getElementById('longitude').value),13);
	addPanoMarker(document.getElementById('longitude').value,document.getElementById('latitude').value);
}

function changeDMS(vl){
	var newLat =0, newLong=0;
	if (vl){
		if(document.getElementById('latitude').value)newLat = document.getElementById('latitudeDMS').value = toDMS(document.getElementById('latitude').value, 'S', 'N');
		if(document.getElementById('longitude').value)newLong = document.getElementById('longitudeDMS').value = toDMS(document.getElementById('longitude').value, 'W', 'E');
	} else {
		if(document.getElementById('latitudeDMS').value)newLat = document.getElementById('latitude').value = toDD(document.getElementById('latitudeDMS').value);
		if(document.getElementById('longitudeDMS').value)newLong = document.getElementById('longitude').value = toDD(document.getElementById('longitudeDMS').value);
	}
	if(!newLat || !newLong)return 1;
	return 0;
}

function toDMS(ns, tp1, tp2) { 
	ch = 0;
	if (ns < 0){
		ns = ns*-1;
		ch = 1;
	}
	ns=parseFloat(ns);
	dd=ns;
	deg=Math.floor(dd);
	dd=dd-deg;
	min=Math.floor(dd/(1/60));
	av=dd-min/60;
	sec=Math.floor(av/(1/3600));
	if(sec==60){min++; sec=0};
	if(min==60){deg++; min=0};
	return deg + unescape("%B0") + min + "'" + sec + "\"" + (ch?tp1:tp2); 
} 

function toDD(ns) { 
	var d1 = ns.indexOf(unescape("%B0")), m1 = ns.indexOf(unescape("'")), s1 = ns.indexOf(unescape("\""));
	var deg = ns.substring(0, d1), min = ns.substring(d1+1, m1), sec = ns.substring(m1+1, s1), tp = ns.substring(s1+1);
	ns = deg;
	ns = parseFloat(ns);
	if(ns=="")ns="0";
	ns=parseInt(ns);
	deg=ns;

	ns = min;
	if(ns=="")ns="0";
	ns = parseFloat(ns);
	ns=parseInt(ns);
	min=ns;

	ns = sec;
	if(ns=="")ns="0"
	ns = parseFloat(ns);
	ns=parseInt(ns);
	sec=ns;
	av = deg + min / 60 + sec / 3600;
	if(tp == 'S' || tp == 'W')av = av*-1;
	return av;
} 

function createMarker0(point,color,html) {
	var f = new GIcon();
	f.image = "http://labs.google.com/ridefinder/images/mm_20_" + color
	         + ".png";
	f.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
	f.iconSize = new GSize(12,20);
	f.shadowSize = new GSize(22,20);
	f.iconAnchor = new GPoint(6,20);
	f.infoWindowAnchor = new GPoint(6,1);
	f.infoShadowAnchor = new GPoint(13,13);

	var marker = new GMarker(point,
    {icon: f,
     draggable: false});
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(html);
	});
	return marker;
}

function createMarker(point, color) {
  var f = new GIcon();
  f.image = "http://labs.google.com/ridefinder/images/mm_20_" + color
            + ".png";
  f.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
  f.iconSize = new GSize(12,20);
  f.shadowSize = new GSize(22,20);
  f.iconAnchor = new GPoint(6,20);
  f.infoWindowAnchor = new GPoint(6,1);
  f.infoShadowAnchor = new GPoint(13,13);

  newMarker = new GMarker(point,
    {icon: f,
     draggable: true});

  return newMarker;
}

function currentMapTypeNumber(map){
  var type=-1;
  for(var ix=0;ix<map.getMapTypes().length;ix++){
    if(map.getMapTypes()[ix]==map.getCurrentMapType())
      type=ix;
  }
  return type;
} 

function addPanoMarker(lng,lat) {

	// The point we are adding the marker to
	point = new GLatLng(lat,lng);
	// if we already have a marker
	if (marker_count > 0) {
		map.clearOverlays();
	}
	marker = createMarker(point, "green");
	current_marker = map.addOverlay(marker);
	marker_count++;
	document.getElementById('latitude').value = lat;
	document.getElementById('longitude').value = lng;
	GEvent.addListener(marker, "drag", function() {
		document.getElementById('latitude').value = marker.getPoint().y;
		document.getElementById('longitude').value = marker.getPoint().x;
		changeDMS(1);
	});
}

function removePanoMarker(overlay) {
	map.removeOverlay(overlay);
	marker_count--;
	document.getElementById('latitude').value = '';
	document.getElementById('longitude').value = '';
}

/* DOM functions */

function addEvent(elm, evType, fn, useCapture)
// cross-browser event handling for IE5+, NS6+ and Mozilla/Gecko
// By Scott Andrew
{
	if (elm.addEventListener) {
	  elm.addEventListener(evType, fn, useCapture); 
	  return true; 
	} else if (elm.attachEvent) {
	  var r = elm.attachEvent('on' + evType, fn); 
	  return r; 
	} else {
	  elm['on' + evType] = fn;
	}
}

// climb up the tree to the supplied tag.
function ascendDOM(e, target) {
  while (e.nodeName.toLowerCase() != target && 
      e.nodeName.toLowerCase() != 'html')
    e = e.parentNode;
  
  return (e.nodeName.toLowerCase() == 'html') ? null : e;
}

function sprintf()
{
   if (!arguments || arguments.length < 1 || !RegExp)
   {
      return;
   }
   var str = arguments[0];
   var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;
   var a = b = [], numSubstitutions = 0, numMatches = 0;
   while (a = re.exec(str))
   {
      var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
      var pPrecision = a[5], pType = a[6], rightPart = a[7];

      numMatches++;
      if (pType == '%')
      {
         subst = '%';
      }
      else
      {
         numSubstitutions++;
         if (numSubstitutions >= arguments.length)
         {
            alert('Error! Not enough function arguments (' + (arguments.length - 1)
               + ', excluding the string)\n'
               + 'for the number of substitution parameters in string ('
               + numSubstitutions + ' so far).');
         }
         var param = arguments[numSubstitutions];
         var pad = '';
                if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1);
           else if (pPad) pad = pPad;
         var justifyRight = true;
                if (pJustify && pJustify === "-") justifyRight = false;
         var minLength = -1;
                if (pMinLength) minLength = parseInt(pMinLength);
         var precision = -1;
                if (pPrecision && pType == 'f')
                   precision = parseInt(pPrecision.substring(1));
         var subst = param;
         switch (pType)
         {
         case 'b':
            subst = parseInt(param).toString(2);
            break;
         case 'c':
            subst = String.fromCharCode(parseInt(param));
            break;
         case 'd':
            subst = parseInt(param) ? parseInt(param) : 0;
            break;
         case 'u':
            subst = Math.abs(param);
            break;
         case 'f':
            subst = (precision > -1)
             ? Math.round(parseFloat(param) * Math.pow(10, precision))
              / Math.pow(10, precision)
             : parseFloat(param);
            break;
         case 'o':
            subst = parseInt(param).toString(8);
            break;
         case 's':
            subst = param;
            break;
         case 'x':
            subst = ('' + parseInt(param).toString(16)).toLowerCase();
            break;
         case 'X':
            subst = ('' + parseInt(param).toString(16)).toUpperCase();
            break;
         }
         var padLeft = minLength - subst.toString().length;
         if (padLeft > 0)
         {
            var arrTmp = new Array(padLeft+1);
            var padding = arrTmp.join(pad?pad:" ");
         }
         else
         {
            var padding = "";
         }
      }
      str = leftpart + padding + subst + rightPart;
   }
   return str;
}

function hasClass(node, className) {
  if (node.className == className) return true;
  var reg = new RegExp('(^| )'+ className +'($| )')
  if (reg.test(node.className)) return true;
  return false;
}

function cleanupObjects() {
	if (window.opera || !document.all) {
		var embeds=document.getElementsByTagName("EMBED");
		for (var i=0; i < embeds.length; i++) embeds[i].style.display="none";
		return;
	}
	var objects = document.getElementsByTagName("OBJECT");
	for (var i=0; i < objects.length; i++) {
		objects[i].style.display = 'none';
		for (var x in objects[i]) {
			if (typeof objects[i][x] == 'function') {
				objects[i][x] = function(){};
			}
		}
	}
}

function loadFS(n){
	document.location='/show/?id='+n;
}

function openFS(n){
	// if SmallFlashVR was used
	smallPanoLoad=n;
	stopPano();
	var w = screen.width ? screen.width : 800;
	var h = screen.height ? screen.height : 550;
	openWindow('/show/?id='+n,w,h,'panowin',false);
}	

function checkBrowser()
{
	this.ver = navigator.appVersion;
	this.dom = document.getElementById?1:0;
	this.ua = navigator.userAgent.toLowerCase();	
	this.opera= this.ua.indexOf("opera")>-1;	// before ns or ie
	this.ie6 = (this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
	this.ie55 = (this.ver.indexOf("MSIE 5.5")>-1 && this.dom)?1:0;
	this.ie5 = (this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4 = (document.all && !this.dom)?1:0;
	this.ns5 = (this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4 = (document.layers)?1:0;
	this.bw  = (this.ie5 || this.ie4 || this.ns4 || this.ns5 || this.ie55);
	this.os  = (this.ver.indexOf("Macintosh")>-1)? "mac":"pc";
	this.ie  = (this.ie5 || this.ie4 || this.ie55 || this.ie6);
	this.ns  = (this.ns4 || this.ns5);
	this.win = (this.ver.indexOf("Win")>-1) ? 1:0;
	this.mac = (this.ver.indexOf("Mac")>-1) ? 1:0;
	this.lin = ((this.ver.indexOf("Lin")>-1) || (this.ver.indexOf("X11")>-1)) ? 1:0;
	return this;
}

function openWindow(urlX,wX,hX,winX,toolbarsX,modalX) {
	var cb=checkBrowser();
	url=urlX?urlX:home+'/fullscreen.html';
	var win=winX?winX:'win';
	var w=wX?wX:1024;
	var h=hX?hX:768;
	var toolbars=toolbarsX?true:false;
	var modal=modalX?true:false;
	var ow = (w>=screen.width)?(screen.width-10):w;
	var oh = (h>=screen.height)?(screen.height-56):h;
	var centerW=(screen.width-w)/2;
	var centerH=(screen.height-h)/2;
	LeftPosition = (screen.width)?((centerW<0)?0:centerW):0;
	TopPosition = (screen.height)?((centerH<0)?0:centerH):0;
	var location='0';
	var status='0';
	var menubar='0';
	var scrollbars='0';
	var resizable='0';
	var scrolling='no';
	var noresize='noresize';
	ow = (modal && window.showModalDialog)?ow+6:ow;
	oh = (modal && window.showModalDialog)?oh+24:oh;
	if ((w>=screen.width) || (h>=screen.height)) {
		scrollbars = '1';
		scrolling='yes';
		ow = (ow<(screen.width-10))?(ow+14):ow;
		oh = (oh<(screen.height-56))?(oh+14):oh;
	}
	if (toolbars) {
		location='0';
		status='1';
		menubar='0';
		scrollbars='1';
		resizable='1';
		scrolling='yes';
		noresize='';
		TopPosition=0;
	}
	if (cb.opera && !toolbars) {
		popupWindow = window.open('',win,'toolbar=0,location='+location+',directories=0,status='+status+',menubar='+menubar+',width='+(ow+2)+',height='+(oh+2));
		popupWindow.document.writeln('<html><head><title>.:: Panoramas viewer by Ebeling Data OY &copy; ::.</title></head>');
		popupWindow.document.writeln('<frameset rows="1*,'+oh+',1*" cols="1*,'+ow+',1*" frameborder="0" border="0" framespacing="0">');
		popupWindow.document.writeln('<frame name="blank" src="'+home+'/blank.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>');
		popupWindow.document.writeln('<frame name="blank" src="'+home+'/blank.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>');
		popupWindow.document.writeln('<frame name="blank" src="'+home+'/blank.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>');
		popupWindow.document.writeln('<frame name="blank" src="'+home+'/blank.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>');
		popupWindow.document.writeln('<frame name="main"  src="'+home+'/blank.html" marginwidth="0" marginheight="0" scrolling='+scrolling+' frameborder="0" '+noresize+'>');
		popupWindow.document.writeln('<frame name="blank" src="'+home+'/blank.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>');
		popupWindow.document.writeln('<frame name="blank" src="'+home+'/blank.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>');
		popupWindow.document.writeln('<frame name="blank" src="'+home+'/blank.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>');
		popupWindow.document.writeln('<frame name="blank" src="'+home+'/blank.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>');
		popupWindow.document.writeln('</frameset>');
		popupWindow.document.writeln('</html>');
		popupWindow.document.close(); 
		popupWindow.main.location=url;
		if(popupWindow.window.focus){popupWindow.window.focus();}
	} else if (modal && window.showModalDialog) {
		popupWindow = window.showModalDialog(url,"return false;","dialogHeight: "+oh+"px; dialogWidth: "+ow+"px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: No; status: No; scroll: "+toolbars+";");
	} else {
		popupWindow = window.open(url,win,'toolbar=0,location='+location+',directories=0,status='+status+',menubar='+menubar+',scrollbars='+scrollbars+',resizable='+resizable+',width='+ow+',height='+oh+',top='+TopPosition+',left='+LeftPosition);
		if(popupWindow.window.focus){popupWindow.window.focus();}
	}
}

function ClickReturn (noret) {
	var cb=checkBrowser();
	if (!noret) {
		if (!cb.opera) return true;
	} else {
		if (cb.mac) return true;
	}
	return false;
}


